summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/example1/example1.c12
-rw-r--r--examples/example2/dlt_id.h2
-rw-r--r--examples/example2/example2.c27
-rw-r--r--examples/example3/dlt_id.h2
-rw-r--r--examples/example3/example3.c27
-rw-r--r--examples/example4/example4.c72
-rw-r--r--include/dlt/dlt.h6
-rw-r--r--include/dlt/dlt_client.h43
-rw-r--r--include/dlt/dlt_common.h1959
-rw-r--r--include/dlt/dlt_common_api.h424
-rw-r--r--include/dlt/dlt_filetransfer.h4
-rw-r--r--include/dlt/dlt_offline_trace.h28
-rw-r--r--include/dlt/dlt_protocol.h29
-rw-r--r--include/dlt/dlt_shm.h22
-rw-r--r--include/dlt/dlt_types.h104
-rw-r--r--include/dlt/dlt_user.h192
-rw-r--r--include/dlt/dlt_user_macros.h282
-rw-r--r--src/adaptor/dlt-adaptor-stdin.c114
-rw-r--r--src/adaptor/dlt-adaptor-udp.c118
-rw-r--r--src/console/dlt-control-common.c159
-rw-r--r--src/console/dlt-control.c583
-rw-r--r--src/console/dlt-convert.c312
-rw-r--r--src/console/dlt-passive-node-ctrl.c111
-rw-r--r--src/console/dlt-receive.c487
-rw-r--r--src/console/dlt-sortbytimestamp.c244
-rw-r--r--src/console/logstorage/dlt-logstorage-common.c54
-rw-r--r--src/console/logstorage/dlt-logstorage-ctrl.c132
-rw-r--r--src/console/logstorage/dlt-logstorage-list.c43
-rw-r--r--src/console/logstorage/dlt-logstorage-prop.h9
-rw-r--r--src/console/logstorage/dlt-logstorage-udev.c93
-rw-r--r--src/core_dump_handler/cityhash_c/city_c.c867
-rw-r--r--src/core_dump_handler/cityhash_c/city_c.h130
-rw-r--r--src/core_dump_handler/cityhash_c/citycrc_c.h74
-rw-r--r--src/core_dump_handler/dlt_cdh.c307
-rw-r--r--src/core_dump_handler/dlt_cdh.h42
-rw-r--r--src/core_dump_handler/dlt_cdh_context.c283
-rw-r--r--src/core_dump_handler/dlt_cdh_coredump.c107
-rw-r--r--src/core_dump_handler/dlt_cdh_cpuinfo.h2
-rw-r--r--src/core_dump_handler/dlt_cdh_crashid.c108
-rw-r--r--src/core_dump_handler/dlt_cdh_streamer.c99
-rw-r--r--src/core_dump_handler/dlt_cdh_streamer.h18
-rw-r--r--src/core_dump_handler/i686/dlt_cdh_cpuinfo.c10
-rw-r--r--src/core_dump_handler/x86_64/dlt_cdh_cpuinfo.c10
-rw-r--r--src/daemon/dlt-daemon.c2217
-rw-r--r--src/daemon/dlt-daemon.h85
-rw-r--r--src/daemon/dlt_daemon_client.c2017
-rw-r--r--src/daemon/dlt_daemon_client.h116
-rw-r--r--src/daemon/dlt_daemon_common.c1023
-rw-r--r--src/daemon/dlt_daemon_common.h112
-rw-r--r--src/daemon/dlt_daemon_common_cfg.h18
-rw-r--r--src/daemon/dlt_daemon_connection.c122
-rw-r--r--src/daemon/dlt_daemon_connection.h16
-rw-r--r--src/daemon/dlt_daemon_event_handler.c155
-rw-r--r--src/daemon/dlt_daemon_event_handler.h20
-rw-r--r--src/daemon/dlt_daemon_event_handler_types.h6
-rw-r--r--src/daemon/dlt_daemon_offline_logstorage.c509
-rw-r--r--src/daemon/dlt_daemon_offline_logstorage_internal.h8
-rw-r--r--src/daemon/dlt_daemon_serial.c24
-rw-r--r--src/daemon/dlt_daemon_serial.h2
-rw-r--r--src/daemon/dlt_daemon_socket.c66
-rw-r--r--src/daemon/dlt_daemon_socket.h4
-rw-r--r--src/daemon/dlt_daemon_unix_socket.c15
-rw-r--r--src/dbus/dlt-dbus-options.c182
-rw-r--r--src/dbus/dlt-dbus.c134
-rw-r--r--src/dbus/dlt-dbus.h30
-rw-r--r--src/examples/dlt-example-filetransfer.c70
-rw-r--r--src/examples/dlt-example-user-common-api.c112
-rw-r--r--src/examples/dlt-example-user-func.c134
-rw-r--r--src/examples/dlt-example-user.c159
-rw-r--r--src/gateway/dlt_gateway.c687
-rw-r--r--src/gateway/dlt_gateway_internal.h10
-rw-r--r--src/kpi/dlt-kpi-common.c59
-rw-r--r--src/kpi/dlt-kpi-common.h2
-rw-r--r--src/kpi/dlt-kpi-interrupt.c90
-rw-r--r--src/kpi/dlt-kpi-options.c124
-rw-r--r--src/kpi/dlt-kpi-process-list.c123
-rw-r--r--src/kpi/dlt-kpi-process-list.h4
-rw-r--r--src/kpi/dlt-kpi-process.c233
-rw-r--r--src/kpi/dlt-kpi-process.h2
-rw-r--r--src/kpi/dlt-kpi.c231
-rw-r--r--src/kpi/dlt-kpi.h8
-rw-r--r--src/lib/dlt_client.c630
-rw-r--r--src/lib/dlt_client_cfg.h4
-rw-r--r--src/lib/dlt_env_ll.c573
-rw-r--r--src/lib/dlt_filetransfer.c555
-rw-r--r--src/lib/dlt_user.c3092
-rw-r--r--src/lib/dlt_user_cfg.h2
-rw-r--r--src/offlinelogstorage/dlt_offline_logstorage.c722
-rw-r--r--src/offlinelogstorage/dlt_offline_logstorage.h8
-rw-r--r--src/offlinelogstorage/dlt_offline_logstorage_behavior.c586
-rw-r--r--src/shared/dlt_common.c3097
-rw-r--r--src/shared/dlt_common_cfg.h4
-rw-r--r--src/shared/dlt_config_file_parser.c170
-rw-r--r--src/shared/dlt_offline_trace.c276
-rw-r--r--src/shared/dlt_protocol.c18
-rw-r--r--src/shared/dlt_shm.c156
-rw-r--r--src/shared/dlt_user_shared.c75
-rw-r--r--src/shared/dlt_user_shared.h4
-rw-r--r--src/system/dlt-system-filetransfer.c481
-rw-r--r--src/system/dlt-system-journal.c586
-rw-r--r--src/system/dlt-system-logfile.c152
-rw-r--r--src/system/dlt-system-options.c693
-rw-r--r--src/system/dlt-system-process-handling.c195
-rw-r--r--src/system/dlt-system-processes.c189
-rw-r--r--src/system/dlt-system-shell.c92
-rw-r--r--src/system/dlt-system-syslog.c161
-rw-r--r--src/system/dlt-system-watchdog.c142
-rw-r--r--src/system/dlt-system.c86
-rw-r--r--src/system/dlt-system.h128
-rw-r--r--src/tests/dlt-test-client.c2335
-rw-r--r--src/tests/dlt-test-filetransfer.c430
-rw-r--r--src/tests/dlt-test-fork-handler.c9
-rw-r--r--src/tests/dlt-test-init-free.c87
-rw-r--r--src/tests/dlt-test-multi-process-client.c193
-rw-r--r--src/tests/dlt-test-multi-process.c258
-rw-r--r--src/tests/dlt-test-stress-client.c277
-rw-r--r--src/tests/dlt-test-stress-user.c81
-rw-r--r--src/tests/dlt-test-stress.c143
-rw-r--r--src/tests/dlt-test-user.c845
-rw-r--r--tests/dlt-test-cpp-extension.cpp15
-rw-r--r--tests/dlt-test-preregister-context.c2
-rw-r--r--tests/dlt_env_ll_unit_test.cpp89
-rw-r--r--tests/dlt_test_receiver.c312
-rw-r--r--tests/gtest_dlt_common.cpp3684
-rw-r--r--tests/gtest_dlt_daemon_common.cpp1450
-rw-r--r--tests/gtest_dlt_daemon_event_handler.cpp112
-rw-r--r--tests/gtest_dlt_daemon_gateway.cpp94
-rw-r--r--tests/gtest_dlt_daemon_offline_log.cpp340
-rw-r--r--tests/gtest_dlt_user.cpp3182
-rw-r--r--tests/mod_system_logger/mod_system_logger.c37
-rw-r--r--util/uncrustify.cfg2736
131 files changed, 23502 insertions, 22766 deletions
diff --git a/examples/example1/example1.c b/examples/example1/example1.c
index e6fea9f..2784a82 100644
--- a/examples/example1/example1.c
+++ b/examples/example1/example1.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file example1.c
-*/
+ */
/*******************************************************************************
@@ -54,15 +54,15 @@ DLT_DECLARE_CONTEXT(con_exa1);
int main()
{
- DLT_REGISTER_APP("EXA1","First Example");
+ DLT_REGISTER_APP("EXA1", "First Example");
- DLT_REGISTER_CONTEXT(con_exa1,"CON","First context");
+ DLT_REGISTER_CONTEXT(con_exa1, "CON", "First context");
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("Hello world!"));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_STRING("Hello world!"));
usleep(1000);
- DLT_UNREGISTER_CONTEXT(con_exa1);
+ DLT_UNREGISTER_CONTEXT(con_exa1);
- DLT_UNREGISTER_APP();
+ DLT_UNREGISTER_APP();
}
diff --git a/examples/example2/dlt_id.h b/examples/example2/dlt_id.h
index 7bfa4c7..488bf4a 100644
--- a/examples/example2/dlt_id.h
+++ b/examples/example2/dlt_id.h
@@ -15,7 +15,7 @@
* @licence end@
*/
-// generated file, do not edit
+/* generated file, do not edit */
#ifndef DLT_ID_H
#define DLT_ID_H
diff --git a/examples/example2/example2.c b/examples/example2/example2.c
index ccd4ff5..445f60a 100644
--- a/examples/example2/example2.c
+++ b/examples/example2/example2.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file example2.c
-*/
+ */
/*******************************************************************************
@@ -56,22 +56,21 @@ DLT_DECLARE_CONTEXT(con_exa2);
int main()
{
- int num;
+ int num;
- DLT_REGISTER_APP("EXA2","Third Example");
- DLT_REGISTER_CONTEXT(con_exa2,"CON","First context");
+ DLT_REGISTER_APP("EXA2", "Third Example");
+ DLT_REGISTER_CONTEXT(con_exa2, "CON", "First context");
- DLT_NONVERBOSE_MODE();
+ DLT_NONVERBOSE_MODE();
- for(num=0;num<10;num++)
- {
- DLT_LOG_ID(con_exa2,DLT_LOG_INFO,DLT_EXA2_CON_EXA2_ID1,DLT_INT32(12345678),DLT_STRING("Hello world 1!"));
- DLT_LOG_ID(con_exa2,DLT_LOG_ERROR,DLT_EXA2_CON_EXA2_ID2,DLT_INT32(87654321),DLT_STRING("Hello world 2!"));
- DLT_LOG_ID(con_exa2,DLT_LOG_WARN,DLT_EXA2_CON_EXA2_ID3,DLT_INT32(11223344),DLT_STRING("Hello world 3!"));
- usleep(1000);
- }
+ for (num = 0; num < 10; num++) {
+ DLT_LOG_ID(con_exa2, DLT_LOG_INFO, DLT_EXA2_CON_EXA2_ID1, DLT_INT32(12345678), DLT_STRING("Hello world 1!"));
+ DLT_LOG_ID(con_exa2, DLT_LOG_ERROR, DLT_EXA2_CON_EXA2_ID2, DLT_INT32(87654321), DLT_STRING("Hello world 2!"));
+ DLT_LOG_ID(con_exa2, DLT_LOG_WARN, DLT_EXA2_CON_EXA2_ID3, DLT_INT32(11223344), DLT_STRING("Hello world 3!"));
+ usleep(1000);
+ }
- DLT_UNREGISTER_CONTEXT(con_exa2);
+ DLT_UNREGISTER_CONTEXT(con_exa2);
- DLT_UNREGISTER_APP();
+ DLT_UNREGISTER_APP();
}
diff --git a/examples/example3/dlt_id.h b/examples/example3/dlt_id.h
index 149e22d..66f0684 100644
--- a/examples/example3/dlt_id.h
+++ b/examples/example3/dlt_id.h
@@ -15,7 +15,7 @@
* @licence end@
*/
-// generated file, do not edit
+/* generated file, do not edit */
#ifndef DLT_ID_H
#define DLT_ID_H
diff --git a/examples/example3/example3.c b/examples/example3/example3.c
index ced6632..d686ec1 100644
--- a/examples/example3/example3.c
+++ b/examples/example3/example3.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file example3.c
-*/
+ */
/*******************************************************************************
@@ -56,22 +56,21 @@ DLT_DECLARE_CONTEXT(con_exa3);
int main()
{
- int num;
+ int num;
- DLT_REGISTER_APP("EXA3","Third Example");
- DLT_REGISTER_CONTEXT(con_exa3,"CON","First context");
+ DLT_REGISTER_APP("EXA3", "Third Example");
+ DLT_REGISTER_CONTEXT(con_exa3, "CON", "First context");
- DLT_NONVERBOSE_MODE();
+ DLT_NONVERBOSE_MODE();
- for(num=0;num<10;num++)
- {
- DLT_LOG_ID(con_exa3,DLT_LOG_INFO,DLT_EXA3_CON_EXA3_ID1,DLT_INT32(12345678),DLT_CSTRING("Hello world 1!"));
- DLT_LOG_ID(con_exa3,DLT_LOG_ERROR,DLT_EXA3_CON_EXA3_ID2,DLT_INT32(87654321),DLT_CSTRING("Hello world 2!"));
- DLT_LOG_ID(con_exa3,DLT_LOG_WARN,DLT_EXA3_CON_EXA3_ID3,DLT_INT32(11223344),DLT_CSTRING("Hello world 3!"));
- usleep(1000);
- }
+ for (num = 0; num < 10; num++) {
+ DLT_LOG_ID(con_exa3, DLT_LOG_INFO, DLT_EXA3_CON_EXA3_ID1, DLT_INT32(12345678), DLT_CSTRING("Hello world 1!"));
+ DLT_LOG_ID(con_exa3, DLT_LOG_ERROR, DLT_EXA3_CON_EXA3_ID2, DLT_INT32(87654321), DLT_CSTRING("Hello world 2!"));
+ DLT_LOG_ID(con_exa3, DLT_LOG_WARN, DLT_EXA3_CON_EXA3_ID3, DLT_INT32(11223344), DLT_CSTRING("Hello world 3!"));
+ usleep(1000);
+ }
- DLT_UNREGISTER_CONTEXT(con_exa3);
+ DLT_UNREGISTER_CONTEXT(con_exa3);
- DLT_UNREGISTER_APP();
+ DLT_UNREGISTER_APP();
}
diff --git a/examples/example4/example4.c b/examples/example4/example4.c
index f4b1da0..59aef18 100644
--- a/examples/example4/example4.c
+++ b/examples/example4/example4.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file example4.c
-*/
+ */
/*******************************************************************************
@@ -54,55 +54,53 @@ DLT_DECLARE_CONTEXT(con_exa1);
int main()
{
- unsigned char buffer[256];
- int num;
+ unsigned char buffer[256];
+ int num;
- DLT_REGISTER_APP("EXA4","Fourth Example");
+ DLT_REGISTER_APP("EXA4", "Fourth Example");
- DLT_REGISTER_CONTEXT(con_exa1,"CON","First context");
+ DLT_REGISTER_CONTEXT(con_exa1, "CON", "First context");
- for(num=0;num<256;num++)
- {
- buffer[num] = num;
- }
+ for (num = 0; num < 256; num++)
+ buffer[num] = num;
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("DLT_RAW"));
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_RAW(buffer,256));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_STRING("DLT_RAW"));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_RAW(buffer, 256));
- uint8_t uint8data = 0x2a;
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("DLT_UINT8"));
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_UINT8(uint8data));
+ uint8_t uint8data = 0x2a;
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_STRING("DLT_UINT8"));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_UINT8(uint8data));
- uint8_t hex8data = 0x1a;
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("DLT_HEX8"));
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_HEX8(hex8data));
+ uint8_t hex8data = 0x1a;
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_STRING("DLT_HEX8"));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_HEX8(hex8data));
- uint16_t hex16data = 0x1ad3;
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("DLT_HEX16"));
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_HEX16(hex16data));
+ uint16_t hex16data = 0x1ad3;
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_STRING("DLT_HEX16"));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_HEX16(hex16data));
- uint32_t hex32data = 0x1abcd3e4;
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("DLT_HEX32"));
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_HEX32(hex32data));
+ uint32_t hex32data = 0x1abcd3e4;
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_STRING("DLT_HEX32"));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_HEX32(hex32data));
- uint64_t hex64data = 0x17b4ddcf34eabb2a;
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("DLT_HEX64"));
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_HEX64(hex64data));
+ uint64_t hex64data = 0x17b4ddcf34eabb2a;
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_STRING("DLT_HEX64"));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_HEX64(hex64data));
- uint8_t bin8data = 0xe2;
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("DLT_BIN8"));
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_BIN8(bin8data));
- bin8data = 0x01;
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("DLT_BIN8"));
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_BIN8(bin8data));
+ uint8_t bin8data = 0xe2;
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_STRING("DLT_BIN8"));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_BIN8(bin8data));
+ bin8data = 0x01;
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_STRING("DLT_BIN8"));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_BIN8(bin8data));
- uint16_t bin16data = 0x1234;
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("DLT_BIN16"));
- DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_BIN16(bin16data));
+ uint16_t bin16data = 0x1234;
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_STRING("DLT_BIN16"));
+ DLT_LOG(con_exa1, DLT_LOG_INFO, DLT_BIN16(bin16data));
usleep(1000);
- DLT_UNREGISTER_CONTEXT(con_exa1);
+ DLT_UNREGISTER_CONTEXT(con_exa1);
- DLT_UNREGISTER_APP();
+ DLT_UNREGISTER_APP();
}
diff --git a/include/dlt/dlt.h b/include/dlt/dlt.h
index 54a2883..6ecd1e1 100644
--- a/include/dlt/dlt.h
+++ b/include/dlt/dlt.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt.h
-*/
+ */
/*******************************************************************************
** **
@@ -63,8 +63,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#ifndef DLT_H
diff --git a/include/dlt/dlt_client.h b/include/dlt/dlt_client.h
index 7ff55cf..8947e2f 100644
--- a/include/dlt/dlt_client.h
+++ b/include/dlt/dlt_client.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_client.h
-*/
+ */
/*******************************************************************************
@@ -67,16 +67,16 @@
*/
#ifndef DLT_CLIENT_H
-#define DLT_CLIENT_H
+# define DLT_CLIENT_H
/**
- \defgroup clientapi DLT Client API
- \addtogroup clientapi
- \{
-*/
+ * \defgroup clientapi DLT Client API
+ * \addtogroup clientapi
+ \{
+ */
-#include "dlt_types.h"
-#include "dlt_common.h"
+# include "dlt_types.h"
+# include "dlt_common.h"
typedef enum
{
@@ -99,11 +99,11 @@ typedef struct
DltClientMode mode; /**< mode DltClientMode */
} DltClient;
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
-void dlt_client_register_message_callback(int (*registerd_callback) (DltMessage *message, void *data));
+void dlt_client_register_message_callback(int (*registerd_callback)(DltMessage *message, void *data));
/**
* Initialising dlt client structure with a specific port
@@ -163,7 +163,12 @@ DltReturnValue dlt_client_send_ctrl_msg(DltClient *client, char *apid, char *cti
* @param size Size of injection data within buffer
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_client_send_inject_msg(DltClient *client, char *apid, char *ctid, uint32_t serviceID, uint8_t *buffer, uint32_t size);
+DltReturnValue dlt_client_send_inject_msg(DltClient *client,
+ char *apid,
+ char *ctid,
+ uint32_t serviceID,
+ uint8_t *buffer,
+ uint32_t size);
/**
* Send an set log level message to the dlt daemon
* @param client pointer to dlt client structure
@@ -196,13 +201,13 @@ int dlt_client_get_software_version(DltClient *client);
* @param void
* @return void
*/
-void dlt_getloginfo_init( void );
+void dlt_getloginfo_init(void);
/**
* To free the memory allocated for app description in get log info
* @param void
* @return void
*/
-void dlt_getloginfo_free( void );
+void dlt_getloginfo_free(void);
/**
* Send a set trace status message to the dlt daemon
* @param client pointer to dlt client structure
@@ -299,7 +304,7 @@ int dlt_client_set_socket_path(DltClient *client, char *socket_path);
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoResponse *resp,
- char *resp_text);
+ char *resp_text);
/**
* Free memory allocated for get log info message
@@ -307,12 +312,12 @@ DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoRespo
* @return 0 on success, -1 otherwise
*/
int dlt_client_cleanup_get_log_info(DltServiceGetLogInfoResponse *resp);
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
/**
- \}
-*/
+ \}
+ */
#endif /* DLT_CLIENT_H */
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h
index 3db3a27..fc02743 100644
--- a/include/dlt/dlt_common.h
+++ b/include/dlt/dlt_common.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_common.h
-*/
+ */
/*******************************************************************************
** **
@@ -63,163 +63,164 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#ifndef DLT_COMMON_H
-#define DLT_COMMON_H
+# define DLT_COMMON_H
/**
- \defgroup commonapi DLT Common API
- \addtogroup commonapi
- \{
-*/
+ * \defgroup commonapi DLT Common API
+ * \addtogroup commonapi
+ \{
+ */
-#include <stdio.h>
-#ifdef __linux__
-#include <linux/limits.h>
-#else
-#include <limits.h>
-#endif
+# include <stdio.h>
+# ifdef __linux__
+# include <linux/limits.h>
+# else
+# include <limits.h>
+# endif
-#if !defined(_MSC_VER)
-#include <unistd.h>
-#include <time.h>
-#endif
+# if !defined(_MSC_VER)
+# include <unistd.h>
+# include <time.h>
+# endif
-#if !defined (__WIN32__) && !defined(_MSC_VER)
-#include <termios.h>
-#endif
+# if !defined (__WIN32__) && !defined(_MSC_VER)
+# include <termios.h>
+# endif
-#include "dlt_types.h"
-#include "dlt_protocol.h"
+# include "dlt_types.h"
+# include "dlt_protocol.h"
-#if !defined (PACKED)
-#define PACKED __attribute__((aligned(1),packed))
-#endif
+# if !defined (PACKED)
+# define PACKED __attribute__((aligned(1), packed))
+# endif
-#if defined (__MSDOS__) || defined (_MSC_VER)
+# if defined (__MSDOS__) || defined (_MSC_VER)
/* set instead /Zp8 flag in Visual C++ configuration */
-#undef PACKED
-#define PACKED
-#endif
+# undef PACKED
+# define PACKED
+# endif
/*
* Macros to swap the byte order.
*/
-#define DLT_SWAP_64(value) ((((uint64_t)DLT_SWAP_32((value)&0xffffffffull))<<32) | (DLT_SWAP_32((value)>>32)))
+# define DLT_SWAP_64(value) ((((uint64_t)DLT_SWAP_32((value) & 0xffffffffull)) << 32) | (DLT_SWAP_32((value) >> 32)))
-#define DLT_SWAP_16(value) ((((value) >> 8)&0xff) | (((value) << 8)&0xff00))
-#define DLT_SWAP_32(value) ((((value) >> 24)&0xff) | (((value) << 8)&0xff0000) | (((value) >> 8)&0xff00) | (((value) << 24)&0xff000000))
+# define DLT_SWAP_16(value) ((((value) >> 8) & 0xff) | (((value) << 8) & 0xff00))
+# define DLT_SWAP_32(value) ((((value) >> 24) & 0xff) | (((value) << 8) & 0xff0000) | (((value) >> 8) & 0xff00) | \
+ (((value) << 24) & 0xff000000))
/* Set Big Endian and Little Endian to a initial value, if not defined */
-#if !defined __USE_BSD
-#ifndef LITTLE_ENDIAN
-#define LITTLE_ENDIAN 1234
-#endif
+# if !defined __USE_BSD
+# ifndef LITTLE_ENDIAN
+# define LITTLE_ENDIAN 1234
+# endif
-#ifndef BIG_ENDIAN
-#define BIG_ENDIAN 4321
-#endif
-#endif /* __USE_BSD */
+# ifndef BIG_ENDIAN
+# define BIG_ENDIAN 4321
+# endif
+# endif /* __USE_BSD */
/* If byte order is not defined, default to little endian */
-#if !defined __USE_BSD
-#ifndef BYTE_ORDER
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-#endif /* __USE_BSD */
+# if !defined __USE_BSD
+# ifndef BYTE_ORDER
+# define BYTE_ORDER LITTLE_ENDIAN
+# endif
+# endif /* __USE_BSD */
/* Check for byte-order */
-#if (BYTE_ORDER==BIG_ENDIAN)
+# if (BYTE_ORDER == BIG_ENDIAN)
/* #warning "Big Endian Architecture!" */
-#define DLT_HTOBE_16(x) ((x))
-#define DLT_HTOLE_16(x) DLT_SWAP_16((x))
-#define DLT_BETOH_16(x) ((x))
-#define DLT_LETOH_16(x) DLT_SWAP_16((x))
-
-#define DLT_HTOBE_32(x) ((x))
-#define DLT_HTOLE_32(x) DLT_SWAP_32((x))
-#define DLT_BETOH_32(x) ((x))
-#define DLT_LETOH_32(x) DLT_SWAP_32((x))
-
-#define DLT_HTOBE_64(x) ((x))
-#define DLT_HTOLE_64(x) DLT_SWAP_64((x))
-#define DLT_BETOH_64(x) ((x))
-#define DLT_LETOH_64(x) DLT_SWAP_64((x))
-#else
+# define DLT_HTOBE_16(x) ((x))
+# define DLT_HTOLE_16(x) DLT_SWAP_16((x))
+# define DLT_BETOH_16(x) ((x))
+# define DLT_LETOH_16(x) DLT_SWAP_16((x))
+
+# define DLT_HTOBE_32(x) ((x))
+# define DLT_HTOLE_32(x) DLT_SWAP_32((x))
+# define DLT_BETOH_32(x) ((x))
+# define DLT_LETOH_32(x) DLT_SWAP_32((x))
+
+# define DLT_HTOBE_64(x) ((x))
+# define DLT_HTOLE_64(x) DLT_SWAP_64((x))
+# define DLT_BETOH_64(x) ((x))
+# define DLT_LETOH_64(x) DLT_SWAP_64((x))
+# else
/* #warning "Litte Endian Architecture!" */
-#define DLT_HTOBE_16(x) DLT_SWAP_16((x))
-#define DLT_HTOLE_16(x) ((x))
-#define DLT_BETOH_16(x) DLT_SWAP_16((x))
-#define DLT_LETOH_16(x) ((x))
-
-#define DLT_HTOBE_32(x) DLT_SWAP_32((x))
-#define DLT_HTOLE_32(x) ((x))
-#define DLT_BETOH_32(x) DLT_SWAP_32((x))
-#define DLT_LETOH_32(x) ((x))
-
-#define DLT_HTOBE_64(x) DLT_SWAP_64((x))
-#define DLT_HTOLE_64(x) ((x))
-#define DLT_BETOH_64(x) DLT_SWAP_64((x))
-#define DLT_LETOH_64(x) ((x))
-#endif
-
-#define DLT_ENDIAN_GET_16(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_16(x):DLT_LETOH_16(x))
-#define DLT_ENDIAN_GET_32(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_32(x):DLT_LETOH_32(x))
-#define DLT_ENDIAN_GET_64(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_64(x):DLT_LETOH_64(x))
-
-#if defined (__WIN32__) || defined (_MSC_VER)
-#define LOG_EMERG 0
-#define LOG_ALERT 1
-#define LOG_CRIT 2
-#define LOG_ERR 3
-#define LOG_WARNING 4
-#define LOG_NOTICE 5
-#define LOG_INFO 6
-#define LOG_DEBUG 7
-
-#define LOG_PID 0x01
-#define LOG_DAEMON (3<<3)
-#endif
+# define DLT_HTOBE_16(x) DLT_SWAP_16((x))
+# define DLT_HTOLE_16(x) ((x))
+# define DLT_BETOH_16(x) DLT_SWAP_16((x))
+# define DLT_LETOH_16(x) ((x))
+
+# define DLT_HTOBE_32(x) DLT_SWAP_32((x))
+# define DLT_HTOLE_32(x) ((x))
+# define DLT_BETOH_32(x) DLT_SWAP_32((x))
+# define DLT_LETOH_32(x) ((x))
+
+# define DLT_HTOBE_64(x) DLT_SWAP_64((x))
+# define DLT_HTOLE_64(x) ((x))
+# define DLT_BETOH_64(x) DLT_SWAP_64((x))
+# define DLT_LETOH_64(x) ((x))
+# endif
+
+# define DLT_ENDIAN_GET_16(htyp, x) ((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_16(x) : DLT_LETOH_16(x))
+# define DLT_ENDIAN_GET_32(htyp, x) ((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_32(x) : DLT_LETOH_32(x))
+# define DLT_ENDIAN_GET_64(htyp, x) ((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_64(x) : DLT_LETOH_64(x))
+
+# if defined (__WIN32__) || defined (_MSC_VER)
+# define LOG_EMERG 0
+# define LOG_ALERT 1
+# define LOG_CRIT 2
+# define LOG_ERR 3
+# define LOG_WARNING 4
+# define LOG_NOTICE 5
+# define LOG_INFO 6
+# define LOG_DEBUG 7
+
+# define LOG_PID 0x01
+# define LOG_DAEMON (3 << 3)
+# endif
enum {
- DLT_LOG_TO_CONSOLE=0,
- DLT_LOG_TO_SYSLOG=1,
- DLT_LOG_TO_FILE=2,
- DLT_LOG_DROPPED=3
+ DLT_LOG_TO_CONSOLE = 0,
+ DLT_LOG_TO_SYSLOG = 1,
+ DLT_LOG_TO_FILE = 2,
+ DLT_LOG_DROPPED = 3
};
/**
* The standard TCP Port used for DLT daemon, can be overwritten via -p <port> when starting dlt-daemon
*/
-#define DLT_DAEMON_TCP_PORT 3490
+# define DLT_DAEMON_TCP_PORT 3490
/* Initial value for file descriptor */
-#define DLT_FD_INIT -1
+# define DLT_FD_INIT -1
/* Minimum value for a file descriptor except the POSIX Standards: stdin=0, stdout=1, stderr=2 */
-#define DLT_FD_MINIMUM 3
+# define DLT_FD_MINIMUM 3
/**
* The size of a DLT ID
*/
-#define DLT_ID_SIZE 4
+# define DLT_ID_SIZE 4
-#define DLT_SIZE_WEID DLT_ID_SIZE
-#define DLT_SIZE_WSID (sizeof(uint32_t))
-#define DLT_SIZE_WTMS (sizeof(uint32_t))
+# define DLT_SIZE_WEID DLT_ID_SIZE
+# define DLT_SIZE_WSID (sizeof(uint32_t))
+# define DLT_SIZE_WTMS (sizeof(uint32_t))
/**
* Definitions for GET_LOG_INFO
*/
-#define DLT_GET_LOG_INFO_HEADER 18 /*Get log info header size in response text */
-#define GET_LOG_INFO_LENGTH 13
-#define SERVICE_OPT_LENGTH 3
+# define DLT_GET_LOG_INFO_HEADER 18 /*Get log info header size in response text */
+# define GET_LOG_INFO_LENGTH 13
+# define SERVICE_OPT_LENGTH 3
/* checks if received size is big enough for expected data */
-#define DLT_CHECK_RCV_DATA_SIZE(received, required) \
+# define DLT_CHECK_RCV_DATA_SIZE(received, required) \
({ \
int _ret = DLT_RETURN_OK; \
if (((int)received - (int)required) < 0) { \
@@ -232,155 +233,158 @@ enum {
/**
* Get the size of extra header parameters, depends on htyp.
*/
-#define DLT_STANDARD_HEADER_EXTRA_SIZE(htyp) ( (DLT_IS_HTYP_WEID(htyp) ? DLT_SIZE_WEID : 0) + (DLT_IS_HTYP_WSID(htyp) ? DLT_SIZE_WSID : 0) + (DLT_IS_HTYP_WTMS(htyp) ? DLT_SIZE_WTMS : 0) )
+# define DLT_STANDARD_HEADER_EXTRA_SIZE(htyp) ((DLT_IS_HTYP_WEID(htyp) ? DLT_SIZE_WEID : 0) + \
+ (DLT_IS_HTYP_WSID(htyp) ? DLT_SIZE_WSID : 0) + \
+ (DLT_IS_HTYP_WTMS(htyp) ? DLT_SIZE_WTMS : 0))
-#if defined (__MSDOS__) || defined (_MSC_VER)
-#define __func__ __FUNCTION__
-#endif
+# if defined (__MSDOS__) || defined (_MSC_VER)
+# define __func__ __FUNCTION__
+# endif
-#define PRINT_FUNCTION_VERBOSE(_verbose) \
-{ \
- static char _strbuf[255]; \
- \
- if(_verbose) \
+# define PRINT_FUNCTION_VERBOSE(_verbose) \
{ \
- snprintf(_strbuf, 255, "%s()\n",__func__); \
- dlt_log(LOG_INFO, _strbuf); \
- } \
-}
+ static char _strbuf[255]; \
+ \
+ if (_verbose) \
+ { \
+ snprintf(_strbuf, 255, "%s()\n", __func__); \
+ dlt_log(LOG_INFO, _strbuf); \
+ } \
+ }
-#ifndef NULL
-#define NULL (char*)0
-#endif
+# ifndef NULL
+# define NULL (char *)0
+# endif
-#define DLT_MSG_IS_CONTROL(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
- (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL))
+# define DLT_MSG_IS_CONTROL(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
+ (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_CONTROL))
-#define DLT_MSG_IS_CONTROL_REQUEST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
- (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \
- (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_REQUEST))
+# define DLT_MSG_IS_CONTROL_REQUEST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
+ (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_CONTROL) && \
+ (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin) == DLT_CONTROL_REQUEST))
-#define DLT_MSG_IS_CONTROL_RESPONSE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
- (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \
- (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_RESPONSE))
+# define DLT_MSG_IS_CONTROL_RESPONSE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
+ (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_CONTROL) && \
+ (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin) == DLT_CONTROL_RESPONSE))
-#define DLT_MSG_IS_CONTROL_TIME(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
- (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \
- (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_TIME))
+# define DLT_MSG_IS_CONTROL_TIME(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
+ (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_CONTROL) && \
+ (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin) == DLT_CONTROL_TIME))
-#define DLT_MSG_IS_NW_TRACE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
- (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_NW_TRACE))
+# define DLT_MSG_IS_NW_TRACE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
+ (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_NW_TRACE))
-#define DLT_MSG_IS_TRACE_MOST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
- (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_NW_TRACE) && \
- (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_NW_TRACE_MOST))
+# define DLT_MSG_IS_TRACE_MOST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
+ (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_NW_TRACE) && \
+ (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin) == DLT_NW_TRACE_MOST))
-#define DLT_MSG_IS_NONVERBOSE(MSG) (!(DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) || \
- ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && (!(DLT_IS_MSIN_VERB((MSG)->extendedheader->msin)))))
+# define DLT_MSG_IS_NONVERBOSE(MSG) (!(DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) || \
+ ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
+ (!(DLT_IS_MSIN_VERB((MSG)->extendedheader->msin)))))
/*
-
+ *
* Definitions of DLT message buffer overflow
*/
-#define DLT_MESSAGE_BUFFER_NO_OVERFLOW 0x00 /**< Buffer overflow has not occured */
-#define DLT_MESSAGE_BUFFER_OVERFLOW 0x01 /**< Buffer overflow has occured */
+# define DLT_MESSAGE_BUFFER_NO_OVERFLOW 0x00/**< Buffer overflow has not occured */
+# define DLT_MESSAGE_BUFFER_OVERFLOW 0x01/**< Buffer overflow has occured */
/*
* Definition of DLT output variants
*/
-#define DLT_OUTPUT_HEX 1
-#define DLT_OUTPUT_ASCII 2
-#define DLT_OUTPUT_MIXED_FOR_PLAIN 3
-#define DLT_OUTPUT_MIXED_FOR_HTML 4
-#define DLT_OUTPUT_ASCII_LIMITED 5
+# define DLT_OUTPUT_HEX 1
+# define DLT_OUTPUT_ASCII 2
+# define DLT_OUTPUT_MIXED_FOR_PLAIN 3
+# define DLT_OUTPUT_MIXED_FOR_HTML 4
+# define DLT_OUTPUT_ASCII_LIMITED 5
-#define DLT_FILTER_MAX 30 /**< Maximum number of filters */
+# define DLT_FILTER_MAX 30 /**< Maximum number of filters */
-#define DLT_MSG_READ_VALUE(dst,src,length,type) \
-{ \
- if((length<0) || ((length)<((int32_t)sizeof(type)))) \
- { length = -1; } \
- else \
- { dst = *((type*)src);src+=sizeof(type);length-=sizeof(type); } \
-}
-
-#define DLT_MSG_READ_ID(dst,src,length) \
-{ \
- if((length<0) || ((length)<DLT_ID_SIZE)) \
- { length = -1; } \
- else \
- { memcpy(dst,src,DLT_ID_SIZE);src+=DLT_ID_SIZE;length-=DLT_ID_SIZE; } \
-}
-
-#define DLT_MSG_READ_STRING(dst,src,maxlength,length) \
-{ \
- if(((maxlength)<0) || ((length)<0) || ((maxlength)<(length))) \
- { maxlength = -1; } \
- else \
- { memcpy(dst,src,length);dlt_clean_string(dst,length);dst[length]=0; \
- src+=length;maxlength-=length; } \
-}
+# define DLT_MSG_READ_VALUE(dst, src, length, type) \
+ { \
+ if ((length < 0) || ((length) < ((int32_t)sizeof(type)))) \
+ { length = -1; } \
+ else \
+ { dst = *((type *)src); src += sizeof(type); length -= sizeof(type); } \
+ }
-#define DLT_MSG_READ_NULL(src,maxlength,length) \
-{ \
- if(((maxlength)<0) || ((length)<0) || ((maxlength)<(length))) \
- { length = -1; } \
- else \
- { src+=length;maxlength-=length; } \
-}
+# define DLT_MSG_READ_ID(dst, src, length) \
+ { \
+ if ((length < 0) || ((length) < DLT_ID_SIZE)) \
+ { length = -1; } \
+ else \
+ { memcpy(dst, src, DLT_ID_SIZE); src += DLT_ID_SIZE; length -= DLT_ID_SIZE; } \
+ }
-#define DLT_HEADER_SHOW_NONE 0x0000
-#define DLT_HEADER_SHOW_TIME 0x0001
-#define DLT_HEADER_SHOW_TMSTP 0x0002
-#define DLT_HEADER_SHOW_MSGCNT 0x0004
-#define DLT_HEADER_SHOW_ECUID 0x0008
-#define DLT_HEADER_SHOW_APID 0x0010
-#define DLT_HEADER_SHOW_CTID 0x0020
-#define DLT_HEADER_SHOW_MSGTYPE 0x0040
-#define DLT_HEADER_SHOW_MSGSUBTYPE 0x0080
-#define DLT_HEADER_SHOW_VNVSTATUS 0x0100
-#define DLT_HEADER_SHOW_NOARG 0x0200
-#define DLT_HEADER_SHOW_ALL 0xFFFF
+# define DLT_MSG_READ_STRING(dst, src, maxlength, length) \
+ { \
+ if (((maxlength) < 0) || ((length) < 0) || ((maxlength) < (length))) \
+ { maxlength = -1; } \
+ else \
+ { memcpy(dst, src, length); dlt_clean_string(dst, length); dst[length] = 0; \
+ src += length; maxlength -= length; } \
+ }
+
+# define DLT_MSG_READ_NULL(src, maxlength, length) \
+ { \
+ if (((maxlength) < 0) || ((length) < 0) || ((maxlength) < (length))) \
+ { length = -1; } \
+ else \
+ { src += length; maxlength -= length; } \
+ }
+
+# define DLT_HEADER_SHOW_NONE 0x0000
+# define DLT_HEADER_SHOW_TIME 0x0001
+# define DLT_HEADER_SHOW_TMSTP 0x0002
+# define DLT_HEADER_SHOW_MSGCNT 0x0004
+# define DLT_HEADER_SHOW_ECUID 0x0008
+# define DLT_HEADER_SHOW_APID 0x0010
+# define DLT_HEADER_SHOW_CTID 0x0020
+# define DLT_HEADER_SHOW_MSGTYPE 0x0040
+# define DLT_HEADER_SHOW_MSGSUBTYPE 0x0080
+# define DLT_HEADER_SHOW_VNVSTATUS 0x0100
+# define DLT_HEADER_SHOW_NOARG 0x0200
+# define DLT_HEADER_SHOW_ALL 0xFFFF
/* dlt_receiver_check_and_get flags */
-#define DLT_RCV_NONE 0
-#define DLT_RCV_SKIP_HEADER (1 << 0)
-#define DLT_RCV_REMOVE (1 << 1)
+# define DLT_RCV_NONE 0
+# define DLT_RCV_SKIP_HEADER (1 << 0)
+# define DLT_RCV_REMOVE (1 << 1)
/**
* Maximal length of mounted path
*/
-#define DLT_MOUNT_PATH_MAX 1024
+# define DLT_MOUNT_PATH_MAX 1024
/**
* Maximal length of an entry
*/
-#define DLT_ENTRY_MAX 100
+# define DLT_ENTRY_MAX 100
/**
* Maximal IPC path len
*/
-#define DLT_IPC_PATH_MAX 100
+# define DLT_IPC_PATH_MAX 100
/**
* Maximal receiver buffer size for application messages
*/
-#define DLT_RECEIVE_BUFSIZE 65535
+# define DLT_RECEIVE_BUFSIZE 65535
/**
* Maximal line length
*/
-#define DLT_LINE_LEN 1024
+# define DLT_LINE_LEN 1024
/**
* Provision to test static function
*/
-#ifndef DLT_UNIT_TESTS
-#define DLT_STATIC static
-#else
-#define DLT_STATIC
-#endif
+# ifndef DLT_UNIT_TESTS
+# define DLT_STATIC static
+# else
+# define DLT_STATIC
+# endif
/**
* Type to specify whether received data is from socket or file/fifo
@@ -470,16 +474,16 @@ typedef struct sDltMessage
int32_t datasize; /**< size of complete payload */
/* buffer for current loaded message */
- uint8_t headerbuffer[sizeof(DltStorageHeader)+
- sizeof(DltStandardHeader)+sizeof(DltStandardHeaderExtra)+sizeof(DltExtendedHeader)]; /**< buffer for loading complete header */
+ uint8_t headerbuffer[sizeof(DltStorageHeader) +
+ sizeof(DltStandardHeader) + sizeof(DltStandardHeaderExtra) + sizeof(DltExtendedHeader)]; /**< buffer for loading complete header */
uint8_t *databuffer; /**< buffer for loading payload */
int32_t databuffersize;
/* header values of current loaded message */
- DltStorageHeader *storageheader; /**< pointer to storage header of current loaded header */
- DltStandardHeader *standardheader; /**< pointer to standard header of current loaded header */
+ DltStorageHeader *storageheader; /**< pointer to storage header of current loaded header */
+ DltStandardHeader *standardheader; /**< pointer to standard header of current loaded header */
DltStandardHeaderExtra headerextra; /**< extra parameters of current loaded header */
- DltExtendedHeader *extendedheader; /**< pointer to extended of current loaded header */
+ DltExtendedHeader *extendedheader; /**< pointer to extended of current loaded header */
} DltMessage;
/**
@@ -615,7 +619,7 @@ typedef struct
typedef struct
{
uint32_t service_id; /**< service ID */
- uint8_t status; /**< reponse status */
+ uint8_t status; /**< reponse status */
uint32_t length; /**< length of following payload */
/*char [] payload;*/
} PACKED DltServiceGetSoftwareVersionResponse;
@@ -719,7 +723,7 @@ typedef struct
{
char apid[DLT_FILTER_MAX][DLT_ID_SIZE]; /**< application id */
char ctid[DLT_FILTER_MAX][DLT_ID_SIZE]; /**< context id */
- int counter; /**< number of filters */
+ int counter; /**< number of filters */
} DltFilter;
/**
@@ -771,13 +775,13 @@ typedef struct
typedef struct
{
- unsigned char* shm; /* pointer to beginning of shared memory */
- int size; /* size of data area in shared memory */
- unsigned char* mem; /* pointer to data area in shared memory */
+ unsigned char *shm; /* pointer to beginning of shared memory */
+ int size; /* size of data area in shared memory */
+ unsigned char *mem; /* pointer to data area in shared memory */
- uint32_t min_size; /**< Minimum size of buffer */
- uint32_t max_size; /**< Maximum size of buffer */
- uint32_t step_size; /**< Step size of buffer */
+ uint32_t min_size; /**< Minimum size of buffer */
+ uint32_t max_size; /**< Maximum size of buffer */
+ uint32_t step_size; /**< Step size of buffer */
} DltBuffer;
typedef struct
@@ -787,7 +791,7 @@ typedef struct
int count;
} DltBufferHead;
-#define DLT_BUFFER_HEAD "SHM"
+# define DLT_BUFFER_HEAD "SHM"
typedef struct
{
@@ -796,759 +800,772 @@ typedef struct
int size;
} DltBufferBlockHead;
-#define DLT_MESSAGE_ERROR_OK 0
-#define DLT_MESSAGE_ERROR_UNKNOWN -1
-#define DLT_MESSAGE_ERROR_SIZE -2
-#define DLT_MESSAGE_ERROR_CONTENT -3
+# define DLT_MESSAGE_ERROR_OK 0
+# define DLT_MESSAGE_ERROR_UNKNOWN -1
+# define DLT_MESSAGE_ERROR_SIZE -2
+# define DLT_MESSAGE_ERROR_CONTENT -3
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C"
{
-#endif
-
- /**
- * Helper function to print a byte array in hex.
- * @param ptr pointer to the byte array.
- * @param size number of bytes to be printed.
- */
- void dlt_print_hex(uint8_t *ptr,int size);
- /**
- * Helper function to print a byte array in hex into a string.
- * @param text pointer to a ASCII string, in which the text is written
- * @param textlength maximal size of text buffer
- * @param ptr pointer to the byte array.
- * @param size number of bytes to be printed.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_print_hex_string(char *text,int textlength,uint8_t *ptr,int size);
- /**
- * Helper function to print a byte array in hex and ascii into a string.
- * @param text pointer to a ASCII string, in which the text is written
- * @param textlength maximal size of text buffer
- * @param ptr pointer to the byte array.
- * @param size number of bytes to be printed.
- * @param html output is html? 0 - false, 1 - true
- * @return negative value if there was an error
- */
- DltReturnValue dlt_print_mixed_string(char *text,int textlength,uint8_t *ptr,int size,int html);
- /**
- * Helper function to print a byte array in ascii into a string.
- * @param text pointer to a ASCII string, in which the text is written
- * @param textlength maximal size of text buffer
- * @param ptr pointer to the byte array.
- * @param size number of bytes to be printed.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_print_char_string(char **text,int textlength,uint8_t *ptr,int size);
-
- /**
- * Helper function to print an id.
- * @param text pointer to ASCII string where to write the id
- * @param id four byte char array as used in DLT mesages as IDs.
- */
- void dlt_print_id(char *text,const char *id);
-
- /**
- * Helper function to set an ID parameter.
- * @param id four byte char array as used in DLT mesages as IDs.
- * @param text string to be copied into char array.
- */
- void dlt_set_id(char *id,const char *text);
-
- /**
- * Helper function to remove not nice to print characters, e.g. NULL or carage return.
- * @param text pointer to string to be cleaned.
- * @param length length of string excluding terminating zero.
- */
- void dlt_clean_string(char *text,int length);
-
- /**
- * Initialise the filter list.
- * This function must be called before using further dlt filter.
- * @param filter pointer to structure of organising DLT filter
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_filter_init(DltFilter *filter,int verbose);
- /**
- * Free the used memory by the organising structure of filter.
- * @param filter pointer to structure of organising DLT filter
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_filter_free(DltFilter *filter,int verbose);
- /**
- * Load filter list from file.
- * @param filter pointer to structure of organising DLT filter
- * @param filename filename to load filters from
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_filter_load(DltFilter *filter,const char *filename,int verbose);
- /**
- * Save filter list to file.
- * @param filter pointer to structure of organising DLT filter
- * @param filename filename to load filters from
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_filter_save(DltFilter *filter,const char *filename,int verbose);
- /**
- * Find index of filter in filter list
- * @param filter pointer to structure of organising DLT filter
- * @param apid application id to be found in filter list
- * @param ctid context id to be found in filter list
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error (or not found), else return index of filter
- */
- int dlt_filter_find(DltFilter *filter,const char *apid,const char *ctid, int verbose);
- /**
- * Add new filter to filter list.
- * @param filter pointer to structure of organising DLT filter
- * @param apid application id to be added to filter list (must always be set).
- * @param ctid context id to be added to filter list. empty equals don't care.
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_filter_add(DltFilter *filter,const char *apid,const char *ctid,int verbose);
- /**
- * Delete filter from filter list
- * @param filter pointer to structure of organising DLT filter
- * @param apid application id to be deleted from filter list
- * @param ctid context id to be deleted from filter list
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_filter_delete(DltFilter *filter,const char *apid,const char *ctid,int verbose);
-
- /**
- * Initialise the structure used to access a DLT message.
- * This function must be called before using further dlt_message functions.
- * @param msg pointer to structure of organising access to DLT messages
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_init(DltMessage *msg,int verbose);
- /**
- * Free the used memory by the organising structure of file.
- * @param msg pointer to structure of organising access to DLT messages
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_free(DltMessage *msg,int verbose);
- /**
- * Print Header into an ASCII string.
- * This function calls dlt_message_header_flags() with flags=DLT_HEADER_SHOW_ALL
- * @param msg pointer to structure of organising access to DLT messages
- * @param text pointer to a ASCII string, in which the header is written
- * @param textlength maximal size of text buffer
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_header(DltMessage *msg,char *text,int textlength,int verbose);
- /**
- * Print Header into an ASCII string, selective.
- * @param msg pointer to structure of organising access to DLT messages
- * @param text pointer to a ASCII string, in which the header is written
- * @param textlength maximal size of text buffer
- * @param flags select, bit-field to select, what should be printed (DLT_HEADER_SHOW_...)
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_header_flags(DltMessage *msg,char *text,int textlength,int flags, int verbose);
- /**
- * Print Payload into an ASCII string.
- * @param msg pointer to structure of organising access to DLT messages
- * @param text pointer to a ASCII string, in which the header is written
- * @param textlength maximal size of text buffer
- * @param type 1 = payload as hex, 2 = payload as ASCII.
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_payload(DltMessage *msg,char *text,int textlength,int type,int verbose);
- /**
- * Check if message is filtered or not. All filters are applied (logical OR).
- * @param msg pointer to structure of organising access to DLT messages
- * @param filter pointer to filter
- * @param verbose if set to true verbose information is printed out.
- * @return 1 = filter matches, 0 = filter does not match, negative value if there was an error
- */
- DltReturnValue dlt_message_filter_check(DltMessage *msg,DltFilter *filter,int verbose);
-
- /**
- * Read message from memory buffer.
- * Message in buffer has no storage header.
- * @param msg pointer to structure of organising access to DLT messages
- * @param buffer pointer to memory buffer
- * @param length length of message in buffer
- * @param resync if set to true resync to serial header is enforced
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- int dlt_message_read(DltMessage *msg,uint8_t *buffer,unsigned int length,int resync,int verbose);
-
- /**
- * Get standard header extra parameters
- * @param msg pointer to structure of organising access to DLT messages
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_get_extraparameters(DltMessage *msg,int verbose);
-
- /**
- * Set standard header extra parameters
- * @param msg pointer to structure of organising access to DLT messages
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_set_extraparameters(DltMessage *msg,int verbose);
-
- /**
- * Initialise the structure used to access a DLT file.
- * This function must be called before using further dlt_file functions.
- * @param file pointer to structure of organising access to DLT file
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_file_init(DltFile *file,int verbose);
- /**
- * Set a list to filters.
- * This function should be called before loading a DLT file, if filters should be used.
- * A filter list is an array of filters. Several filters are combined logically by or operation.
- * The filter list is not copied, so take care to keep list in memory.
- * @param file pointer to structure of organising access to DLT file
- * @param filter pointer to filter list array
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_file_set_filter(DltFile *file,DltFilter *filter,int verbose);
- /**
- * Initialising loading a DLT file.
- * @param file pointer to structure of organising access to DLT file
- * @param filename filename of DLT file
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_file_open(DltFile *file,const char *filename,int verbose);
- /**
- * Find next message in the DLT file and parse them.
- * This function finds the next message in the DLT file.
- * If a filter is set, the filter list is used.
- * @param file pointer to structure of organising access to DLT file
- * @param verbose if set to true verbose information is printed out.
- * @return 0 = message does not match filter, 1 = message was read, negative value if there was an error
- */
- DltReturnValue dlt_file_read(DltFile *file,int verbose);
- /**
- * Find next message in the DLT file in RAW format (without storage header) and parse them.
- * This function finds the next message in the DLT file.
- * If a filter is set, the filter list is used.
- * @param file pointer to structure of organising access to DLT file
- * @param resync Resync to serial header when set to true
- * @param verbose if set to true verbose information is printed out.
- * @return 0 = message does not match filter, 1 = message was read, negative value if there was an error
- */
- DltReturnValue dlt_file_read_raw(DltFile *file,int resync,int verbose);
- /**
- * Closing loading a DLT file.
- * @param file pointer to structure of organising access to DLT file
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_file_close(DltFile *file,int verbose);
- /**
- * Load standard header of a message from file
- * @param file pointer to structure of organising access to DLT file
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_file_read_header(DltFile *file,int verbose);
- /**
- * Load standard header of a message from file in RAW format (without storage header)
- * @param file pointer to structure of organising access to DLT file
- * @param resync Resync to serial header when set to true
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_file_read_header_raw(DltFile *file,int resync,int verbose);
- /**
- * Load, if available in message, extra standard header fields and
- * extended header of a message from file
- * (dlt_file_read_header() must have been called before this call!)
- * @param file pointer to structure of organising access to DLT file
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_file_read_header_extended(DltFile *file, int verbose);
- /**
- * Load payload of a message from file
- * (dlt_file_read_header() must have been called before this call!)
- * @param file pointer to structure of organising access to DLT file
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_file_read_data(DltFile *file, int verbose);
- /**
- * Load headers and payload of a message selected by the index.
- * If filters are set, index is based on the filtered list.
- * @param file pointer to structure of organising access to DLT file
- * @param index position of message in the files beginning from zero
- * @param verbose if set to true verbose information is printed out.
- * @return number of messages loaded, negative value if there was an error
- */
- DltReturnValue dlt_file_message(DltFile *file,int index,int verbose);
- /**
- * Free the used memory by the organising structure of file.
- * @param file pointer to structure of organising access to DLT file
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_file_free(DltFile *file,int verbose);
-
- /**
- * Set internal logging filename if mode 2
- * @param filename the filename
- */
- void dlt_log_set_filename(const char *filename);
- /**
- * Set internal logging level
- * @param level the level
- */
- void dlt_log_set_level(int level);
- /**
- * Initialize (external) logging facility
- * @param mode positive, 0 = log to stdout, 1 = log to syslog, 2 = log to file
- */
- void dlt_log_init(int mode);
- /**
- * Log ASCII string with null-termination to (external) logging facility
- * @param prio priority (see syslog() call)
- * @param s Pointer to ASCII string with null-termination
- * @return negative value if there was an error
- */
- DltReturnValue dlt_log(int prio, char *s);
- /**
- * Log with variable arguments to (external) logging facility (like printf)
- * @param prio priority (see syslog() call)
- * @param format format string for log message
- * @return negative value if there was an error
- */
- DltReturnValue dlt_vlog(int prio, const char *format, ...);
- /**
- * Log size bytes with variable arguments to (external) logging facility (similar to snprintf)
- * @param prio priority (see syslog() call)
- * @param size number of bytes to log
- * @param format format string for log message
- * @return negative value if there was an error
- */
- DltReturnValue dlt_vnlog(int prio, size_t size, const char *format, ...);
- /**
- * De-Initialize (external) logging facility
- */
- void dlt_log_free(void);
-
- /**
- * Initialising a dlt receiver structure
- * @param receiver pointer to dlt receiver structure
- * @param _fd handle to file/socket/fifo, fram which the data should be received
- * @param _buffersize size of data buffer for storing the received data
- * @return negative value if there was an error
- */
- DltReturnValue dlt_receiver_init(DltReceiver *receiver,int _fd, int _buffersize);
- /**
- * De-Initialize a dlt receiver structure
- * @param receiver pointer to dlt receiver structure
- * @return negative value if there was an error
- */
- DltReturnValue dlt_receiver_free(DltReceiver *receiver);
- /**
- * Initialising a dlt receiver structure
- * @param receiver pointer to dlt receiver structure
- * @param fd handle to file/socket/fifo, fram which the data should be received
- * @param buffer data buffer for storing the received data
- * @return negative value if there was an error and zero if success
- */
- DltReturnValue dlt_receiver_init_unix_socket(DltReceiver *receiver, int fd, char **buffer);
- /**
- * De-Initialize a dlt receiver structure
- * @param receiver pointer to dlt receiver structure
- * @return negative value if there was an error and zero if success
- */
- DltReturnValue dlt_receiver_free_unix_socket(DltReceiver *receiver);
- /**
- * Receive data from socket or file/fifo using the dlt receiver structure
- * @param receiver pointer to dlt receiver structure
- * @param from_src specify whether received data is from socket or file/fifo
- * @return number of received bytes or negative value if there was an error
- */
- int dlt_receiver_receive(DltReceiver *receiver, DltReceiverType from_src);
- /**
- * Remove a specific size of bytes from the received data
- * @param receiver pointer to dlt receiver structure
- * @param size amount of bytes to be removed
- * @return negative value if there was an error
- */
- DltReturnValue dlt_receiver_remove(DltReceiver *receiver,int size);
- /**
- * Move data from last receive call to front of receive buffer
- * @param receiver pointer to dlt receiver structure
- * @return negative value if there was an error
- */
- DltReturnValue dlt_receiver_move_to_begin(DltReceiver *receiver);
-
- /**
- * Check whether to_get amount of data is available in receiver and
- * copy it to dest. Skip the DltUserHeader if skip_header is set to 1.
- * @param receiver pointer to dlt receiver structure
- * @param dest pointer to the destination buffer
- * @param to_get size of the data to copy in dest
- * @skip_header whether if the DltUserHeader must be skipped.
- */
- int dlt_receiver_check_and_get(DltReceiver *receiver,
- void *dest,
- unsigned int to_get,
- unsigned int skip_header);
-
- /**
- * Fill out storage header of a dlt message
- * @param storageheader pointer to storage header of a dlt message
- * @param ecu name of ecu to be set in storage header
- * @return negative value if there was an error
- */
- DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char *ecu);
- /**
- * Check if a storage header contains its marker
- * @param storageheader pointer to storage header of a dlt message
- * @return 0 no, 1 yes, negative value if there was an error
- */
- DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader);
-
-
- /**
- * Initialise static ringbuffer with a size of size.
- * Initialise as server. Init counters.
- * Memory is already allocated.
- * @param buf Pointer to ringbuffer structure
- * @param ptr Ptr to ringbuffer memory
- * @param size Maximum size of buffer in bytes
- * @return negative value if there was an error
- */
- DltReturnValue dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint32_t size);
-
- /**
- * Initialize static ringbuffer with a size of size.
- * Initialise as a client. Do not change counters.
- * Memory is already allocated.
- * @param buf Pointer to ringbuffer structure
- * @param ptr Ptr to ringbuffer memory
- * @param size Maximum size of buffer in bytes
- * @return negative value if there was an error
- */
- DltReturnValue dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint32_t size);
-
- /**
- * Initialize dynamic ringbuffer with a size of size.
- * Initialise as a client. Do not change counters.
- * Memory will be allocated starting with min_size.
- * If more memory is needed size is increased wit step_size.
- * The maximum size is max_size.
- * @param buf Pointer to ringbuffer structure
- * @param min_size Minimum size of buffer in bytes
- * @param max_size Maximum size of buffer in bytes
- * @param step_size size of which ringbuffer is increased
- * @return negative value if there was an error
- */
- DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size,uint32_t step_size);
-
- /**
- * Deinitilaise usage of static ringbuffer
- * @param buf Pointer to ringbuffer structure
- * @return negative value if there was an error
- */
- DltReturnValue dlt_buffer_free_static(DltBuffer *buf);
-
- /**
- * Release and free memory used by dynamic ringbuffer
- * @param buf Pointer to ringbuffer structure
- * @return negative value if there was an error
- */
- DltReturnValue dlt_buffer_free_dynamic(DltBuffer *buf);
-
- /**
- * Check if message fits into buffer.
- * @param buf Pointer to buffer structure
- * @return DLT_RETURN_OK if enough space, DLT_RETURN_ERROR otherwise
- */
- DltReturnValue dlt_buffer_check_size(DltBuffer *buf, int needed);
-
- /**
- * Write one entry to ringbuffer
- * @param buf Pointer to ringbuffer structure
- * @param data Pointer to data to be written to ringbuffer
- * @param size Size of data in bytes to be written to ringbuffer
- * @return negative value if there was an error
- */
- DltReturnValue dlt_buffer_push(DltBuffer *buf,const unsigned char *data,unsigned int size);
-
- /**
- * Write up to three entries to ringbuffer.
- * Entries are joined to one block.
- * @param dlt Pointer to ringbuffer structure
- * @param data1 Pointer to data to be written to ringbuffer
- * @param size1 Size of data in bytes to be written to ringbuffer
- * @param data2 Pointer to data to be written to ringbuffer
- * @param size2 Size of data in bytes to be written to ringbuffer
- * @param data3 Pointer to data to be written to ringbuffer
- * @param size3 Size of data in bytes to be written to ringbuffer
- * @return negative value if there was an error
- */
- DltReturnValue dlt_buffer_push3(DltBuffer *buf,const unsigned char *data1,unsigned int size1,const unsigned char *data2,unsigned int size2,const unsigned char *data3,unsigned int size3);
-
- /**
- * Read one entry from ringbuffer.
- * Remove it from ringbuffer.
- * @param buf Pointer to ringbuffer structure
- * @param data Pointer to data read from ringbuffer
- * @param max_size Max size of read data in bytes from ringbuffer
- * @return size of read data, zero if no data available, negative value if there was an error
- */
- int dlt_buffer_pull(DltBuffer *buf,unsigned char *data, int max_size);
-
- /**
- * Read one entry from ringbuffer.
- * Do not remove it from ringbuffer.
- * @param buf Pointer to ringbuffer structure
- * @param data Pointer to data read from ringbuffer
- * @param max_size Max size of read data in bytes from ringbuffer
- * @return size of read data, zero if no data available, negative value if there was an error
- */
- int dlt_buffer_copy(DltBuffer *buf,unsigned char *data, int max_size);
-
- /**
- * Remove entry from ringbuffer.
- * @param buf Pointer to ringbuffer structure
- * @return size of read data, zero if no data available, negative value if there was an error
- */
- int dlt_buffer_remove(DltBuffer *buf);
-
- /**
- * Print information about buffer and log to internal DLT log.
- * @param buf Pointer to ringbuffer structure
- */
- void dlt_buffer_info(DltBuffer *buf);
-
- /**
- * Print status of buffer and log to internal DLT log.
- * @param buf Pointer to ringbuffer structure
- */
- void dlt_buffer_status(DltBuffer *buf);
-
- /**
- * Get total size in bytes of ringbuffer.
- * If buffer is dynamic, max size is returned.
- * @param buf Pointer to ringbuffer structure
- * @return total size of buffer
- */
- uint32_t dlt_buffer_get_total_size(DltBuffer *buf);
-
- /**
- * Get used size in bytes of ringbuffer.
- * @param buf Pointer to ringbuffer structure
- * @return used size of buffer
- */
- int dlt_buffer_get_used_size(DltBuffer *buf);
-
- /**
- * Get number of entries in ringbuffer.
- * @param buf Pointer to ringbuffer structure
- * @return number of entries
- */
- int dlt_buffer_get_message_count(DltBuffer *buf);
-
-#if !defined (__WIN32__)
-
- /**
- * Helper function: Setup serial connection
- * @param fd File descriptor of serial tty device
- * @param speed Serial line speed, as defined in termios.h
- * @return negative value if there was an error
- */
- DltReturnValue dlt_setup_serial(int fd, speed_t speed);
-
- /**
- * Helper function: Convert serial line baudrate (as number) to line speed (as defined in termios.h)
- * @param baudrate Serial line baudrate (as number)
- * @return Serial line speed, as defined in termios.h
- */
- speed_t dlt_convert_serial_speed(int baudrate);
-
- /**
- * Print dlt version and dlt svn version to buffer
- * @param buf Pointer to buffer
- * @param size size of buffer
- */
- void dlt_get_version(char *buf, size_t size);
-
- /**
- * Print dlt major version to buffer
- * @param buf Pointer to buffer
- * @param size size of buffer
- */
- void dlt_get_major_version(char *buf, size_t size);
-
- /**
- * Print dlt minor version to buffer
- * @param buf Pointer to buffer
- * @param size size of buffer
- */
- void dlt_get_minor_version(char *buf, size_t size);
-
-#endif
-
- /* Function prototypes which should be used only internally */
- /* */
-
- /**
- * Common part of initialisation
- * @return negative value if there was an error
- */
- DltReturnValue dlt_init_common(void);
-
- /**
- * Return the uptime of the system in 0.1 ms resolution
- * @return 0 if there was an error
- */
- uint32_t dlt_uptime(void);
-
- /**
- * Print header of a DLT message
- * @param message pointer to structure of organising access to DLT messages
- * @param text pointer to a ASCII string, in which the header is written
- * @param size maximal size of text buffer
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_print_header(DltMessage *message, char *text, uint32_t size, int verbose);
-
- /**
- * Print payload of a DLT message as Hex-Output
- * @param message pointer to structure of organising access to DLT messages
- * @param text pointer to a ASCII string, in which the output is written
- * @param size maximal size of text buffer
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_print_hex(DltMessage *message, char *text, uint32_t size, int verbose);
-
- /**
- * Print payload of a DLT message as ASCII-Output
- * @param message pointer to structure of organising access to DLT messages
- * @param text pointer to a ASCII string, in which the output is written
- * @param size maximal size of text buffer
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_print_ascii(DltMessage *message, char *text, uint32_t size, int verbose);
-
- /**
- * Print payload of a DLT message as Mixed-Ouput (Hex and ASCII), for plain text output
- * @param message pointer to structure of organising access to DLT messages
- * @param text pointer to a ASCII string, in which the output is written
- * @param size maximal size of text buffer
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_print_mixed_plain(DltMessage *message, char *text, uint32_t size, int verbose);
-
- /**
- * Print payload of a DLT message as Mixed-Ouput (Hex and ASCII), for HTML text output
- * @param message pointer to structure of organising access to DLT messages
- * @param text pointer to a ASCII string, in which the output is written
- * @param size maximal size of text buffer
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_print_mixed_html(DltMessage *message, char *text, uint32_t size, int verbose);
-
- /**
- * Decode and print a argument of a DLT message
- * @param msg pointer to structure of organising access to DLT messages
- * @param type_info Type of argument
- * @param ptr pointer to pointer to data (pointer to data is changed within this function)
- * @param datalength pointer to datalength (datalength is changed within this function)
- * @param text pointer to a ASCII string, in which the output is written
- * @param textlength maximal size of text buffer
- * @param byteLength If argument is a string, and this value is 0 or greater, this value will be taken as string length
- * @param verbose if set to true verbose information is printed out.
- * @return negative value if there was an error
- */
- DltReturnValue dlt_message_argument_print(DltMessage *msg,uint32_t type_info,uint8_t **ptr,int32_t *datalength,char *text,int textlength,int byteLength,int verbose);
-
- /**
- * Check environment variables.
- */
- void dlt_check_envvar();
-
- /**
- * Parse the response text and identifying service id and its options.
- *
- * @param resp_text char *
- * @param service_id int *
- * @param service_opt int *
- * @return pointer to resp_text
- */
- int dlt_set_loginfo_parse_service_id(char *resp_text, uint32_t *service_id, uint8_t *service_opt);
-
- /**
- * Convert get log info from ASCII to uint16
- *
- * @param rp char
- * @param rp_count int
- * @return length
- */
- int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count);
-
- /**
- * Convert get log info from ASCII to int16
- *
- * @param rp char
- * @param rp_count int
- * @return length
- */
- int16_t dlt_getloginfo_conv_ascii_to_int16_t(char *rp, int *rp_count);
-
- /**
- * Convert get log info from ASCII to ID
- *
- * @param rp char
- * @param rp_count int
- * @param wp char
- * @param length int
- */
- void dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len);
-
- /**
- * Convert from hex ASCII to binary
- * @param ptr const char
- * @param binary uint8_t
- * @param size int
- */
- void dlt_hex_ascii_to_binary(const char *ptr, uint8_t *binary, int *size);
-
-#ifndef DLT_USE_UNIX_SOCKET_IPC
- /**
- * Create the specified path, recursive if necessary
- * behaves like calling mkdir -p <dir> on the console
- */
- int dlt_mkdir_recursive(const char *dir);
-#endif
-
-#ifdef __cplusplus
+# endif
+
+/**
+ * Helper function to print a byte array in hex.
+ * @param ptr pointer to the byte array.
+ * @param size number of bytes to be printed.
+ */
+void dlt_print_hex(uint8_t *ptr, int size);
+/**
+ * Helper function to print a byte array in hex into a string.
+ * @param text pointer to a ASCII string, in which the text is written
+ * @param textlength maximal size of text buffer
+ * @param ptr pointer to the byte array.
+ * @param size number of bytes to be printed.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_print_hex_string(char *text, int textlength, uint8_t *ptr, int size);
+/**
+ * Helper function to print a byte array in hex and ascii into a string.
+ * @param text pointer to a ASCII string, in which the text is written
+ * @param textlength maximal size of text buffer
+ * @param ptr pointer to the byte array.
+ * @param size number of bytes to be printed.
+ * @param html output is html? 0 - false, 1 - true
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_print_mixed_string(char *text, int textlength, uint8_t *ptr, int size, int html);
+/**
+ * Helper function to print a byte array in ascii into a string.
+ * @param text pointer to a ASCII string, in which the text is written
+ * @param textlength maximal size of text buffer
+ * @param ptr pointer to the byte array.
+ * @param size number of bytes to be printed.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_print_char_string(char **text, int textlength, uint8_t *ptr, int size);
+
+/**
+ * Helper function to print an id.
+ * @param text pointer to ASCII string where to write the id
+ * @param id four byte char array as used in DLT mesages as IDs.
+ */
+void dlt_print_id(char *text, const char *id);
+
+/**
+ * Helper function to set an ID parameter.
+ * @param id four byte char array as used in DLT mesages as IDs.
+ * @param text string to be copied into char array.
+ */
+void dlt_set_id(char *id, const char *text);
+
+/**
+ * Helper function to remove not nice to print characters, e.g. NULL or carage return.
+ * @param text pointer to string to be cleaned.
+ * @param length length of string excluding terminating zero.
+ */
+void dlt_clean_string(char *text, int length);
+
+/**
+ * Initialise the filter list.
+ * This function must be called before using further dlt filter.
+ * @param filter pointer to structure of organising DLT filter
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_filter_init(DltFilter *filter, int verbose);
+/**
+ * Free the used memory by the organising structure of filter.
+ * @param filter pointer to structure of organising DLT filter
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_filter_free(DltFilter *filter, int verbose);
+/**
+ * Load filter list from file.
+ * @param filter pointer to structure of organising DLT filter
+ * @param filename filename to load filters from
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_filter_load(DltFilter *filter, const char *filename, int verbose);
+/**
+ * Save filter list to file.
+ * @param filter pointer to structure of organising DLT filter
+ * @param filename filename to load filters from
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_filter_save(DltFilter *filter, const char *filename, int verbose);
+/**
+ * Find index of filter in filter list
+ * @param filter pointer to structure of organising DLT filter
+ * @param apid application id to be found in filter list
+ * @param ctid context id to be found in filter list
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error (or not found), else return index of filter
+ */
+int dlt_filter_find(DltFilter *filter, const char *apid, const char *ctid, int verbose);
+/**
+ * Add new filter to filter list.
+ * @param filter pointer to structure of organising DLT filter
+ * @param apid application id to be added to filter list (must always be set).
+ * @param ctid context id to be added to filter list. empty equals don't care.
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_filter_add(DltFilter *filter, const char *apid, const char *ctid, int verbose);
+/**
+ * Delete filter from filter list
+ * @param filter pointer to structure of organising DLT filter
+ * @param apid application id to be deleted from filter list
+ * @param ctid context id to be deleted from filter list
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_filter_delete(DltFilter *filter, const char *apid, const char *ctid, int verbose);
+
+/**
+ * Initialise the structure used to access a DLT message.
+ * This function must be called before using further dlt_message functions.
+ * @param msg pointer to structure of organising access to DLT messages
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_init(DltMessage *msg, int verbose);
+/**
+ * Free the used memory by the organising structure of file.
+ * @param msg pointer to structure of organising access to DLT messages
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_free(DltMessage *msg, int verbose);
+/**
+ * Print Header into an ASCII string.
+ * This function calls dlt_message_header_flags() with flags=DLT_HEADER_SHOW_ALL
+ * @param msg pointer to structure of organising access to DLT messages
+ * @param text pointer to a ASCII string, in which the header is written
+ * @param textlength maximal size of text buffer
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_header(DltMessage *msg, char *text, int textlength, int verbose);
+/**
+ * Print Header into an ASCII string, selective.
+ * @param msg pointer to structure of organising access to DLT messages
+ * @param text pointer to a ASCII string, in which the header is written
+ * @param textlength maximal size of text buffer
+ * @param flags select, bit-field to select, what should be printed (DLT_HEADER_SHOW_...)
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_header_flags(DltMessage *msg, char *text, int textlength, int flags, int verbose);
+/**
+ * Print Payload into an ASCII string.
+ * @param msg pointer to structure of organising access to DLT messages
+ * @param text pointer to a ASCII string, in which the header is written
+ * @param textlength maximal size of text buffer
+ * @param type 1 = payload as hex, 2 = payload as ASCII.
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength, int type, int verbose);
+/**
+ * Check if message is filtered or not. All filters are applied (logical OR).
+ * @param msg pointer to structure of organising access to DLT messages
+ * @param filter pointer to filter
+ * @param verbose if set to true verbose information is printed out.
+ * @return 1 = filter matches, 0 = filter does not match, negative value if there was an error
+ */
+DltReturnValue dlt_message_filter_check(DltMessage *msg, DltFilter *filter, int verbose);
+
+/**
+ * Read message from memory buffer.
+ * Message in buffer has no storage header.
+ * @param msg pointer to structure of organising access to DLT messages
+ * @param buffer pointer to memory buffer
+ * @param length length of message in buffer
+ * @param resync if set to true resync to serial header is enforced
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+int dlt_message_read(DltMessage *msg, uint8_t *buffer, unsigned int length, int resync, int verbose);
+
+/**
+ * Get standard header extra parameters
+ * @param msg pointer to structure of organising access to DLT messages
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_get_extraparameters(DltMessage *msg, int verbose);
+
+/**
+ * Set standard header extra parameters
+ * @param msg pointer to structure of organising access to DLT messages
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_set_extraparameters(DltMessage *msg, int verbose);
+
+/**
+ * Initialise the structure used to access a DLT file.
+ * This function must be called before using further dlt_file functions.
+ * @param file pointer to structure of organising access to DLT file
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_file_init(DltFile *file, int verbose);
+/**
+ * Set a list to filters.
+ * This function should be called before loading a DLT file, if filters should be used.
+ * A filter list is an array of filters. Several filters are combined logically by or operation.
+ * The filter list is not copied, so take care to keep list in memory.
+ * @param file pointer to structure of organising access to DLT file
+ * @param filter pointer to filter list array
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_file_set_filter(DltFile *file, DltFilter *filter, int verbose);
+/**
+ * Initialising loading a DLT file.
+ * @param file pointer to structure of organising access to DLT file
+ * @param filename filename of DLT file
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_file_open(DltFile *file, const char *filename, int verbose);
+/**
+ * Find next message in the DLT file and parse them.
+ * This function finds the next message in the DLT file.
+ * If a filter is set, the filter list is used.
+ * @param file pointer to structure of organising access to DLT file
+ * @param verbose if set to true verbose information is printed out.
+ * @return 0 = message does not match filter, 1 = message was read, negative value if there was an error
+ */
+DltReturnValue dlt_file_read(DltFile *file, int verbose);
+/**
+ * Find next message in the DLT file in RAW format (without storage header) and parse them.
+ * This function finds the next message in the DLT file.
+ * If a filter is set, the filter list is used.
+ * @param file pointer to structure of organising access to DLT file
+ * @param resync Resync to serial header when set to true
+ * @param verbose if set to true verbose information is printed out.
+ * @return 0 = message does not match filter, 1 = message was read, negative value if there was an error
+ */
+DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose);
+/**
+ * Closing loading a DLT file.
+ * @param file pointer to structure of organising access to DLT file
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_file_close(DltFile *file, int verbose);
+/**
+ * Load standard header of a message from file
+ * @param file pointer to structure of organising access to DLT file
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_file_read_header(DltFile *file, int verbose);
+/**
+ * Load standard header of a message from file in RAW format (without storage header)
+ * @param file pointer to structure of organising access to DLT file
+ * @param resync Resync to serial header when set to true
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_file_read_header_raw(DltFile *file, int resync, int verbose);
+/**
+ * Load, if available in message, extra standard header fields and
+ * extended header of a message from file
+ * (dlt_file_read_header() must have been called before this call!)
+ * @param file pointer to structure of organising access to DLT file
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_file_read_header_extended(DltFile *file, int verbose);
+/**
+ * Load payload of a message from file
+ * (dlt_file_read_header() must have been called before this call!)
+ * @param file pointer to structure of organising access to DLT file
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_file_read_data(DltFile *file, int verbose);
+/**
+ * Load headers and payload of a message selected by the index.
+ * If filters are set, index is based on the filtered list.
+ * @param file pointer to structure of organising access to DLT file
+ * @param index position of message in the files beginning from zero
+ * @param verbose if set to true verbose information is printed out.
+ * @return number of messages loaded, negative value if there was an error
+ */
+DltReturnValue dlt_file_message(DltFile *file, int index, int verbose);
+/**
+ * Free the used memory by the organising structure of file.
+ * @param file pointer to structure of organising access to DLT file
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_file_free(DltFile *file, int verbose);
+
+/**
+ * Set internal logging filename if mode 2
+ * @param filename the filename
+ */
+void dlt_log_set_filename(const char *filename);
+/**
+ * Set internal logging level
+ * @param level the level
+ */
+void dlt_log_set_level(int level);
+/**
+ * Initialize (external) logging facility
+ * @param mode positive, 0 = log to stdout, 1 = log to syslog, 2 = log to file
+ */
+void dlt_log_init(int mode);
+/**
+ * Log ASCII string with null-termination to (external) logging facility
+ * @param prio priority (see syslog() call)
+ * @param s Pointer to ASCII string with null-termination
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_log(int prio, char *s);
+/**
+ * Log with variable arguments to (external) logging facility (like printf)
+ * @param prio priority (see syslog() call)
+ * @param format format string for log message
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_vlog(int prio, const char *format, ...);
+/**
+ * Log size bytes with variable arguments to (external) logging facility (similar to snprintf)
+ * @param prio priority (see syslog() call)
+ * @param size number of bytes to log
+ * @param format format string for log message
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_vnlog(int prio, size_t size, const char *format, ...);
+/**
+ * De-Initialize (external) logging facility
+ */
+void dlt_log_free(void);
+
+/**
+ * Initialising a dlt receiver structure
+ * @param receiver pointer to dlt receiver structure
+ * @param _fd handle to file/socket/fifo, fram which the data should be received
+ * @param _buffersize size of data buffer for storing the received data
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_receiver_init(DltReceiver *receiver, int _fd, int _buffersize);
+/**
+ * De-Initialize a dlt receiver structure
+ * @param receiver pointer to dlt receiver structure
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_receiver_free(DltReceiver *receiver);
+/**
+ * Initialising a dlt receiver structure
+ * @param receiver pointer to dlt receiver structure
+ * @param fd handle to file/socket/fifo, fram which the data should be received
+ * @param buffer data buffer for storing the received data
+ * @return negative value if there was an error and zero if success
+ */
+DltReturnValue dlt_receiver_init_unix_socket(DltReceiver *receiver, int fd, char **buffer);
+/**
+ * De-Initialize a dlt receiver structure
+ * @param receiver pointer to dlt receiver structure
+ * @return negative value if there was an error and zero if success
+ */
+DltReturnValue dlt_receiver_free_unix_socket(DltReceiver *receiver);
+/**
+ * Receive data from socket or file/fifo using the dlt receiver structure
+ * @param receiver pointer to dlt receiver structure
+ * @param from_src specify whether received data is from socket or file/fifo
+ * @return number of received bytes or negative value if there was an error
+ */
+int dlt_receiver_receive(DltReceiver *receiver, DltReceiverType from_src);
+/**
+ * Remove a specific size of bytes from the received data
+ * @param receiver pointer to dlt receiver structure
+ * @param size amount of bytes to be removed
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_receiver_remove(DltReceiver *receiver, int size);
+/**
+ * Move data from last receive call to front of receive buffer
+ * @param receiver pointer to dlt receiver structure
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_receiver_move_to_begin(DltReceiver *receiver);
+
+/**
+ * Check whether to_get amount of data is available in receiver and
+ * copy it to dest. Skip the DltUserHeader if skip_header is set to 1.
+ * @param receiver pointer to dlt receiver structure
+ * @param dest pointer to the destination buffer
+ * @param to_get size of the data to copy in dest
+ * @skip_header whether if the DltUserHeader must be skipped.
+ */
+int dlt_receiver_check_and_get(DltReceiver *receiver,
+ void *dest,
+ unsigned int to_get,
+ unsigned int skip_header);
+
+/**
+ * Fill out storage header of a dlt message
+ * @param storageheader pointer to storage header of a dlt message
+ * @param ecu name of ecu to be set in storage header
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char *ecu);
+/**
+ * Check if a storage header contains its marker
+ * @param storageheader pointer to storage header of a dlt message
+ * @return 0 no, 1 yes, negative value if there was an error
+ */
+DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader);
+
+
+/**
+ * Initialise static ringbuffer with a size of size.
+ * Initialise as server. Init counters.
+ * Memory is already allocated.
+ * @param buf Pointer to ringbuffer structure
+ * @param ptr Ptr to ringbuffer memory
+ * @param size Maximum size of buffer in bytes
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint32_t size);
+
+/**
+ * Initialize static ringbuffer with a size of size.
+ * Initialise as a client. Do not change counters.
+ * Memory is already allocated.
+ * @param buf Pointer to ringbuffer structure
+ * @param ptr Ptr to ringbuffer memory
+ * @param size Maximum size of buffer in bytes
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint32_t size);
+
+/**
+ * Initialize dynamic ringbuffer with a size of size.
+ * Initialise as a client. Do not change counters.
+ * Memory will be allocated starting with min_size.
+ * If more memory is needed size is increased wit step_size.
+ * The maximum size is max_size.
+ * @param buf Pointer to ringbuffer structure
+ * @param min_size Minimum size of buffer in bytes
+ * @param max_size Maximum size of buffer in bytes
+ * @param step_size size of which ringbuffer is increased
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size, uint32_t step_size);
+
+/**
+ * Deinitilaise usage of static ringbuffer
+ * @param buf Pointer to ringbuffer structure
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_buffer_free_static(DltBuffer *buf);
+
+/**
+ * Release and free memory used by dynamic ringbuffer
+ * @param buf Pointer to ringbuffer structure
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_buffer_free_dynamic(DltBuffer *buf);
+
+/**
+ * Check if message fits into buffer.
+ * @param buf Pointer to buffer structure
+ * @return DLT_RETURN_OK if enough space, DLT_RETURN_ERROR otherwise
+ */
+DltReturnValue dlt_buffer_check_size(DltBuffer *buf, int needed);
+
+/**
+ * Write one entry to ringbuffer
+ * @param buf Pointer to ringbuffer structure
+ * @param data Pointer to data to be written to ringbuffer
+ * @param size Size of data in bytes to be written to ringbuffer
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_buffer_push(DltBuffer *buf, const unsigned char *data, unsigned int size);
+
+/**
+ * Write up to three entries to ringbuffer.
+ * Entries are joined to one block.
+ * @param dlt Pointer to ringbuffer structure
+ * @param data1 Pointer to data to be written to ringbuffer
+ * @param size1 Size of data in bytes to be written to ringbuffer
+ * @param data2 Pointer to data to be written to ringbuffer
+ * @param size2 Size of data in bytes to be written to ringbuffer
+ * @param data3 Pointer to data to be written to ringbuffer
+ * @param size3 Size of data in bytes to be written to ringbuffer
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_buffer_push3(DltBuffer *buf,
+ const unsigned char *data1,
+ unsigned int size1,
+ const unsigned char *data2,
+ unsigned int size2,
+ const unsigned char *data3,
+ unsigned int size3);
+
+/**
+ * Read one entry from ringbuffer.
+ * Remove it from ringbuffer.
+ * @param buf Pointer to ringbuffer structure
+ * @param data Pointer to data read from ringbuffer
+ * @param max_size Max size of read data in bytes from ringbuffer
+ * @return size of read data, zero if no data available, negative value if there was an error
+ */
+int dlt_buffer_pull(DltBuffer *buf, unsigned char *data, int max_size);
+
+/**
+ * Read one entry from ringbuffer.
+ * Do not remove it from ringbuffer.
+ * @param buf Pointer to ringbuffer structure
+ * @param data Pointer to data read from ringbuffer
+ * @param max_size Max size of read data in bytes from ringbuffer
+ * @return size of read data, zero if no data available, negative value if there was an error
+ */
+int dlt_buffer_copy(DltBuffer *buf, unsigned char *data, int max_size);
+
+/**
+ * Remove entry from ringbuffer.
+ * @param buf Pointer to ringbuffer structure
+ * @return size of read data, zero if no data available, negative value if there was an error
+ */
+int dlt_buffer_remove(DltBuffer *buf);
+
+/**
+ * Print information about buffer and log to internal DLT log.
+ * @param buf Pointer to ringbuffer structure
+ */
+void dlt_buffer_info(DltBuffer *buf);
+
+/**
+ * Print status of buffer and log to internal DLT log.
+ * @param buf Pointer to ringbuffer structure
+ */
+void dlt_buffer_status(DltBuffer *buf);
+
+/**
+ * Get total size in bytes of ringbuffer.
+ * If buffer is dynamic, max size is returned.
+ * @param buf Pointer to ringbuffer structure
+ * @return total size of buffer
+ */
+uint32_t dlt_buffer_get_total_size(DltBuffer *buf);
+
+/**
+ * Get used size in bytes of ringbuffer.
+ * @param buf Pointer to ringbuffer structure
+ * @return used size of buffer
+ */
+int dlt_buffer_get_used_size(DltBuffer *buf);
+
+/**
+ * Get number of entries in ringbuffer.
+ * @param buf Pointer to ringbuffer structure
+ * @return number of entries
+ */
+int dlt_buffer_get_message_count(DltBuffer *buf);
+
+# if !defined (__WIN32__)
+
+/**
+ * Helper function: Setup serial connection
+ * @param fd File descriptor of serial tty device
+ * @param speed Serial line speed, as defined in termios.h
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_setup_serial(int fd, speed_t speed);
+
+/**
+ * Helper function: Convert serial line baudrate (as number) to line speed (as defined in termios.h)
+ * @param baudrate Serial line baudrate (as number)
+ * @return Serial line speed, as defined in termios.h
+ */
+speed_t dlt_convert_serial_speed(int baudrate);
+
+/**
+ * Print dlt version and dlt svn version to buffer
+ * @param buf Pointer to buffer
+ * @param size size of buffer
+ */
+void dlt_get_version(char *buf, size_t size);
+
+/**
+ * Print dlt major version to buffer
+ * @param buf Pointer to buffer
+ * @param size size of buffer
+ */
+void dlt_get_major_version(char *buf, size_t size);
+
+/**
+ * Print dlt minor version to buffer
+ * @param buf Pointer to buffer
+ * @param size size of buffer
+ */
+void dlt_get_minor_version(char *buf, size_t size);
+
+# endif
+
+/* Function prototypes which should be used only internally */
+/* */
+
+/**
+ * Common part of initialisation
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_init_common(void);
+
+/**
+ * Return the uptime of the system in 0.1 ms resolution
+ * @return 0 if there was an error
+ */
+uint32_t dlt_uptime(void);
+
+/**
+ * Print header of a DLT message
+ * @param message pointer to structure of organising access to DLT messages
+ * @param text pointer to a ASCII string, in which the header is written
+ * @param size maximal size of text buffer
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_print_header(DltMessage *message, char *text, uint32_t size, int verbose);
+
+/**
+ * Print payload of a DLT message as Hex-Output
+ * @param message pointer to structure of organising access to DLT messages
+ * @param text pointer to a ASCII string, in which the output is written
+ * @param size maximal size of text buffer
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_print_hex(DltMessage *message, char *text, uint32_t size, int verbose);
+
+/**
+ * Print payload of a DLT message as ASCII-Output
+ * @param message pointer to structure of organising access to DLT messages
+ * @param text pointer to a ASCII string, in which the output is written
+ * @param size maximal size of text buffer
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_print_ascii(DltMessage *message, char *text, uint32_t size, int verbose);
+
+/**
+ * Print payload of a DLT message as Mixed-Ouput (Hex and ASCII), for plain text output
+ * @param message pointer to structure of organising access to DLT messages
+ * @param text pointer to a ASCII string, in which the output is written
+ * @param size maximal size of text buffer
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_print_mixed_plain(DltMessage *message, char *text, uint32_t size, int verbose);
+
+/**
+ * Print payload of a DLT message as Mixed-Ouput (Hex and ASCII), for HTML text output
+ * @param message pointer to structure of organising access to DLT messages
+ * @param text pointer to a ASCII string, in which the output is written
+ * @param size maximal size of text buffer
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_print_mixed_html(DltMessage *message, char *text, uint32_t size, int verbose);
+
+/**
+ * Decode and print a argument of a DLT message
+ * @param msg pointer to structure of organising access to DLT messages
+ * @param type_info Type of argument
+ * @param ptr pointer to pointer to data (pointer to data is changed within this function)
+ * @param datalength pointer to datalength (datalength is changed within this function)
+ * @param text pointer to a ASCII string, in which the output is written
+ * @param textlength maximal size of text buffer
+ * @param byteLength If argument is a string, and this value is 0 or greater, this value will be taken as string length
+ * @param verbose if set to true verbose information is printed out.
+ * @return negative value if there was an error
+ */
+DltReturnValue dlt_message_argument_print(DltMessage *msg,
+ uint32_t type_info,
+ uint8_t **ptr,
+ int32_t *datalength,
+ char *text,
+ int textlength,
+ int byteLength,
+ int verbose);
+
+/**
+ * Check environment variables.
+ */
+void dlt_check_envvar();
+
+/**
+ * Parse the response text and identifying service id and its options.
+ *
+ * @param resp_text char *
+ * @param service_id int *
+ * @param service_opt int *
+ * @return pointer to resp_text
+ */
+int dlt_set_loginfo_parse_service_id(char *resp_text, uint32_t *service_id, uint8_t *service_opt);
+
+/**
+ * Convert get log info from ASCII to uint16
+ *
+ * @param rp char
+ * @param rp_count int
+ * @return length
+ */
+int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count);
+
+/**
+ * Convert get log info from ASCII to int16
+ *
+ * @param rp char
+ * @param rp_count int
+ * @return length
+ */
+int16_t dlt_getloginfo_conv_ascii_to_int16_t(char *rp, int *rp_count);
+
+/**
+ * Convert get log info from ASCII to ID
+ *
+ * @param rp char
+ * @param rp_count int
+ * @param wp char
+ * @param length int
+ */
+void dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len);
+
+/**
+ * Convert from hex ASCII to binary
+ * @param ptr const char
+ * @param binary uint8_t
+ * @param size int
+ */
+void dlt_hex_ascii_to_binary(const char *ptr, uint8_t *binary, int *size);
+
+# ifndef DLT_USE_UNIX_SOCKET_IPC
+/**
+ * Create the specified path, recursive if necessary
+ * behaves like calling mkdir -p <dir> on the console
+ */
+int dlt_mkdir_recursive(const char *dir);
+# endif
+
+# ifdef __cplusplus
}
-#endif
+# endif
/**
- \}
-*/
+ \}
+ */
#endif /* DLT_COMMON_H */
diff --git a/include/dlt/dlt_common_api.h b/include/dlt/dlt_common_api.h
index 701105f..5927ac7 100644
--- a/include/dlt/dlt_common_api.h
+++ b/include/dlt/dlt_common_api.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_common_api.h
-*/
+ */
/*******************************************************************************
** **
@@ -93,8 +93,8 @@
* @param APPID context id with maximal four characters
* @param DESCRIPTION ASCII string containing description
*/
-#define DLT_REGISTER_CONTEXT_APP(CONTEXT,CONTEXTID,APPID,DESCRIPTION) \
- DLT_REGISTER_CONTEXT(CONTEXT,CONTEXTID,DESCRIPTION)
+#define DLT_REGISTER_CONTEXT_APP(CONTEXT, CONTEXTID, APPID, DESCRIPTION) \
+ DLT_REGISTER_CONTEXT(CONTEXT, CONTEXTID, DESCRIPTION)
/**
* Send log message with variable list of messages (intended for verbose mode)
@@ -104,56 +104,193 @@
* @param ARGS variable list of arguments
*/
/*****************************************/
-#define DLT_LOG0(CONTEXT,LOGLEVEL) \
- DLT_LOG(CONTEXT, LOGLEVEL )
+#define DLT_LOG0(CONTEXT, LOGLEVEL) \
+ DLT_LOG(CONTEXT, LOGLEVEL)
/*****************************************/
-#define DLT_LOG1(CONTEXT,LOGLEVEL, ARGS1) \
+#define DLT_LOG1(CONTEXT, LOGLEVEL, ARGS1) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1)
/*****************************************/
-#define DLT_LOG2(CONTEXT,LOGLEVEL, ARGS1, ARGS2) \
+#define DLT_LOG2(CONTEXT, LOGLEVEL, ARGS1, ARGS2) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2)
/*****************************************/
-#define DLT_LOG3(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3) \
+#define DLT_LOG3(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3)
/*****************************************/
-#define DLT_LOG4(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4) \
+#define DLT_LOG4(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4)
/*****************************************/
-#define DLT_LOG5(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5) \
+#define DLT_LOG5(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5)
/*****************************************/
-#define DLT_LOG6(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6) \
+#define DLT_LOG6(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6)
/*****************************************/
-#define DLT_LOG7(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7) \
+#define DLT_LOG7(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7)
/*****************************************/
-#define DLT_LOG8(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8) \
+#define DLT_LOG8(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8)
/*****************************************/
-#define DLT_LOG9(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9) \
+#define DLT_LOG9(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9)
/*****************************************/
-#define DLT_LOG10(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10) \
+#define DLT_LOG10(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10)
/*****************************************/
-#define DLT_LOG11(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11) \
+#define DLT_LOG11(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11)
/*****************************************/
-#define DLT_LOG12(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12) \
+#define DLT_LOG12(CONTEXT, \
+ LOGLEVEL, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12) \
DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12)
/*****************************************/
-#define DLT_LOG13(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13) \
- DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13)
-/*****************************************/
-#define DLT_LOG14(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14) \
- DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14)
-/*****************************************/
-#define DLT_LOG15(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15) \
- DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15)
-/*****************************************/
-#define DLT_LOG16(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15, ARGS16) \
- DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15, ARGS16)
+#define DLT_LOG13(CONTEXT, \
+ LOGLEVEL, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13) \
+ DLT_LOG(CONTEXT, \
+ LOGLEVEL, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13)
+/*****************************************/
+#define DLT_LOG14(CONTEXT, \
+ LOGLEVEL, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14) \
+ DLT_LOG(CONTEXT, \
+ LOGLEVEL, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14)
+/*****************************************/
+#define DLT_LOG15(CONTEXT, \
+ LOGLEVEL, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14, \
+ ARGS15) \
+ DLT_LOG(CONTEXT, \
+ LOGLEVEL, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14, \
+ ARGS15)
+/*****************************************/
+#define DLT_LOG16(CONTEXT, \
+ LOGLEVEL, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14, \
+ ARGS15, \
+ ARGS16) \
+ DLT_LOG(CONTEXT, \
+ LOGLEVEL, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14, \
+ ARGS15, \
+ ARGS16)
/**
* Send log message with variable list of messages (intended for non-verbose mode)
@@ -162,60 +299,233 @@
* @param LOGLEVEL the log level of the log message
* @param MSGID the message id of log message
* @param ARGS variable list of arguments:
- calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
- DLT_INT(), DLT_UINT(), DLT_RAW()
+ * calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
+ * DLT_INT(), DLT_UINT(), DLT_RAW()
*/
/*****************************************/
-#define DLT_LOG_ID0(CONTEXT,LOGLEVEL,MSGID) \
- DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID )
+#define DLT_LOG_ID0(CONTEXT, LOGLEVEL, MSGID) \
+ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID)
/*****************************************/
-#define DLT_LOG_ID1(CONTEXT,LOGLEVEL,MSGID, ARGS1) \
+#define DLT_LOG_ID1(CONTEXT, LOGLEVEL, MSGID, ARGS1) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1)
/*****************************************/
-#define DLT_LOG_ID2(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2) \
+#define DLT_LOG_ID2(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2)
/*****************************************/
-#define DLT_LOG_ID3(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3) \
+#define DLT_LOG_ID3(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3)
/*****************************************/
-#define DLT_LOG_ID4(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4) \
+#define DLT_LOG_ID4(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4)
/*****************************************/
-#define DLT_LOG_ID5(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5) \
+#define DLT_LOG_ID5(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5)
/*****************************************/
-#define DLT_LOG_ID6(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6) \
+#define DLT_LOG_ID6(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6)
/*****************************************/
-#define DLT_LOG_ID7(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7) \
+#define DLT_LOG_ID7(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7)
/*****************************************/
-#define DLT_LOG_ID8(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8) \
+#define DLT_LOG_ID8(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8)
/*****************************************/
-#define DLT_LOG_ID9(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9) \
+#define DLT_LOG_ID9(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9)
/*****************************************/
-#define DLT_LOG_ID10(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10) \
+#define DLT_LOG_ID10(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10)
/*****************************************/
-#define DLT_LOG_ID11(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11) \
+#define DLT_LOG_ID11(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11) \
DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11)
/*****************************************/
-#define DLT_LOG_ID12(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12) \
- DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12)
-/*****************************************/
-#define DLT_LOG_ID13(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13) \
- DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13)
-/*****************************************/
-#define DLT_LOG_ID14(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14) \
- DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14)
-/*****************************************/
-#define DLT_LOG_ID15(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15) \
- DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15)
-/*****************************************/
-#define DLT_LOG_ID16(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15, ARGS16) \
- DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15, ARGS16)
+#define DLT_LOG_ID12(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12) \
+ DLT_LOG_ID(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12)
+/*****************************************/
+#define DLT_LOG_ID13(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13) \
+ DLT_LOG_ID(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13)
+/*****************************************/
+#define DLT_LOG_ID14(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14) \
+ DLT_LOG_ID(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14)
+/*****************************************/
+#define DLT_LOG_ID15(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14, \
+ ARGS15) \
+ DLT_LOG_ID(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14, \
+ ARGS15)
+/*****************************************/
+#define DLT_LOG_ID16(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14, \
+ ARGS15, \
+ ARGS16) \
+ DLT_LOG_ID(CONTEXT, \
+ LOGLEVEL, \
+ MSGID, \
+ ARGS1, \
+ ARGS2, \
+ ARGS3, \
+ ARGS4, \
+ ARGS5, \
+ ARGS6, \
+ ARGS7, \
+ ARGS8, \
+ ARGS9, \
+ ARGS10, \
+ ARGS11, \
+ ARGS12, \
+ ARGS13, \
+ ARGS14, \
+ ARGS15, \
+ ARGS16)
/**
* Unregister context.
diff --git a/include/dlt/dlt_filetransfer.h b/include/dlt/dlt_filetransfer.h
index 2f2089f..1cc96cc 100644
--- a/include/dlt/dlt_filetransfer.h
+++ b/include/dlt/dlt_filetransfer.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_filetransfer.h
-*/
+ */
#include <limits.h> /* Needed for LONG_MAX */
#include <sys/stat.h> /* Needed for struct stat st*/
@@ -134,4 +134,4 @@ extern int dlt_user_log_file_data(DltContext *fileContext, const char *filename,
* @param deleteFlag Flag to delete the file after the whole file is transferred (logged to dlt).1->delete,0->NotDelete
* @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
*/
-extern int dlt_user_log_file_end(DltContext *fileContext, const char *filename,int deleteFlag);
+extern int dlt_user_log_file_end(DltContext *fileContext, const char *filename, int deleteFlag);
diff --git a/include/dlt/dlt_offline_trace.h b/include/dlt/dlt_offline_trace.h
index 7612b90..a8cf1ee 100644
--- a/include/dlt/dlt_offline_trace.h
+++ b/include/dlt/dlt_offline_trace.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_offline_trace.h
-*/
+ */
/*******************************************************************************
@@ -68,17 +68,17 @@
#define DLT_OFFLINETRACE_FILENAME_TO_COMPARE "dlt_offlinetrace_"
/* "dlt_offlinetrace.4294967295.dlt" -> MAX 32byte include NULL terminate */
#define DLT_OFFLINETRACE_FILENAME_MAX_SIZE (sizeof(DLT_OFFLINETRACE_FILENAME_BASE) + \
- sizeof(DLT_OFFLINETRACE_FILENAME_DELI) + \
- DLT_OFFLINETRACE_INDEX_MAX_SIZE + \
- sizeof(DLT_OFFLINETRACE_FILENAME_EXT) + 1)
+ sizeof(DLT_OFFLINETRACE_FILENAME_DELI) + \
+ DLT_OFFLINETRACE_INDEX_MAX_SIZE + \
+ sizeof(DLT_OFFLINETRACE_FILENAME_EXT) + 1)
typedef struct
{
char directory[NAME_MAX + 1];/**< (String) Store DLT messages to local directory */
char filename[NAME_MAX + 1]; /**< (String) Filename of currently used log file */
- int fileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */
- int maxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */
- int filenameTimestampBased; /**< (int) timestamp based or index based (Default: 1 Timestamp based) */
+ int fileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */
+ int maxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */
+ int filenameTimestampBased; /**< (int) timestamp based or index based (Default: 1 Timestamp based) */
int ohandle;
} DltOfflineTrace;
@@ -95,7 +95,11 @@ typedef struct
*.@param filenameTimestampBased filename to be created on timestamp based or index based
* @return negative value if there was an error
*/
-extern DltReturnValue dlt_offline_trace_init(DltOfflineTrace *trace,const char *directory,int fileSize,int maxSize,int filenameTimestampBased);
+extern DltReturnValue dlt_offline_trace_init(DltOfflineTrace *trace,
+ const char *directory,
+ int fileSize,
+ int maxSize,
+ int filenameTimestampBased);
/**
* Uninitialise the offline trace
@@ -120,7 +124,13 @@ extern DltReturnValue dlt_offline_trace_free(DltOfflineTrace *buf);
* @param size3 size in bytes of third data block to be written, 0 if not used
* @return negative value if there was an error
*/
-extern DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace,unsigned char *data1,int size1,unsigned char *data2,int size2,unsigned char *data3,int size3);
+extern DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace,
+ unsigned char *data1,
+ int size1,
+ unsigned char *data2,
+ int size2,
+ unsigned char *data3,
+ int size3);
/**
* Get size of currently used offline trace buffer
diff --git a/include/dlt/dlt_protocol.h b/include/dlt/dlt_protocol.h
index 45df907..4a96128 100644
--- a/include/dlt/dlt_protocol.h
+++ b/include/dlt/dlt_protocol.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_protocol.h
-*/
+ */
/*******************************************************************************
@@ -64,17 +64,17 @@
* $LastChangedRevision$
* $LastChangedDate$
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#ifndef DLT_PROTOCOL_H
#define DLT_PROTOCOL_H
/**
- \defgroup protocolapi DLT Protocol API
- \addtogroup protocolapi
- \{
-*/
+ * \defgroup protocolapi DLT Protocol API
+ * \addtogroup protocolapi
+ \{
+ */
/*
* Definitions of the htyp parameter in standard header.
@@ -92,7 +92,7 @@
#define DLT_IS_HTYP_WSID(htyp) ((htyp) & DLT_HTYP_WSID)
#define DLT_IS_HTYP_WTMS(htyp) ((htyp) & DLT_HTYP_WTMS)
-#define DLT_HTYP_PROTOCOL_VERSION1 (1<<5)
+#define DLT_HTYP_PROTOCOL_VERSION1 (1 << 5)
/*
* Definitions of msin parameter in extended header.
@@ -138,9 +138,12 @@
#define DLT_CONTROL_RESPONSE 0x02 /**< Response to request message */
#define DLT_CONTROL_TIME 0x03 /**< keep-alive message */
-#define DLT_MSIN_CONTROL_REQUEST ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | (DLT_CONTROL_REQUEST << DLT_MSIN_MTIN_SHIFT))
-#define DLT_MSIN_CONTROL_RESPONSE ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | (DLT_CONTROL_RESPONSE << DLT_MSIN_MTIN_SHIFT))
-#define DLT_MSIN_CONTROL_TIME ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | (DLT_CONTROL_TIME << DLT_MSIN_MTIN_SHIFT))
+#define DLT_MSIN_CONTROL_REQUEST ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | \
+ (DLT_CONTROL_REQUEST << DLT_MSIN_MTIN_SHIFT))
+#define DLT_MSIN_CONTROL_RESPONSE ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | \
+ (DLT_CONTROL_RESPONSE << DLT_MSIN_MTIN_SHIFT))
+#define DLT_MSIN_CONTROL_TIME ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | \
+ (DLT_CONTROL_TIME << DLT_MSIN_MTIN_SHIFT))
/*
* Definitions of types of arguments in payload.
@@ -248,7 +251,7 @@ extern const char *dlt_get_service_name(unsigned int id);
/**
- \}
-*/
+ \}
+ */
#endif /* DLT_PROTOCOL_H */
diff --git a/include/dlt/dlt_shm.h b/include/dlt/dlt_shm.h
index 20f9110..93cbe14 100644
--- a/include/dlt/dlt_shm.h
+++ b/include/dlt/dlt_shm.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_shm.h
-*/
+ */
/*******************************************************************************
@@ -89,8 +89,8 @@ typedef struct
int size;
} DltShmBlockHead;
-#define DLT_SHM_SEM_GET(id) dlt_shm_pv(id,-1)
-#define DLT_SHM_SEM_FREE(id) dlt_shm_pv(id,1)
+#define DLT_SHM_SEM_GET(id) dlt_shm_pv(id, -1)
+#define DLT_SHM_SEM_FREE(id) dlt_shm_pv(id, 1)
/**
* Initialise the shared memory on the client side.
@@ -99,7 +99,7 @@ typedef struct
* @param key the identifier of the shm, must be the same for server and client
* @return negative value if there was an error
*/
-extern DltReturnValue dlt_shm_init_client(DltShm *buf,int key);
+extern DltReturnValue dlt_shm_init_client(DltShm *buf, int key);
/**
* Initialise the shared memory on the server side.
@@ -109,7 +109,7 @@ extern DltReturnValue dlt_shm_init_client(DltShm *buf,int key);
* @param size the requested size of the shm
* @return negative value if there was an error
*/
-extern DltReturnValue dlt_shm_init_server(DltShm *buf,int key,int size);
+extern DltReturnValue dlt_shm_init_server(DltShm *buf, int key, int size);
/**
* Push data from client onto the shm.
@@ -122,7 +122,13 @@ extern DltReturnValue dlt_shm_init_server(DltShm *buf,int key,int size);
* @param size3 size in bytes of third data block to be written, 0 if not used
* @return negative value if there was an error
*/
-extern int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size1,const unsigned char *data2,unsigned int size2,const unsigned char *data3,unsigned int size3);
+extern int dlt_shm_push(DltShm *buf,
+ const unsigned char *data1,
+ unsigned int size1,
+ const unsigned char *data2,
+ unsigned int size2,
+ const unsigned char *data3,
+ unsigned int size3);
/**
* Pull data from shm.
@@ -133,7 +139,7 @@ extern int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size
* @param size maximum size to be written into buffer
* @return negative value if there was an error
*/
-extern int dlt_shm_pull(DltShm *buf,unsigned char *data, int size);
+extern int dlt_shm_pull(DltShm *buf, unsigned char *data, int size);
/**
* Copy message from shm.
@@ -144,7 +150,7 @@ extern int dlt_shm_pull(DltShm *buf,unsigned char *data, int size);
* @param size maximum size to be written into buffer
* @return negative value if there was an error
*/
-extern int dlt_shm_copy(DltShm *buf,unsigned char *data, int size);
+extern int dlt_shm_copy(DltShm *buf, unsigned char *data, int size);
/**
* Delete message from shm.
diff --git a/include/dlt/dlt_types.h b/include/dlt/dlt_types.h
index 2393174..6a46c08 100644
--- a/include/dlt/dlt_types.h
+++ b/include/dlt/dlt_types.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_types.h
-*/
+ */
/*******************************************************************************
@@ -63,21 +63,21 @@
typedef __int64 int64_t;
typedef __int32 int32_t;
typedef __int16 int16_t;
-typedef __int8 int8_t;
+typedef __int8 int8_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
-typedef unsigned __int8 uint8_t;
+typedef unsigned __int8 uint8_t;
typedef int pid_t;
typedef unsigned int speed_t;
-#define UINT16_MAX 0xFFFF
+# define UINT16_MAX 0xFFFF
-#include <varargs.h>
+# include <varargs.h>
#else
-#include <stdint.h>
+# include <stdint.h>
#endif
/**
@@ -87,13 +87,13 @@ typedef enum
{
DLT_RETURN_LOGGING_DISABLED = -7,
DLT_RETURN_USER_BUFFER_FULL = -6,
- DLT_RETURN_WRONG_PARAMETER = -5,
- DLT_RETURN_BUFFER_FULL = -4,
- DLT_RETURN_PIPE_FULL = -3,
- DLT_RETURN_PIPE_ERROR = -2,
- DLT_RETURN_ERROR = -1,
- DLT_RETURN_OK = 0,
- DLT_RETURN_TRUE = 1
+ DLT_RETURN_WRONG_PARAMETER = -5,
+ DLT_RETURN_BUFFER_FULL = -4,
+ DLT_RETURN_PIPE_FULL = -3,
+ DLT_RETURN_PIPE_ERROR = -2,
+ DLT_RETURN_ERROR = -1,
+ DLT_RETURN_OK = 0,
+ DLT_RETURN_TRUE = 1
} DltReturnValue;
/**
@@ -101,14 +101,14 @@ typedef enum
*/
typedef enum
{
- DLT_LOG_DEFAULT = -1, /**< Default log level */
- DLT_LOG_OFF = 0x00, /**< Log level off */
- DLT_LOG_FATAL = 0x01, /**< fatal system error */
- DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */
- DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */
- DLT_LOG_INFO = 0x04, /**< informational */
- DLT_LOG_DEBUG = 0x05, /**< debug */
- DLT_LOG_VERBOSE = 0x06, /**< highest grade of information */
+ DLT_LOG_DEFAULT = -1, /**< Default log level */
+ DLT_LOG_OFF = 0x00, /**< Log level off */
+ DLT_LOG_FATAL = 0x01, /**< fatal system error */
+ DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */
+ DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */
+ DLT_LOG_INFO = 0x04, /**< informational */
+ DLT_LOG_DEBUG = 0x05, /**< debug */
+ DLT_LOG_VERBOSE = 0x06, /**< highest grade of information */
DLT_LOG_MAX /**< maximum value, used for range check */
} DltLogLevelType;
@@ -117,13 +117,13 @@ typedef enum
*/
typedef enum
{
- DLT_FORMAT_DEFAULT = 0x00, /**< no sepecial format */
- DLT_FORMAT_HEX8 = 0x01, /**< Hex 8 */
- DLT_FORMAT_HEX16 = 0x02, /**< Hex 16 */
- DLT_FORMAT_HEX32 = 0x03, /**< Hex 32 */
- DLT_FORMAT_HEX64 = 0x04, /**< Hex 64 */
- DLT_FORMAT_BIN8 = 0x05, /**< Binary 8 */
- DLT_FORMAT_BIN16 = 0x06, /**< Binary 16 */
+ DLT_FORMAT_DEFAULT = 0x00, /**< no sepecial format */
+ DLT_FORMAT_HEX8 = 0x01, /**< Hex 8 */
+ DLT_FORMAT_HEX16 = 0x02, /**< Hex 16 */
+ DLT_FORMAT_HEX32 = 0x03, /**< Hex 32 */
+ DLT_FORMAT_HEX64 = 0x04, /**< Hex 64 */
+ DLT_FORMAT_BIN8 = 0x05, /**< Binary 8 */
+ DLT_FORMAT_BIN16 = 0x06, /**< Binary 16 */
DLT_FORMAT_MAX /**< maximum value, used for range check */
} DltFormatType;
@@ -132,9 +132,9 @@ typedef enum
*/
typedef enum
{
- DLT_TRACE_STATUS_DEFAULT = -1, /**< Default trace status */
- DLT_TRACE_STATUS_OFF = 0x00, /**< Trace status: Off */
- DLT_TRACE_STATUS_ON = 0x01, /**< Trace status: On */
+ DLT_TRACE_STATUS_DEFAULT = -1, /**< Default trace status */
+ DLT_TRACE_STATUS_OFF = 0x00, /**< Trace status: Off */
+ DLT_TRACE_STATUS_ON = 0x01, /**< Trace status: On */
DLT_TRACE_STATUS_MAX /**< maximum value, used for range check */
} DltTraceStatusType;
@@ -144,21 +144,21 @@ typedef enum
*/
typedef enum
{
- DLT_NW_TRACE_IPC = 0x01, /**< Interprocess communication */
- DLT_NW_TRACE_CAN = 0x02, /**< Controller Area Network Bus */
- DLT_NW_TRACE_FLEXRAY = 0x03, /**< Flexray Bus */
- DLT_NW_TRACE_MOST = 0x04, /**< Media Oriented System Transport Bus */
- DLT_NW_TRACE_RESERVED0 = 0x05,
- DLT_NW_TRACE_RESERVED1 = 0x06,
- DLT_NW_TRACE_RESERVED2 = 0x07,
- DLT_NW_TRACE_USER_DEFINED0 = 0x08,
- DLT_NW_TRACE_USER_DEFINED1 = 0x09,
- DLT_NW_TRACE_USER_DEFINED2 = 0x0A,
- DLT_NW_TRACE_USER_DEFINED3 = 0x0B,
- DLT_NW_TRACE_USER_DEFINED4 = 0x0C,
- DLT_NW_TRACE_USER_DEFINED5 = 0x0D,
- DLT_NW_TRACE_USER_DEFINED6 = 0x0E,
- DLT_NW_TRACE_USER_DEFINED7 = 0x0F,
+ DLT_NW_TRACE_IPC = 0x01, /**< Interprocess communication */
+ DLT_NW_TRACE_CAN = 0x02, /**< Controller Area Network Bus */
+ DLT_NW_TRACE_FLEXRAY = 0x03, /**< Flexray Bus */
+ DLT_NW_TRACE_MOST = 0x04, /**< Media Oriented System Transport Bus */
+ DLT_NW_TRACE_RESERVED0 = 0x05,
+ DLT_NW_TRACE_RESERVED1 = 0x06,
+ DLT_NW_TRACE_RESERVED2 = 0x07,
+ DLT_NW_TRACE_USER_DEFINED0 = 0x08,
+ DLT_NW_TRACE_USER_DEFINED1 = 0x09,
+ DLT_NW_TRACE_USER_DEFINED2 = 0x0A,
+ DLT_NW_TRACE_USER_DEFINED3 = 0x0B,
+ DLT_NW_TRACE_USER_DEFINED4 = 0x0C,
+ DLT_NW_TRACE_USER_DEFINED5 = 0x0D,
+ DLT_NW_TRACE_USER_DEFINED6 = 0x0E,
+ DLT_NW_TRACE_USER_DEFINED7 = 0x0F,
DLT_NW_TRACE_MAX /**< maximum value, used for range check */
} DltNetworkTraceType;
@@ -167,15 +167,15 @@ typedef enum
*/
typedef enum
{
- DLT_USER_MODE_UNDEFINED = -1,
- DLT_USER_MODE_OFF = 0,
- DLT_USER_MODE_EXTERNAL ,
- DLT_USER_MODE_INTERNAL ,
- DLT_USER_MODE_BOTH ,
+ DLT_USER_MODE_UNDEFINED = -1,
+ DLT_USER_MODE_OFF = 0,
+ DLT_USER_MODE_EXTERNAL,
+ DLT_USER_MODE_INTERNAL,
+ DLT_USER_MODE_BOTH,
DLT_USER_MODE_MAX /**< maximum value, used for range check */
} DltUserLogMode;
-typedef float float32_t;
+typedef float float32_t;
typedef double float64_t;
/**
diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h
index 997c1c4..d736032 100644
--- a/include/dlt/dlt_user.h
+++ b/include/dlt/dlt_user.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_user.h
-*/
+ */
/*******************************************************************************
** **
@@ -63,39 +63,39 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#ifndef DLT_USER_H
-#define DLT_USER_H
+# define DLT_USER_H
/**
- \defgroup userapi DLT User API
- \addtogroup userapi
- \{
-*/
-#include <mqueue.h>
+ * \defgroup userapi DLT User API
+ * \addtogroup userapi
+ \{
+ */
+# include <mqueue.h>
-#if !defined (__WIN32__)
-#include <semaphore.h>
-#endif
+# if !defined (__WIN32__)
+# include <semaphore.h>
+# endif
-#include "dlt_types.h"
-#include "dlt_user_macros.h"
-#include "dlt_shm.h"
+# include "dlt_types.h"
+# include "dlt_user_macros.h"
+# include "dlt_shm.h"
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
-#define DLT_USER_BUF_MAX_SIZE 1390 /**< maximum size of each user buffer, also used for injection buffer */
+# define DLT_USER_BUF_MAX_SIZE 1390 /**< maximum size of each user buffer, also used for injection buffer */
-#define DLT_USER_RESENDBUF_MAX_SIZE (DLT_USER_BUF_MAX_SIZE + 100) /**< Size of resend buffer; Max DLT message size is 1390 bytes plus some extra header space */
+# define DLT_USER_RESENDBUF_MAX_SIZE (DLT_USER_BUF_MAX_SIZE + 100) /**< Size of resend buffer; Max DLT message size is 1390 bytes plus some extra header space */
/* Use a semaphore or mutex from your OS to prevent concurrent access to the DLT buffer. */
-#define DLT_SEM_LOCK() { sem_wait(&dlt_mutex); }
-#define DLT_SEM_FREE() { sem_post(&dlt_mutex); }
+# define DLT_SEM_LOCK() { sem_wait(&dlt_mutex); }
+# define DLT_SEM_FREE() { sem_post(&dlt_mutex); }
/**
* This structure is used for every context used in an application.
@@ -120,7 +120,7 @@ typedef struct
int32_t log_level; /**< log level */
int32_t trace_status; /**< trace status */
int32_t args_num; /**< number of arguments for extended header*/
- char* context_description; /**< description of context */
+ char *context_description; /**< description of context */
} DltContextData;
typedef struct
@@ -136,7 +136,7 @@ typedef struct
char contextID[DLT_ID_SIZE]; /**< Context ID */
int8_t log_level; /**< Log level */
int8_t trace_status; /**< Trace status */
- void (*log_level_changed_callback) (char context_id[DLT_ID_SIZE],uint8_t log_level,uint8_t trace_status);
+ void (*log_level_changed_callback)(char context_id[DLT_ID_SIZE], uint8_t log_level, uint8_t trace_status);
} DltUserLogLevelChangedCallback;
/**
@@ -154,7 +154,7 @@ typedef struct
uint32_t nrcallbacks;
/* Log Level changed callback */
- void (*log_level_changed_callback) (char context_id[DLT_ID_SIZE],uint8_t log_level,uint8_t trace_status);
+ void (*log_level_changed_callback)(char context_id[DLT_ID_SIZE], uint8_t log_level, uint8_t trace_status);
} dlt_ll_ts_type;
@@ -174,7 +174,7 @@ typedef struct
*/
typedef struct
{
- dlt_env_ll_item * item;
+ dlt_env_ll_item *item;
size_t array_size;
size_t num_elem;
} dlt_env_ll_set;
@@ -196,7 +196,7 @@ typedef struct
int8_t dlt_is_file; /**< Target of logging: 1 to file, 0 to daemon */
dlt_ll_ts_type *dlt_ll_ts; /** [MAX_DLT_LL_TS_ENTRIES]; < Internal management struct for all
- contexts */
+ * contexts */
uint32_t dlt_ll_ts_max_num_entries; /**< Maximum number of contexts */
uint32_t dlt_ll_ts_num_entries; /**< Number of used contexts */
@@ -218,9 +218,9 @@ typedef struct
int8_t local_print_mode; /**< Local print mode, controlled by environment variable */
int8_t log_state; /**< Log state of external connection:
- 1 client connected,
- 0 not connected,
- -1 unknown */
+ * 1 client connected,
+ * 0 not connected,
+ * -1 unknown */
DltBuffer startup_buffer; /**< Ring-buffer for buffering messages during startup and missing connection */
/* Buffer used for resending, locked by DLT semaphore */
@@ -229,14 +229,14 @@ typedef struct
uint32_t timeout_at_exit_handler; /**< timeout used in dlt_user_atexit_blow_out_user_buffer, in 0.1 milliseconds */
dlt_env_ll_set initial_ll_set;
-#ifdef DLT_SHM_ENABLE
+# ifdef DLT_SHM_ENABLE
DltShm dlt_shm;
-#endif
-#ifdef DLT_TEST_ENABLE
+# endif
+# ifdef DLT_TEST_ENABLE
int corrupt_user_header;
int corrupt_message_size;
int16_t corrupt_message_size_size;
-#endif
+# endif
DltUserConnectionState connection_state;
uint16_t log_buf_len; /**< length of message buffer, by default: DLT_USER_BUF_MAX_SIZE */
} DltUser;
@@ -271,7 +271,10 @@ DltReturnValue dlt_user_log_write_start(DltContext *handle, DltContextData *log,
* @param messageid message id of message
* @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is matching
*/
-DltReturnValue dlt_user_log_write_start_id(DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid);
+DltReturnValue dlt_user_log_write_start_id(DltContext *handle,
+ DltContextData *log,
+ DltLogLevelType loglevel,
+ uint32_t messageid);
/**
* Finishing the generation of a DLT log message and sending it to the DLT daemon.
@@ -370,7 +373,7 @@ DltReturnValue dlt_user_log_write_int64(DltContextData *log, int64_t data);
* @param text pointer to the parameter written into log message containing null termination.
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_user_log_write_string( DltContextData *log, const char *text);
+DltReturnValue dlt_user_log_write_string(DltContextData *log, const char *text);
/**
* Write a constant null terminated ASCII string into a DLT log message.
@@ -381,7 +384,7 @@ DltReturnValue dlt_user_log_write_string( DltContextData *log, const char *text)
* @param text pointer to the parameter written into log message containing null termination.
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_user_log_write_constant_string( DltContextData *log, const char *text);
+DltReturnValue dlt_user_log_write_constant_string(DltContextData *log, const char *text);
/**
* Write a null terminated UTF8 string into a DLT log message.
@@ -402,7 +405,7 @@ DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *t
* @param length length in bytes of the parameter written into log message.
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t length);
+DltReturnValue dlt_user_log_write_raw(DltContextData *log, void *data, uint16_t length);
/**
* Write a binary memory block into a DLT log message.
@@ -414,7 +417,7 @@ DltReturnValue dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t le
* @param type the format information.
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log,void *data,uint16_t length,DltFormatType type);
+DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log, void *data, uint16_t length, DltFormatType type);
/**
* Trace network message
@@ -426,7 +429,12 @@ DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log,void *data,u
* @param payload pointer to network message payload
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_user_trace_network(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
+DltReturnValue dlt_user_trace_network(DltContext *handle,
+ DltNetworkTraceType nw_trace_type,
+ uint16_t header_len,
+ void *header,
+ uint16_t payload_len,
+ void *payload);
/**
* Trace network message, truncated if necessary.
@@ -439,7 +447,13 @@ DltReturnValue dlt_user_trace_network(DltContext *handle, DltNetworkTraceType nw
* @param allow_truncate Set to > 0 to allow truncating of the message if it is too large.
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload, int allow_truncate);
+DltReturnValue dlt_user_trace_network_truncated(DltContext *handle,
+ DltNetworkTraceType nw_trace_type,
+ uint16_t header_len,
+ void *header,
+ uint16_t payload_len,
+ void *payload,
+ int allow_truncate);
/**
* Trace network message in segmented asynchronous mode.
@@ -454,11 +468,16 @@ DltReturnValue dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTr
* @param payload pointer to network message payload
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_user_trace_network_segmented(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
+DltReturnValue dlt_user_trace_network_segmented(DltContext *handle,
+ DltNetworkTraceType nw_trace_type,
+ uint16_t header_len,
+ void *header,
+ uint16_t payload_len,
+ void *payload);
/**************************************************************************************************
- * The following API functions define a high level function interface for DLT
- **************************************************************************************************/
+* The following API functions define a high level function interface for DLT
+**************************************************************************************************/
/**
* Initialize the user lib communication with daemon.
@@ -488,7 +507,7 @@ DltReturnValue dlt_free();
* @param user_minor_version the minor version to be compared
* @return Value from DltReturnValue enum, DLT_RETURN_ERROR if there is a mismatch
*/
-DltReturnValue dlt_check_library_version(const char * user_major_version, const char * user_minor_version);
+DltReturnValue dlt_check_library_version(const char *user_major_version, const char *user_minor_version);
/**
* Register an application in the daemon.
@@ -496,7 +515,7 @@ DltReturnValue dlt_check_library_version(const char * user_major_version, const
* @param description long name of the application
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_register_app(const char *appid, const char * description);
+DltReturnValue dlt_register_app(const char *appid, const char *description);
/**
* Unregister an application in the daemon.
@@ -520,7 +539,7 @@ DltReturnValue dlt_unregister_app_flush_buffered_logs(void);
* @param description long name of the context
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, const char * description);
+DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, const char *description);
/**
* Register a context in the daemon with pre-defined log level and pre-defined trace status.
@@ -529,12 +548,16 @@ DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, c
* @param contextid four byte long character array with the context id
* @param description long name of the context
* @param loglevel This is the log level to be pre-set for this context
- (DLT_LOG_DEFAULT is not allowed here)
+ * (DLT_LOG_DEFAULT is not allowed here)
* @param tracestatus This is the trace status to be pre-set for this context
- (DLT_TRACE_STATUS_DEFAULT is not allowed here)
+ * (DLT_TRACE_STATUS_DEFAULT is not allowed here)
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_register_context_ll_ts(DltContext *handle, const char *contextid, const char * description, int loglevel, int tracestatus);
+DltReturnValue dlt_register_context_ll_ts(DltContext *handle,
+ const char *contextid,
+ const char *description,
+ int loglevel,
+ int tracestatus);
/**
* Register a context in the daemon with log level changed callback fn.
@@ -547,7 +570,7 @@ DltReturnValue dlt_register_context_ll_ts(DltContext *handle, const char *contex
*/
DltReturnValue dlt_register_context_llccb(DltContext *handle,
const char *contextid,
- const char * description,
+ const char *description,
void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],
uint8_t log_level,
uint8_t trace_status));
@@ -594,7 +617,9 @@ int dlt_get_log_state();
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_injection_callback(DltContext *handle, uint32_t service_id,
- int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length));
+ int (*dlt_injection_callback)(uint32_t service_id,
+ void *data,
+ uint32_t length));
/**
* Register callback function with private data called when injection message was received
@@ -604,7 +629,10 @@ DltReturnValue dlt_register_injection_callback(DltContext *handle, uint32_t serv
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint32_t service_id,
- int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length, void *priv_data), void *priv);
+ int (*dlt_injection_callback)(uint32_t service_id,
+ void *data,
+ uint32_t length,
+ void *priv_data), void *priv);
/**
* Register callback function called when log level of context was changed
@@ -613,7 +641,10 @@ DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint3
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_log_level_changed_callback(DltContext *handle,
- void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],uint8_t log_level, uint8_t trace_status));
+ void (*dlt_log_level_changed_callback)(
+ char context_id[DLT_ID_SIZE],
+ uint8_t log_level,
+ uint8_t trace_status));
/**
* Switch to verbose mode
@@ -627,7 +658,7 @@ DltReturnValue dlt_verbose_mode(void);
* @param Minor version number of application - see dlt_version.h
* @return Value from DltReturnValue enum, DLT_RETURN_ERROR if there is a mismatch
*/
-DltReturnValue dlt_user_check_library_version(const char *user_major_version,const char *user_minor_version);
+DltReturnValue dlt_user_check_library_version(const char *user_major_version, const char *user_minor_version);
/**
* Switch to non-verbose mode
@@ -692,7 +723,10 @@ DltReturnValue dlt_set_application_ll_ts_limit(DltLogLevelType loglevel, DltTrac
*
* If no item matches or in case of error, the original log-level (\param ll) is returned
*/
-int dlt_env_adjust_ll_from_env(dlt_env_ll_set const * const ll_set, char const * const apid, char const * const ctid, int const ll);
+int dlt_env_adjust_ll_from_env(dlt_env_ll_set const *const ll_set,
+ char const *const apid,
+ char const *const ctid,
+ int const ll);
/**
* @brief extract log-level settings from given string
@@ -706,9 +740,9 @@ int dlt_env_adjust_ll_from_env(dlt_env_ll_set const * const ll_set, char const *
* @return 0 on success
* @return -1 on failure
*/
-int dlt_env_extract_ll_set(char ** const env, dlt_env_ll_set * const ll_set);
+int dlt_env_extract_ll_set(char **const env, dlt_env_ll_set *const ll_set);
-void dlt_env_free_ll_set(dlt_env_ll_set * const ll_set);
+void dlt_env_free_ll_set(dlt_env_ll_set *const ll_set);
/**
* Enable local printing of messages
@@ -729,7 +763,7 @@ DltReturnValue dlt_disable_local_print(void);
* @param text pointer to the ASCII string written into log message containing null termination.
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const char *text);
+DltReturnValue dlt_log_string(DltContext *handle, DltLogLevelType loglevel, const char *text);
/**
* Write a null terminated ASCII string and an integer value into a DLT log message.
@@ -739,7 +773,7 @@ DltReturnValue dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const
* @param data integer value written into the log message
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, const char *text, int data);
+DltReturnValue dlt_log_string_int(DltContext *handle, DltLogLevelType loglevel, const char *text, int data);
/**
* Write a null terminated ASCII string and an unsigned integer value into a DLT log message.
@@ -749,7 +783,7 @@ DltReturnValue dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, c
* @param data unsigned integer value written into the log message
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel, const char *text, unsigned int data);
+DltReturnValue dlt_log_string_uint(DltContext *handle, DltLogLevelType loglevel, const char *text, unsigned int data);
/**
* Write an integer value into a DLT log message.
@@ -758,7 +792,7 @@ DltReturnValue dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel,
* @param data integer value written into the log message
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_log_int(DltContext *handle,DltLogLevelType loglevel, int data);
+DltReturnValue dlt_log_int(DltContext *handle, DltLogLevelType loglevel, int data);
/**
* Write an unsigned integer value into a DLT log message.
@@ -767,7 +801,7 @@ DltReturnValue dlt_log_int(DltContext *handle,DltLogLevelType loglevel, int data
* @param data unsigned integer value written into the log message
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigned int data);
+DltReturnValue dlt_log_uint(DltContext *handle, DltLogLevelType loglevel, unsigned int data);
/**
* Write an unsigned integer value into a DLT log message.
@@ -777,7 +811,7 @@ DltReturnValue dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigne
* @param length length in bytes of the parameter written into log message.
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_log_raw(DltContext *handle,DltLogLevelType loglevel, void *data,uint16_t length);
+DltReturnValue dlt_log_raw(DltContext *handle, DltLogLevelType loglevel, void *data, uint16_t length);
/**
* Write marker message to DLT.
@@ -791,7 +825,7 @@ DltReturnValue dlt_log_marker();
* @param size Size of DLT message
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_forward_msg(void *msgdata,size_t size);
+DltReturnValue dlt_forward_msg(void *msgdata, size_t size);
/**
* Get the total size and available size of the shared memory buffer between daemon and applications.
@@ -825,37 +859,31 @@ DltReturnValue dlt_user_log_resend_buffer(void);
* @param loglevel this is the current log level of the log message to be sent
* @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is enabled
*/
-static inline DltReturnValue dlt_user_is_logLevel_enabled(DltContext *handle,DltLogLevelType loglevel)
+static inline DltReturnValue dlt_user_is_logLevel_enabled(DltContext *handle, DltLogLevelType loglevel)
{
- if (loglevel < DLT_LOG_DEFAULT || loglevel >= DLT_LOG_MAX)
- {
+ if ((loglevel < DLT_LOG_DEFAULT) || (loglevel >= DLT_LOG_MAX))
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (handle == NULL || handle->log_level_ptr == NULL)
- {
+ if ((handle == NULL) || (handle->log_level_ptr == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (loglevel <= (DltLogLevelType)(*(handle->log_level_ptr)) && loglevel != DLT_LOG_OFF)
- {
+ if ((loglevel <= (DltLogLevelType)(*(handle->log_level_ptr))) && (loglevel != DLT_LOG_OFF))
return DLT_RETURN_TRUE;
- }
return DLT_RETURN_LOGGING_DISABLED;
}
-#ifdef DLT_TEST_ENABLE
- void dlt_user_test_corrupt_user_header(int enable);
- void dlt_user_test_corrupt_message_size(int enable,int16_t size);
-#endif /* DLT_TEST_ENABLE */
+# ifdef DLT_TEST_ENABLE
+void dlt_user_test_corrupt_user_header(int enable);
+void dlt_user_test_corrupt_message_size(int enable, int16_t size);
+# endif /* DLT_TEST_ENABLE */
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
/**
- \}
-*/
+ \}
+ */
#endif /* DLT_USER_H */
diff --git a/include/dlt/dlt_user_macros.h b/include/dlt/dlt_user_macros.h
index 7455811..74e5cf5 100644
--- a/include/dlt/dlt_user_macros.h
+++ b/include/dlt/dlt_user_macros.h
@@ -22,49 +22,49 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_user_macros.h
-*/
+ */
/*******************************************************************************
- ** **
- ** SRC-MODULE: dlt_user_macros.h **
- ** **
- ** TARGET : linux **
- ** **
- ** PROJECT : DLT **
- ** **
- ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
- ** Markus Klein **
- ** **
- ** PURPOSE : **
- ** **
- ** REMARKS : **
- ** **
- ** PLATFORM DEPENDANT [yes/no]: yes **
- ** **
- ** TO BE CHANGED BY USER [yes/no]: no **
- ** **
- *******************************************************************************/
+** **
+** SRC-MODULE: dlt_user_macros.h **
+** **
+** TARGET : linux **
+** **
+** PROJECT : DLT **
+** **
+** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
+** Markus Klein **
+** **
+** PURPOSE : **
+** **
+** REMARKS : **
+** **
+** PLATFORM DEPENDANT [yes/no]: yes **
+** **
+** TO BE CHANGED BY USER [yes/no]: no **
+** **
+*******************************************************************************/
/*******************************************************************************
- ** Author Identity **
- ********************************************************************************
- ** **
- ** Initials Name Company **
- ** -------- ------------------------- ---------------------------------- **
- ** aw Alexander Wenzel BMW **
- ** mk Markus Klein Fraunhofer ESK **
- *******************************************************************************/
+** Author Identity **
+********************************************************************************
+** **
+** Initials Name Company **
+** -------- ------------------------- ---------------------------------- **
+** aw Alexander Wenzel BMW **
+** mk Markus Klein Fraunhofer ESK **
+*******************************************************************************/
/*******************************************************************************
- ** Revision Control History **
- *******************************************************************************/
+** Revision Control History **
+*******************************************************************************/
/*
* $LastChangedRevision: 1515 $
* $LastChangedDate: 2010-12-13 09:18:54 +0100 (Mon, 13 Dec 2010) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#ifndef DLT_USER_MACROS_H
@@ -73,14 +73,14 @@
#include "dlt_version.h"
/**
- \defgroup userapi DLT User API
- \addtogroup userapi
- \{
-*/
+ * \defgroup userapi DLT User API
+ * \addtogroup userapi
+ \{
+ */
/**************************************************************************************************
- * The folowing macros define a macro interface for DLT
- **************************************************************************************************/
+* The folowing macros define a macro interface for DLT
+**************************************************************************************************/
/**
* Create an object for a new context.
@@ -109,22 +109,22 @@
* @param APPID application id with maximal four characters
* @param DESCRIPTION ASCII string containing description
*/
-#define DLT_REGISTER_APP(APPID,DESCRIPTION) do {\
- (void)dlt_check_library_version(_DLT_PACKAGE_MAJOR_VERSION, _DLT_PACKAGE_MINOR_VERSION ); \
- (void)dlt_register_app( APPID, DESCRIPTION);} while(0)
+#define DLT_REGISTER_APP(APPID, DESCRIPTION) do { \
+ (void)dlt_check_library_version(_DLT_PACKAGE_MAJOR_VERSION, _DLT_PACKAGE_MINOR_VERSION); \
+ (void)dlt_register_app(APPID, DESCRIPTION); } while (0)
/**
* Unregister application.
*/
-#define DLT_UNREGISTER_APP() do{\
- (void)dlt_unregister_app();} while(0)
+#define DLT_UNREGISTER_APP() do { \
+ (void)dlt_unregister_app(); } while (0)
/**
* Unregister application and flush the logs buffered in startup buffer if any.
*/
-#define DLT_UNREGISTER_APP_FLUSH_BUFFERED_LOGS() do{\
- (void)dlt_unregister_app_flush_buffered_logs();} while(0)
+#define DLT_UNREGISTER_APP_FLUSH_BUFFERED_LOGS() do { \
+ (void)dlt_unregister_app_flush_buffered_logs(); } while (0)
/**
* Register context (with default log level and default trace status)
@@ -132,8 +132,8 @@
* @param CONTEXTID context id with maximal four characters
* @param DESCRIPTION ASCII string containing description
*/
-#define DLT_REGISTER_CONTEXT(CONTEXT,CONTEXTID,DESCRIPTION) do{\
- (void)dlt_register_context(&(CONTEXT), CONTEXTID, DESCRIPTION);} while(0)
+#define DLT_REGISTER_CONTEXT(CONTEXT, CONTEXTID, DESCRIPTION) do { \
+ (void)dlt_register_context(&(CONTEXT), CONTEXTID, DESCRIPTION); } while (0)
/**
* Register context with pre-defined log level and pre-defined trace status.
@@ -141,12 +141,12 @@
* @param CONTEXTID context id with maximal four characters
* @param DESCRIPTION ASCII string containing description
* @param LOGLEVEL log level to be pre-set for this context
- (DLT_LOG_DEFAULT is not allowed here)
+ * (DLT_LOG_DEFAULT is not allowed here)
* @param TRACESTATUS trace status to be pre-set for this context
- (DLT_TRACE_STATUS_DEFAULT is not allowed here)
+ * (DLT_TRACE_STATUS_DEFAULT is not allowed here)
*/
-#define DLT_REGISTER_CONTEXT_LL_TS(CONTEXT,CONTEXTID,DESCRIPTION,LOGLEVEL,TRACESTATUS) do{\
- (void)dlt_register_context_ll_ts(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS);} while(0)
+#define DLT_REGISTER_CONTEXT_LL_TS(CONTEXT, CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS) do { \
+ (void)dlt_register_context_ll_ts(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS); } while (0)
/**
* Register context (with default log level and default trace status and log level change callback)
@@ -155,15 +155,15 @@
* @param DESCRIPTION ASCII string containing description
* @param CBK log level change callback to be registered
*/
-#define DLT_REGISTER_CONTEXT_LLCCB(CONTEXT, CONTEXTID, DESCRIPTION, CBK) do{\
- (void)dlt_register_context_llccb(&(CONTEXT), CONTEXTID, DESCRIPTION, CBK);} while(0)
+#define DLT_REGISTER_CONTEXT_LLCCB(CONTEXT, CONTEXTID, DESCRIPTION, CBK) do { \
+ (void)dlt_register_context_llccb(&(CONTEXT), CONTEXTID, DESCRIPTION, CBK); } while (0)
/**
* Unregister context.
* @param CONTEXT object containing information about one special logging context
*/
-#define DLT_UNREGISTER_CONTEXT(CONTEXT) do{\
- (void)dlt_unregister_context(&(CONTEXT));} while(0)
+#define DLT_UNREGISTER_CONTEXT(CONTEXT) do { \
+ (void)dlt_unregister_context(&(CONTEXT)); } while (0)
/**
* Register callback function called when injection message was received
@@ -171,8 +171,8 @@
* @param SERVICEID service id of the injection message
* @param CALLBACK function pointer to callback function
*/
-#define DLT_REGISTER_INJECTION_CALLBACK(CONTEXT, SERVICEID, CALLBACK) do{\
- (void)dlt_register_injection_callback(&(CONTEXT),SERVICEID, CALLBACK);} while(0)
+#define DLT_REGISTER_INJECTION_CALLBACK(CONTEXT, SERVICEID, CALLBACK) do { \
+ (void)dlt_register_injection_callback(&(CONTEXT), SERVICEID, CALLBACK); } while (0)
/**
* Register callback function called when injection message was received
@@ -181,16 +181,16 @@
* @param CALLBACK function pointer to callback function
* @param PRIV_DATA data specific to context
*/
-#define DLT_REGISTER_INJECTION_CALLBACK_WITH_ID(CONTEXT, SERVICEID, CALLBACK, PRIV_DATA) do{\
- (void)dlt_register_injection_callback_with_id(&(CONTEXT),SERVICEID, CALLBACK, PRIV_DATA);} while(0)
+#define DLT_REGISTER_INJECTION_CALLBACK_WITH_ID(CONTEXT, SERVICEID, CALLBACK, PRIV_DATA) do { \
+ (void)dlt_register_injection_callback_with_id(&(CONTEXT), SERVICEID, CALLBACK, PRIV_DATA); } while (0)
/**
* Register callback function called when log level of context was changed
* @param CONTEXT object containing information about one special logging context
* @param CALLBACK function pointer to callback function
*/
-#define DLT_REGISTER_LOG_LEVEL_CHANGED_CALLBACK(CONTEXT, CALLBACK) do{\
- (void)dlt_register_log_level_changed_callback(&(CONTEXT),CALLBACK);} while(0)
+#define DLT_REGISTER_LOG_LEVEL_CHANGED_CALLBACK(CONTEXT, CALLBACK) do { \
+ (void)dlt_register_log_level_changed_callback(&(CONTEXT), CALLBACK); } while (0)
/**
* Send log message with variable list of messages (intended for verbose mode)
@@ -205,17 +205,17 @@
/* DLT_LOG is not supported by MS Visual C++ */
/* use function interface instead */
#else
-#define DLT_LOG(CONTEXT,LOGLEVEL,ARGS...) \
+# define DLT_LOG(CONTEXT, LOGLEVEL, ARGS ...) \
do { \
DltContextData log_local; \
int dlt_local; \
- dlt_local = dlt_user_log_write_start(&CONTEXT,&log_local,LOGLEVEL); \
+ dlt_local = dlt_user_log_write_start(&CONTEXT, &log_local, LOGLEVEL); \
if (dlt_local == DLT_RETURN_TRUE) \
{ \
ARGS; \
(void)dlt_user_log_write_finish(&log_local); \
} \
- } while(0)
+ } while (0)
#endif
/**
@@ -224,8 +224,8 @@
* @param LOGLEVEL the log level of the log message
* @param MSGID the message id of log message
* @param ARGS variable list of arguments:
- calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
- DLT_INT(), DLT_UINT(), DLT_RAW()
+ * calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
+ * DLT_INT(), DLT_UINT(), DLT_RAW()
* @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
* use a semicolon instead of a comma to separate the ARGS.
* Example: DLT_LOG_ID(hContext, DLT_LOG_INFO, 0x1234, DLT_STRING("Hello world"); DLT_INT(123));
@@ -234,17 +234,17 @@
/* DLT_LOG_ID is not supported by MS Visual C++ */
/* use function interface instead */
#else
-#define DLT_LOG_ID(CONTEXT,LOGLEVEL,MSGID,ARGS...) \
+# define DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS ...) \
do { \
DltContextData log_local; \
int dlt_local; \
- dlt_local = dlt_user_log_write_start_id(&CONTEXT,&log_local,LOGLEVEL,MSGID); \
+ dlt_local = dlt_user_log_write_start_id(&CONTEXT, &log_local, LOGLEVEL, MSGID); \
if (dlt_local == DLT_RETURN_TRUE) \
{ \
ARGS; \
(void)dlt_user_log_write_finish(&log_local); \
} \
- } while(0)
+ } while (0)
#endif
/**
@@ -252,100 +252,100 @@
* @param TEXT ASCII string
*/
#define DLT_STRING(TEXT) \
- (void)dlt_user_log_write_string(&log_local,TEXT)
+ (void)dlt_user_log_write_string(&log_local, TEXT)
/**
* Add constant string parameter to the log messsage.
* @param TEXT Constant ASCII string
*/
#define DLT_CSTRING(TEXT) \
- (void)dlt_user_log_write_constant_string(&log_local,TEXT)
+ (void)dlt_user_log_write_constant_string(&log_local, TEXT)
/**
* Add utf8-encoded string parameter to the log messsage.
* @param TEXT UTF8-encoded string
*/
#define DLT_UTF8(TEXT) \
- (void)dlt_user_log_write_utf8_string(&log_local,TEXT)
+ (void)dlt_user_log_write_utf8_string(&log_local, TEXT)
/**
* Add boolean parameter to the log messsage.
* @param BOOL_VAR Boolean value (mapped to uint8)
*/
#define DLT_BOOL(BOOL_VAR) \
- (void)dlt_user_log_write_bool(&log_local,BOOL_VAR)
+ (void)dlt_user_log_write_bool(&log_local, BOOL_VAR)
/**
* Add float32 parameter to the log messsage.
* @param FLOAT32_VAR Float32 value (mapped to float)
*/
#define DLT_FLOAT32(FLOAT32_VAR) \
- (void)dlt_user_log_write_float32(&log_local,FLOAT32_VAR)
+ (void)dlt_user_log_write_float32(&log_local, FLOAT32_VAR)
/**
* Add float64 parameter to the log messsage.
* @param FLOAT64_VAR Float64 value (mapped to double)
*/
#define DLT_FLOAT64(FLOAT64_VAR) \
- (void)dlt_user_log_write_float64(&log_local,FLOAT64_VAR)
+ (void)dlt_user_log_write_float64(&log_local, FLOAT64_VAR)
/**
* Add integer parameter to the log messsage.
* @param INT_VAR integer value
*/
#define DLT_INT(INT_VAR) \
- (void)dlt_user_log_write_int(&log_local,INT_VAR)
+ (void)dlt_user_log_write_int(&log_local, INT_VAR)
#define DLT_INT8(INT_VAR) \
- (void)dlt_user_log_write_int8(&log_local,INT_VAR)
+ (void)dlt_user_log_write_int8(&log_local, INT_VAR)
#define DLT_INT16(INT_VAR) \
- (void)dlt_user_log_write_int16(&log_local,INT_VAR)
+ (void)dlt_user_log_write_int16(&log_local, INT_VAR)
#define DLT_INT32(INT_VAR) \
- (void)dlt_user_log_write_int32(&log_local,INT_VAR)
+ (void)dlt_user_log_write_int32(&log_local, INT_VAR)
#define DLT_INT64(INT_VAR) \
- (void)dlt_user_log_write_int64(&log_local,INT_VAR)
+ (void)dlt_user_log_write_int64(&log_local, INT_VAR)
/**
* Add unsigned integer parameter to the log messsage.
* @param UINT_VAR unsigned integer value
*/
#define DLT_UINT(UINT_VAR) \
- (void)dlt_user_log_write_uint(&log_local,UINT_VAR)
+ (void)dlt_user_log_write_uint(&log_local, UINT_VAR)
#define DLT_UINT8(UINT_VAR) \
- (void)dlt_user_log_write_uint8(&log_local,UINT_VAR)
+ (void)dlt_user_log_write_uint8(&log_local, UINT_VAR)
#define DLT_UINT16(UINT_VAR) \
- (void)dlt_user_log_write_uint16(&log_local,UINT_VAR)
+ (void)dlt_user_log_write_uint16(&log_local, UINT_VAR)
#define DLT_UINT32(UINT_VAR) \
- (void)dlt_user_log_write_uint32(&log_local,UINT_VAR)
+ (void)dlt_user_log_write_uint32(&log_local, UINT_VAR)
#define DLT_UINT64(UINT_VAR) \
- (void)dlt_user_log_write_uint64(&log_local,UINT_VAR)
+ (void)dlt_user_log_write_uint64(&log_local, UINT_VAR)
/**
* Add binary memory block to the log messages.
* @param BUF pointer to memory block
* @param LEN length of memory block
*/
-#define DLT_RAW(BUF,LEN) \
- (void)dlt_user_log_write_raw(&log_local,BUF,LEN)
+#define DLT_RAW(BUF, LEN) \
+ (void)dlt_user_log_write_raw(&log_local, BUF, LEN)
#define DLT_HEX8(UINT_VAR) \
- (void)dlt_user_log_write_uint8_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX8)
+ (void)dlt_user_log_write_uint8_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX8)
#define DLT_HEX16(UINT_VAR) \
- (void)dlt_user_log_write_uint16_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX16)
+ (void)dlt_user_log_write_uint16_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX16)
#define DLT_HEX32(UINT_VAR) \
- (void)dlt_user_log_write_uint32_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX32)
+ (void)dlt_user_log_write_uint32_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX32)
#define DLT_HEX64(UINT_VAR) \
- (void)dlt_user_log_write_uint64_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX64)
+ (void)dlt_user_log_write_uint64_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX64)
#define DLT_BIN8(UINT_VAR) \
- (void)dlt_user_log_write_uint8_formatted(&log_local,UINT_VAR,DLT_FORMAT_BIN8)
+ (void)dlt_user_log_write_uint8_formatted(&log_local, UINT_VAR, DLT_FORMAT_BIN8)
#define DLT_BIN16(UINT_VAR) \
- (void)dlt_user_log_write_uint16_formatted(&log_local,UINT_VAR,DLT_FORMAT_BIN16)
+ (void)dlt_user_log_write_uint16_formatted(&log_local, UINT_VAR, DLT_FORMAT_BIN16)
/**
* Architecture independent macro to print pointers
@@ -362,13 +362,13 @@
* @param PAYLOADLEN length of network message payload
* @param PAYLOAD pointer to network message payload
*/
-#define DLT_TRACE_NETWORK(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \
+#define DLT_TRACE_NETWORK(CONTEXT, TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD) \
do { \
- if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \
+ if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr) == DLT_TRACE_STATUS_ON) \
{ \
- (void)dlt_user_trace_network(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
+ (void)dlt_user_trace_network(&(CONTEXT), TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD); \
} \
- }while(0)
+ } while (0)
/**
* Trace network message, allow truncation
@@ -379,13 +379,13 @@
* @param PAYLOADLEN length of network message payload
* @param PAYLOAD pointer to network message payload
*/
-#define DLT_TRACE_NETWORK_TRUNCATED(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \
+#define DLT_TRACE_NETWORK_TRUNCATED(CONTEXT, TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD) \
do { \
- if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \
+ if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr) == DLT_TRACE_STATUS_ON) \
{ \
- (void)dlt_user_trace_network_truncated(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD, 1); \
+ (void)dlt_user_trace_network_truncated(&(CONTEXT), TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD, 1); \
} \
- }while(0)
+ } while (0)
/**
* Trace network message, segment large messages
@@ -396,13 +396,13 @@
* @param PAYLOADLEN length of network message payload
* @param PAYLOAD pointer to network message payload
*/
-#define DLT_TRACE_NETWORK_SEGMENTED(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \
+#define DLT_TRACE_NETWORK_SEGMENTED(CONTEXT, TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD) \
do { \
- if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \
+ if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr) == DLT_TRACE_STATUS_ON) \
{ \
- (void)dlt_user_trace_network_segmented(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
+ (void)dlt_user_trace_network_segmented(&(CONTEXT), TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD); \
} \
- }while(0)
+ } while (0)
/**
* Send log message with string parameter.
@@ -410,13 +410,13 @@
* @param LOGLEVEL the log level of the log message
* @param TEXT ASCII string
*/
-#define DLT_LOG_STRING(CONTEXT,LOGLEVEL,TEXT) \
+#define DLT_LOG_STRING(CONTEXT, LOGLEVEL, TEXT) \
do { \
- if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \
+ if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_string(&(CONTEXT), LOGLEVEL, TEXT); \
} \
- } while(0)
+ } while (0)
/**
* Send log message with string parameter and integer parameter.
@@ -425,13 +425,13 @@
* @param TEXT ASCII string
* @param INT_VAR integer value
*/
-#define DLT_LOG_STRING_INT(CONTEXT,LOGLEVEL,TEXT,INT_VAR) \
+#define DLT_LOG_STRING_INT(CONTEXT, LOGLEVEL, TEXT, INT_VAR) \
do { \
- if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \
+ if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_string_int(&(CONTEXT), LOGLEVEL, TEXT, INT_VAR); \
} \
- } while(0)
+ } while (0)
/**
* Send log message with string parameter and unsigned integer parameter.
@@ -440,13 +440,13 @@
* @param TEXT ASCII string
* @param UINT_VAR unsigned integer value
*/
-#define DLT_LOG_STRING_UINT(CONTEXT,LOGLEVEL,TEXT,UINT_VAR) \
+#define DLT_LOG_STRING_UINT(CONTEXT, LOGLEVEL, TEXT, UINT_VAR) \
do { \
- if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \
+ if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
- (void)dlt_log_string_uint(&(CONTEXT),LOGLEVEL,TEXT,UINT_VAR); \
+ (void)dlt_log_string_uint(&(CONTEXT), LOGLEVEL, TEXT, UINT_VAR); \
} \
- } while(0)
+ } while (0)
/**
* Send log message with unsigned integer parameter.
@@ -454,13 +454,13 @@
* @param LOGLEVEL the log level of the log message
* @param UINT_VAR unsigned integer value
*/
-#define DLT_LOG_UINT(CONTEXT,LOGLEVEL,UINT_VAR) \
+#define DLT_LOG_UINT(CONTEXT, LOGLEVEL, UINT_VAR) \
do { \
- if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \
+ if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
- (void)dlt_log_uint(&(CONTEXT),LOGLEVEL,UINT_VAR); \
+ (void)dlt_log_uint(&(CONTEXT), LOGLEVEL, UINT_VAR); \
} \
- } while(0)
+ } while (0)
/**
* Send log message with integer parameter.
@@ -468,13 +468,13 @@
* @param LOGLEVEL the log level of the log message
* @param INT_VAR integer value
*/
-#define DLT_LOG_INT(CONTEXT,LOGLEVEL,INT_VAR) \
+#define DLT_LOG_INT(CONTEXT, LOGLEVEL, INT_VAR) \
do { \
- if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \
+ if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
- (void)dlt_log_int(&(CONTEXT),LOGLEVEL,INT_VAR); \
+ (void)dlt_log_int(&(CONTEXT), LOGLEVEL, INT_VAR); \
} \
- } while(0)
+ } while (0)
/**
* Send log message with binary memory block.
@@ -483,13 +483,13 @@
* @param BUF pointer to memory block
* @param LEN length of memory block
*/
-#define DLT_LOG_RAW(CONTEXT,LOGLEVEL,BUF,LEN) \
+#define DLT_LOG_RAW(CONTEXT, LOGLEVEL, BUF, LEN) \
do { \
- if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \
+ if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
- (void)dlt_log_raw(&(CONTEXT),LOGLEVEL,BUF,LEN); \
+ (void)dlt_log_raw(&(CONTEXT), LOGLEVEL, BUF, LEN); \
} \
- } while(0)
+ } while (0)
/**
* Send log message with marker.
@@ -497,21 +497,21 @@
#define DLT_LOG_MARKER() \
do { \
(void)dlt_log_marker(); \
- } while(0)
+ } while (0)
/**
* Switch to verbose mode
*
*/
#define DLT_VERBOSE_MODE() do { \
- (void)dlt_verbose_mode();} while(0)
+ (void)dlt_verbose_mode(); } while (0)
/**
* Switch to non-verbose mode
*
*/
-#define DLT_NONVERBOSE_MODE() do {\
- (void)dlt_nonverbose_mode();} while(0)
+#define DLT_NONVERBOSE_MODE() do { \
+ (void)dlt_nonverbose_mode(); } while (0)
/**
* Set maximum logged log level and trace status of application
@@ -519,22 +519,22 @@
* @param LOGLEVEL This is the log level to be set for the whole application
* @param TRACESTATUS This is the trace status to be set for the whole application
*/
-#define DLT_SET_APPLICATION_LL_TS_LIMIT(LOGLEVEL, TRACESTATUS) do {\
- (void)dlt_set_application_ll_ts_limit(LOGLEVEL, TRACESTATUS);} while(0)
+#define DLT_SET_APPLICATION_LL_TS_LIMIT(LOGLEVEL, TRACESTATUS) do { \
+ (void)dlt_set_application_ll_ts_limit(LOGLEVEL, TRACESTATUS); } while (0)
/**
* Enable local printing of messages
*
*/
-#define DLT_ENABLE_LOCAL_PRINT() do {\
- (void)dlt_enable_local_print();} while(0)
+#define DLT_ENABLE_LOCAL_PRINT() do { \
+ (void)dlt_enable_local_print(); } while (0)
/**
* Disable local printing of messages
*
*/
-#define DLT_DISABLE_LOCAL_PRINT() do {\
- (void)dlt_disable_local_print();} while(0)
+#define DLT_DISABLE_LOCAL_PRINT() do { \
+ (void)dlt_disable_local_print(); } while (0)
/**
* Check if log level is enabled
@@ -542,11 +542,11 @@
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
*/
-#define DLT_IS_LOG_LEVEL_ENABLED(CONTEXT,LOGLEVEL) \
- (dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL) == DLT_RETURN_TRUE)
+#define DLT_IS_LOG_LEVEL_ENABLED(CONTEXT, LOGLEVEL) \
+ (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE)
/**
- \}
-*/
+ \}
+ */
#endif /* DLT_USER_MACROS_H */
diff --git a/src/adaptor/dlt-adaptor-stdin.c b/src/adaptor/dlt-adaptor-stdin.c
index aeca49b..e7817b1 100644
--- a/src/adaptor/dlt-adaptor-stdin.c
+++ b/src/adaptor/dlt-adaptor-stdin.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt-adaptor-stdin.c
-*/
+ */
/*******************************************************************************
** **
@@ -63,7 +63,7 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
-*/
+ */
#include <stdio.h>
#include <stdlib.h>
@@ -82,7 +82,7 @@
DLT_DECLARE_CONTEXT(mycontext)
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
char str[MAXSTRLEN];
int opt;
@@ -98,17 +98,15 @@ int main(int argc, char* argv[])
dlt_set_id(ctid, PS_DLT_CONTEXT);
while ((opt = getopt(argc, argv, "a:c:bht:v:")) != -1)
- {
- switch (opt)
- {
+ switch (opt) {
case 'a':
{
- dlt_set_id(apid,optarg);
+ dlt_set_id(apid, optarg);
break;
}
case 'c':
{
- dlt_set_id(ctid,optarg);
+ dlt_set_id(ctid, optarg);
break;
}
case 'b':
@@ -118,12 +116,12 @@ int main(int argc, char* argv[])
}
case 't':
{
- timeout = atoi(optarg);
- break;
+ timeout = atoi(optarg);
+ break;
}
case 'h':
{
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-adaptor-stdin [options]\n");
printf("Adaptor for forwarding input from stdin to DLT daemon.\n");
@@ -133,49 +131,51 @@ int main(int argc, char* argv[])
printf(" -c ctid - Set context id to ctid (default: SINC)\n");
printf(" -b - Flush buffered logs before unregistering app\n");
printf(" -t timeout - Set timeout when sending messages at exit, in ms (Default: 10000 = 10sec)\n");
- printf(" -v verbosity level - Set verbosity level (Default: INFO, values: FATAL ERROR WARN INFO DEBUG VERBOSE)\n");
+ printf(
+ " -v verbosity level - Set verbosity level (Default: INFO, values: FATAL ERROR WARN INFO DEBUG VERBOSE)\n");
printf(" -h - This help\n");
return 0;
break;
}
case 'v':
{
- if(!strcmp(optarg, "FATAL"))
- {
- verbosity = DLT_LOG_FATAL;
- break;
- }
- else if(!strcmp(optarg, "ERROR"))
- {
- verbosity = DLT_LOG_ERROR;
- break;
- }
- else if(!strcmp(optarg, "WARN"))
- {
- verbosity = DLT_LOG_WARN;
- break;
- }
- else if(!strcmp(optarg, "INFO"))
- {
- verbosity = DLT_LOG_INFO;
- break;
- }
- else if(!strcmp(optarg, "DEBUG"))
- {
- verbosity = DLT_LOG_DEBUG;
- break;
- }
- else if(!strcmp(optarg, "VERBOSE"))
- {
- verbosity = DLT_LOG_VERBOSE;
- break;
- } else
- {
- printf("Wrong verbosity level, setting to INFO. Accepted values are: FATAL ERROR WARN INFO DEBUG VERBOSE\n");
- verbosity = DLT_LOG_INFO;
- break;
- }
- break;
+ if (!strcmp(optarg, "FATAL")) {
+ verbosity = DLT_LOG_FATAL;
+ break;
+ }
+ else if (!strcmp(optarg, "ERROR"))
+ {
+ verbosity = DLT_LOG_ERROR;
+ break;
+ }
+ else if (!strcmp(optarg, "WARN"))
+ {
+ verbosity = DLT_LOG_WARN;
+ break;
+ }
+ else if (!strcmp(optarg, "INFO"))
+ {
+ verbosity = DLT_LOG_INFO;
+ break;
+ }
+ else if (!strcmp(optarg, "DEBUG"))
+ {
+ verbosity = DLT_LOG_DEBUG;
+ break;
+ }
+ else if (!strcmp(optarg, "VERBOSE"))
+ {
+ verbosity = DLT_LOG_VERBOSE;
+ break;
+ }
+ else {
+ printf(
+ "Wrong verbosity level, setting to INFO. Accepted values are: FATAL ERROR WARN INFO DEBUG VERBOSE\n");
+ verbosity = DLT_LOG_INFO;
+ break;
+ }
+
+ break;
}
default: /* '?' */
{
@@ -183,33 +183,23 @@ int main(int argc, char* argv[])
return -1;
}
}
- }
- DLT_REGISTER_APP(apid,PS_DLT_APP_DESC);
+ DLT_REGISTER_APP(apid, PS_DLT_APP_DESC);
DLT_REGISTER_CONTEXT(mycontext, ctid, PS_DLT_CONTEXT_DESC);
+
if (timeout > -1)
- {
- dlt_set_resend_timeout_atexit(timeout);
- }
+ dlt_set_resend_timeout_atexit(timeout);
while (fgets(str, MAXSTRLEN, stdin))
- {
- if (strcmp(str,"")!=0)
- {
+ if (strcmp(str, "") != 0)
DLT_LOG(mycontext, verbosity, DLT_STRING(str));
- }
- }
DLT_UNREGISTER_CONTEXT(mycontext);
if (bflag == 1)
- {
DLT_UNREGISTER_APP_FLUSH_BUFFERED_LOGS();
- }
else
- {
DLT_UNREGISTER_APP();
- }
return 0;
}
diff --git a/src/adaptor/dlt-adaptor-udp.c b/src/adaptor/dlt-adaptor-udp.c
index 3322eab..05b33d2 100644
--- a/src/adaptor/dlt-adaptor-udp.c
+++ b/src/adaptor/dlt-adaptor-udp.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt-adaptor-udp.c
-*/
+ */
/*******************************************************************************
** **
@@ -91,7 +91,7 @@
DLT_DECLARE_CONTEXT(mycontext)
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
int sock;
int bytes_read;
@@ -111,22 +111,20 @@ int main(int argc, char* argv[])
port = RCVPORT;
while ((opt = getopt(argc, argv, "a:c:hp:v:")) != -1)
- {
- switch (opt)
- {
+ switch (opt) {
case 'a':
{
- dlt_set_id(apid,optarg);
+ dlt_set_id(apid, optarg);
break;
}
case 'c':
{
- dlt_set_id(ctid,optarg);
+ dlt_set_id(ctid, optarg);
break;
}
case 'h':
{
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-adaptor-udp [options]\n");
printf("Adaptor for forwarding received UDP messages to DLT daemon.\n");
@@ -135,7 +133,8 @@ int main(int argc, char* argv[])
printf("-a apid - Set application id to apid (default: UDPA)\n");
printf("-c ctid - Set context id to ctid (default: UDPC)\n");
printf("-p - Set receive port number for UDP messages (default: %d) \n", port);
- printf("-v verbosity level - Set verbosity level (Default: INFO, values: FATAL ERROR WARN INFO DEBUG VERBOSE)\n");
+ printf(
+ "-v verbosity level - Set verbosity level (Default: INFO, values: FATAL ERROR WARN INFO DEBUG VERBOSE)\n");
printf("-h - This help\n");
return 0;
break;
@@ -147,55 +146,58 @@ int main(int argc, char* argv[])
}
case 'v':
{
- if(!strcmp(optarg, "FATAL"))
- {
- verbosity = DLT_LOG_FATAL;
- break;
- }
- else if(!strcmp(optarg, "ERROR"))
- {
- verbosity = DLT_LOG_ERROR;
- break;
- }
- else if(!strcmp(optarg, "WARN"))
- {
- verbosity = DLT_LOG_WARN;
- break;
- }
- else if(!strcmp(optarg, "INFO"))
- {
- verbosity = DLT_LOG_INFO;
- break;
- }
- else if(!strcmp(optarg, "DEBUG"))
- {
- verbosity = DLT_LOG_DEBUG;
- break;
- }
- else if(!strcmp(optarg, "VERBOSE"))
- {
- verbosity = DLT_LOG_VERBOSE;
- break;
- } else
- {
- printf("Wrong verbosity level, setting to INFO. Accepted values are: FATAL ERROR WARN INFO DEBUG VERBOSE\n");
- verbosity = DLT_LOG_INFO;
- break;
- }
- break;
+ if (!strcmp(optarg, "FATAL")) {
+ verbosity = DLT_LOG_FATAL;
+ break;
+ }
+ else if (!strcmp(optarg, "ERROR"))
+ {
+ verbosity = DLT_LOG_ERROR;
+ break;
+ }
+ else if (!strcmp(optarg, "WARN"))
+ {
+ verbosity = DLT_LOG_WARN;
+ break;
+ }
+ else if (!strcmp(optarg, "INFO"))
+ {
+ verbosity = DLT_LOG_INFO;
+ break;
+ }
+ else if (!strcmp(optarg, "DEBUG"))
+ {
+ verbosity = DLT_LOG_DEBUG;
+ break;
+ }
+ else if (!strcmp(optarg, "VERBOSE"))
+ {
+ verbosity = DLT_LOG_VERBOSE;
+ break;
+ }
+ else {
+ printf(
+ "Wrong verbosity level, setting to INFO. Accepted values are: FATAL ERROR WARN INFO DEBUG VERBOSE\n");
+ verbosity = DLT_LOG_INFO;
+ break;
+ }
+
+ break;
}
default: /* '?' */
{
fprintf(stderr, "Unknown option '%c'\n", optopt);
exit(3);
- return 3;//for parasoft
+ return 3;/*for parasoft */
}
}
- }
+
#ifdef DLT_USE_IPv6
+
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) == -1)
#else
+
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
#endif
{
@@ -212,34 +214,28 @@ int main(int argc, char* argv[])
server_addr.sin_addr.s_addr = INADDR_ANY;
bzero(&(server_addr.sin_zero), 8);
-
if (bind(sock, (struct sockaddr *)&server_addr,
- sizeof(struct sockaddr)) == -1)
- {
+ sizeof(struct sockaddr)) == -1) {
perror("Bind");
return -1;
}
addr_len = sizeof(struct sockaddr);
- DLT_REGISTER_APP(apid,PU_DLT_APP_DESC);
- DLT_REGISTER_CONTEXT(mycontext,ctid,PU_DLT_CONTEXT_DESC);
+ DLT_REGISTER_APP(apid, PU_DLT_APP_DESC);
+ DLT_REGISTER_CONTEXT(mycontext, ctid, PU_DLT_CONTEXT_DESC);
- while (1)
- {
+ while (1) {
bytes_read = 0;
bytes_read = recvfrom(sock, recv_data, MAXSTRLEN, 0,
(struct sockaddr *)&client_addr, &addr_len);
- if (bytes_read == -1)
- {
- if (errno == EINTR)
- {
+ if (bytes_read == -1) {
+ if (errno == EINTR) {
continue;
}
- else
- {
+ else {
DLT_UNREGISTER_CONTEXT(mycontext);
DLT_UNREGISTER_APP();
exit(1);
@@ -249,9 +245,7 @@ int main(int argc, char* argv[])
recv_data[bytes_read] = '\0';
if (bytes_read != 0)
- {
DLT_LOG(mycontext, verbosity, DLT_STRING(recv_data));
- }
}
DLT_UNREGISTER_CONTEXT(mycontext);
diff --git a/src/console/dlt-control-common.c b/src/console/dlt-control-common.c
index 37c5a62..964dbe8 100644
--- a/src/console/dlt-control-common.c
+++ b/src/console/dlt-control-common.c
@@ -111,24 +111,19 @@ void set_ecuid(char *ecuid)
{
char *ecuid_conf = NULL;
- if (local_ecuid != ecuid)
- {
+ if (local_ecuid != ecuid) {
/* If user pass NULL, read ECUId from dlt.conf */
- if (ecuid == NULL)
- {
- if (dlt_parse_config_param("ECUId", &ecuid_conf) == 0)
- {
+ if (ecuid == NULL) {
+ if (dlt_parse_config_param("ECUId", &ecuid_conf) == 0) {
memset(local_ecuid, 0, DLT_CTRL_ECUID_LEN);
strncpy(local_ecuid, ecuid_conf, DLT_CTRL_ECUID_LEN);
local_ecuid[DLT_CTRL_ECUID_LEN - 1] = '\0';
}
- else
- {
+ else {
pr_error("Cannot read ECUid from dlt.conf\n");
}
}
- else
- {
+ else {
/* Set user passed ECUID */
memset(local_ecuid, 0, DLT_CTRL_ECUID_LEN);
strncpy(local_ecuid, ecuid, DLT_CTRL_ECUID_LEN);
@@ -147,23 +142,19 @@ void set_timeout(long t)
local_timeout = DLT_CTRL_TIMEOUT;
if (t > 1)
- {
local_timeout = t;
- }
else
- {
pr_error("Timeout to small. Set to default: %d",
DLT_CTRL_TIMEOUT);
- }
}
int dlt_parse_config_param(char *config_id, char **config_data)
{
- FILE * pFile = NULL;
+ FILE *pFile = NULL;
int value_length = DLT_LINE_LEN;
- char line[DLT_LINE_LEN-1] = {0};
- char token[DLT_LINE_LEN] = {0};
- char value[DLT_LINE_LEN] = {0};
+ char line[DLT_LINE_LEN - 1] = { 0 };
+ char token[DLT_LINE_LEN] = { 0 };
+ char value[DLT_LINE_LEN] = { 0 };
char *pch = NULL;
const char *filename = NULL;
@@ -174,58 +165,48 @@ int dlt_parse_config_param(char *config_id, char **config_data)
filename = CONFIGURATION_FILES_DIR "/dlt.conf";
pFile = fopen(filename, "r");
- if (pFile != NULL)
- {
- while (1)
- {
+ if (pFile != NULL) {
+ while (1) {
/* fetch line from configuration file */
- if (fgets(line, value_length - 1, pFile) != NULL)
- {
- if (strncmp(line, config_id, strlen(config_id)) == 0)
- {
+ if (fgets(line, value_length - 1, pFile) != NULL) {
+ if (strncmp(line, config_id, strlen(config_id)) == 0) {
pch = strtok(line, " =\r\n");
token[0] = 0;
value[0] = 0;
- while (pch != NULL)
- {
- if (token[0] == 0)
- {
+ while (pch != NULL) {
+ if (token[0] == 0) {
strncpy(token, pch, sizeof(token) - 1);
token[sizeof(token) - 1] = 0;
}
- else
- {
+ else {
strncpy(value, pch, sizeof(value) - 1);
value[sizeof(value) - 1] = 0;
break;
}
+
pch = strtok(NULL, " =\r\n");
}
- if (token[0] && value[0])
- {
- if (strcmp(token, config_id) == 0)
- {
- *(config_data) = (char*)
- calloc(DLT_DAEMON_FLAG_MAX, sizeof(char));
+ if (token[0] && value[0]) {
+ if (strcmp(token, config_id) == 0) {
+ *(config_data) = (char *)
+ calloc(DLT_DAEMON_FLAG_MAX, sizeof(char));
memcpy(*config_data,
- value,
- DLT_DAEMON_FLAG_MAX-1);
+ value,
+ DLT_DAEMON_FLAG_MAX - 1);
}
}
-
}
}
- else
- {
+ else {
break;
}
}
+
fclose (pFile);
}
- else
- {
+ else {
fprintf(stderr, "Cannot open configuration file: %s\n", filename);
}
@@ -248,14 +229,12 @@ static int dlt_control_send_message_to_socket(int sock, DltMessage *msg)
{
if (send(sock,
(const char *)(msg->headerbuffer + sizeof(DltStorageHeader)),
- msg->headersize - sizeof(DltStorageHeader), 0) == -1)
- {
+ msg->headersize - sizeof(DltStorageHeader), 0) == -1) {
pr_error("Sending message header failed: %s\n", strerror(errno));
return -1;
}
- if (send(sock, (const char *) msg->databuffer, msg->datasize, 0) == -1)
- {
+ if (send(sock, (const char *)msg->databuffer, msg->datasize, 0) == -1) {
pr_error("Sending message failed: %s\n", strerror(errno));
return -1;
}
@@ -279,9 +258,7 @@ static int prepare_extra_headers(DltMessage *msg, uint8_t *header)
pr_verbose("Preparing extra headers.\n");
if (!msg || !header)
- {
return -1;
- }
shift = sizeof(DltStorageHeader) +
sizeof(DltStandardHeader) +
@@ -293,8 +270,7 @@ static int prepare_extra_headers(DltMessage *msg, uint8_t *header)
msg->headerextra.tmsp = dlt_uptime();
/* Copy header extra parameters to header buffer */
- if (dlt_message_set_extraparameters(msg, get_verbosity()) == -1)
- {
+ if (dlt_message_set_extraparameters(msg, get_verbosity()) == -1) {
pr_error("Cannot copy header extra parameter\n");
return -1;
}
@@ -329,21 +305,18 @@ static int prepare_headers(DltMessage *msg, uint8_t *header)
pr_verbose("Preparing headers.\n");
if (!msg || !header)
- {
return -1;
- }
- msg->storageheader = (DltStorageHeader *) header;
+ msg->storageheader = (DltStorageHeader *)header;
- if (dlt_set_storageheader(msg->storageheader, "") == -1)
- {
+ if (dlt_set_storageheader(msg->storageheader, "") == -1) {
pr_error("Storage header initialization failed.\n");
return -1;
}
/* prepare standard header */
msg->standardheader =
- (DltStandardHeader *) (header + sizeof(DltStorageHeader));
+ (DltStandardHeader *)(header + sizeof(DltStorageHeader));
msg->standardheader->htyp = DLT_HTYP_WEID |
DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
@@ -362,8 +335,7 @@ static int prepare_headers(DltMessage *msg, uint8_t *header)
len = msg->headersize - sizeof(DltStorageHeader) + msg->datasize;
- if (len > UINT16_MAX)
- {
+ if (len > UINT16_MAX) {
pr_error("Message header is too long.\n");
return -1;
}
@@ -388,22 +360,19 @@ static DltMessage *dlt_control_prepare_message(DltControlMsgBody *data)
pr_verbose("Preparing message.\n");
- if (data == NULL)
- {
+ if (data == NULL) {
pr_error("Data for message body is NULL\n");
return NULL;
}
msg = calloc(1, sizeof(DltMessage));
- if (msg == NULL)
- {
+ if (msg == NULL) {
pr_error("Cannot allocate memory for Dlt Message\n");
return NULL;
}
- if (dlt_message_init(msg, get_verbosity()) == -1)
- {
+ if (dlt_message_init(msg, get_verbosity()) == -1) {
pr_error("Cannot initialize Dlt Message\n");
free(msg);
return NULL;
@@ -415,8 +384,7 @@ static DltMessage *dlt_control_prepare_message(DltControlMsgBody *data)
/* Allocate memory for Dlt Message's buffer */
msg->databuffer = (uint8_t *)calloc(1, data->size);
- if (msg->databuffer == NULL)
- {
+ if (msg->databuffer == NULL) {
pr_error("Cannot allocate memory for data buffer\n");
free(msg);
return NULL;
@@ -426,16 +394,14 @@ static DltMessage *dlt_control_prepare_message(DltControlMsgBody *data)
memcpy(msg->databuffer, data->data, data->size);
/* prepare storage header */
- if (prepare_headers(msg, msg->headerbuffer))
- {
+ if (prepare_headers(msg, msg->headerbuffer)) {
dlt_message_free(msg, get_verbosity());
free(msg);
return NULL;
}
/* prepare extra headers */
- if (prepare_extra_headers(msg, msg->headerbuffer))
- {
+ if (prepare_extra_headers(msg, msg->headerbuffer)) {
dlt_message_free(msg, get_verbosity());
free(msg);
return NULL;
@@ -459,15 +425,14 @@ static int dlt_control_init_connection(DltClient *client, void *cb)
{
int (*callback)(DltMessage *message, void *data) = cb;
- if (!cb || !client)
- {
+ if (!cb || !client) {
pr_error("%s Invalid parameters (%p, %p)\n", __func__, client, cb);
return -1;
}
pr_verbose("Initializing the connection.\n");
- if (dlt_client_init(client, get_verbosity()) != 0)
- {
+
+ if (dlt_client_init(client, get_verbosity()) != 0) {
pr_error("Failed to register callback (NULL)\n");
return -1;
}
@@ -475,15 +440,15 @@ static int dlt_control_init_connection(DltClient *client, void *cb)
dlt_client_register_message_callback(callback);
client->socketPath = NULL;
- if (dlt_parse_config_param("ControlSocketPath", &client->socketPath) != 0)
- {
+
+ if (dlt_parse_config_param("ControlSocketPath", &client->socketPath) != 0) {
/* Failed to read from conf, copy default */
- if(dlt_client_set_socket_path(client, DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH) == -1)
- {
+ if (dlt_client_set_socket_path(client, DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH) == -1) {
pr_error("set socket path didn't succeed\n");
return -1;
}
}
+
client->mode = DLT_CLIENT_MODE_UNIX;
return dlt_client_connect(client, get_verbosity());
@@ -525,23 +490,18 @@ static void *dlt_control_listen_to_daemon(void *data)
static int dlt_control_callback(DltMessage *message, void *data)
{
char text[DLT_RECEIVE_BUFSIZE] = { 0 };
- (void) data;
+ (void)data;
- if (message == NULL)
- {
+ if (message == NULL) {
pr_error("Received message is null\n");
return -1;
}
/* prepare storage header */
if (DLT_IS_HTYP_WEID(message->standardheader->htyp))
- {
dlt_set_storageheader(message->storageheader, message->headerextra.ecu);
- }
else
- {
dlt_set_storageheader(message->storageheader, "LCTL");
- }
dlt_message_header(message, text, DLT_RECEIVE_BUFSIZE, get_verbosity());
@@ -582,14 +542,12 @@ int dlt_control_send_message(DltControlMsgBody *body, int timeout)
struct timespec t;
DltMessage *msg = NULL;
- if (!body)
- {
+ if (!body) {
pr_error("Invalid input (%p).\n", body);
return -1;
}
- if (clock_gettime(CLOCK_REALTIME, &t) == -1)
- {
+ if (clock_gettime(CLOCK_REALTIME, &t) == -1) {
pr_error("Cannot read system time.\n");
return -1;
}
@@ -599,8 +557,7 @@ int dlt_control_send_message(DltControlMsgBody *body, int timeout)
/* send command to daemon here */
msg = dlt_control_prepare_message(body);
- if (msg == NULL)
- {
+ if (msg == NULL) {
pr_error("Control message preparation failed\n");
return -1;
}
@@ -610,8 +567,7 @@ int dlt_control_send_message(DltControlMsgBody *body, int timeout)
/* Re-init the return value */
callback_return = -1;
- if (dlt_control_send_message_to_socket(client.sock, msg) != 0)
- {
+ if (dlt_control_send_message_to_socket(client.sock, msg) != 0) {
pr_error("Sending message to daemon failed\n");
free(msg);
return -1;
@@ -619,9 +575,7 @@ int dlt_control_send_message(DltControlMsgBody *body, int timeout)
/* If we timeout the lock is not taken back */
if (!pthread_cond_timedwait(&answer_cond, &answer_lock, &t))
- {
pthread_mutex_unlock(&answer_lock);
- }
/* Destroying the message */
dlt_message_free(msg, get_verbosity());
@@ -648,8 +602,7 @@ int dlt_control_init(int (*response_analyzer)(char *, void *, int),
char *ecuid,
int verbosity)
{
- if (!response_analyzer || !ecuid)
- {
+ if (!response_analyzer || !ecuid) {
pr_error("Invalid input (%p %p).\n", response_analyzer, ecuid);
return -1;
}
@@ -658,8 +611,7 @@ int dlt_control_init(int (*response_analyzer)(char *, void *, int),
set_ecuid(ecuid);
set_verbosity(verbosity);
- if (dlt_control_init_connection(&client, dlt_control_callback) != 0)
- {
+ if (dlt_control_init_connection(&client, dlt_control_callback) != 0) {
pr_error("Connection initialization failed\n");
dlt_client_cleanup(&client, get_verbosity());
return -1;
@@ -669,8 +621,7 @@ int dlt_control_init(int (*response_analyzer)(char *, void *, int),
if (pthread_create(&daemon_connect_thread,
NULL,
dlt_control_listen_to_daemon,
- NULL) != 0)
- {
+ NULL) != 0) {
pr_error("Cannot create thread to communicate with DLT daemon.\n");
return -1;
}
diff --git a/src/console/dlt-control.c b/src/console/dlt-control.c
index f291afa..a1eb408 100644
--- a/src/console/dlt-control.c
+++ b/src/console/dlt-control.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt-control.cpp
-*/
+ */
/*******************************************************************************
@@ -80,7 +80,7 @@ typedef struct
uint32_t service_id; /**< service ID */
} PACKED DltServiceGetDefaultLogLevel;
-DltClient g_dltclient;
+DltClient g_dltclient;
DltServiceGetLogInfoResponse *g_resp = NULL;
/* Function prototypes */
@@ -119,7 +119,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-control [options] hostname/serial_device_name\n");
printf("Send control message to DLT daemon.\n");
@@ -166,73 +166,59 @@ void usage()
*/
void dlt_process_get_log_info(void)
{
- char apid[DLT_ID_SIZE+1] = {0};
- char ctid[DLT_ID_SIZE+1] = {0};
+ char apid[DLT_ID_SIZE + 1] = { 0 };
+ char ctid[DLT_ID_SIZE + 1] = { 0 };
AppIDsType app;
ContextIDsInfoType con;
int i = 0;
int j = 0;
- g_resp = (DltServiceGetLogInfoResponse*) calloc(1, sizeof(DltServiceGetLogInfoResponse));
+ g_resp = (DltServiceGetLogInfoResponse *)calloc(1, sizeof(DltServiceGetLogInfoResponse));
- if (g_resp == NULL)
- {
+ if (g_resp == NULL) {
fprintf(stderr, "%s: Calloc failed for resp..\n", __func__);
return;
}
/* send control message*/
- if (0 != dlt_client_get_log_info(&g_dltclient))
- {
+ if (0 != dlt_client_get_log_info(&g_dltclient)) {
fprintf(stderr, "ERROR: Could not get log info\n");
dlt_client_cleanup_get_log_info(g_resp);
return;
}
if (dlt_client_main_loop(&g_dltclient, NULL, 0) == DLT_RETURN_TRUE)
- {
fprintf(stdout, "DLT-daemon's response is invalid.\n");
- }
- for (i = 0; i < g_resp->log_info_type.count_app_ids; i++)
- {
+ for (i = 0; i < g_resp->log_info_type.count_app_ids; i++) {
app = g_resp->log_info_type.app_ids[i];
dlt_print_id(apid, app.app_id);
if (app.app_description != 0)
- {
printf("APID:%4s %s\n", apid, app.app_description);
- }
else
- {
printf("APID:%4s \n", apid);
- }
- for (j = 0; j < app.count_context_ids; j++)
- {
+ for (j = 0; j < app.count_context_ids; j++) {
con = app.context_id_info[j];
dlt_print_id(ctid, con.context_id);
if (con.context_description != 0)
- {
- printf("CTID:%4s %2d %2d %s\n",
- ctid,
- con.log_level,
- con.trace_status,
- con.context_description);
- }
+ printf("CTID:%4s %2d %2d %s\n",
+ ctid,
+ con.log_level,
+ con.trace_status,
+ con.context_description);
else
- {
printf("CTID:%4s %2d %2d\n",
ctid,
con.log_level,
con.trace_status);
- }
- }
- }
+ }
+ }
dlt_client_cleanup_get_log_info(g_resp);
}
@@ -240,7 +226,7 @@ void dlt_process_get_log_info(void)
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
DltReceiveData dltdata;
int c;
@@ -271,152 +257,150 @@ int main(int argc, char* argv[])
opterr = 0;
while ((c = getopt (argc, argv, "vhye:b:a:c:s:m:x:t:l:r:d:f:i:ogju")) != -1)
- switch (c)
- {
+ switch (c) {
case 'v':
- {
- dltdata.vflag = 1;
- break;
- }
+ {
+ dltdata.vflag = 1;
+ break;
+ }
case 'h':
- {
- usage();
- return -1;
- }
+ {
+ usage();
+ return -1;
+ }
case 'y':
- {
- dltdata.yflag = DLT_CLIENT_MODE_SERIAL;
- break;
- }
+ {
+ dltdata.yflag = DLT_CLIENT_MODE_SERIAL;
+ break;
+ }
case 'e':
- {
- dltdata.evalue = optarg;
- break;
- }
+ {
+ dltdata.evalue = optarg;
+ break;
+ }
case 'b':
- {
- dltdata.bvalue = atoi(optarg);
- break;
- }
+ {
+ dltdata.bvalue = atoi(optarg);
+ break;
+ }
case 'a':
- {
- dltdata.avalue = optarg;
- if (strlen(dltdata.avalue) > DLT_ID_SIZE)
- {
- fprintf (stderr, "Invalid appid\n");
- return -1;
- }
- break;
+ {
+ dltdata.avalue = optarg;
+
+ if (strlen(dltdata.avalue) > DLT_ID_SIZE) {
+ fprintf (stderr, "Invalid appid\n");
+ return -1;
}
+
+ break;
+ }
case 'c':
- {
- dltdata.cvalue = optarg;
- if (strlen(dltdata.cvalue) > DLT_ID_SIZE)
- {
- fprintf (stderr, "Invalid context id\n");
- return -1;
- }
- break;
+ {
+ dltdata.cvalue = optarg;
+
+ if (strlen(dltdata.cvalue) > DLT_ID_SIZE) {
+ fprintf (stderr, "Invalid context id\n");
+ return -1;
}
+
+ break;
+ }
case 's':
- {
- dltdata.svalue = atoi(optarg);
- break;
- }
+ {
+ dltdata.svalue = atoi(optarg);
+ break;
+ }
case 'm':
- {
- dltdata.mvalue = optarg;
- break;
- }
+ {
+ dltdata.mvalue = optarg;
+ break;
+ }
case 'x':
- {
- dltdata.xvalue = optarg;
- break;
- }
+ {
+ dltdata.xvalue = optarg;
+ break;
+ }
case 't':
- {
- dltdata.tvalue = atoi(optarg);;
- break;
- }
+ {
+ dltdata.tvalue = atoi(optarg);
+ break;
+ }
case 'l':
- {
- dltdata.lvalue = strtol(optarg, &endptr, 10);
- if ((dltdata.lvalue < DLT_LOG_DEFAULT) || (dltdata.lvalue > DLT_LOG_VERBOSE))
- {
- fprintf (stderr, "invalid log level, supported log level 0-6\n");
- return -1;
- }
- break;
+ {
+ dltdata.lvalue = strtol(optarg, &endptr, 10);
+
+ if ((dltdata.lvalue < DLT_LOG_DEFAULT) || (dltdata.lvalue > DLT_LOG_VERBOSE)) {
+ fprintf (stderr, "invalid log level, supported log level 0-6\n");
+ return -1;
}
+
+ break;
+ }
case 'r':
- {
- dltdata.rvalue = strtol(optarg, &endptr, 10);
- if ((dltdata.rvalue < DLT_TRACE_STATUS_DEFAULT) || (dltdata.rvalue > DLT_TRACE_STATUS_ON))
- {
- fprintf (stderr, "invalid trace status, supported trace status -1, 0, 1\n");
- return -1;
- }
- break;
- }
+ {
+ dltdata.rvalue = strtol(optarg, &endptr, 10);
+
+ if ((dltdata.rvalue < DLT_TRACE_STATUS_DEFAULT) || (dltdata.rvalue > DLT_TRACE_STATUS_ON)) {
+ fprintf (stderr, "invalid trace status, supported trace status -1, 0, 1\n");
+ return -1;
+ }
+
+ break;
+ }
case 'd':
- {
- dltdata.dvalue = atoi(optarg);;
- break;
- }
+ {
+ dltdata.dvalue = atoi(optarg);
+ break;
+ }
case 'f':
- {
- dltdata.fvalue = atoi(optarg);;
- break;
- }
+ {
+ dltdata.fvalue = atoi(optarg);
+ break;
+ }
case 'i':
- {
- dltdata.ivalue = atoi(optarg);;
- break;
- }
+ {
+ dltdata.ivalue = atoi(optarg);
+ break;
+ }
case 'o':
- {
- dltdata.oflag = 1;
- break;
- }
+ {
+ dltdata.oflag = 1;
+ break;
+ }
case 'g':
- {
- dltdata.gflag = 1;
- break;
- }
+ {
+ dltdata.gflag = 1;
+ break;
+ }
case 'j':
- {
- dltdata.jvalue = 1;
- break;
- }
+ {
+ dltdata.jvalue = 1;
+ break;
+ }
case 'u':
- {
- dltdata.yflag = DLT_CLIENT_MODE_UNIX;
- break;
- }
+ {
+ dltdata.yflag = DLT_CLIENT_MODE_UNIX;
+ break;
+ }
case '?':
- {
- if ((optopt == 'o') || (optopt == 'f'))
- {
- fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
- else if (isprint (optopt))
- {
- fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
- else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
- /* unknown or wrong option used, show usage information and terminate */
- usage();
- return -1;
- }
+ {
+ if ((optopt == 'o') || (optopt == 'f'))
+ fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+ else if (isprint (optopt))
+ fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+ else
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
+ /* unknown or wrong option used, show usage information and terminate */
+ usage();
+ return -1;
+ }
default:
- {
- abort ();
- return -1;//for parasoft
- }
+ {
+ abort ();
+ return -1; /*for parasoft */
+ }
}
/* Initialize DLT Client */
@@ -426,8 +410,7 @@ int main(int argc, char* argv[])
dlt_client_register_message_callback(dlt_receive_message_callback);
/* Setup DLT Client structure */
- if (dltdata.yflag == DLT_CLIENT_MODE_SERIAL)
- {
+ if (dltdata.yflag == DLT_CLIENT_MODE_SERIAL) {
g_dltclient.mode = DLT_CLIENT_MODE_SERIAL;
}
else if (dltdata.yflag == DLT_CLIENT_MODE_UNIX)
@@ -436,267 +419,240 @@ int main(int argc, char* argv[])
g_dltclient.socketPath = NULL;
dlt_parse_config_param("ControlSocketPath", &g_dltclient.socketPath);
}
- else
- {
+ else {
g_dltclient.mode = DLT_CLIENT_MODE_TCP;
}
- if (g_dltclient.mode==DLT_CLIENT_MODE_TCP)
- {
+ if (g_dltclient.mode == DLT_CLIENT_MODE_TCP) {
for (index = optind; index < argc; index++)
- {
- if(dlt_client_set_server_ip(&g_dltclient, argv[index]) == -1)
- {
+ if (dlt_client_set_server_ip(&g_dltclient, argv[index]) == -1) {
pr_error("set server ip didn't succeed\n");
return -1;
}
- }
- if (g_dltclient.servIP == 0)
- {
+
+
+
+ if (g_dltclient.servIP == 0) {
/* no hostname selected, show usage and terminate */
- fprintf(stderr,"ERROR: No hostname selected\n");
+ fprintf(stderr, "ERROR: No hostname selected\n");
usage();
- dlt_client_cleanup(&g_dltclient,dltdata.vflag);
+ dlt_client_cleanup(&g_dltclient, dltdata.vflag);
return -1;
}
}
else if (g_dltclient.mode == DLT_CLIENT_MODE_SERIAL)
{
for (index = optind; index < argc; index++)
- {
- if(dlt_client_set_serial_device(&g_dltclient, argv[index]) == -1)
- {
+ if (dlt_client_set_serial_device(&g_dltclient, argv[index]) == -1) {
pr_error("set serial device didn't succeed\n");
return -1;
}
- }
- if (g_dltclient.serialDevice == 0)
- {
+
+
+
+ if (g_dltclient.serialDevice == 0) {
/* no serial device name selected, show usage and terminate */
- fprintf(stderr,"ERROR: No serial device name specified\n");
+ fprintf(stderr, "ERROR: No serial device name specified\n");
usage();
return -1;
}
- dlt_client_setbaudrate(&g_dltclient,dltdata.bvalue);
+ dlt_client_setbaudrate(&g_dltclient, dltdata.bvalue);
}
/* initialise structure to use DLT file */
- dlt_file_init(&(dltdata.file),dltdata.vflag);
+ dlt_file_init(&(dltdata.file), dltdata.vflag);
/* first parse filter file if filter parameter is used */
- dlt_filter_init(&(dltdata.filter),dltdata.vflag);
+ dlt_filter_init(&(dltdata.filter), dltdata.vflag);
- if (dltdata.evalue)
- {
- dlt_set_id(dltdata.ecuid,dltdata.evalue);
- dlt_set_id(g_dltclient.ecuid,dltdata.evalue);
+ if (dltdata.evalue) {
+ dlt_set_id(dltdata.ecuid, dltdata.evalue);
+ dlt_set_id(g_dltclient.ecuid, dltdata.evalue);
}
- else
- {
+ else {
dltdata.evalue = NULL;
- if (dlt_parse_config_param("ECUId", &dltdata.evalue) == 0)
- {
- dlt_set_id(dltdata.ecuid,dltdata.evalue);
- dlt_set_id(g_dltclient.ecuid,dltdata.evalue);
+
+ if (dlt_parse_config_param("ECUId", &dltdata.evalue) == 0) {
+ dlt_set_id(dltdata.ecuid, dltdata.evalue);
+ dlt_set_id(g_dltclient.ecuid, dltdata.evalue);
free (dltdata.evalue);
}
- else
- {
+ else {
fprintf(stderr, "ERROR: Failed to read ECUId from dlt.conf \n");
}
}
/* Connect to TCP socket or open serial device */
- if (dlt_client_connect(&g_dltclient, dltdata.vflag) != DLT_RETURN_ERROR)
- {
- /* send injection message */
- if(dltdata.mvalue && dltdata.avalue && dltdata.cvalue)
- {
- /* ASCII */
- printf("Send injection message:\n");
- printf("AppId: %s\n",dltdata.avalue);
- printf("ConId: %s\n",dltdata.cvalue);
- printf("ServiceId: %d\n",dltdata.svalue);
- printf("Message: %s\n",dltdata.mvalue);
- /* send control message in ascii */
+ if (dlt_client_connect(&g_dltclient, dltdata.vflag) != DLT_RETURN_ERROR) {
+ /* send injection message */
+ if (dltdata.mvalue && dltdata.avalue && dltdata.cvalue) {
+ /* ASCII */
+ printf("Send injection message:\n");
+ printf("AppId: %s\n", dltdata.avalue);
+ printf("ConId: %s\n", dltdata.cvalue);
+ printf("ServiceId: %d\n", dltdata.svalue);
+ printf("Message: %s\n", dltdata.mvalue);
+
+ /* send control message in ascii */
if (dlt_client_send_inject_msg(&g_dltclient,
- dltdata.avalue,
- dltdata.cvalue,
- dltdata.svalue,
- (uint8_t*)dltdata.mvalue,
- strlen(dltdata.mvalue)) != DLT_RETURN_OK)
- {
+ dltdata.avalue,
+ dltdata.cvalue,
+ dltdata.svalue,
+ (uint8_t *)dltdata.mvalue,
+ strlen(dltdata.mvalue)) != DLT_RETURN_OK)
fprintf(stderr, "ERROR: Could not send inject message\n");
- }
- }
- else if(dltdata.xvalue && dltdata.avalue && dltdata.cvalue)
- {
- /* Hex */
- uint8_t buffer[1024];
- int size = 1024;
- printf("Send injection message:\n");
- printf("AppId: %s\n",dltdata.avalue);
- printf("ConId: %s\n",dltdata.cvalue);
- printf("ServiceId: %d\n",dltdata.svalue);
- printf("Message: %s\n",dltdata.xvalue);
- dlt_hex_ascii_to_binary(dltdata.xvalue,buffer,&size);
- printf("Size: %d\n",size);
+ }
+ else if (dltdata.xvalue && dltdata.avalue && dltdata.cvalue)
+ {
+ /* Hex */
+ uint8_t buffer[1024];
+ int size = 1024;
+ printf("Send injection message:\n");
+ printf("AppId: %s\n", dltdata.avalue);
+ printf("ConId: %s\n", dltdata.cvalue);
+ printf("ServiceId: %d\n", dltdata.svalue);
+ printf("Message: %s\n", dltdata.xvalue);
+ dlt_hex_ascii_to_binary(dltdata.xvalue, buffer, &size);
+ printf("Size: %d\n", size);
+
/* send control message in hex */
if (dlt_client_send_inject_msg(&g_dltclient,
- dltdata.avalue,
- dltdata.cvalue,
- dltdata.svalue,
- buffer,size) != DLT_RETURN_OK)
- {
+ dltdata.avalue,
+ dltdata.cvalue,
+ dltdata.svalue,
+ buffer, size) != DLT_RETURN_OK)
fprintf(stderr, "ERROR: Could not send inject message\n");
- }
- }
- else if (dltdata.lvalue != DLT_INVALID_LOG_LEVEL) /*&& dltdata.avalue && dltdata.cvalue)*/
+ }
+ else if (dltdata.lvalue != DLT_INVALID_LOG_LEVEL) /*&& dltdata.avalue && dltdata.cvalue)*/
{
- if ((dltdata.avalue == 0) && (dltdata.cvalue == 0))
- {
- if (dltdata.vflag)
- {
+ if ((dltdata.avalue == 0) && (dltdata.cvalue == 0)) {
+ if (dltdata.vflag) {
printf("Set all log level:\n");
printf("Loglevel: %d\n", dltdata.lvalue);
}
+
if (0 != dlt_client_send_all_log_level(&g_dltclient,
dltdata.lvalue))
- {
fprintf(stderr, "ERROR: Could not send log level\n");
- }
}
- else
- {
+ else {
/* log level */
- if (dltdata.vflag)
- {
+ if (dltdata.vflag) {
printf("Set log level:\n");
printf("AppId: %s\n", dltdata.avalue);
printf("ConId: %s\n", dltdata.cvalue);
printf("Loglevel: %d\n", dltdata.lvalue);
}
+
/* send control message*/
if (0 != dlt_client_send_log_level(&g_dltclient,
dltdata.avalue,
dltdata.cvalue,
dltdata.lvalue))
- {
fprintf(stderr, "ERROR: Could not send log level\n");
- }
}
}
else if (dltdata.rvalue != DLT_INVALID_TRACE_STATUS)
{
- if ((dltdata.avalue == 0) && (dltdata.cvalue == 0))
- {
- if (dltdata.vflag)
- {
+ if ((dltdata.avalue == 0) && (dltdata.cvalue == 0)) {
+ if (dltdata.vflag) {
printf("Set all trace status:\n");
printf("Tracestatus: %d\n", dltdata.rvalue);
}
+
if (0 != dlt_client_send_all_trace_status(&g_dltclient,
dltdata.rvalue))
- {
fprintf(stderr, "ERROR: Could not send trace status\n");
- }
}
- else
- {
+ else {
/* trace status */
- if (dltdata.vflag)
- {
+ if (dltdata.vflag) {
printf("Set trace status:\n");
printf("AppId: %s\n", dltdata.avalue);
printf("ConId: %s\n", dltdata.cvalue);
printf("Tracestatus: %d\n", dltdata.rvalue);
}
+
/* send control message*/
if (0 != dlt_client_send_trace_status(&g_dltclient,
dltdata.avalue,
dltdata.cvalue,
dltdata.rvalue))
- {
fprintf(stderr, "ERROR: Could not send trace status\n");
- }
}
}
- else if(dltdata.dvalue!=-1)
- {
- /* default log level */
- printf("Set default log level:\n");
- printf("Loglevel: %d\n",dltdata.dvalue);
- /* send control message in*/
+ else if (dltdata.dvalue != -1)
+ {
+ /* default log level */
+ printf("Set default log level:\n");
+ printf("Loglevel: %d\n", dltdata.dvalue);
+
+ /* send control message in*/
if (dlt_client_send_default_log_level(&g_dltclient, dltdata.dvalue) != DLT_RETURN_OK)
- {
fprintf (stderr, "ERROR: Could not send default log level\n");
- }
- }
- else if(dltdata.fvalue!=-1)
- {
- /* default trace status */
- printf("Set default trace status:\n");
- printf("TraceStatus: %d\n",dltdata.fvalue);
- /* send control message in*/
+ }
+ else if (dltdata.fvalue != -1)
+ {
+ /* default trace status */
+ printf("Set default trace status:\n");
+ printf("TraceStatus: %d\n", dltdata.fvalue);
+
+ /* send control message in*/
if (dlt_client_send_default_trace_status(&g_dltclient, dltdata.fvalue) != DLT_RETURN_OK)
- {
fprintf (stderr, "ERROR: Could not send default trace status\n");
- }
- }
- else if(dltdata.ivalue!=-1)
- {
- /* timing pakets */
- printf("Set timing pakets:\n");
- printf("Timing packets: %d\n",dltdata.ivalue);
- /* send control message in*/
+ }
+ else if (dltdata.ivalue != -1)
+ {
+ /* timing pakets */
+ printf("Set timing pakets:\n");
+ printf("Timing packets: %d\n", dltdata.ivalue);
+
+ /* send control message in*/
if (dlt_client_send_timing_pakets(&g_dltclient, dltdata.ivalue) != DLT_RETURN_OK)
- {
fprintf (stderr, "ERROR: Could not send timing packets\n");
- }
- }
- else if(dltdata.oflag!=-1)
- {
- /* default trace status */
- printf("Store config\n");
- /* send control message in*/
+ }
+ else if (dltdata.oflag != -1)
+ {
+ /* default trace status */
+ printf("Store config\n");
+
+ /* send control message in*/
if (dlt_client_send_store_config(&g_dltclient) != DLT_RETURN_OK)
- {
fprintf (stderr, "ERROR: Could not send store config\n");
- }
- }
- else if(dltdata.gflag!=-1)
- {
- /* reset to factory default */
- printf("Reset to factory default\n");
- /* send control message in*/
+ }
+ else if (dltdata.gflag != -1)
+ {
+ /* reset to factory default */
+ printf("Reset to factory default\n");
+
+ /* send control message in*/
if (dlt_client_send_reset_to_factory_default(&g_dltclient) != DLT_RETURN_OK)
- {
fprintf (stderr, "ERROR: Could send reset to factory default\n");
- }
- }
+ }
else if (dltdata.jvalue == 1)
{
/* get log info */
printf("Get log info:\n");
dlt_process_get_log_info();
}
+
/* Dlt Client Main Loop */
- //dlt_client_main_loop(&dltclient, &dltdata, dltdata.vflag);
+ /*dlt_client_main_loop(&dltclient, &dltdata, dltdata.vflag); */
- /* Wait timeout */
- usleep(dltdata.tvalue*1000);
+ /* Wait timeout */
+ usleep(dltdata.tvalue * 1000);
}
/* Dlt Client Cleanup */
- dlt_client_cleanup(&g_dltclient,dltdata.vflag);
+ dlt_client_cleanup(&g_dltclient, dltdata.vflag);
if (g_dltclient.socketPath != NULL)
free(g_dltclient.socketPath);
- dlt_file_free(&(dltdata.file),dltdata.vflag);
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
- dlt_filter_free(&(dltdata.filter),dltdata.vflag);
+ dlt_filter_free(&(dltdata.filter), dltdata.vflag);
return 0;
}
@@ -708,56 +664,49 @@ int dlt_receive_message_callback(DltMessage *message, void *data)
/* parameter check */
if (message == NULL)
- {
return -1;
- }
+
/* to avoid warning */
data = data;
/* prepare storage header */
if (DLT_IS_HTYP_WEID(message->standardheader->htyp))
- {
dlt_set_storageheader(message->storageheader, message->headerextra.ecu);
- }
else
- {
dlt_set_storageheader(message->storageheader, "LCTL");
- }
/* get response data */
ret = dlt_message_header(message, resp_text, DLT_RECEIVE_BUFSIZE, 0);
- if (ret < 0)
- {
+
+ if (ret < 0) {
fprintf(stderr, "GET_LOG_INFO message_header result failed..\n");
dlt_client_cleanup(&g_dltclient, 0);
return -1;
}
ret = dlt_message_payload(message, resp_text, DLT_RECEIVE_BUFSIZE, DLT_OUTPUT_ASCII, 0);
- if (ret < 0)
- {
+
+ if (ret < 0) {
fprintf(stderr, "GET_LOG_INFO message_payload result failed..\n");
dlt_client_cleanup(&g_dltclient, 0);
return -1;
}
/* check service id */
- if (g_resp == NULL)
- {
+ if (g_resp == NULL) {
fprintf(stderr, "%s: g_resp isn't allocated.\n", __func__);
dlt_client_cleanup(&g_dltclient, 0);
return -1;
}
ret = dlt_set_loginfo_parse_service_id(resp_text, &g_resp->service_id, &g_resp->status);
- if ((ret == 0) && (g_resp->service_id == DLT_SERVICE_ID_GET_LOG_INFO))
- {
+
+ if ((ret == 0) && (g_resp->service_id == DLT_SERVICE_ID_GET_LOG_INFO)) {
ret = dlt_client_parse_get_log_info_resp_text(g_resp, resp_text);
if (ret != 0)
- {
fprintf(stderr, "GET_LOG_INFO result failed..\n");
- }
+
dlt_client_cleanup(&g_dltclient, 0);
}
diff --git a/src/console/dlt-convert.c b/src/console/dlt-convert.c
index 8c5c901..8c71684 100644
--- a/src/console/dlt-convert.c
+++ b/src/console/dlt-convert.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt-convert.cpp
-*/
+ */
/*******************************************************************************
** **
@@ -72,8 +72,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <stdio.h>
#include <stdlib.h>
@@ -97,7 +97,7 @@ void usage()
{
char version[DLT_CONVERT_TEXTBUFSIZE];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-convert [options] [commands] file1 [file2]\n");
printf("Read DLT files, print DLT messages as ASCII and store the messages again.\n");
@@ -124,7 +124,7 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
int vflag = 0;
int cflag = 0;
@@ -141,271 +141,239 @@ int main(int argc, char* argv[])
int index;
int c;
- DltFile file;
- DltFilter filter;
+ DltFile file;
+ DltFilter filter;
- int ohandle=-1;
+ int ohandle = -1;
- int num, begin, end;
+ int num, begin, end;
- char text[DLT_CONVERT_TEXTBUFSIZE];
+ char text[DLT_CONVERT_TEXTBUFSIZE];
- struct iovec iov[2];
+ struct iovec iov[2];
int bytes_written;
opterr = 0;
while ((c = getopt (argc, argv, "vcashxmwf:b:e:o:")) != -1)
- switch (c)
- {
+ switch (c) {
case 'v':
- {
- vflag = 1;
- break;
- }
+ {
+ vflag = 1;
+ break;
+ }
case 'c':
- {
- cflag = 1;
- break;
- }
+ {
+ cflag = 1;
+ break;
+ }
case 'a':
- {
- aflag = 1;
- break;
- }
+ {
+ aflag = 1;
+ break;
+ }
case 's':
- {
- sflag = 1;
- break;
- }
+ {
+ sflag = 1;
+ break;
+ }
case 'x':
- {
- xflag = 1;
- break;
- }
+ {
+ xflag = 1;
+ break;
+ }
case 'm':
- {
- mflag = 1;
- break;
- }
+ {
+ mflag = 1;
+ break;
+ }
case 'w':
- {
- wflag = 1;
- break;
- }
+ {
+ wflag = 1;
+ break;
+ }
case 'h':
- {
- usage();
- return -1;
- }
+ {
+ usage();
+ return -1;
+ }
case 'f':
- {
- fvalue = optarg;
- break;
- }
+ {
+ fvalue = optarg;
+ break;
+ }
case 'b':
- {
- bvalue = optarg;
- break;
- }
+ {
+ bvalue = optarg;
+ break;
+ }
case 'e':
- {
- evalue = optarg;
- break;
- }
+ {
+ evalue = optarg;
+ break;
+ }
case 'o':
- {
- ovalue = optarg;
- break;
- }
+ {
+ ovalue = optarg;
+ break;
+ }
case '?':
- {
- if (optopt == 'f' || optopt == 'b' || optopt == 'e' || optopt == 'o')
- {
- fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
- else if (isprint (optopt))
- {
- fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
- else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
- /* unknown or wrong option used, show usage information and terminate */
- usage();
- return -1;
- }
+ {
+ if ((optopt == 'f') || (optopt == 'b') || (optopt == 'e') || (optopt == 'o'))
+ fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+ else if (isprint (optopt))
+ fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+ else
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
+ /* unknown or wrong option used, show usage information and terminate */
+ usage();
+ return -1;
+ }
default:
- {
- abort();
- return -1;//for parasoft
- }
+ {
+ abort();
+ return -1; /*for parasoft */
+ }
}
/* initialise structure to use DLT file */
- dlt_file_init(&file,vflag);
+ dlt_file_init(&file, vflag);
/* first parse filter file if filter parameter is used */
- if (fvalue)
- {
- if (dlt_filter_load(&filter,fvalue,vflag) < DLT_RETURN_OK)
- {
- dlt_file_free(&file,vflag);
+ if (fvalue) {
+ if (dlt_filter_load(&filter, fvalue, vflag) < DLT_RETURN_OK) {
+ dlt_file_free(&file, vflag);
return -1;
}
- dlt_file_set_filter(&file,&filter,vflag);
+ dlt_file_set_filter(&file, &filter, vflag);
}
- if (ovalue)
- {
- ohandle = open(ovalue,O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
- if (ohandle == -1)
- {
- dlt_file_free(&file,vflag);
- fprintf(stderr,"ERROR: Output file %s cannot be opened!\n",ovalue);
+ if (ovalue) {
+ ohandle = open(ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
+
+ if (ohandle == -1) {
+ dlt_file_free(&file, vflag);
+ fprintf(stderr, "ERROR: Output file %s cannot be opened!\n", ovalue);
return -1;
}
-
}
- for (index = optind; index < argc; index++)
- {
+ for (index = optind; index < argc; index++) {
/* load, analyse data file and create index list */
- if (dlt_file_open(&file,argv[index],vflag) >= DLT_RETURN_OK)
- {
- while (dlt_file_read(&file,vflag) >= DLT_RETURN_OK)
- {
- }
+ if (dlt_file_open(&file, argv[index], vflag) >= DLT_RETURN_OK) {
+ while (dlt_file_read(&file, vflag) >= DLT_RETURN_OK) {}
}
- if (aflag || sflag || xflag || mflag || ovalue)
- {
+ if (aflag || sflag || xflag || mflag || ovalue) {
if (bvalue)
- {
begin = atoi(bvalue);
- }
- else
- {
+ else
begin = 0;
- }
- if (evalue && (wflag==0))
- {
+ if (evalue && (wflag == 0))
end = atoi(evalue);
- }
- else
- {
- end = file.counter-1;
- }
-
- if (begin<0 || begin>=file.counter)
- {
- fprintf(stderr,"ERROR: Selected first message %d is out of range!\n",begin);
+ else
+ end = file.counter - 1;
+
+ if ((begin < 0) || (begin >= file.counter)) {
+ fprintf(stderr, "ERROR: Selected first message %d is out of range!\n", begin);
return -1;
}
- if (end<0 || end>=file.counter || end<begin)
- {
- fprintf(stderr,"ERROR: Selected end message %d is out of range!\n",end);
+
+ if ((end < 0) || (end >= file.counter) || (end < begin)) {
+ fprintf(stderr, "ERROR: Selected end message %d is out of range!\n", end);
return -1;
}
- for (num = begin; num <= end ;num++)
- {
- dlt_file_message(&file,num,vflag);
- if (xflag)
- {
- printf("%d ",num);
- dlt_message_print_hex(&(file.msg),text,DLT_CONVERT_TEXTBUFSIZE,vflag);
+ for (num = begin; num <= end; num++) {
+ dlt_file_message(&file, num, vflag);
+
+ if (xflag) {
+ printf("%d ", num);
+ dlt_message_print_hex(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag);
}
else if (aflag)
{
- printf("%d ",num);
+ printf("%d ", num);
- dlt_message_header(&(file.msg),text,DLT_CONVERT_TEXTBUFSIZE,vflag);
+ dlt_message_header(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag);
- printf("%s ",text);
+ printf("%s ", text);
- dlt_message_payload(&file.msg,text,DLT_CONVERT_TEXTBUFSIZE,DLT_OUTPUT_ASCII,vflag);
+ dlt_message_payload(&file.msg, text, DLT_CONVERT_TEXTBUFSIZE, DLT_OUTPUT_ASCII, vflag);
- printf("[%s]\n",text);
+ printf("[%s]\n", text);
}
else if (mflag)
{
- printf("%d ",num);
- dlt_message_print_mixed_plain(&(file.msg),text,DLT_CONVERT_TEXTBUFSIZE,vflag);
+ printf("%d ", num);
+ dlt_message_print_mixed_plain(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag);
}
else if (sflag)
{
- printf("%d ",num);
+ printf("%d ", num);
- dlt_message_header(&(file.msg),text,DLT_CONVERT_TEXTBUFSIZE,vflag);
+ dlt_message_header(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag);
- printf("%s \n",text);
+ printf("%s \n", text);
}
/* if file output enabled write message */
- if (ovalue)
- {
+ if (ovalue) {
iov[0].iov_base = file.msg.headerbuffer;
iov[0].iov_len = file.msg.headersize;
iov[1].iov_base = file.msg.databuffer;
iov[1].iov_len = file.msg.datasize;
bytes_written = writev(ohandle, iov, 2);
- if (0 > bytes_written){
- printf("in main: writev(ohandle, iov, 2); returned an error!" );
- dlt_file_free(&file,vflag);
- return -1;
+
+ if (0 > bytes_written) {
+ printf("in main: writev(ohandle, iov, 2); returned an error!");
+ dlt_file_free(&file, vflag);
+ return -1;
}
}
/* check for new messages if follow flag set */
- if (wflag && num==end)
- {
- while (1)
- {
- while (dlt_file_read(&file,0)>=0)
- {
- }
- if (end == (file.counter-1))
- {
+ if (wflag && (num == end)) {
+ while (1) {
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ if (end == (file.counter - 1)) {
/* Sleep if no new message was received */
sleep(1);
}
- else
- {
+ else {
/* set new end of log file and continue reading */
- end = file.counter-1;
+ end = file.counter - 1;
break;
}
}
}
}
}
- if (cflag)
- {
- printf("Total number of messages: %d\n",file.counter_total);
+
+ if (cflag) {
+ printf("Total number of messages: %d\n", file.counter_total);
+
if (file.filter)
- {
- printf("Filtered number of messages: %d\n",file.counter);
- }
+ printf("Filtered number of messages: %d\n", file.counter);
}
}
+
if (ovalue)
- {
close(ohandle);
- }
- if (index == optind)
- {
+
+ if (index == optind) {
/* no file selected, show usage and terminate */
- fprintf(stderr,"ERROR: No file selected\n");
+ fprintf(stderr, "ERROR: No file selected\n");
usage();
return -1;
}
- dlt_file_free(&file,vflag);
+ dlt_file_free(&file, vflag);
return 0;
}
diff --git a/src/console/dlt-passive-node-ctrl.c b/src/console/dlt-passive-node-ctrl.c
index 88a03a8..76ff789 100644
--- a/src/console/dlt-passive-node-ctrl.c
+++ b/src/console/dlt-passive-node-ctrl.c
@@ -78,7 +78,7 @@ static struct PassiveNodeOptions {
} g_options = {
.command = UNDEFINED,
.connection_state = UNDEFINED,
- .node_id = {'\0'},
+ .node_id = { '\0' },
};
unsigned int get_command(void)
@@ -98,13 +98,11 @@ unsigned int get_connection_state(void)
void set_connection_state(unsigned int s)
{
- if ((s == DLT_NODE_CONNECT) || (s == DLT_NODE_DISCONNECT))
- {
+ if ((s == DLT_NODE_CONNECT) || (s == DLT_NODE_DISCONNECT)) {
g_options.connection_state = s;
set_command(DLT_SERVICE_ID_PASSIVE_NODE_CONNECT);
}
- else
- {
+ else {
pr_error("Connection status %u invalid\n", s);
exit(-1);
}
@@ -112,13 +110,11 @@ void set_connection_state(unsigned int s)
void set_node_id(char *id)
{
- if (id == 0)
- {
+ if (id == 0) {
pr_error("node identifier is NULL\n");
exit(-1);
}
- else
- {
+ else {
strncpy(g_options.node_id, id, DLT_ID_SIZE);
}
}
@@ -134,28 +130,22 @@ char *get_node_id()
* @param info DltServicePassiveNodeConnectionInfo
*/
static void dlt_print_passive_node_status(
- DltServicePassiveNodeConnectionInfo *info)
+ DltServicePassiveNodeConnectionInfo *info)
{
unsigned int i = 0;
char *status;
if (info == NULL)
- {
return;
- }
printf("\nPassive Node connection status:\n"
"---------------------------------\n");
- for(i = 0; i < info->num_connections; i++)
- {
+
+ for (i = 0; i < info->num_connections; i++) {
if (info->connection_status[i] == DLT_GATEWAY_CONNECTED)
- {
status = DLT_NODE_CONNECTED_STR;
- }
else
- {
status = DLT_NODE_DISCONNECTED_STR;
- }
printf("%.4s: %s\n", &info->node_id[i * DLT_ID_SIZE], status);
}
@@ -181,10 +171,8 @@ static int dlt_passive_node_analyze_response(char *answer,
int ret = -1;
char resp_ok[MAX_RESPONSE_LENGTH] = { 0 };
- if (answer == NULL || payload == NULL)
- {
+ if ((answer == NULL) || (payload == NULL))
return -1;
- }
snprintf(resp_ok,
MAX_RESPONSE_LENGTH,
@@ -194,26 +182,22 @@ static int dlt_passive_node_analyze_response(char *answer,
pr_verbose("Response received: '%s'\n", answer);
pr_verbose("Response expected: '%s'\n", resp_ok);
- if (strncmp(answer, resp_ok, strlen(resp_ok)) == 0)
- {
+ if (strncmp(answer, resp_ok, strlen(resp_ok)) == 0) {
ret = 0;
- if (get_command() == DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS)
- {
- if ((int)sizeof(DltServicePassiveNodeConnectionInfo) > len)
- {
+ if (get_command() == DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS) {
+ if ((int)sizeof(DltServicePassiveNodeConnectionInfo) > len) {
pr_error("Received payload is smaller than expected\n");
pr_verbose("Expected: %lu,\nreceived: %d",
sizeof(DltServicePassiveNodeConnectionInfo),
len);
ret = -1;
}
- else
- {
+ else {
DltServicePassiveNodeConnectionInfo *info =
- (DltServicePassiveNodeConnectionInfo *) (payload);
- if (info == NULL)
- {
+ (DltServicePassiveNodeConnectionInfo *)(payload);
+
+ if (info == NULL) {
fprintf(stderr, "Received response is NULL\n");
return -1;
}
@@ -235,19 +219,18 @@ DltControlMsgBody *dlt_passive_node_prepare_message_body()
{
DltControlMsgBody *mb = calloc(1, sizeof(DltControlMsgBody));
char *ecuid = get_node_id();
+
if (mb == NULL)
- {
return NULL;
- }
- if (get_command() == DLT_SERVICE_ID_PASSIVE_NODE_CONNECT)
- {
+ if (get_command() == DLT_SERVICE_ID_PASSIVE_NODE_CONNECT) {
mb->data = calloc(1, sizeof(DltServicePassiveNodeConnect));
- if (mb->data == NULL)
- {
+
+ if (mb->data == NULL) {
free(mb);
return NULL;
}
+
mb->size = sizeof(DltServicePassiveNodeConnect);
DltServicePassiveNodeConnect *serv = (DltServicePassiveNodeConnect *)
mb->data;
@@ -256,18 +239,17 @@ DltControlMsgBody *dlt_passive_node_prepare_message_body()
memcpy(serv->node_id, ecuid, DLT_ID_SIZE);
}
- else /* DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS */
- {
+ else { /* DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS */
mb->data = calloc(1, sizeof(DltServicePassiveNodeConnectionInfo));
- if (mb->data == NULL)
- {
+
+ if (mb->data == NULL) {
free(mb);
return NULL;
}
mb->size = sizeof(DltServicePassiveNodeConnectionInfo);
DltServicePassiveNodeConnectionInfo *serv =
- (DltServicePassiveNodeConnectionInfo *) mb->data;
+ (DltServicePassiveNodeConnectionInfo *)mb->data;
serv->service_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS;
}
@@ -280,14 +262,11 @@ DltControlMsgBody *dlt_passive_node_prepare_message_body()
void dlt_passive_node_destroy_message_body(DltControlMsgBody *msg_body)
{
if (msg_body == NULL)
- {
return;
- }
if (msg_body->data != NULL)
- {
free(msg_body->data);
- }
+
free(msg_body);
}
@@ -303,8 +282,7 @@ static int dlt_passive_node_ctrl_single_request()
/* Initializing the communication with the daemon */
if (dlt_control_init(dlt_passive_node_analyze_response,
get_ecuid(),
- get_verbosity()) != 0)
- {
+ get_verbosity()) != 0) {
pr_error("Failed to initialize connection with the daemon.\n");
return ret;
}
@@ -313,8 +291,7 @@ static int dlt_passive_node_ctrl_single_request()
DltControlMsgBody *msg_body = NULL;
msg_body = dlt_passive_node_prepare_message_body();
- if (msg_body == NULL)
- {
+ if (msg_body == NULL) {
pr_error("Data for Dlt Message body is NULL\n");
return ret;
}
@@ -362,21 +339,19 @@ static int parse_args(int argc, char *argv[])
opterr = 0;
while ((c = getopt(argc, argv, "c:hn:stv")) != -1)
- {
- switch(c)
- {
+ switch (c) {
case 'c':
- state = (int)strtol(optarg,NULL, 10);
- if (state == DLT_NODE_CONNECT || state == DLT_NODE_DISCONNECT)
- {
+ state = (int)strtol(optarg, NULL, 10);
+
+ if ((state == DLT_NODE_CONNECT) || (state == DLT_NODE_DISCONNECT)) {
set_connection_state(state);
set_command(DLT_SERVICE_ID_PASSIVE_NODE_CONNECT);
}
- else
- {
+ else {
pr_error("unknown connection state: %d\n", state);
return -1;
}
+
break;
case 'h':
usage();
@@ -395,21 +370,18 @@ static int parse_args(int argc, char *argv[])
pr_verbose("Now in verbose mode.\n");
break;
case '?':
+
if (isprint(optopt))
- {
pr_error("Unknown option -%c.\n", optopt);
- }
else
- {
pr_error("Unknown option character \\x%x.\n", optopt);
- }
+
usage();
return -1;
default:
pr_error("Try %s -h for more information.\n", argv[0]);
return -1;
}
- }
return 0;
}
@@ -432,15 +404,12 @@ int main(int argc, char *argv[])
/* Get command line arguments */
if (parse_args(argc, argv) != 0)
- {
return -1;
- }
- if (get_command() == UNDEFINED ||
- (get_command() == DLT_SERVICE_ID_PASSIVE_NODE_CONNECT &&
- g_options.node_id[0] == '\0' &&
- g_options.connection_state == DLT_NODE_CONNECT_UNDEF))
- {
+ if ((get_command() == UNDEFINED) ||
+ ((get_command() == DLT_SERVICE_ID_PASSIVE_NODE_CONNECT) &&
+ (g_options.node_id[0] == '\0') &&
+ (g_options.connection_state == DLT_NODE_CONNECT_UNDEF))) {
pr_error("No valid parameter configuration given!\n");
usage();
return -1;
diff --git a/src/console/dlt-receive.c b/src/console/dlt-receive.c
index e22d15e..9cfad36 100644
--- a/src/console/dlt-receive.c
+++ b/src/console/dlt-receive.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt-receive.cpp
-*/
+ */
/*******************************************************************************
@@ -64,8 +64,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <ctype.h> /* for isprint() */
@@ -78,9 +78,9 @@
#include <glob.h>
#include <syslog.h>
#ifdef __linux__
-#include <linux/limits.h>
+# include <linux/limits.h>
#else
-#include <limits.h>
+# include <limits.h>
#endif
#include <inttypes.h>
@@ -119,7 +119,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-receive [options] hostname/serial_device_name\n");
printf("Receive DLT messages from DLT daemon and print or store the messages.\n");
@@ -143,49 +143,40 @@ void usage()
}
-int64_t convert_arg_to_byte_size(char * arg)
+int64_t convert_arg_to_byte_size(char *arg)
{
size_t i;
int64_t factor;
int64_t result;
+
/* check if valid input */
- for (i = 0; i<strlen(arg)-1; ++i)
- {
+ for (i = 0; i < strlen(arg) - 1; ++i)
if (!isdigit(arg[i]))
- {
return -2;
- }
- }
/* last character */
factor = 1;
- if ((arg[strlen(arg)-1] == 'K') || (arg[strlen(arg)-1] == 'k'))
- {
+
+ if ((arg[strlen(arg) - 1] == 'K') || (arg[strlen(arg) - 1] == 'k')) {
factor = 1024;
}
- else if ((arg[strlen(arg)-1] == 'M') || (arg[strlen(arg)-1] == 'm'))
+ else if ((arg[strlen(arg) - 1] == 'M') || (arg[strlen(arg) - 1] == 'm'))
{
factor = 1024 * 1024;
}
- else if ((arg[strlen(arg)-1] == 'G') || (arg[strlen(arg)-1] == 'g'))
+ else if ((arg[strlen(arg) - 1] == 'G') || (arg[strlen(arg) - 1] == 'g'))
{
factor = 1024 * 1024 * 1024;
}
- else
- {
- if (!isdigit(arg[strlen(arg)-1]))
- {
- return -2;
- }
- }
+ else if (!isdigit(arg[strlen(arg) - 1]))
+ return -2;
/* range checking */
int64_t const mult = atoll(arg);
- if (((INT64_MAX)/factor) < mult)
- {
- /* Would overflow! */
- return -2;
- }
+
+ if (((INT64_MAX) / factor) < mult)
+ /* Would overflow! */
+ return -2;
result = factor * mult;
@@ -196,10 +187,13 @@ int64_t convert_arg_to_byte_size(char * arg)
int64_t min_size = sizeof(msg.headerbuffer);
min_size += 2048 /* DLT_USER_BUF_MAX_SIZE */;
- if (min_size > result)
- {
+ if (min_size > result) {
char tmp[256];
- snprintf(tmp, 256, "ERROR: Specified limit: %" PRId64 "is smaller than a the size of a single message: %" PRId64 "!\n", result, min_size);
+ snprintf(tmp,
+ 256,
+ "ERROR: Specified limit: %" PRId64 "is smaller than a the size of a single message: %" PRId64 "!\n",
+ result,
+ min_size);
dlt_log(LOG_ERR, tmp);
result = -2;
}
@@ -211,22 +205,20 @@ int64_t convert_arg_to_byte_size(char * arg)
/*
* open output file
*/
-int dlt_receive_open_output_file(DltReceiveData * dltdata)
+int dlt_receive_open_output_file(DltReceiveData *dltdata)
{
/* if (file_already_exists) */
glob_t outer;
- if (glob(dltdata->ovalue, GLOB_TILDE | GLOB_NOSORT, NULL, &outer) == 0)
- {
- if (dltdata->vflag)
- {
- char tmp[256];
- snprintf(tmp, 256, "File %s already exists, need to rename first\n", dltdata->ovalue);
- dlt_log(LOG_INFO, tmp);
+
+ if (glob(dltdata->ovalue, GLOB_TILDE | GLOB_NOSORT, NULL, &outer) == 0) {
+ if (dltdata->vflag) {
+ char tmp[256];
+ snprintf(tmp, 256, "File %s already exists, need to rename first\n", dltdata->ovalue);
+ dlt_log(LOG_INFO, tmp);
}
- if (dltdata->part_num < 0)
- {
- char pattern[PATH_MAX+1];
+ if (dltdata->part_num < 0) {
+ char pattern[PATH_MAX + 1];
pattern[PATH_MAX] = 0;
snprintf(pattern, PATH_MAX, "%s.*.dlt", dltdata->ovaluebase);
glob_t inner;
@@ -238,60 +230,55 @@ int dlt_receive_open_output_file(DltReceiveData * dltdata)
* foo.1000.dlt
* foo.11.dlt
*/
- if (glob(pattern, GLOB_TILDE | GLOB_NOSORT, NULL, &inner) == 0)
- {
- /* search for the highest number used */
- size_t i;
- for (i= 0; i<inner.gl_pathc; ++i)
- {
- /* convert string that follows the period after the initial portion,
- * e.g. gt.gl_pathv[i] = foo.1.dlt -> atoi("1.dlt");
- */
- int cur = atoi(&inner.gl_pathv[i][strlen(dltdata->ovaluebase)+1]);
- if (cur > dltdata->part_num)
- {
- dltdata->part_num = cur;
+ if (glob(pattern, GLOB_TILDE | GLOB_NOSORT, NULL, &inner) == 0) {
+ /* search for the highest number used */
+ size_t i;
+
+ for (i = 0; i < inner.gl_pathc; ++i) {
+ /* convert string that follows the period after the initial portion,
+ * e.g. gt.gl_pathv[i] = foo.1.dlt -> atoi("1.dlt");
+ */
+ int cur = atoi(&inner.gl_pathv[i][strlen(dltdata->ovaluebase) + 1]);
+
+ if (cur > dltdata->part_num)
+ dltdata->part_num = cur;
}
- }
}
+
globfree(&inner);
++dltdata->part_num;
}
- char filename[PATH_MAX+1];
+ char filename[PATH_MAX + 1];
filename[PATH_MAX] = 0;
snprintf(filename, PATH_MAX, "%s.%i.dlt", dltdata->ovaluebase, dltdata->part_num++);
- if (rename(dltdata->ovalue, filename) != 0)
- {
- char tmp[256];
- snprintf(tmp, 256, "ERROR: rename %s to %s failed with error %s\n", dltdata->ovalue, filename, strerror(errno));
- dlt_log(LOG_ERR, tmp);
+
+ if (rename(dltdata->ovalue, filename) != 0) {
+ char tmp[256];
+ snprintf(tmp, 256, "ERROR: rename %s to %s failed with error %s\n", dltdata->ovalue, filename,
+ strerror(errno));
+ dlt_log(LOG_ERR, tmp);
}
- else
- {
- if (dltdata->vflag)
- {
+ else if (dltdata->vflag) {
char tmp[256];
snprintf(tmp, 256, "Renaming existing file from %s to %s\n", dltdata->ovalue, filename);
dlt_log(LOG_INFO, tmp);
- }
}
-
} /* if (file_already_exists) */
+
globfree(&outer);
- dltdata->ohandle = open(dltdata->ovalue, O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ dltdata->ohandle = open(dltdata->ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
return dltdata->ohandle;
}
-void dlt_receive_close_output_file(DltReceiveData * dltdata)
+void dlt_receive_close_output_file(DltReceiveData *dltdata)
{
- if (dltdata->ohandle)
- {
+ if (dltdata->ohandle) {
close(dltdata->ohandle);
dltdata->ohandle = -1;
}
@@ -301,9 +288,9 @@ void dlt_receive_close_output_file(DltReceiveData * dltdata)
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- DltClient dltclient;
+ DltClient dltclient;
DltReceiveData dltdata;
int c;
int index;
@@ -321,7 +308,7 @@ int main(int argc, char* argv[])
dltdata.evalue = 0;
dltdata.bvalue = 0;
dltdata.climit = -1; /* default: -1 = unlimited */
- dltdata.ohandle=-1;
+ dltdata.ohandle = -1;
dltdata.totalbytes = 0;
dltdata.part_num = -1;
@@ -329,115 +316,108 @@ int main(int argc, char* argv[])
opterr = 0;
while ((c = getopt (argc, argv, "vashyxmf:o:e:b:c:")) != -1)
- switch (c)
- {
+ switch (c) {
case 'v':
- {
- dltdata.vflag = 1;
- break;
- }
+ {
+ dltdata.vflag = 1;
+ break;
+ }
case 'a':
- {
- dltdata.aflag = 1;
- break;
- }
+ {
+ dltdata.aflag = 1;
+ break;
+ }
case 's':
- {
- dltdata.sflag = 1;
- break;
- }
+ {
+ dltdata.sflag = 1;
+ break;
+ }
case 'x':
- {
- dltdata.xflag = 1;
- break;
- }
+ {
+ dltdata.xflag = 1;
+ break;
+ }
case 'm':
- {
- dltdata.mflag = 1;
- break;
- }
+ {
+ dltdata.mflag = 1;
+ break;
+ }
case 'h':
- {
- usage();
- return -1;
- }
+ {
+ usage();
+ return -1;
+ }
case 'y':
- {
- dltdata.yflag = 1;
- break;
- }
+ {
+ dltdata.yflag = 1;
+ break;
+ }
case 'f':
- {
- dltdata.fvalue = optarg;
- break;
- }
+ {
+ dltdata.fvalue = optarg;
+ break;
+ }
case 'o':
- {
- dltdata.ovalue = optarg;
- size_t to_copy = strlen(dltdata.ovalue);
- if (strcmp(&dltdata.ovalue[to_copy-4], ".dlt") == 0)
- {
- to_copy = to_copy - 4;
- }
-
- dltdata.ovaluebase = (char *)calloc(1, to_copy + 1);
-
- if (dltdata.ovaluebase == NULL)
- {
- fprintf (stderr, "Memory allocation failed.\n");
- return -1;
- }
+ {
+ dltdata.ovalue = optarg;
+ size_t to_copy = strlen(dltdata.ovalue);
- dltdata.ovaluebase[to_copy] = '\0';
- memcpy(dltdata.ovaluebase, dltdata.ovalue, to_copy);
- break;
- }
+ if (strcmp(&dltdata.ovalue[to_copy - 4], ".dlt") == 0)
+ to_copy = to_copy - 4;
+
+ dltdata.ovaluebase = (char *)calloc(1, to_copy + 1);
+
+ if (dltdata.ovaluebase == NULL) {
+ fprintf (stderr, "Memory allocation failed.\n");
+ return -1;
+ }
+
+ dltdata.ovaluebase[to_copy] = '\0';
+ memcpy(dltdata.ovaluebase, dltdata.ovalue, to_copy);
+ break;
+ }
case 'e':
- {
- dltdata.evalue = optarg;
- break;
- }
+ {
+ dltdata.evalue = optarg;
+ break;
+ }
case 'b':
- {
- dltdata.bvalue = atoi(optarg);
- break;
- }
+ {
+ dltdata.bvalue = atoi(optarg);
+ break;
+ }
case 'c':
- {
- dltdata.climit = convert_arg_to_byte_size(optarg);
- if (dltdata.climit < -1)
- {
- fprintf (stderr, "Invalid argument for option -c.\n");
- /* unknown or wrong option used, show usage information and terminate */
- usage();
- return -1;
- }
- break;
- }
+ {
+ dltdata.climit = convert_arg_to_byte_size(optarg);
+
+ if (dltdata.climit < -1) {
+ fprintf (stderr, "Invalid argument for option -c.\n");
+ /* unknown or wrong option used, show usage information and terminate */
+ usage();
+ return -1;
+ }
+
+ break;
+ }
case '?':
- {
- if (optopt == 'o' || optopt == 'f' || optopt == 'c')
- {
- fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
- else if (isprint (optopt))
- {
- fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
- else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
- /* unknown or wrong option used, show usage information and terminate */
- usage();
- return -1;
- }
+ {
+ if ((optopt == 'o') || (optopt == 'f') || (optopt == 'c'))
+ fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+ else if (isprint (optopt))
+ fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+ else
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
+ /* unknown or wrong option used, show usage information and terminate */
+ usage();
+ return -1;
+ }
default:
- {
- abort ();
- return -1;//for parasoft
- }
+ {
+ abort ();
+ return -1; /*for parasoft */
+ }
}
/* Initialize DLT Client */
@@ -449,212 +429,183 @@ int main(int argc, char* argv[])
/* Setup DLT Client structure */
dltclient.mode = dltdata.yflag;
- if (dltclient.mode==DLT_CLIENT_MODE_TCP)
- {
+ if (dltclient.mode == DLT_CLIENT_MODE_TCP) {
for (index = optind; index < argc; index++)
- {
- if(dlt_client_set_server_ip(&dltclient, argv[index]) == -1)
- {
- fprintf(stderr,"set server ip didn't succeed\n");
+ if (dlt_client_set_server_ip(&dltclient, argv[index]) == -1) {
+ fprintf(stderr, "set server ip didn't succeed\n");
return -1;
}
- }
- if (dltclient.servIP == 0)
- {
+
+
+ if (dltclient.servIP == 0) {
/* no hostname selected, show usage and terminate */
- fprintf(stderr,"ERROR: No hostname selected\n");
+ fprintf(stderr, "ERROR: No hostname selected\n");
usage();
- dlt_client_cleanup(&dltclient,dltdata.vflag);
+ dlt_client_cleanup(&dltclient, dltdata.vflag);
return -1;
}
}
- else
- {
+ else {
for (index = optind; index < argc; index++)
- {
- if(dlt_client_set_serial_device(&dltclient, argv[index]) == -1)
- {
- fprintf(stderr,"set serial device didn't succeed\n");
+ if (dlt_client_set_serial_device(&dltclient, argv[index]) == -1) {
+ fprintf(stderr, "set serial device didn't succeed\n");
return -1;
}
- }
- if (dltclient.serialDevice == 0)
- {
+
+
+ if (dltclient.serialDevice == 0) {
/* no serial device name selected, show usage and terminate */
- fprintf(stderr,"ERROR: No serial device name specified\n");
+ fprintf(stderr, "ERROR: No serial device name specified\n");
usage();
return -1;
}
- dlt_client_setbaudrate(&dltclient,dltdata.bvalue);
+ dlt_client_setbaudrate(&dltclient, dltdata.bvalue);
}
/* initialise structure to use DLT file */
- dlt_file_init(&(dltdata.file),dltdata.vflag);
+ dlt_file_init(&(dltdata.file), dltdata.vflag);
/* first parse filter file if filter parameter is used */
- dlt_filter_init(&(dltdata.filter),dltdata.vflag);
+ dlt_filter_init(&(dltdata.filter), dltdata.vflag);
- if (dltdata.fvalue)
- {
- if (dlt_filter_load(&(dltdata.filter),dltdata.fvalue,dltdata.vflag) < DLT_RETURN_OK)
- {
- dlt_file_free(&(dltdata.file),dltdata.vflag);
+ if (dltdata.fvalue) {
+ if (dlt_filter_load(&(dltdata.filter), dltdata.fvalue, dltdata.vflag) < DLT_RETURN_OK) {
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
return -1;
}
- dlt_file_set_filter(&(dltdata.file),&(dltdata.filter),dltdata.vflag);
+ dlt_file_set_filter(&(dltdata.file), &(dltdata.filter), dltdata.vflag);
}
/* open DLT output file */
- if (dltdata.ovalue)
- {
- if (dltdata.climit > -1)
- {
+ if (dltdata.ovalue) {
+ if (dltdata.climit > -1) {
char tmp[256];
snprintf(tmp, 256, "Using file size limit of %" PRId64 "bytes\n", dltdata.climit);
dlt_log(LOG_INFO, tmp);
dltdata.ohandle = dlt_receive_open_output_file(&dltdata);
}
- else /* in case no limit for the output file is given, we simply overwrite any existing file */
- {
- dltdata.ohandle = open(dltdata.ovalue, O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ else { /* in case no limit for the output file is given, we simply overwrite any existing file */
+ dltdata.ohandle = open(dltdata.ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
}
- if (dltdata.ohandle == -1)
- {
- dlt_file_free(&(dltdata.file),dltdata.vflag);
- fprintf(stderr,"ERROR: Output file %s cannot be opened!\n",dltdata.ovalue);
+ if (dltdata.ohandle == -1) {
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
+ fprintf(stderr, "ERROR: Output file %s cannot be opened!\n", dltdata.ovalue);
return -1;
}
}
if (dltdata.evalue)
- {
- dlt_set_id(dltdata.ecuid,dltdata.evalue);
- }
- else
- {
- dlt_set_id(dltdata.ecuid,DLT_RECEIVE_ECU_ID);
- }
+ dlt_set_id(dltdata.ecuid, dltdata.evalue);
+ else
+ dlt_set_id(dltdata.ecuid, DLT_RECEIVE_ECU_ID);
/* Connect to TCP socket or open serial device */
- if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR)
- {
+ if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR) {
/* Dlt Client Main Loop */
dlt_client_main_loop(&dltclient, &dltdata, dltdata.vflag);
/* Dlt Client Cleanup */
- dlt_client_cleanup(&dltclient,dltdata.vflag);
+ dlt_client_cleanup(&dltclient, dltdata.vflag);
}
/* dlt-receive cleanup */
if (dltdata.ovalue)
- {
close(dltdata.ohandle);
- }
free(dltdata.ovaluebase);
- dlt_file_free(&(dltdata.file),dltdata.vflag);
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
- dlt_filter_free(&(dltdata.filter),dltdata.vflag);
+ dlt_filter_free(&(dltdata.filter), dltdata.vflag);
return 0;
}
int dlt_receive_message_callback(DltMessage *message, void *data)
{
- DltReceiveData *dltdata;
+ DltReceiveData *dltdata;
static char text[DLT_RECEIVE_BUFSIZE];
- struct iovec iov[2];
+ struct iovec iov[2];
int bytes_written;
- if ((message==0) || (data==0))
- {
+ if ((message == 0) || (data == 0))
return -1;
- }
- dltdata = (DltReceiveData*)data;
+ dltdata = (DltReceiveData *)data;
/* prepare storage header */
if (DLT_IS_HTYP_WEID(message->standardheader->htyp))
- {
- dlt_set_storageheader(message->storageheader,message->headerextra.ecu);
- }
+ dlt_set_storageheader(message->storageheader, message->headerextra.ecu);
else
- {
- dlt_set_storageheader(message->storageheader,dltdata->ecuid);
- }
+ dlt_set_storageheader(message->storageheader, dltdata->ecuid);
- if ((dltdata->fvalue==0) ||
- (dltdata->fvalue && dlt_message_filter_check(message,&(dltdata->filter),dltdata->vflag) == DLT_RETURN_TRUE))
- {
+ if ((dltdata->fvalue == 0) ||
+ (dltdata->fvalue &&
+ (dlt_message_filter_check(message, &(dltdata->filter), dltdata->vflag) == DLT_RETURN_TRUE))) {
/* if no filter set or filter is matching display message */
- if (dltdata->xflag)
- {
- dlt_message_print_hex(message,text,DLT_RECEIVE_BUFSIZE,dltdata->vflag);
+ if (dltdata->xflag) {
+ dlt_message_print_hex(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
}
else if (dltdata->aflag)
{
- dlt_message_header(message,text,DLT_RECEIVE_BUFSIZE,dltdata->vflag);
+ dlt_message_header(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
- printf("%s ",text);
+ printf("%s ", text);
- dlt_message_payload(message,text,DLT_RECEIVE_BUFSIZE,DLT_OUTPUT_ASCII,dltdata->vflag);
+ dlt_message_payload(message, text, DLT_RECEIVE_BUFSIZE, DLT_OUTPUT_ASCII, dltdata->vflag);
- printf("[%s]\n",text);
+ printf("[%s]\n", text);
}
else if (dltdata->mflag)
{
- dlt_message_print_mixed_plain(message,text,DLT_RECEIVE_BUFSIZE,dltdata->vflag);
+ dlt_message_print_mixed_plain(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
}
else if (dltdata->sflag)
{
- dlt_message_header(message,text,DLT_RECEIVE_BUFSIZE,dltdata->vflag);
+ dlt_message_header(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
- printf("%s \n",text);
+ printf("%s \n", text);
}
/* if file output enabled write message */
- if (dltdata->ovalue)
- {
+ if (dltdata->ovalue) {
iov[0].iov_base = message->headerbuffer;
iov[0].iov_len = message->headersize;
iov[1].iov_base = message->databuffer;
iov[1].iov_len = message->datasize;
- if (dltdata->climit > -1)
- {
- int bytes_to_write = message->headersize + message->datasize;
-
- if ((bytes_to_write + dltdata->totalbytes > dltdata->climit))
- {
+ if (dltdata->climit > -1) {
+ int bytes_to_write = message->headersize + message->datasize;
+
+ if ((bytes_to_write + dltdata->totalbytes > dltdata->climit)) {
dlt_receive_close_output_file(dltdata);
-
- if (dlt_receive_open_output_file(dltdata) < 0)
- {
- printf("ERROR: dlt_receive_message_callback: Unable to open log when maximum filesize was reached!\n");
+
+ if (dlt_receive_open_output_file(dltdata) < 0) {
+ printf(
+ "ERROR: dlt_receive_message_callback: Unable to open log when maximum filesize was reached!\n");
return -1;
- }
-
- dltdata->totalbytes = 0;
- }
+ }
+
+ dltdata->totalbytes = 0;
+ }
}
-
+
bytes_written = writev(dltdata->ohandle, iov, 2);
dltdata->totalbytes += bytes_written;
- if (0 > bytes_written){
- printf("dlt_receive_message_callback: writev(dltdata->ohandle, iov, 2); returned an error!" );
- return -1;
+ if (0 > bytes_written) {
+ printf("dlt_receive_message_callback: writev(dltdata->ohandle, iov, 2); returned an error!");
+ return -1;
}
}
}
diff --git a/src/console/dlt-sortbytimestamp.c b/src/console/dlt-sortbytimestamp.c
index 6d1d590..c006681 100644
--- a/src/console/dlt-sortbytimestamp.c
+++ b/src/console/dlt-sortbytimestamp.c
@@ -24,7 +24,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt-sortbytimestamp.cpp
-*/
+ */
/*******************************************************************************
** **
@@ -86,16 +86,15 @@ int verbosity = 0;
/**
* Print information, conditional upon requested verbosity level
*/
-void verbose(int level, char * msg, ...)
+void verbose(int level, char *msg, ...)
{
- if (level <= verbosity)
- {
- if (verbosity > 1) /* timestamp */
- {
- time_t tnow = time((time_t*)0);
+ if (level <= verbosity) {
+ if (verbosity > 1) { /* timestamp */
+ time_t tnow = time((time_t *)0);
+
if (tnow != -1) {
- char * snow = ctime(&tnow);
- /* suppress newline char */
+ char *snow = ctime(&tnow);
+ /* suppress newline char */
snow[strlen(snow) - 1] = 0;
printf("%s: ", snow);
}
@@ -107,26 +106,21 @@ void verbose(int level, char * msg, ...)
vprintf(msg, args);
/* lines without a terminal newline aren't guaranteed to be displayed */
- if (msg[len-1] != '\n')
- {
+ if (msg[len - 1] != '\n')
fflush(stdout);
- }
}
}
/**
* Comparison function for use with qsort
*/
-int compare_index_timestamps(const void* a, const void *b)
+int compare_index_timestamps(const void *a, const void *b)
{
- if (((TimestampIndex*)a)->tmsp > ((TimestampIndex*)b)->tmsp)
- {
+ if (((TimestampIndex *)a)->tmsp > ((TimestampIndex *)b)->tmsp)
return 1;
- }
- else if (((TimestampIndex*)a)->tmsp == ((TimestampIndex*)b)->tmsp)
- {
+ else if (((TimestampIndex *)a)->tmsp == ((TimestampIndex *)b)->tmsp)
return 0;
- }
+
return -1;
}
@@ -140,23 +134,22 @@ void write_messages(int ohandle, DltFile *file, TimestampIndex *timestamps, int
verbose(1, "Writing %d messages\n", message_count);
- for (int i = 0; i < message_count; ++i)
- {
- if (0 == i % 1001 || i == message_count - 1)
- {
+ for (int i = 0; i < message_count; ++i) {
+ if ((0 == i % 1001) || (i == message_count - 1))
verbose(2, "Writing message %d\r", i);
- }
- dlt_file_message(file,timestamps[i].num,0);
+
+ dlt_file_message(file, timestamps[i].num, 0);
iov[0].iov_base = file->msg.headerbuffer;
iov[0].iov_len = file->msg.headersize;
iov[1].iov_base = file->msg.databuffer;
iov[1].iov_len = file->msg.datasize;
bytes_written = writev(ohandle, iov, 2);
- if (0 > bytes_written){
- printf("in main: writev(ohandle, iov, 2); returned an error!" );
- dlt_file_free(file,0);
- exit (-1);
+
+ if (0 > bytes_written) {
+ printf("in main: writev(ohandle, iov, 2); returned an error!");
+ dlt_file_free(file, 0);
+ exit (-1);
}
}
@@ -170,7 +163,7 @@ void usage()
{
char version[DLT_VERBUFSIZE];
- dlt_get_version(version,DLT_VERBUFSIZE);
+ dlt_get_version(version, DLT_VERBUFSIZE);
printf("Usage: dlt-sortbytimestamp [options] [commands] file_in file_out\n");
printf("Read DLT file, sort by timestamp and store the messages again.\n");
@@ -190,7 +183,7 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
int vflag = 0;
int cflag = 0;
@@ -208,7 +201,7 @@ int main(int argc, char* argv[])
DltFile file;
DltFilter filter;
- int ohandle=-1;
+ int ohandle = -1;
int num, begin, end;
@@ -217,168 +210,138 @@ int main(int argc, char* argv[])
verbose(1, "Configuring\n");
while ((c = getopt (argc, argv, "vchf:b:e:")) != -1)
- switch (c)
- {
+ switch (c) {
case 'v':
- {
- verbosity += 1;
- break;
- }
+ {
+ verbosity += 1;
+ break;
+ }
case 'c':
- {
- cflag = 1;
- break;
- }
+ {
+ cflag = 1;
+ break;
+ }
case 'h':
- {
- usage();
- return -1;
- }
+ {
+ usage();
+ return -1;
+ }
case 'f':
- {
- fvalue = optarg;
- break;
- }
+ {
+ fvalue = optarg;
+ break;
+ }
case 'b':
- {
- bvalue = optarg;
- break;
- }
+ {
+ bvalue = optarg;
+ break;
+ }
case 'e':
- {
- evalue = optarg;
- break;
- }
+ {
+ evalue = optarg;
+ break;
+ }
case '?':
- {
- if (optopt == 'f' || optopt == 'b' || optopt == 'e')
- {
- fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
- else if (isprint (optopt))
- {
- fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
- else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
- /* unknown or wrong option used, show usage information and terminate */
- usage();
- return -1;
- }
+ {
+ if ((optopt == 'f') || (optopt == 'b') || (optopt == 'e'))
+ fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+ else if (isprint (optopt))
+ fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+ else
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
+ /* unknown or wrong option used, show usage information and terminate */
+ usage();
+ return -1;
+ }
default:
- {
- abort();
- return -1;//for parasoft
- }
+ {
+ abort();
+ return -1; /*for parasoft */
+ }
}
/* Don't use vflag on quietest levels */
if (verbosity > 2)
- {
vflag = 1;
- }
verbose (1, "Initializing\n");
/* initialise structure to use DLT file */
- dlt_file_init(&file,vflag);
+ dlt_file_init(&file, vflag);
/* first parse filter file if filter parameter is used */
- if (fvalue)
- {
- if (bvalue || evalue)
- {
- fprintf(stderr,"ERROR: can't specify a range *and* filtering!\n");
- dlt_file_free(&file,vflag);
+ if (fvalue) {
+ if (bvalue || evalue) {
+ fprintf(stderr, "ERROR: can't specify a range *and* filtering!\n");
+ dlt_file_free(&file, vflag);
return -1;
}
- if (dlt_filter_load(&filter,fvalue,vflag) < DLT_RETURN_OK)
- {
- dlt_file_free(&file,vflag);
+ if (dlt_filter_load(&filter, fvalue, vflag) < DLT_RETURN_OK) {
+ dlt_file_free(&file, vflag);
return -1;
}
- dlt_file_set_filter(&file,&filter,vflag);
+ dlt_file_set_filter(&file, &filter, vflag);
}
ivalue = argv[optind];
- if (!ivalue)
- {
- dlt_file_free(&file,vflag);
- fprintf(stderr,"ERROR: Need an input file!\n");
+ if (!ivalue) {
+ dlt_file_free(&file, vflag);
+ fprintf(stderr, "ERROR: Need an input file!\n");
return -1;
}
ovalue = argv[optind + 1];
- if (ovalue)
- {
- ohandle = open(ovalue,O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
- if (ohandle == -1)
- {
- dlt_file_free(&file,vflag);
- fprintf(stderr,"ERROR: Output file %s cannot be opened!\n",ovalue);
+ if (ovalue) {
+ ohandle = open(ovalue, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
+
+ if (ohandle == -1) {
+ dlt_file_free(&file, vflag);
+ fprintf(stderr, "ERROR: Output file %s cannot be opened!\n", ovalue);
return -1;
}
}
- else
- {
- dlt_file_free(&file,vflag);
- fprintf(stderr,"ERROR: Need an output file!\n");
+ else {
+ dlt_file_free(&file, vflag);
+ fprintf(stderr, "ERROR: Need an output file!\n");
return -1;
}
verbose(1, "Loading\n");
/* load, analyse data file and create index list */
- if (dlt_file_open(&file,ivalue,vflag) >= DLT_RETURN_OK)
- {
- while (dlt_file_read(&file,vflag) >= DLT_RETURN_OK)
- {
- }
+ if (dlt_file_open(&file, ivalue, vflag) >= DLT_RETURN_OK) {
+ while (dlt_file_read(&file, vflag) >= DLT_RETURN_OK) {}
}
if (cflag) {
if (fvalue)
- {
printf("Loaded %d messages, %d after filtering.\n", file.counter_total, file.counter);
- }
else
- {
printf("Loaded %d messages.\n", file.counter_total);
- }
}
if (bvalue)
- {
begin = atoi(bvalue);
- }
else
- {
begin = 0;
- }
if (evalue)
- {
end = atoi(evalue);
- }
else
- {
- end = file.counter-1;
- }
+ end = file.counter - 1;
- if (begin<0 || begin>=file.counter || begin>end)
- {
- fprintf(stderr,"ERROR: Selected first message %d is out of range!\n",begin);
+ if ((begin < 0) || (begin >= file.counter) || (begin > end)) {
+ fprintf(stderr, "ERROR: Selected first message %d is out of range!\n", begin);
return -1;
}
- if (end<0 || end<begin || end>=file.counter)
- {
- fprintf(stderr,"ERROR: Selected end message %d is out of range!\n",end);
+
+ if ((end < 0) || (end < begin) || (end >= file.counter)) {
+ fprintf(stderr, "ERROR: Selected end message %d is out of range!\n", end);
return -1;
}
@@ -388,31 +351,30 @@ int main(int argc, char* argv[])
message_count = 1 + end - begin;
- timestamp_index = (TimestampIndex*)malloc(sizeof(TimestampIndex) * message_count);
+ timestamp_index = (TimestampIndex *)malloc(sizeof(TimestampIndex) * message_count);
- if (timestamp_index == 0)
- {
- fprintf(stderr,"ERROR: Failed to allocate memory for message index!\n");
- dlt_file_free(&file,vflag);
+ if (timestamp_index == 0) {
+ fprintf(stderr, "ERROR: Failed to allocate memory for message index!\n");
+ dlt_file_free(&file, vflag);
return -1;
}
verbose(1, "Filling %d entries\n", message_count);
- for (num = begin; num <= end; num++)
- {
- dlt_file_message(&file,num,vflag);
+
+ for (num = begin; num <= end; num++) {
+ dlt_file_message(&file, num, vflag);
timestamp_index[num - begin].num = num;
timestamp_index[num - begin].tmsp = file.msg.headerextra.tmsp;
}
verbose(1, "Sorting\n");
- qsort((void*)timestamp_index, message_count, sizeof(TimestampIndex), compare_index_timestamps);
+ qsort((void *)timestamp_index, message_count, sizeof(TimestampIndex), compare_index_timestamps);
write_messages(ohandle, &file, timestamp_index, message_count);
close(ohandle);
verbose(1, "Tidying up.\n");
free(timestamp_index);
- dlt_file_free(&file,vflag);
+ dlt_file_free(&file, vflag);
return 0;
}
diff --git a/src/console/logstorage/dlt-logstorage-common.c b/src/console/logstorage/dlt-logstorage-common.c
index ae67c9a..0655d66 100644
--- a/src/console/logstorage/dlt-logstorage-common.c
+++ b/src/console/logstorage/dlt-logstorage-common.c
@@ -71,7 +71,7 @@
#include "dlt-logstorage-common.h"
#ifdef DLT_LOGSTORAGE_CTRL_UDEV_ENABLE
-#include "dlt-logstorage-udev.h"
+# include "dlt-logstorage-udev.h"
#endif
#include "dlt-logstorage-prop.h"
@@ -96,9 +96,7 @@ void set_handler_type(char *type)
g_options.handler_type = CTRL_UDEV;
if (type && check_proprietary_handling(type))
- {
g_options.handler_type = CTRL_PROPRIETARY;
- }
}
int get_default_event_type(void)
@@ -121,9 +119,7 @@ void set_default_path(char *path)
memset(g_options.device_path, 0, DLT_MOUNT_PATH_MAX);
if (path != NULL)
- {
strncpy(g_options.device_path, path, DLT_MOUNT_PATH_MAX - 1);
- }
}
/* Used by the handlers */
@@ -150,8 +146,7 @@ int dlt_logstorage_get_handler_fd(void)
*/
int dlt_logstorage_init_handler(void)
{
- switch (get_handler_type())
- {
+ switch (get_handler_type()) {
case CTRL_PROPRIETARY:
return dlt_logstorage_prop_init();
case CTRL_UDEV:
@@ -170,8 +165,7 @@ int dlt_logstorage_init_handler(void)
*/
int dlt_logstorage_deinit_handler(void)
{
- switch (get_handler_type())
- {
+ switch (get_handler_type()) {
case CTRL_PROPRIETARY:
return dlt_logstorage_prop_deinit();
case CTRL_UDEV:
@@ -179,7 +173,7 @@ int dlt_logstorage_deinit_handler(void)
#ifdef DLT_LOGSTORAGE_CTRL_UDEV_ENABLE
return dlt_logstorage_udev_deinit();
#else
- return -1;
+ return -1;
#endif
}
}
@@ -200,8 +194,7 @@ int dlt_logstorage_check_config_file(char *mnt_point)
int i = 0;
int ret = 0;
- if ((mnt_point == NULL) || (mnt_point[0] == '\0'))
- {
+ if ((mnt_point == NULL) || (mnt_point[0] == '\0')) {
pr_error("Mount point missing.\n");
return ret;
}
@@ -210,30 +203,24 @@ int dlt_logstorage_check_config_file(char *mnt_point)
n = scandir(mnt_point, &files, NULL, alphasort);
- if (n <= 0)
- {
+ if (n <= 0) {
pr_error("Cannot read mounted directory\n");
return ret;
}
- do
- {
+ do {
pr_verbose("Checking %s.\n", files[i]->d_name);
- if (strncmp(files[i]->d_name, CONF_NAME, strlen(CONF_NAME)) == 0)
- {
+ if (strncmp(files[i]->d_name, CONF_NAME, strlen(CONF_NAME)) == 0) {
/* We found it ! */
pr_verbose("File found.\n");
ret = 1;
break;
}
- }
- while (++i < n);
+ } while (++i < n);
- for (i = 0 ; i < n ; i++)
- {
+ for (i = 0; i < n; i++)
free(files[i]);
- }
free(files);
return ret;
@@ -247,16 +234,13 @@ int dlt_logstorage_check_config_file(char *mnt_point)
*/
int dlt_logstorage_check_directory_permission(char *mnt_point)
{
- if (mnt_point == NULL)
- {
+ if (mnt_point == NULL) {
pr_error("Given mount point is NULL\n");
return 0;
}
if (access(mnt_point, W_OK) == 0)
- {
return 1;
- }
return 0;
}
@@ -275,8 +259,7 @@ static DltControlMsgBody *prepare_message_body(DltControlMsgBody **body,
{
DltServiceOfflineLogstorage *serv = NULL;
- if (path == NULL)
- {
+ if (path == NULL) {
pr_error("Mount path is uninitialized: %s\n", path);
return NULL;
}
@@ -285,16 +268,14 @@ static DltControlMsgBody *prepare_message_body(DltControlMsgBody **body,
*body = calloc(1, sizeof(DltControlMsgBody));
- if (!*body)
- {
+ if (!*body) {
pr_error("Not able to allocate memory for body.\n");
return *body;
}
(*body)->data = calloc(1, sizeof(DltServiceOfflineLogstorage));
- if (!(*body)->data)
- {
+ if (!(*body)->data) {
free(*body);
*body = NULL;
pr_error("Not able to allocate memory for body data.\n");
@@ -303,14 +284,14 @@ static DltControlMsgBody *prepare_message_body(DltControlMsgBody **body,
(*body)->size = sizeof(DltServiceOfflineLogstorage);
- serv = (DltServiceOfflineLogstorage *) (*body)->data;
+ serv = (DltServiceOfflineLogstorage *)(*body)->data;
serv->service_id = DLT_SERVICE_ID_OFFLINE_LOGSTORAGE;
serv->connection_type = conn_type;
/* mount_point is DLT_MOUNT_PATH_MAX + 1 long,
* and the memory is already zeroed.
*/
- strncpy(serv->mount_point, path, DLT_MOUNT_PATH_MAX-1);
+ strncpy(serv->mount_point, path, DLT_MOUNT_PATH_MAX - 1);
pr_verbose("Body is now ready.\n");
@@ -330,8 +311,7 @@ int dlt_logstorage_send_event(int type, char *mount_point)
DltControlMsgBody *msg_body = NULL;
/* mount_point is checked against NULL in the preparation */
- if (!prepare_message_body(&msg_body, type, mount_point))
- {
+ if (!prepare_message_body(&msg_body, type, mount_point)) {
pr_error("Data for Dlt Message body is NULL\n");
return -1;
}
diff --git a/src/console/logstorage/dlt-logstorage-ctrl.c b/src/console/logstorage/dlt-logstorage-ctrl.c
index 87e303b..af014eb 100644
--- a/src/console/logstorage/dlt-logstorage-ctrl.c
+++ b/src/console/logstorage/dlt-logstorage-ctrl.c
@@ -66,7 +66,7 @@
#include <sys/poll.h>
#if defined(__linux__)
-#include "sd-daemon.h"
+# include "sd-daemon.h"
#endif
#include "dlt_protocol.h"
@@ -111,8 +111,7 @@ int dlt_logstorage_must_exit(void)
*/
static void catch_signal(int signo)
{
- if (signo)
- {
+ if (signo) {
pr_error("Signal %d received, exiting.", signo);
dlt_logstorage_exit();
}
@@ -132,16 +131,13 @@ static void install_signal_handler(void)
pr_verbose("Installing signal handler.\n");
/* install a signal handler for the above listed signals */
- for (i = 0 ; signals[i] ; i++)
- {
+ for (i = 0; signals[i]; i++) {
memset(&sa, 0, sizeof(sa));
sa.sa_handler = catch_signal;
if (sigaction(signals[i], &sa, NULL) < 0)
- {
pr_error("Failed to install signal %u handler. Error: %s\n",
signals[i], strerror(errno));
- }
}
}
@@ -163,10 +159,8 @@ static int analyze_response(char *data, void *payload, int len)
char resp_warning[MAX_RESPONSE_LENGTH] = { 0 };
char resp_perm_denied[MAX_RESPONSE_LENGTH] = { 0 };
- if (data == NULL || payload == NULL)
- {
+ if ((data == NULL) || (payload == NULL))
return -1;
- }
/* satisfy compiler */
payload = payload;
@@ -188,16 +182,14 @@ static int analyze_response(char *data, void *payload, int len)
DLT_SERVICE_ID_OFFLINE_LOGSTORAGE);
if (strncmp(data, resp_ok, strlen(resp_ok)) == 0)
- {
ret = 0;
- }
- if (strncmp(data, resp_warning, strlen(resp_warning)) == 0)
- {
+
+ if (strncmp(data, resp_warning, strlen(resp_warning)) == 0) {
pr_error("Warning:Some filter configurations are ignored due to configuration issues \n");
ret = 0;
}
- if (strncmp(data, resp_perm_denied, strlen(resp_perm_denied)) == 0)
- {
+
+ if (strncmp(data, resp_perm_denied, strlen(resp_perm_denied)) == 0) {
pr_error("Warning: Permission denied.\n");
ret = 0;
}
@@ -223,8 +215,7 @@ static int dlt_logstorage_ctrl_add_event(struct dlt_event *ev_hdl,
int fd,
void *cb)
{
- if ((fd < 0) || !cb || !ev_hdl)
- {
+ if ((fd < 0) || !cb || !ev_hdl) {
pr_error("Wrong parameter to add event (%d %p)\n", fd, cb);
return -1;
}
@@ -251,28 +242,20 @@ static int dlt_logstorage_ctrl_execute_event_loop(struct dlt_event *ev)
ret = poll(&ev->pfd, 1, POLL_TIME_OUT);
- if (ret <= 0)
- {
+ if (ret <= 0) {
if (errno == EINTR)
- {
ret = 0;
- }
if (ret < 0)
- {
pr_error("poll error: %s\n", strerror(errno));
- }
return ret;
}
if (ev->pfd.revents == 0)
- {
return 0;
- }
- if (ev->pfd.events & EV_MASK_REJECTED)
- {
+ if (ev->pfd.events & EV_MASK_REJECTED) {
pr_error("Error while polling. Event received: 0x%x\n", ev->pfd.events);
/* We only support one event producer.
* Error means that this producer died.
@@ -284,8 +267,7 @@ static int dlt_logstorage_ctrl_execute_event_loop(struct dlt_event *ev)
return -1;
}
- if (!callback)
- {
+ if (!callback) {
pr_error("Callback not found, exiting.\n");
dlt_logstorage_exit();
return -1;
@@ -293,8 +275,7 @@ static int dlt_logstorage_ctrl_execute_event_loop(struct dlt_event *ev)
pr_verbose("Got new event, calling %p.\n", callback);
- if (callback() < 0)
- {
+ if (callback() < 0) {
pr_error("Error while calling the callback, exiting.\n");
dlt_logstorage_exit();
return -1;
@@ -327,23 +308,20 @@ static int dlt_logstorage_ctrl_setup_event_loop(void)
/* Initializing the communication with the daemon */
while (dlt_control_init(analyze_response, get_ecuid(), get_verbosity()) &&
- !dlt_logstorage_must_exit())
- {
+ !dlt_logstorage_must_exit()) {
pr_error("Failed to initialize connection with the daemon.\n");
pr_error("Retrying to connect in %lds.\n", get_timeout());
sleep(get_timeout());
}
- if (dlt_logstorage_must_exit())
- {
+ if (dlt_logstorage_must_exit()) {
pr_verbose("Exiting.\n");
return 0;
}
pr_verbose("Initializing event generator.\n");
- if (dlt_logstorage_init_handler() < 0)
- {
+ if (dlt_logstorage_init_handler() < 0) {
pr_error("Failed to initialize handler.\n");
dlt_control_deinit();
return -1;
@@ -351,16 +329,13 @@ static int dlt_logstorage_ctrl_setup_event_loop(void)
if (dlt_logstorage_ctrl_add_event(&ev_hdl,
dlt_logstorage_get_handler_fd(),
- dlt_logstorage_get_handler_cb()) < 0)
- {
+ dlt_logstorage_get_handler_cb()) < 0) {
pr_error("add_event error: %s\n", strerror(errno));
dlt_logstorage_exit();
}
while (!dlt_logstorage_must_exit() && (ret == 0))
- {
ret = dlt_logstorage_ctrl_execute_event_loop(&ev_hdl);
- }
/* Clean up */
dlt_logstorage_deinit_handler();
@@ -378,19 +353,16 @@ static int dlt_logstorage_ctrl_single_request()
int ret = 0;
/* in case sync all caches, an empty path is given */
- if (get_default_event_type() != EVENT_SYNC_CACHE)
- {
+ if (get_default_event_type() != EVENT_SYNC_CACHE) {
/* Check if a 'CONF_NAME' file is present at the given path */
- if (!dlt_logstorage_check_config_file(get_default_path()))
- {
+ if (!dlt_logstorage_check_config_file(get_default_path())) {
pr_error("No '%s' file available at: %s\n",
CONF_NAME,
get_default_path());
return -1;
}
- if (!dlt_logstorage_check_directory_permission(get_default_path()))
- {
+ if (!dlt_logstorage_check_directory_permission(get_default_path())) {
pr_error("'%s' is not writable\n", get_default_path());
return -1;
}
@@ -398,8 +370,7 @@ static int dlt_logstorage_ctrl_single_request()
/* Initializing the communication with the daemon */
while (dlt_control_init(analyze_response, get_ecuid(), get_verbosity()) &&
- !dlt_logstorage_must_exit())
- {
+ !dlt_logstorage_must_exit()) {
pr_error("Failed to initialize connection with the daemon.\n");
pr_error("Retrying to connect in %lds.\n", get_timeout());
sleep(get_timeout());
@@ -441,15 +412,15 @@ static void usage(void)
}
static struct option long_options[] = {
- {"command", required_argument, 0, 'c'},
- {"daemonize", optional_argument, 0, 'd'},
- {"ecuid", required_argument, 0, 'e'},
- {"help", no_argument, 0, 'h'},
- {"path", required_argument, 0, 'p'},
- {"snapshot", optional_argument, 0, 's'},
- {"timeout", required_argument, 0, 't'},
- {"verbose", no_argument, 0, 'v'},
- {0, 0, 0, 0}
+ { "command", required_argument, 0, 'c' },
+ { "daemonize", optional_argument, 0, 'd' },
+ { "ecuid", required_argument, 0, 'e' },
+ { "help", no_argument, 0, 'h' },
+ { "path", required_argument, 0, 'p' },
+ { "snapshot", optional_argument, 0, 's' },
+ { "timeout", required_argument, 0, 't' },
+ { "verbose", no_argument, 0, 'v' },
+ { 0, 0, 0, 0 }
};
/** @brief Parses the application arguments
@@ -471,14 +442,11 @@ static int parse_args(int argc, char *argv[])
":s::t:he:p:d::c:v",
long_options,
&long_index)) != -1)
- {
- switch (c)
- {
+ switch (c) {
case 's':
set_default_event_type(EVENT_SYNC_CACHE);
- if (optarg != NULL && strlen(optarg) >= DLT_MOUNT_PATH_MAX)
- {
+ if ((optarg != NULL) && (strlen(optarg) >= DLT_MOUNT_PATH_MAX)) {
pr_error("Mount path '%s' too long\n", optarg);
return -1;
}
@@ -501,8 +469,7 @@ static int parse_args(int argc, char *argv[])
break;
case 'p':
- if (strlen(optarg) >= DLT_MOUNT_PATH_MAX)
- {
+ if (strlen(optarg) >= DLT_MOUNT_PATH_MAX) {
pr_error("Mount path '%s' too long\n", optarg);
return -1;
}
@@ -523,13 +490,9 @@ static int parse_args(int argc, char *argv[])
case '?':
if (isprint(optopt))
- {
pr_error("Unknown option -%c.\n", optopt);
- }
else
- {
pr_error("Unknown option character \\x%x.\n", optopt);
- }
usage();
return -1;
@@ -537,11 +500,11 @@ static int parse_args(int argc, char *argv[])
pr_error("Try %s -h for more information.\n", argv[0]);
return -1;
}
- }
- if (get_default_event_type() == EVENT_SYNC_CACHE &&
- get_handler_type() != CTRL_NOHANDLER)
- {
+
+
+ if ((get_default_event_type() == EVENT_SYNC_CACHE) &&
+ (get_handler_type() != CTRL_NOHANDLER)) {
pr_error("Sync caches not available in daemon mode\n");
return -1;
}
@@ -553,8 +516,8 @@ static int parse_args(int argc, char *argv[])
int sd_notify(int unset_environment, const char *state)
{
/* Satisfy Compiler for warnings */
- (void) unset_environment;
- (void) state;
+ (void)unset_environment;
+ (void)state;
return 0;
}
#endif
@@ -577,36 +540,29 @@ int main(int argc, char *argv[])
/* Get command line arguments */
if (parse_args(argc, argv) != 0)
- {
return -1;
- }
/* all parameter valid, start communication with daemon or setup
* communication with control daemon */
- if (get_handler_type() == CTRL_NOHANDLER)
- {
+ if (get_handler_type() == CTRL_NOHANDLER) {
pr_verbose("One shot.\n");
ret = dlt_logstorage_ctrl_single_request();
+
if (ret < 0)
- {
pr_error("Message failed to be send. Please check DLT config.\n");
- }
}
- else
- {
+ else {
pr_verbose("Entering in daemon mode.\n");
/* Let's daemonize */
- if (sd_notify(0, "READY=1") <= 0)
- {
+ if (sd_notify(0, "READY=1") <= 0) {
pr_verbose("SD notify failed, manually daemonizing.\n");
/* No message can be sent or Systemd is not available.
* Daemonizing manually.
*/
- if (daemon(1, 1))
- {
+ if (daemon(1, 1)) {
pr_error("Failed to daemonize: %s\n", strerror(errno));
return EXIT_FAILURE;
}
diff --git a/src/console/logstorage/dlt-logstorage-list.c b/src/console/logstorage/dlt-logstorage-list.c
index a18fca6..9adda9a 100644
--- a/src/console/logstorage/dlt-logstorage-list.c
+++ b/src/console/logstorage/dlt-logstorage-list.c
@@ -83,8 +83,7 @@ void print_list()
struct LogstorageDeviceInfo *ptr = g_info;
pr_verbose(" -------Device list-------\n");
- while (ptr != NULL)
- {
+ while (ptr != NULL) {
pr_verbose("%p:\t[%s][%s] \n", ptr, ptr->dev_node, ptr->mnt_point);
ptr = ptr->next;
}
@@ -108,21 +107,16 @@ static struct LogstorageDeviceInfo *logstorage_find_dev_info(const char *node)
struct LogstorageDeviceInfo *ptr = g_info;
if (!node)
- {
return NULL;
- }
pr_verbose("Looking for %s.\n", node);
- while (ptr != NULL)
- {
- if (strncmp(ptr->dev_node, node, DLT_MOUNT_PATH_MAX) == 0)
- {
+ while (ptr != NULL) {
+ if (strncmp(ptr->dev_node, node, DLT_MOUNT_PATH_MAX) == 0) {
pr_verbose("%s found in %p.\n", node, ptr);
break;
}
- else
- {
+ else {
ptr = ptr->next;
}
}
@@ -145,14 +139,12 @@ int logstorage_store_dev_info(const char *node, const char *path)
struct LogstorageDeviceInfo *ptr = NULL;
size_t path_len = 0;
- if ((node == NULL) || (path == NULL))
- {
+ if ((node == NULL) || (path == NULL)) {
pr_error("Invalid input\n");
return -1;
}
- if (logstorage_find_dev_info(node))
- {
+ if (logstorage_find_dev_info(node)) {
pr_verbose("%s already in list.\n", node);
print_list();
return 0;
@@ -160,22 +152,20 @@ int logstorage_store_dev_info(const char *node, const char *path)
ptr = calloc(1, sizeof(struct LogstorageDeviceInfo));
- if (ptr == NULL)
- {
+ if (ptr == NULL) {
pr_error("Node creation failed\n");
return -1;
}
ptr->dev_node = strdup(node);
path_len = strlen(path);
- if (path_len >DLT_MOUNT_PATH_MAX)
- {
+
+ if (path_len > DLT_MOUNT_PATH_MAX)
path_len = (size_t)DLT_MOUNT_PATH_MAX;
- }
+
ptr->mnt_point = (char *)calloc(1, path_len + 1);
- if (ptr->mnt_point == NULL)
- {
+ if (ptr->mnt_point == NULL) {
pr_error("memory allocation failed for mnt_point\n");
return -1;
}
@@ -187,9 +177,7 @@ int logstorage_store_dev_info(const char *node, const char *path)
ptr->next = g_info;
if (g_info)
- {
g_info->prev = ptr;
- }
g_info = ptr;
@@ -216,8 +204,7 @@ char *logstorage_delete_dev_info(const char *node)
del = logstorage_find_dev_info(node);
- if (del == NULL)
- {
+ if (del == NULL) {
pr_verbose("%s not found in list.\n", node);
print_list();
return ret;
@@ -227,19 +214,13 @@ char *logstorage_delete_dev_info(const char *node)
ret = del->mnt_point;
if (del->prev)
- {
del->prev->next = del->next;
- }
if (del->next)
- {
del->next->prev = del->prev;
- }
if (del == g_info)
- {
g_info = g_info->next;
- }
free(del->dev_node);
free(del);
diff --git a/src/console/logstorage/dlt-logstorage-prop.h b/src/console/logstorage/dlt-logstorage-prop.h
index 836dc99..13eb57c 100644
--- a/src/console/logstorage/dlt-logstorage-prop.h
+++ b/src/console/logstorage/dlt-logstorage-prop.h
@@ -27,7 +27,8 @@
*
* @return 0
*/
-static inline int dlt_logstorage_prop_init(void) {
+static inline int dlt_logstorage_prop_init(void)
+{
return 0;
}
@@ -35,7 +36,8 @@ static inline int dlt_logstorage_prop_init(void) {
*
* @return 0
*/
-static inline int dlt_logstorage_prop_deinit(void) {
+static inline int dlt_logstorage_prop_deinit(void)
+{
return 0;
}
@@ -43,7 +45,8 @@ static inline int dlt_logstorage_prop_deinit(void) {
*
* @return 0
*/
-static inline int check_proprietary_handling(char *type) {
+static inline int check_proprietary_handling(char *type)
+{
(void)type; return 0;
}
#else
diff --git a/src/console/logstorage/dlt-logstorage-udev.c b/src/console/logstorage/dlt-logstorage-udev.c
index e3584d7..578f1fa 100644
--- a/src/console/logstorage/dlt-logstorage-udev.c
+++ b/src/console/logstorage/dlt-logstorage-udev.c
@@ -90,42 +90,33 @@ static char *dlt_logstorage_udev_get_mount_point(char *dev_node)
char *mnt_point = NULL;
if (dev_node == NULL)
- {
return NULL;
- }
f = setmntent("/proc/mounts", "r");
- if (f == NULL)
- {
+ if (f == NULL) {
pr_error("Cannot read /proc/mounts\n");
return NULL;
}
while (NULL != (ent = getmntent(f)))
- {
- if (strncmp(ent->mnt_fsname, dev_node, strlen(ent->mnt_fsname)) == 0)
- {
+ if (strncmp(ent->mnt_fsname, dev_node, strlen(ent->mnt_fsname)) == 0) {
mnt_point = strdup(ent->mnt_dir);
- if (mnt_point == NULL)
- {
+ if (mnt_point == NULL) {
pr_error("Cannot duplicate string.\n");
return NULL;
}
/* Remounting rw */
if (strlen(mnt_point))
- {
/* capabilities needed. Thus we don't really car on failure.
* Therefor we can ignore the return value.
*/
- (void) mount(NULL, mnt_point, NULL, MS_REMOUNT, ent->mnt_opts);
- }
+ (void)mount(NULL, mnt_point, NULL, MS_REMOUNT, ent->mnt_opts);
break;
}
- }
endmntent(f);
@@ -153,56 +144,47 @@ static int check_mountpoint_from_partition(int event, struct udev_device *part)
char *dev_node = NULL;
int ret = 0;
- if (!part)
- {
+ if (!part) {
pr_verbose("No partition structure given.\n");
return -1;
}
pr_verbose("Checking mount point.\n");
- if (!udev_device_get_devnode(part))
- {
+ if (!udev_device_get_devnode(part)) {
pr_verbose("Skipping as no devnode.\n");
return 0;
}
dev_node = strdup(udev_device_get_devnode(part));
- if (dev_node == NULL)
- {
+
+ if (dev_node == NULL) {
pr_error("Cannot allocate memory for to store string\n");
return -1;
}
- if (event == EVENT_MOUNTED)
- {
+ if (event == EVENT_MOUNTED) {
mnt_point = dlt_logstorage_udev_get_mount_point(dev_node);
logstorage_dev = dlt_logstorage_check_config_file(mnt_point);
- if (logstorage_dev) /* Configuration file available, add node to internal list */
- {
+ if (logstorage_dev) { /* Configuration file available, add node to internal list */
logstorage_store_dev_info(dev_node, mnt_point);
}
- else
- {
+ else {
free(mnt_point);
mnt_point = NULL;
}
}
- else
- {
+ else {
/* remove device information */
mnt_point = logstorage_delete_dev_info(dev_node);
}
- if (mnt_point)
- {
+ if (mnt_point) {
ret = dlt_logstorage_send_event(event, mnt_point);
if (ret)
- {
pr_error("Can't send event for %s to DLT.\n", mnt_point);
- }
}
free(dev_node);
@@ -226,32 +208,28 @@ static int logstorage_udev_udevd_callback(void)
LogstorageCtrlUdev *prvt = NULL;
struct udev_device *partition = NULL;
- if (!lctrl)
- {
+ if (!lctrl) {
pr_error("Not able to get logstorage control instance.\n");
return -1;
}
prvt = (LogstorageCtrlUdev *)lctrl->prvt;
- if ((!prvt) || (!prvt->mon))
- {
+ if ((!prvt) || (!prvt->mon)) {
pr_error("Not able to get private data.\n");
return -1;
}
partition = udev_monitor_receive_device(prvt->mon);
- if (!partition)
- {
+ if (!partition) {
pr_error("Not able to get partition.\n");
return -1;
}
action = udev_device_get_action(partition);
- if (!action)
- {
+ if (!action) {
pr_error("Not able to get action.\n");
udev_device_unref(partition);
return -1;
@@ -261,8 +239,7 @@ static int logstorage_udev_udevd_callback(void)
action,
udev_device_get_devnode(partition));
- if (strncmp(action, "add", sizeof("add")) == 0)
- {
+ if (strncmp(action, "add", sizeof("add")) == 0) {
/*TODO: This can be replaced by polling on /proc/mount.
* we could get event on modification, and keep track on a list
* of mounted devices. New devices could be check that way.
@@ -294,8 +271,7 @@ static int logstorage_udev_udevd_callback(void)
*/
static int dlt_logstorage_udev_check_mounted(struct udev *udev)
{
- if (udev == NULL)
- {
+ if (udev == NULL) {
pr_error("%s: udev structure is NULL\n", __func__);
return -1;
}
@@ -305,8 +281,7 @@ static int dlt_logstorage_udev_check_mounted(struct udev *udev)
struct udev_list_entry *devices = NULL;
struct udev_list_entry *dev_list_entry = NULL;
- if (!enumerate)
- {
+ if (!enumerate) {
pr_error("Can't enumerate devices.\n");
return -1;
}
@@ -330,9 +305,7 @@ static int dlt_logstorage_udev_check_mounted(struct udev *udev)
partition = udev_device_new_from_syspath(udev, path);
if (!partition)
- {
continue;
- }
pr_verbose("Found device %s %s %s.\n",
path,
@@ -362,26 +335,18 @@ int dlt_logstorage_udev_deinit(void)
LogstorageCtrlUdev *prvt = NULL;
if (!lctrl)
- {
return -1;
- }
prvt = (LogstorageCtrlUdev *)lctrl->prvt;
if (prvt == NULL)
- {
return -1;
- }
if (prvt->mon)
- {
udev_monitor_unref(prvt->mon);
- }
if (prvt->udev)
- {
udev_unref(prvt->udev);
- }
free(prvt);
lctrl->prvt = NULL;
@@ -404,16 +369,14 @@ int dlt_logstorage_udev_init(void)
pr_verbose("Initializing.\n");
- if (!lctrl)
- {
+ if (!lctrl) {
pr_error("Not able to get logstorage control instance.\n");
return -1;
}
lctrl->prvt = calloc(1, sizeof(LogstorageCtrlUdev));
- if (!lctrl->prvt)
- {
+ if (!lctrl->prvt) {
pr_error("No memory to allocate private data.\n");
return -1;
}
@@ -423,8 +386,7 @@ int dlt_logstorage_udev_init(void)
/* Initialize udev object */
prvt->udev = udev_new();
- if (!prvt->udev)
- {
+ if (!prvt->udev) {
pr_error("Cannot initialize udev object\n");
dlt_logstorage_udev_deinit();
return -1;
@@ -435,8 +397,7 @@ int dlt_logstorage_udev_init(void)
* "add", "remove", "change", etc */
prvt->mon = udev_monitor_new_from_netlink(prvt->udev, "udev");
- if (!prvt->mon)
- {
+ if (!prvt->mon) {
pr_error("Cannot initialize udev monitor\n");
dlt_logstorage_udev_deinit();
return -1;
@@ -446,8 +407,7 @@ int dlt_logstorage_udev_init(void)
"block",
NULL);
- if (ret)
- {
+ if (ret) {
pr_error("Cannot attach filter to monitor: %s.\n", strerror(-ret));
dlt_logstorage_udev_deinit();
return -1;
@@ -455,8 +415,7 @@ int dlt_logstorage_udev_init(void)
ret = udev_monitor_enable_receiving(prvt->mon);
- if (ret < 0)
- {
+ if (ret < 0) {
pr_error("Cannot start receiving: %s.\n", strerror(-ret));
dlt_logstorage_udev_deinit();
return -1;
diff --git a/src/core_dump_handler/cityhash_c/city_c.c b/src/core_dump_handler/cityhash_c/city_c.c
index 0cf7afe..0ccbcd5 100644
--- a/src/core_dump_handler/cityhash_c/city_c.c
+++ b/src/core_dump_handler/cityhash_c/city_c.c
@@ -1,424 +1,458 @@
-// Copyright (c) 2011 Google, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-// CityHash, by Geoff Pike and Jyrki Alakuijala
-//
-// This file provides CityHash64() and related functions.
-//
-// It's probably possible to create even faster hash functions by
-// writing a program that systematically explores some of the space of
-// possible hash functions, by using SIMD instructions, or by
-// compromising on hash quality.
+/* Copyright (c) 2011 Google, Inc. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining a copy */
+/* of this software and associated documentation files (the "Software"), to deal */
+/* in the Software without restriction, including without limitation the rights */
+/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
+/* copies of the Software, and to permit persons to whom the Software is */
+/* furnished to do so, subject to the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be included in */
+/* all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
+/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
+/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
+/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
+/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
+/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
+/* THE SOFTWARE. */
+/* */
+/* CityHash, by Geoff Pike and Jyrki Alakuijala */
+/* */
+/* This file provides CityHash64() and related functions. */
+/* */
+/* It's probably possible to create even faster hash functions by */
+/* writing a program that systematically explores some of the space of */
+/* possible hash functions, by using SIMD instructions, or by */
+/* compromising on hash quality. */
#include "city_c.h"
#include <string.h>
#if defined(__sparc) || defined(__sparc__) \
- || defined(_POWER) || defined(__powerpc__) \
-|| defined(__ppc__) || defined(__hpux) || defined(__hppa) \
-|| defined(_MIPSEB) || defined(_POWER) \
-|| defined(__s390__)
-# define WORDS_BIGENDIAN
+ || defined(_POWER) || defined(__powerpc__) \
+ || defined(__ppc__) || defined(__hpux) || defined(__hppa) \
+ || defined(_MIPSEB) || defined(_POWER) \
+ || defined(__s390__)
+# define WORDS_BIGENDIAN
#elif defined(__i386__) || defined(__alpha__) \
- || defined(__ia64) || defined(__ia64__) \
-|| defined(_M_IX86) || defined(_M_IA64) \
-|| defined(_M_ALPHA) || defined(__amd64) \
-|| defined(__amd64__) || defined(_M_AMD64) \
-|| defined(__x86_64) || defined(__x86_64__) \
-|| defined(_M_X64) || defined(__bfin__)
-# define WORDS_LITTLEENDIAN
+ || defined(__ia64) || defined(__ia64__) \
+ || defined(_M_IX86) || defined(_M_IA64) \
+ || defined(_M_ALPHA) || defined(__amd64) \
+ || defined(__amd64__) || defined(_M_AMD64) \
+ || defined(__x86_64) || defined(__x86_64__) \
+ || defined(_M_X64) || defined(__bfin__)
+# define WORDS_LITTLEENDIAN
#endif
#if !defined(WORDS_BIGENDIAN)
-# define uint32_in_expected_order(x) (x)
-# define uint64_in_expected_order(x) (x)
+# define uint32_in_expected_order(x) (x)
+# define uint64_in_expected_order(x) (x)
#else
-# if defined _MSC_VER
-# include <stdlib.h>
-# define bswap_32(x) _byteswap_ulong(x)
-# define bswap_64(x) _byteswap_uint64(x)
-# elif defined(__APPLE__)
-// Mac OS X / Darwin features
-# include <libkern/OSByteOrder.h>
-# define bswap_32(x) OSSwapInt32(x)
-# define bswap_64(x) OSSwapInt64(x)
-# else
-# include <byteswap.h>
-# endif
-# define uint32_in_expected_order(x) (bswap_32(x))
-# define uint64_in_expected_order(x) (bswap_64(x))
-#endif // WORDS_BIGENDIAN
+# if defined _MSC_VER
+# include <stdlib.h>
+# define bswap_32(x) _byteswap_ulong(x)
+# define bswap_64(x) _byteswap_uint64(x)
+# elif defined(__APPLE__)
+/* Mac OS X / Darwin features */
+# include <libkern/OSByteOrder.h>
+# define bswap_32(x) OSSwapInt32(x)
+# define bswap_64(x) OSSwapInt64(x)
+# else
+# include <byteswap.h>
+# endif
+# define uint32_in_expected_order(x) (bswap_32(x))
+# define uint64_in_expected_order(x) (bswap_64(x))
+#endif /* WORDS_BIGENDIAN */
#if !defined inline
-# ifdef _MSC_VER
-# define inline __inline
-# endif
+# ifdef _MSC_VER
+# define inline __inline
+# endif
#endif
#if !defined LIKELY
-# if defined __GNUC__ && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))//GCC 2.96 above
-# define LIKELY(x) (__builtin_expect(!!(x), 1))
-# else
-# define LIKELY(x) (x)
-# endif
+# if defined __GNUC__ && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))/*GCC 2.96 above */
+# define LIKELY(x) (__builtin_expect(!!(x), 1))
+# else
+# define LIKELY(x) (x)
+# endif
#endif
-#define UNSAFE_SWAP(type, a, b) do {type tmp;tmp=(a);(a)=(b);(b)=tmp;} while (0)
+#define UNSAFE_SWAP(type, a, b) do { type tmp; tmp = (a); (a) = (b); (b) = tmp; } while (0)
-static inline uint128 UInt128(uint64 low, uint64 high) {
- uint128 val;
- val.first = low;
- val.second = high;
- return val;
+static inline uint128 UInt128(uint64 low, uint64 high)
+{
+ uint128 val;
+ val.first = low;
+ val.second = high;
+ return val;
}
-static inline uint64 UNALIGNED_LOAD64(const char *p) {
- uint64 result;
- memcpy(&result, p, sizeof(result));
- return result;
+static inline uint64 UNALIGNED_LOAD64(const char *p)
+{
+ uint64 result;
+ memcpy(&result, p, sizeof(result));
+ return result;
}
-static inline uint32 UNALIGNED_LOAD32(const char *p) {
- uint32 result;
- memcpy(&result, p, sizeof(result));
- return result;
+static inline uint32 UNALIGNED_LOAD32(const char *p)
+{
+ uint32 result;
+ memcpy(&result, p, sizeof(result));
+ return result;
}
-static uint64 Hash64Pairto64(uint64 u, uint64 v) {
- // Murmur-inspired hashing.
- static const uint64 kMul = 0x9ddfea08eb382d69ULL;
- uint64 a, b;
- a = (u ^ v) * kMul;
- a ^= (a >> 47);
- b = (v ^ a) * kMul;
- b ^= (b >> 47);
- b *= kMul;
- return b;
+static uint64 Hash64Pairto64(uint64 u, uint64 v)
+{
+ /* Murmur-inspired hashing. */
+ static const uint64 kMul = 0x9ddfea08eb382d69ULL;
+ uint64 a, b;
+ a = (u ^ v) * kMul;
+ a ^= (a >> 47);
+ b = (v ^ a) * kMul;
+ b ^= (b >> 47);
+ b *= kMul;
+ return b;
}
-static inline uint64 Fetch64(const char *p) {
- return uint64_in_expected_order(UNALIGNED_LOAD64(p));
+static inline uint64 Fetch64(const char *p)
+{
+ return uint64_in_expected_order(UNALIGNED_LOAD64(p));
}
-static inline uint32 Fetch32(const char *p) {
- return uint32_in_expected_order(UNALIGNED_LOAD32(p));
+static inline uint32 Fetch32(const char *p)
+{
+ return uint32_in_expected_order(UNALIGNED_LOAD32(p));
}
-// Some primes between 2^63 and 2^64 for various uses.
+/* Some primes between 2^63 and 2^64 for various uses. */
static const uint64 k0 = 0xc3a5c85c97cb3127ULL;
static const uint64 k1 = 0xb492b66fbe98f273ULL;
static const uint64 k2 = 0x9ae16a3b2f90404fULL;
static const uint64 k3 = 0xc949d7c7509e6557ULL;
-// Bitwise right rotate. Normally this will compile to a single
-// instruction, especially if the shift is a manifest constant.
-static inline uint64 Rotate(uint64 val, int shift) {
- // Avoid shifting by 64: doing so yields an undefined result.
- return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
+/* Bitwise right rotate. Normally this will compile to a single */
+/* instruction, especially if the shift is a manifest constant. */
+static inline uint64 Rotate(uint64 val, int shift)
+{
+ /* Avoid shifting by 64: doing so yields an undefined result. */
+ return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
}
-// Equivalent to Rotate(), but requires the second arg to be non-zero.
-// On x86-64, and probably others, it's possible for this to compile
-// to a single instruction if both args are already in registers.
-static inline uint64 RotateByAtLeast1(uint64 val, int shift) {
- return (val >> shift) | (val << (64 - shift));
+/* Equivalent to Rotate(), but requires the second arg to be non-zero. */
+/* On x86-64, and probably others, it's possible for this to compile */
+/* to a single instruction if both args are already in registers. */
+static inline uint64 RotateByAtLeast1(uint64 val, int shift)
+{
+ return (val >> shift) | (val << (64 - shift));
}
-static inline uint64 ShiftMix(uint64 val) {
- return val ^ (val >> 47);
+static inline uint64 ShiftMix(uint64 val)
+{
+ return val ^ (val >> 47);
}
-static inline uint64 HashLen16(uint64 u, uint64 v) {
- //return Hash128to64(uint128(u, v));
- return Hash64Pairto64(u, v);
+static inline uint64 HashLen16(uint64 u, uint64 v)
+{
+ /*return Hash128to64(uint128(u, v)); */
+ return Hash64Pairto64(u, v);
}
-static uint64 HashLen0to16(const char *s, size_t len) {
- if (len > 8) {
- uint64 a = Fetch64(s);
- uint64 b = Fetch64(s + len - 8);
- return HashLen16(a, RotateByAtLeast1(b + len, len)) ^ b;
- }
- if (len >= 4) {
- uint64 a = Fetch32(s);
- return HashLen16(len + (a << 3), Fetch32(s + len - 4));
- }
- if (len > 0) {
- uint8 a = s[0];
- uint8 b = s[len >> 1];
- uint8 c = s[len - 1];
- uint32 y = (uint32)a + ((uint32)b << 8);
- uint32 z = len + ((uint32)c << 2);
- return ShiftMix(y * k2 ^ z * k3) * k2;
- }
- return k2;
+static uint64 HashLen0to16(const char *s, size_t len)
+{
+ if (len > 8) {
+ uint64 a = Fetch64(s);
+ uint64 b = Fetch64(s + len - 8);
+ return HashLen16(a, RotateByAtLeast1(b + len, len)) ^ b;
+ }
+
+ if (len >= 4) {
+ uint64 a = Fetch32(s);
+ return HashLen16(len + (a << 3), Fetch32(s + len - 4));
+ }
+
+ if (len > 0) {
+ uint8 a = s[0];
+ uint8 b = s[len >> 1];
+ uint8 c = s[len - 1];
+ uint32 y = (uint32)a + ((uint32)b << 8);
+ uint32 z = len + ((uint32)c << 2);
+ return ShiftMix(y * k2 ^ z * k3) * k2;
+ }
+
+ return k2;
}
-// This probably works well for 16-byte strings as well, but it may be overkill
-// in that case.
-static uint64 HashLen17to32(const char *s, size_t len) {
- uint64 a = Fetch64(s) * k1;
- uint64 b = Fetch64(s + 8);
- uint64 c = Fetch64(s + len - 8) * k2;
- uint64 d = Fetch64(s + len - 16) * k0;
- return HashLen16(Rotate(a - b, 43) + Rotate(c, 30) + d,
- a + Rotate(b ^ k3, 20) - c + len);
+/* This probably works well for 16-byte strings as well, but it may be overkill */
+/* in that case. */
+static uint64 HashLen17to32(const char *s, size_t len)
+{
+ uint64 a = Fetch64(s) * k1;
+ uint64 b = Fetch64(s + 8);
+ uint64 c = Fetch64(s + len - 8) * k2;
+ uint64 d = Fetch64(s + len - 16) * k0;
+ return HashLen16(Rotate(a - b, 43) + Rotate(c, 30) + d,
+ a + Rotate(b ^ k3, 20) - c + len);
}
-// Return a 16-byte hash for 48 bytes. Quick and dirty.
-// Callers do best to use "random-looking" values for a and b.
-static uint128 WeakHashLen32WithSeeds6(uint64 w, uint64 x, uint64 y, uint64 z, uint64 a, uint64 b) {
- uint64 c;
- a += w;
- b = Rotate(b + a + z, 21);
- c = a;
- a += x;
- a += y;
- b += Rotate(a, 44);
- return UInt128(a + z, b + c);
+/* Return a 16-byte hash for 48 bytes. Quick and dirty. */
+/* Callers do best to use "random-looking" values for a and b. */
+static uint128 WeakHashLen32WithSeeds6(uint64 w, uint64 x, uint64 y, uint64 z, uint64 a, uint64 b)
+{
+ uint64 c;
+ a += w;
+ b = Rotate(b + a + z, 21);
+ c = a;
+ a += x;
+ a += y;
+ b += Rotate(a, 44);
+ return UInt128(a + z, b + c);
}
-// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
-static uint128 WeakHashLen32WithSeeds3(const char* s, uint64 a, uint64 b) {
- return WeakHashLen32WithSeeds6(Fetch64(s),
- Fetch64(s + 8),
- Fetch64(s + 16),
- Fetch64(s + 24),
- a,
- b);
+/* Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. */
+static uint128 WeakHashLen32WithSeeds3(const char *s, uint64 a, uint64 b)
+{
+ return WeakHashLen32WithSeeds6(Fetch64(s),
+ Fetch64(s + 8),
+ Fetch64(s + 16),
+ Fetch64(s + 24),
+ a,
+ b);
}
-// Return an 8-byte hash for 33 to 64 bytes.
-static uint64 HashLen33to64(const char *s, size_t len) {
- uint64 z = Fetch64(s + 24);
- uint64 a = Fetch64(s) + (len + Fetch64(s + len - 16)) * k0;
- uint64 b = Rotate(a + z, 52);
- uint64 c = Rotate(a, 37);
- uint64 vf, vs, wf, ws, r;
- a += Fetch64(s + 8);
- c += Rotate(a, 7);
- a += Fetch64(s + 16);
- vf = a + z;
- vs = b + Rotate(a, 31) + c;
- a = Fetch64(s + 16) + Fetch64(s + len - 32);
- z = Fetch64(s + len - 8);
- b = Rotate(a + z, 52);
- c = Rotate(a, 37);
- a += Fetch64(s + len - 24);
- c += Rotate(a, 7);
- a += Fetch64(s + len - 16);
- wf = a + z;
- ws = b + Rotate(a, 31) + c;
- r = ShiftMix((vf + ws) * k2 + (wf + vs) * k0);
- return ShiftMix(r * k0 + vs) * k2;
+/* Return an 8-byte hash for 33 to 64 bytes. */
+static uint64 HashLen33to64(const char *s, size_t len)
+{
+ uint64 z = Fetch64(s + 24);
+ uint64 a = Fetch64(s) + (len + Fetch64(s + len - 16)) * k0;
+ uint64 b = Rotate(a + z, 52);
+ uint64 c = Rotate(a, 37);
+ uint64 vf, vs, wf, ws, r;
+ a += Fetch64(s + 8);
+ c += Rotate(a, 7);
+ a += Fetch64(s + 16);
+ vf = a + z;
+ vs = b + Rotate(a, 31) + c;
+ a = Fetch64(s + 16) + Fetch64(s + len - 32);
+ z = Fetch64(s + len - 8);
+ b = Rotate(a + z, 52);
+ c = Rotate(a, 37);
+ a += Fetch64(s + len - 24);
+ c += Rotate(a, 7);
+ a += Fetch64(s + len - 16);
+ wf = a + z;
+ ws = b + Rotate(a, 31) + c;
+ r = ShiftMix((vf + ws) * k2 + (wf + vs) * k0);
+ return ShiftMix(r * k0 + vs) * k2;
}
-uint64 CityHash64(const char *s, size_t len) {
- if (len <= 32) {
- if (len <= 16) {
- return HashLen0to16(s, len);
- } else {
- return HashLen17to32(s, len);
+uint64 CityHash64(const char *s, size_t len)
+{
+ if (len <= 32) {
+ if (len <= 16)
+ return HashLen0to16(s, len);
+ else
+ return HashLen17to32(s, len);
+ }
+ else if (len <= 64)
+ {
+ return HashLen33to64(s, len);
}
- } else if (len <= 64) {
- return HashLen33to64(s, len);
- }
-
- do {
- // For strings over 64 bytes we hash the end first, and then as we
- // loop we keep 56 bytes of state: v, w, x, y, and z.
- uint64 x = Fetch64(s + len - 40);
- uint64 y = Fetch64(s + len - 16) + Fetch64(s + len - 56);
- uint64 z = HashLen16(Fetch64(s + len - 48) + len, Fetch64(s + len - 24));
- uint128 v = WeakHashLen32WithSeeds3(s + len - 64, len, z);
- uint128 w = WeakHashLen32WithSeeds3(s + len - 32, y + k1, x);
- x = x * k1 + Fetch64(s);
-
- // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
- len = (len - 1) & ~(size_t)63;
+
do {
- x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
- y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
- x ^= w.second;
- y += v.first + Fetch64(s + 40);
- z = Rotate(z + w.first, 33) * k1;
- v = WeakHashLen32WithSeeds3(s, v.second * k1, x + w.first);
- w = WeakHashLen32WithSeeds3(s + 32, z + w.second, y + Fetch64(s + 16));
- UNSAFE_SWAP(uint64, z, x);
- s += 64;
- len -= 64;
- } while (len != 0);
- return HashLen16(HashLen16(v.first, w.first) + ShiftMix(y) * k1 + z,
- HashLen16(v.second, w.second) + x);
- } while(0);
+ /* For strings over 64 bytes we hash the end first, and then as we */
+ /* loop we keep 56 bytes of state: v, w, x, y, and z. */
+ uint64 x = Fetch64(s + len - 40);
+ uint64 y = Fetch64(s + len - 16) + Fetch64(s + len - 56);
+ uint64 z = HashLen16(Fetch64(s + len - 48) + len, Fetch64(s + len - 24));
+ uint128 v = WeakHashLen32WithSeeds3(s + len - 64, len, z);
+ uint128 w = WeakHashLen32WithSeeds3(s + len - 32, y + k1, x);
+ x = x * k1 + Fetch64(s);
+
+ /* Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. */
+ len = (len - 1) & ~(size_t)63;
+
+ do {
+ x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
+ y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
+ x ^= w.second;
+ y += v.first + Fetch64(s + 40);
+ z = Rotate(z + w.first, 33) * k1;
+ v = WeakHashLen32WithSeeds3(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds3(s + 32, z + w.second, y + Fetch64(s + 16));
+ UNSAFE_SWAP(uint64, z, x);
+ s += 64;
+ len -= 64;
+ } while (len != 0);
+
+ return HashLen16(HashLen16(v.first, w.first) + ShiftMix(y) * k1 + z,
+ HashLen16(v.second, w.second) + x);
+ } while (0);
}
-uint64 CityHash64WithSeed(const char *s, size_t len, uint64 seed) {
- return CityHash64WithSeeds(s, len, k2, seed);
+uint64 CityHash64WithSeed(const char *s, size_t len, uint64 seed)
+{
+ return CityHash64WithSeeds(s, len, k2, seed);
}
-uint64 CityHash64WithSeeds(const char *s, size_t len, uint64 seed0, uint64 seed1) {
- return HashLen16(CityHash64(s, len) - seed0, seed1);
+uint64 CityHash64WithSeeds(const char *s, size_t len, uint64 seed0, uint64 seed1)
+{
+ return HashLen16(CityHash64(s, len) - seed0, seed1);
}
-// A subroutine for CityHash128(). Returns a decent 128-bit hash for strings
-// of any length representable in signed long. Based on City and Murmur.
-static uint128 CityMurmur(const char *s, size_t len, uint128 seed) {
- uint64 a = Uint128Low64(seed);
- uint64 b = Uint128High64(seed);
- uint64 c = 0;
- uint64 d = 0;
- signed long l = len - 16;
- if (l <= 0) { // len <= 16
- a = ShiftMix(a * k1) * k1;
- c = b * k1 + HashLen0to16(s, len);
- d = ShiftMix(a + (len >= 8 ? Fetch64(s) : c));
- } else { // len > 16
- c = HashLen16(Fetch64(s + len - 8) + k1, a);
- d = HashLen16(b + len, c + Fetch64(s + len - 16));
- a += d;
- do {
- a ^= ShiftMix(Fetch64(s) * k1) * k1;
- a *= k1;
- b ^= a;
- c ^= ShiftMix(Fetch64(s + 8) * k1) * k1;
- c *= k1;
- d ^= c;
- s += 16;
- l -= 16;
- } while (l > 0);
- }
- a = HashLen16(a, c);
- b = HashLen16(d, b);
- return UInt128(a ^ b, HashLen16(b, a));
+/* A subroutine for CityHash128(). Returns a decent 128-bit hash for strings */
+/* of any length representable in signed long. Based on City and Murmur. */
+static uint128 CityMurmur(const char *s, size_t len, uint128 seed)
+{
+ uint64 a = Uint128Low64(seed);
+ uint64 b = Uint128High64(seed);
+ uint64 c = 0;
+ uint64 d = 0;
+ signed long l = len - 16;
+
+ if (l <= 0) { /* len <= 16 */
+ a = ShiftMix(a * k1) * k1;
+ c = b * k1 + HashLen0to16(s, len);
+ d = ShiftMix(a + (len >= 8 ? Fetch64(s) : c));
+ }
+ else { /* len > 16 */
+ c = HashLen16(Fetch64(s + len - 8) + k1, a);
+ d = HashLen16(b + len, c + Fetch64(s + len - 16));
+ a += d;
+
+ do {
+ a ^= ShiftMix(Fetch64(s) * k1) * k1;
+ a *= k1;
+ b ^= a;
+ c ^= ShiftMix(Fetch64(s + 8) * k1) * k1;
+ c *= k1;
+ d ^= c;
+ s += 16;
+ l -= 16;
+ } while (l > 0);
+ }
+
+ a = HashLen16(a, c);
+ b = HashLen16(d, b);
+ return UInt128(a ^ b, HashLen16(b, a));
}
-uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed) {
- if (len < 128) {
- return CityMurmur(s, len, seed);
- }
-
- do {
- // We expect len >= 128 to be the common case. Keep 56 bytes of state:
- // v, w, x, y, and z.
- uint128 v, w;
- uint64 x = Uint128Low64(seed);
- uint64 y = Uint128High64(seed);
- uint64 z = len * k1;
- size_t tail_done;
- v.first = Rotate(y ^ k1, 49) * k1 + Fetch64(s);
- v.second = Rotate(v.first, 42) * k1 + Fetch64(s + 8);
- w.first = Rotate(y + z, 35) * k1 + x;
- w.second = Rotate(x + Fetch64(s + 88), 53) * k1;
-
- // This is the same inner loop as CityHash64(), manually unrolled.
+uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed)
+{
+ if (len < 128)
+ return CityMurmur(s, len, seed);
+
do {
- x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
- y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
- x ^= w.second;
- y += v.first + Fetch64(s + 40);
- z = Rotate(z + w.first, 33) * k1;
- v = WeakHashLen32WithSeeds3(s, v.second * k1, x + w.first);
- w = WeakHashLen32WithSeeds3(s + 32, z + w.second, y + Fetch64(s + 16));
- UNSAFE_SWAP(uint64, z, x);
- s += 64;
- x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
- y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
- x ^= w.second;
- y += v.first + Fetch64(s + 40);
- z = Rotate(z + w.first, 33) * k1;
- v = WeakHashLen32WithSeeds3(s, v.second * k1, x + w.first);
- w = WeakHashLen32WithSeeds3(s + 32, z + w.second, y + Fetch64(s + 16));
- UNSAFE_SWAP(uint64, z, x);
- s += 64;
- len -= 128;
- } while (LIKELY(len >= 128));
- x += Rotate(v.first + z, 49) * k0;
- z += Rotate(w.first, 37) * k0;
- // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
- for (tail_done = 0; tail_done < len; ) {
- tail_done += 32;
- y = Rotate(x + y, 42) * k0 + v.second;
- w.first += Fetch64(s + len - tail_done + 16);
- x = x * k0 + w.first;
- z += w.second + Fetch64(s + len - tail_done);
- w.second += v.first;
- v = WeakHashLen32WithSeeds3(s + len - tail_done, v.first + z, v.second);
- }
- // At this point our 56 bytes of state should contain more than
- // enough information for a strong 128-bit hash. We use two
- // different 56-byte-to-8-byte hashes to get a 16-byte final result.
- x = HashLen16(x, v.first);
- y = HashLen16(y + z, w.first);
- return UInt128(HashLen16(x + v.second, w.second) + y,
- HashLen16(x + w.second, y + v.second));
- } while(0);
+ /* We expect len >= 128 to be the common case. Keep 56 bytes of state: */
+ /* v, w, x, y, and z. */
+ uint128 v, w;
+ uint64 x = Uint128Low64(seed);
+ uint64 y = Uint128High64(seed);
+ uint64 z = len * k1;
+ size_t tail_done;
+ v.first = Rotate(y ^ k1, 49) * k1 + Fetch64(s);
+ v.second = Rotate(v.first, 42) * k1 + Fetch64(s + 8);
+ w.first = Rotate(y + z, 35) * k1 + x;
+ w.second = Rotate(x + Fetch64(s + 88), 53) * k1;
+
+ /* This is the same inner loop as CityHash64(), manually unrolled. */
+ do {
+ x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
+ y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
+ x ^= w.second;
+ y += v.first + Fetch64(s + 40);
+ z = Rotate(z + w.first, 33) * k1;
+ v = WeakHashLen32WithSeeds3(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds3(s + 32, z + w.second, y + Fetch64(s + 16));
+ UNSAFE_SWAP(uint64, z, x);
+ s += 64;
+ x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
+ y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
+ x ^= w.second;
+ y += v.first + Fetch64(s + 40);
+ z = Rotate(z + w.first, 33) * k1;
+ v = WeakHashLen32WithSeeds3(s, v.second * k1, x + w.first);
+ w = WeakHashLen32WithSeeds3(s + 32, z + w.second, y + Fetch64(s + 16));
+ UNSAFE_SWAP(uint64, z, x);
+ s += 64;
+ len -= 128;
+ } while (LIKELY(len >= 128));
+
+ x += Rotate(v.first + z, 49) * k0;
+ z += Rotate(w.first, 37) * k0;
+
+ /* If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s. */
+ for (tail_done = 0; tail_done < len;) {
+ tail_done += 32;
+ y = Rotate(x + y, 42) * k0 + v.second;
+ w.first += Fetch64(s + len - tail_done + 16);
+ x = x * k0 + w.first;
+ z += w.second + Fetch64(s + len - tail_done);
+ w.second += v.first;
+ v = WeakHashLen32WithSeeds3(s + len - tail_done, v.first + z, v.second);
+ }
+
+ /* At this point our 56 bytes of state should contain more than */
+ /* enough information for a strong 128-bit hash. We use two */
+ /* different 56-byte-to-8-byte hashes to get a 16-byte final result. */
+ x = HashLen16(x, v.first);
+ y = HashLen16(y + z, w.first);
+ return UInt128(HashLen16(x + v.second, w.second) + y,
+ HashLen16(x + w.second, y + v.second));
+ } while (0);
}
-uint128 CityHash128(const char *s, size_t len) {
- if (len >= 16) {
- return CityHash128WithSeed(s + 16,
- len - 16,
- UInt128(Fetch64(s) ^ k3,
- Fetch64(s + 8)));
- } else if (len >= 8) {
- return CityHash128WithSeed(NULL,
- 0,
- UInt128(Fetch64(s) ^ (len * k0),
- Fetch64(s + len - 8) ^ k1));
- } else {
- return CityHash128WithSeed(s, len, UInt128(k0, k1));
- }
+uint128 CityHash128(const char *s, size_t len)
+{
+ if (len >= 16)
+ return CityHash128WithSeed(s + 16,
+ len - 16,
+ UInt128(Fetch64(s) ^ k3,
+ Fetch64(s + 8)));
+ else if (len >= 8)
+ return CityHash128WithSeed(NULL,
+ 0,
+ UInt128(Fetch64(s) ^ (len * k0),
+ Fetch64(s + len - 8) ^ k1));
+ else
+ return CityHash128WithSeed(s, len, UInt128(k0, k1));
}
#ifdef __SSE4_2__
-#include "citycrc_c.h"
-#include <nmmintrin.h>
-
-// Requires len >= 240.
-static void CityHashCrc256Long(const char *s, size_t len, uint32 seed, uint64 *result) {
- uint64 a = Fetch64(s + 56) + k0;
- uint64 b = Fetch64(s + 96) + k0;
- uint64 c = result[0] = HashLen16(b, len);
- uint64 d = result[1] = Fetch64(s + 120) * k0 + len;
- uint64 e = Fetch64(s + 184) + seed;
- uint64 f = seed;
- uint64 g = 0;
- uint64 h = 0;
- uint64 i = 0;
- uint64 j = 0;
- uint64 t = c + d;
-
- // 240 bytes of input per iter.
- size_t iters = len / 240;
- len -= iters * 240;
- do {
-#define CHUNK(multiplier, z) \
+# include "citycrc_c.h"
+# include <nmmintrin.h>
+
+/* Requires len >= 240. */
+static void CityHashCrc256Long(const char *s, size_t len, uint32 seed, uint64 *result)
+{
+ uint64 a = Fetch64(s + 56) + k0;
+ uint64 b = Fetch64(s + 96) + k0;
+ uint64 c = result[0] = HashLen16(b, len);
+ uint64 d = result[1] = Fetch64(s + 120) * k0 + len;
+ uint64 e = Fetch64(s + 184) + seed;
+ uint64 f = seed;
+ uint64 g = 0;
+ uint64 h = 0;
+ uint64 i = 0;
+ uint64 j = 0;
+ uint64 t = c + d;
+
+ /* 240 bytes of input per iter. */
+ size_t iters = len / 240;
+ len -= iters * 240;
+
+ do {
+# define CHUNK(multiplier, z) \
{ \
- uint64 old_a = a; \
- a = Rotate(b, 41 ^ z) * multiplier + Fetch64(s); \
- b = Rotate(c, 27 ^ z) * multiplier + Fetch64(s + 8); \
- c = Rotate(d, 41 ^ z) * multiplier + Fetch64(s + 16); \
- d = Rotate(e, 33 ^ z) * multiplier + Fetch64(s + 24); \
- e = Rotate(t, 25 ^ z) * multiplier + Fetch64(s + 32); \
- t = old_a; \
+ uint64 old_a = a; \
+ a = Rotate(b, 41 ^ z) * multiplier + Fetch64(s); \
+ b = Rotate(c, 27 ^ z) * multiplier + Fetch64(s + 8); \
+ c = Rotate(d, 41 ^ z) * multiplier + Fetch64(s + 16); \
+ d = Rotate(e, 33 ^ z) * multiplier + Fetch64(s + 24); \
+ e = Rotate(t, 25 ^ z) * multiplier + Fetch64(s + 32); \
+ t = old_a; \
} \
f = _mm_crc32_u64(f, a); \
g = _mm_crc32_u64(g, b); \
@@ -427,76 +461,83 @@ static void CityHashCrc256Long(const char *s, size_t len, uint32 seed, uint64 *r
j = _mm_crc32_u64(j, e); \
s += 40
- CHUNK(1, 1); CHUNK(k0, 0);
- CHUNK(1, 1); CHUNK(k0, 0);
- CHUNK(1, 1); CHUNK(k0, 0);
- } while (--iters > 0);
-
- while (len >= 40) {
- CHUNK(k0, 0);
- len -= 40;
- }
- if (len > 0) {
- s = s + len - 40;
- CHUNK(k0, 0);
- }
- j += i << 32;
- a = HashLen16(a, j);
- h += g << 32;
- b += h;
- c = HashLen16(c, f) + i;
- d = HashLen16(d, e + result[0]);
- j += e;
- i += HashLen16(h, t);
- e = HashLen16(a, d) + j;
- f = HashLen16(b, c) + a;
- g = HashLen16(j, i) + c;
- result[0] = e + f + g + h;
- a = ShiftMix((a + g) * k0) * k0 + b;
- result[1] += a + result[0];
- a = ShiftMix(a * k0) * k0 + c;
- result[2] = a + result[1];
- a = ShiftMix((a + e) * k0) * k0;
- result[3] = a + result[2];
+ CHUNK(1, 1); CHUNK(k0, 0);
+ CHUNK(1, 1); CHUNK(k0, 0);
+ CHUNK(1, 1); CHUNK(k0, 0);
+ } while (--iters > 0);
+
+ while (len >= 40) {
+ CHUNK(k0, 0);
+ len -= 40;
+ }
+
+ if (len > 0) {
+ s = s + len - 40;
+ CHUNK(k0, 0);
+ }
+
+ j += i << 32;
+ a = HashLen16(a, j);
+ h += g << 32;
+ b += h;
+ c = HashLen16(c, f) + i;
+ d = HashLen16(d, e + result[0]);
+ j += e;
+ i += HashLen16(h, t);
+ e = HashLen16(a, d) + j;
+ f = HashLen16(b, c) + a;
+ g = HashLen16(j, i) + c;
+ result[0] = e + f + g + h;
+ a = ShiftMix((a + g) * k0) * k0 + b;
+ result[1] += a + result[0];
+ a = ShiftMix(a * k0) * k0 + c;
+ result[2] = a + result[1];
+ a = ShiftMix((a + e) * k0) * k0;
+ result[3] = a + result[2];
}
-// Requires len < 240.
-static inline void CityHashCrc256Short(const char *s, size_t len, uint64 *result) {
- char buf[240];
- memcpy(buf, s, len);
- memset(buf + len, 0, 240 - len);
- CityHashCrc256Long(buf, 240, ~(uint32)len, result);
+/* Requires len < 240. */
+static inline void CityHashCrc256Short(const char *s, size_t len, uint64 *result)
+{
+ char buf[240];
+ memcpy(buf, s, len);
+ memset(buf + len, 0, 240 - len);
+ CityHashCrc256Long(buf, 240, ~(uint32)len, result);
}
-void CityHashCrc256(const char *s, size_t len, uint64 *result) {
- if (LIKELY(len >= 240)) {
- CityHashCrc256Long(s, len, 0, result);
- } else {
- CityHashCrc256Short(s, len, result);
- }
+void CityHashCrc256(const char *s, size_t len, uint64 *result)
+{
+ if (LIKELY(len >= 240))
+ CityHashCrc256Long(s, len, 0, result);
+ else
+ CityHashCrc256Short(s, len, result);
}
-uint128 CityHashCrc128WithSeed(const char *s, size_t len, uint128 seed) {
- if (len <= 900) {
- return CityHash128WithSeed(s, len, seed);
- } else {
- uint64 result[4], u, v;
- CityHashCrc256(s, len, result);
- u = Uint128High64(seed) + result[0];
- v = Uint128Low64(seed) + result[1];
- return UInt128(HashLen16(u, v + result[2]),
- HashLen16(Rotate(v, 32), u * k0 + result[3]));
- }
+uint128 CityHashCrc128WithSeed(const char *s, size_t len, uint128 seed)
+{
+ if (len <= 900) {
+ return CityHash128WithSeed(s, len, seed);
+ }
+ else {
+ uint64 result[4], u, v;
+ CityHashCrc256(s, len, result);
+ u = Uint128High64(seed) + result[0];
+ v = Uint128Low64(seed) + result[1];
+ return UInt128(HashLen16(u, v + result[2]),
+ HashLen16(Rotate(v, 32), u * k0 + result[3]));
+ }
}
-uint128 CityHashCrc128(const char *s, size_t len) {
- if (len <= 900) {
- return CityHash128(s, len);
- } else {
- uint64 result[4];
- CityHashCrc256(s, len, result);
- return UInt128(result[2], result[3]);
- }
+uint128 CityHashCrc128(const char *s, size_t len)
+{
+ if (len <= 900) {
+ return CityHash128(s, len);
+ }
+ else {
+ uint64 result[4];
+ CityHashCrc256(s, len, result);
+ return UInt128(result[2], result[3]);
+ }
}
#endif
diff --git a/src/core_dump_handler/cityhash_c/city_c.h b/src/core_dump_handler/cityhash_c/city_c.h
index 2fa469f..d2e1f5d 100644
--- a/src/core_dump_handler/cityhash_c/city_c.h
+++ b/src/core_dump_handler/cityhash_c/city_c.h
@@ -1,95 +1,95 @@
-// Copyright (c) 2011 Google, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-// CityHash, by Geoff Pike and Jyrki Alakuijala
-//
-// This file provides a few functions for hashing strings. On x86-64
-// hardware in 2011, CityHash64() is faster than other high-quality
-// hash functions, such as Murmur. This is largely due to higher
-// instruction-level parallelism. CityHash64() and CityHash128() also perform
-// well on hash-quality tests.
-//
-// CityHash128() is optimized for relatively long strings and returns
-// a 128-bit hash. For strings more than about 2000 bytes it can be
-// faster than CityHash64().
-//
-// Functions in the CityHash family are not suitable for cryptography.
-//
-// WARNING: This code has not been tested on big-endian platforms!
-// It is known to work well on little-endian platforms that have a small penalty
-// for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs.
-//
-// By the way, for some hash functions, given strings a and b, the hash
-// of a+b is easily derived from the hashes of a and b. This property
-// doesn't hold for any hash functions in this file.
+/* Copyright (c) 2011 Google, Inc. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining a copy */
+/* of this software and associated documentation files (the "Software"), to deal */
+/* in the Software without restriction, including without limitation the rights */
+/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
+/* copies of the Software, and to permit persons to whom the Software is */
+/* furnished to do so, subject to the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be included in */
+/* all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
+/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
+/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
+/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
+/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
+/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
+/* THE SOFTWARE. */
+/* */
+/* CityHash, by Geoff Pike and Jyrki Alakuijala */
+/* */
+/* This file provides a few functions for hashing strings. On x86-64 */
+/* hardware in 2011, CityHash64() is faster than other high-quality */
+/* hash functions, such as Murmur. This is largely due to higher */
+/* instruction-level parallelism. CityHash64() and CityHash128() also perform */
+/* well on hash-quality tests. */
+/* */
+/* CityHash128() is optimized for relatively long strings and returns */
+/* a 128-bit hash. For strings more than about 2000 bytes it can be */
+/* faster than CityHash64(). */
+/* */
+/* Functions in the CityHash family are not suitable for cryptography. */
+/* */
+/* WARNING: This code has not been tested on big-endian platforms! */
+/* It is known to work well on little-endian platforms that have a small penalty */
+/* for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs. */
+/* */
+/* By the way, for some hash functions, given strings a and b, the hash */
+/* of a+b is easily derived from the hashes of a and b. This property */
+/* doesn't hold for any hash functions in this file. */
#ifndef CITY_HASH_H_
-#define CITY_HASH_H_
+# define CITY_HASH_H_
-#include <stddef.h>
-#ifdef _MSC_VER
+# include <stddef.h>
+# ifdef _MSC_VER
typedef unsigned char uint8;
typedef unsigned int uint32;
typedef unsigned long long uint64;
-#else
-# include <stdint.h>
+# else
+# include <stdint.h>
typedef uint8_t uint8;
typedef uint32_t uint32;
typedef uint64_t uint64;
-#endif
+# endif
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
-#pragma pack(1)
+# pragma pack(1)
typedef struct
{
- uint64 first, second;
+ uint64 first, second;
} uint128;
-#pragma pack()
+# pragma pack()
-#define Uint128Low64(x) ((x).first)
-#define Uint128High64(x) ((x).second)
+# define Uint128Low64(x) ((x).first)
+# define Uint128High64(x) ((x).second)
-// Hash function for a byte array.
+/* Hash function for a byte array. */
uint64 CityHash64(const char *buf, size_t len);
-// Hash function for a byte array. For convenience, a 64-bit seed is also
-// hashed into the result.
+/* Hash function for a byte array. For convenience, a 64-bit seed is also */
+/* hashed into the result. */
uint64 CityHash64WithSeed(const char *buf, size_t len, uint64 seed);
-// Hash function for a byte array. For convenience, two seeds are also
-// hashed into the result.
+/* Hash function for a byte array. For convenience, two seeds are also */
+/* hashed into the result. */
uint64 CityHash64WithSeeds(const char *buf, size_t len,
uint64 seed0, uint64 seed1);
-// Hash function for a byte array.
+/* Hash function for a byte array. */
uint128 CityHash128(const char *s, size_t len);
-// Hash function for a byte array. For convenience, a 128-bit seed is also
-// hashed into the result.
+/* Hash function for a byte array. For convenience, a 128-bit seed is also */
+/* hashed into the result. */
uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed);
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
-#endif // CITY_HASH_H_
+#endif /* CITY_HASH_H_ */
diff --git a/src/core_dump_handler/cityhash_c/citycrc_c.h b/src/core_dump_handler/cityhash_c/citycrc_c.h
index 5f440de..7b716b1 100644
--- a/src/core_dump_handler/cityhash_c/citycrc_c.h
+++ b/src/core_dump_handler/cityhash_c/citycrc_c.h
@@ -1,51 +1,51 @@
-// Copyright (c) 2011 Google, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-// CityHash, by Geoff Pike and Jyrki Alakuijala
-//
-// This file declares the subset of the CityHash functions that require
-// _mm_crc32_u64(). See the CityHash README for details.
-//
-// Functions in the CityHash family are not suitable for cryptography.
+/* Copyright (c) 2011 Google, Inc. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining a copy */
+/* of this software and associated documentation files (the "Software"), to deal */
+/* in the Software without restriction, including without limitation the rights */
+/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
+/* copies of the Software, and to permit persons to whom the Software is */
+/* furnished to do so, subject to the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be included in */
+/* all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
+/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
+/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
+/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
+/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
+/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
+/* THE SOFTWARE. */
+/* */
+/* CityHash, by Geoff Pike and Jyrki Alakuijala */
+/* */
+/* This file declares the subset of the CityHash functions that require */
+/* _mm_crc32_u64(). See the CityHash README for details. */
+/* */
+/* Functions in the CityHash family are not suitable for cryptography. */
#ifndef CITY_HASH_CRC_H_
-#define CITY_HASH_CRC_H_
+# define CITY_HASH_CRC_H_
-#include "city_c.h"
+# include "city_c.h"
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
-// Hash function for a byte array.
+/* Hash function for a byte array. */
uint128 CityHashCrc128(const char *s, size_t len);
-// Hash function for a byte array. For convenience, a 128-bit seed is also
-// hashed into the result.
+/* Hash function for a byte array. For convenience, a 128-bit seed is also */
+/* hashed into the result. */
uint128 CityHashCrc128WithSeed(const char *s, size_t len, uint128 seed);
-// Hash function for a byte array. Sets result[0] ... result[3].
+/* Hash function for a byte array. Sets result[0] ... result[3]. */
void CityHashCrc256(const char *s, size_t len, uint64 *result);
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
-#endif // CITY_HASH_CRC_H_
+#endif /* CITY_HASH_CRC_H_ */
diff --git a/src/core_dump_handler/dlt_cdh.c b/src/core_dump_handler/dlt_cdh.c
index c573982..477a873 100644
--- a/src/core_dump_handler/dlt_cdh.c
+++ b/src/core_dump_handler/dlt_cdh.c
@@ -41,7 +41,7 @@
#include "dlt_cdh.h"
#include <dirent.h>
-// Unusual characters in a windows filename are replaced
+/* Unusual characters in a windows filename are replaced */
#define UNUSUAL_CHARS ":/\\!*"
#define REPLACEMENT_CHAR '_'
@@ -49,19 +49,19 @@
#define COREDUMP_FILESYSTEM_MIN_SIZE_MB 40
#define COREDUMP_HANDLER_PRIORITY -19
-void core_locks(const proc_info_t* p_proc, int action);
+void core_locks(const proc_info_t *p_proc, int action);
/* ===================================================================
- ** Method : init_proc_info(...)
- **
- ** Description : initialises all members of process info structure to defined values
- **
- ** Parameters : INPUT p_proc
- ** OUTPUT pointer to initialised crashed process info structure
- **
- ** Returns : nothing
- ** ===================================================================*/
-void init_proc_info(proc_info_t* p_proc)
+** Method : init_proc_info(...)
+**
+** Description : initialises all members of process info structure to defined values
+**
+** Parameters : INPUT p_proc
+** OUTPUT pointer to initialised crashed process info structure
+**
+** Returns : nothing
+** ===================================================================*/
+void init_proc_info(proc_info_t *p_proc)
{
memset(p_proc->name, 0, sizeof(p_proc->name));
memset(p_proc->threadname, 0, sizeof(p_proc->threadname));
@@ -87,107 +87,98 @@ void init_proc_info(proc_info_t* p_proc)
}
/* ===================================================================
- ** Method : read_args(...)
- **
- ** Description : reads command line arguments
- **
- ** Parameters : INPUT argc
- ** INPUT argv
- ** OUTPUT pointer to crashed process info structure
- **
- ** Returns : 0 if success, else -1
- ** ===================================================================*/
-cdh_status_t read_args(int argc, char** argv, proc_info_t* proc)
+** Method : read_args(...)
+**
+** Description : reads command line arguments
+**
+** Parameters : INPUT argc
+** INPUT argv
+** OUTPUT pointer to crashed process info structure
+**
+** Returns : 0 if success, else -1
+** ===================================================================*/
+cdh_status_t read_args(int argc, char **argv, proc_info_t *proc)
{
- if (argc < 5)
- {
+ if (argc < 5) {
syslog(LOG_ERR, "Usage: cdh timestamp pid signal procname");
return CDH_NOK;
}
init_proc_info(proc);
- if (sscanf(argv[1], "%u", &proc->timestamp) != 1)
- {
+ if (sscanf(argv[1], "%u", &proc->timestamp) != 1) {
syslog(LOG_ERR, "Unable to read timestamp argument <%s>. Closing", argv[1]);
return CDH_NOK;
}
- if (sscanf(argv[2], "%d", &proc->pid) != 1)
- {
+ if (sscanf(argv[2], "%d", &proc->pid) != 1) {
syslog(LOG_ERR, "Unable to read pid argument <%s>. Closing", argv[2]);
return CDH_NOK;
}
- if (sscanf(argv[3], "%d", &proc->signal) != 1)
- {
+ if (sscanf(argv[3], "%d", &proc->signal) != 1) {
syslog(LOG_ERR, "Unable to read signal argument <%s>. Closing", argv[3]);
return CDH_NOK;
}
- // save the thread name given by the kernel
+ /* save the thread name given by the kernel */
strncpy(proc->threadname, argv[4], sizeof(proc->threadname) - 1);
- // initialize the binary name with threadname... in case we cannot read it from /proc
+ /* initialize the binary name with threadname... in case we cannot read it from /proc */
strncpy(proc->name, argv[4], sizeof(proc->name) - 1);
return CDH_OK;
}
/* ===================================================================
- ** Method : remove_unusual_chars(...)
- **
- ** Description : modify the input string to change UNUSUALS_CHARS to
- ** REPLACEMENT_CHAR
- ** Parameters : INPUT/OUTPUT string to be modified
- **
- ** Returns : nothing
- ** ===================================================================*/
-void remove_unusual_chars(char* p_string)
+** Method : remove_unusual_chars(...)
+**
+** Description : modify the input string to change UNUSUALS_CHARS to
+** REPLACEMENT_CHAR
+** Parameters : INPUT/OUTPUT string to be modified
+**
+** Returns : nothing
+** ===================================================================*/
+void remove_unusual_chars(char *p_string)
{
unsigned int l_char_index = 0;
- for (l_char_index = 0; l_char_index < sizeof(UNUSUAL_CHARS) - 1; l_char_index++)
- {
- char* l_str_pointer = p_string;
+ for (l_char_index = 0; l_char_index < sizeof(UNUSUAL_CHARS) - 1; l_char_index++) {
+ char *l_str_pointer = p_string;
- do
- {
+ do {
l_str_pointer = strchr(l_str_pointer, UNUSUAL_CHARS[l_char_index]);
- if (l_str_pointer != NULL)
- {
+ if (l_str_pointer != NULL) {
*l_str_pointer = REPLACEMENT_CHAR;
l_str_pointer++;
}
- }
- while (l_str_pointer != NULL);
+ } while (l_str_pointer != NULL);
}
}
/* ===================================================================
- ** Method : check_disk_space(...)
- **
- ** Description : check if there is sufficient disk space to write a coredump
- ** Parameters : INPUT/OUTPUT string to be modified
- **
- ** Returns : 0 if success, else -1
- ** ===================================================================*/
+** Method : check_disk_space(...)
+**
+** Description : check if there is sufficient disk space to write a coredump
+** Parameters : INPUT/OUTPUT string to be modified
+**
+** Returns : 0 if success, else -1
+** ===================================================================*/
cdh_status_t check_disk_space()
{
struct statvfs stat;
unsigned long free_size = 0;
- if (statvfs(COREDUMP_FILESYSTEM, &stat) < 0)
- {
+ if (statvfs(COREDUMP_FILESYSTEM, &stat) < 0) {
syslog(LOG_ERR, "ERR cannot stat disk space on %s: %s", COREDUMP_FILESYSTEM, strerror(errno));
return CDH_NOK;
}
- // free space: size of block * number of free blocks (>>20 => MB)
+ /* free space: size of block * number of free blocks (>>20 => MB) */
free_size = (stat.f_bsize * stat.f_bavail) >> 20;
- if (free_size < COREDUMP_FILESYSTEM_MIN_SIZE_MB)
- {
+
+ if (free_size < COREDUMP_FILESYSTEM_MIN_SIZE_MB) {
syslog(LOG_WARNING, "ERR insufficient disk space for coredump: %ld MB.", free_size);
return CDH_NOK;
}
@@ -201,20 +192,17 @@ void clean_core_tmp_dir()
DIR *d = NULL;
struct dirent *dir = NULL;
- if ((d = opendir(CORE_TMP_DIRECTORY)) != NULL)
- {
+ if ((d = opendir(CORE_TMP_DIRECTORY)) != NULL) {
char lockfilepath[CORE_MAX_FILENAME_LENGTH];
- while ((dir = readdir(d)) != NULL)
- {
+ while ((dir = readdir(d)) != NULL) {
struct stat unused_stat;
- // check if lock file exists
+ /* check if lock file exists */
snprintf(lockfilepath, sizeof(lockfilepath), "%s/%s", CORE_LOCK_DIRECTORY, dir->d_name);
- if (stat(lockfilepath, &unused_stat) != 0)
- {
- // No lock file found for this coredump => from previous LC => delete
+ if (stat(lockfilepath, &unused_stat) != 0) {
+ /* No lock file found for this coredump => from previous LC => delete */
char filepath[CORE_MAX_FILENAME_LENGTH] = { 0 };
snprintf(filepath, sizeof(filepath), "%s/%s", CORE_TMP_DIRECTORY, dir->d_name);
@@ -230,24 +218,23 @@ void clean_core_tmp_dir()
}
/* ===================================================================
- ** Method : check_core_directory(...)
- **
- ** Description : checks the availability of core dumps directory.
- ** if not available, there is an installation issue.
- **
- ** Parameters :
- **
- ** Returns : 0 if success, else -1
- ** ===================================================================*/
-cdh_status_t check_and_create_directory(const char* p_dirname, int create_silently)
+** Method : check_core_directory(...)
+**
+** Description : checks the availability of core dumps directory.
+** if not available, there is an installation issue.
+**
+** Parameters :
+**
+** Returns : 0 if success, else -1
+** ===================================================================*/
+cdh_status_t check_and_create_directory(const char *p_dirname, int create_silently)
{
int l_need_create = 0;
int l_need_delete = 0;
struct stat l_stat;
- if (lstat(p_dirname, &l_stat) < 0)
- {
+ if (lstat(p_dirname, &l_stat) < 0) {
l_need_create = 1;
}
else if (!S_ISDIR(l_stat.st_mode))
@@ -256,23 +243,20 @@ cdh_status_t check_and_create_directory(const char* p_dirname, int create_silent
l_need_create = 1;
}
- if (l_need_delete > 0)
- {
+ if (l_need_delete > 0) {
syslog(LOG_WARNING, "WARN core directory '%s' is not a directory => removing it", p_dirname);
- if (unlink(p_dirname) == -1)
- {
+ if (unlink(p_dirname) == -1) {
syslog(LOG_ERR, "ERR core directory '%s' cannot be unlinked: %s", p_dirname, strerror(errno));
return CDH_NOK;
}
}
- if (l_need_create > 0)
- {
+
+ if (l_need_create > 0) {
if (create_silently == 0)
syslog(LOG_WARNING, "WARN core directory '%s' does not exist => creation", p_dirname);
- if (mkdir(p_dirname, 0666) == -1)
- {
+ if (mkdir(p_dirname, 0666) == -1) {
syslog(LOG_ERR, "ERR core directory '%s' cannot be created: %s", p_dirname, strerror(errno));
return CDH_NOK;
}
@@ -282,15 +266,15 @@ cdh_status_t check_and_create_directory(const char* p_dirname, int create_silent
}
/* ===================================================================
- ** Method : check_core_directory(...)
- **
- ** Description : checks the availability of core dumps directory.
- ** if not available, there is an installation issue.
- **
- ** Parameters :
- **
- ** Returns : 0 if success, else -1
- ** ===================================================================*/
+** Method : check_core_directory(...)
+**
+** Description : checks the availability of core dumps directory.
+** if not available, there is an installation issue.
+**
+** Parameters :
+**
+** Returns : 0 if success, else -1
+** ===================================================================*/
cdh_status_t check_core_directory()
{
if (check_and_create_directory(CORE_DIRECTORY, 0) < 0)
@@ -308,36 +292,35 @@ cdh_status_t check_core_directory()
}
/* ===================================================================
- ** Method : move_to_core_directory(...)
- **
- ** Description : move the coredump and context files
- ** from temporary dir to final core directory
- **
- ** Parameters :
- **
- ** Returns : 0 if success, else -1
- ** ===================================================================*/
-cdh_status_t move_to_core_directory(proc_info_t* p_proc)
+** Method : move_to_core_directory(...)
+**
+** Description : move the coredump and context files
+** from temporary dir to final core directory
+**
+** Parameters :
+**
+** Returns : 0 if success, else -1
+** ===================================================================*/
+cdh_status_t move_to_core_directory(proc_info_t *p_proc)
{
char l_src_filename[CORE_MAX_FILENAME_LENGTH] = { 0 };
char l_dst_filename[CORE_MAX_FILENAME_LENGTH] = { 0 };
- char* patterns[] = { CORE_FILE_PATTERN, CONTEXT_FILE_PATTERN };
+ char *patterns[] = { CORE_FILE_PATTERN, CONTEXT_FILE_PATTERN };
unsigned int pattern_num = 0;
if (p_proc == NULL)
return CDH_NOK;
- for (pattern_num = 0; pattern_num < sizeof(patterns) / sizeof(char*); pattern_num++)
- {
- // Don't move coredump if it cannot be created
- if (p_proc->can_create_coredump == 0 && pattern_num == 0)
+ for (pattern_num = 0; pattern_num < sizeof(patterns) / sizeof(char *); pattern_num++) {
+ /* Don't move coredump if it cannot be created */
+ if ((p_proc->can_create_coredump == 0) && (pattern_num == 0))
continue;
snprintf(l_src_filename, sizeof(l_src_filename), patterns[pattern_num],
- CORE_TMP_DIRECTORY, p_proc->timestamp, p_proc->name, p_proc->pid);
+ CORE_TMP_DIRECTORY, p_proc->timestamp, p_proc->name, p_proc->pid);
snprintf(l_dst_filename, sizeof(l_dst_filename), patterns[pattern_num],
- CORE_DIRECTORY, p_proc->timestamp, p_proc->name, p_proc->pid);
+ CORE_DIRECTORY, p_proc->timestamp, p_proc->name, p_proc->pid);
syslog(LOG_INFO, "Moving coredump from %s to %s", l_src_filename, l_dst_filename);
@@ -349,18 +332,18 @@ cdh_status_t move_to_core_directory(proc_info_t* p_proc)
}
/* ===================================================================
- ** Method : main(...)
- **
- ** Description :
- **
- ** Parameters : argc, argv
- **
- ** Returns :
- ** ===================================================================*/
-int main(int argc, char* argv[])
+** Method : main(...)
+**
+** Description :
+**
+** Parameters : argc, argv
+**
+** Returns :
+** ===================================================================*/
+int main(int argc, char *argv[])
{
proc_info_t l_proc_info;
-// char l_exec_name[CORE_MAX_FILENAME_LENGTH] = {0};
+/* char l_exec_name[CORE_MAX_FILENAME_LENGTH] = {0}; */
openlog("CoredumpHandler", 0, LOG_DAEMON);
@@ -371,26 +354,22 @@ int main(int argc, char* argv[])
syslog(LOG_ERR, "Failed to get executable name");
syslog(LOG_NOTICE, "Handling coredump procname:%s pid:%d timest:%d signal:%d",
- l_proc_info.name,
- l_proc_info.pid,
- l_proc_info.timestamp,
- l_proc_info.signal);
+ l_proc_info.name,
+ l_proc_info.pid,
+ l_proc_info.timestamp,
+ l_proc_info.signal);
- // Increase priority of the coredump handler
+ /* Increase priority of the coredump handler */
if (nice(COREDUMP_HANDLER_PRIORITY) != COREDUMP_HANDLER_PRIORITY)
syslog(LOG_WARNING, "Failed to change CDH priority");
if (check_disk_space() < 0)
- {
- //return CDH_NOK;
+ /*return CDH_NOK; */
l_proc_info.can_create_coredump = 0;
- }
if (check_core_directory() < 0)
- {
- //return CDH_NOK;
+ /*return CDH_NOK; */
l_proc_info.can_create_coredump = 0;
- }
remove_unusual_chars(l_proc_info.name);
@@ -411,48 +390,44 @@ int main(int argc, char* argv[])
return CDH_OK;
}
-void core_locks(const proc_info_t* p_proc, int action)
+void core_locks(const proc_info_t *p_proc, int action)
{
char l_lockfilepath[CORE_MAX_FILENAME_LENGTH] = { 0 };
- char* patterns[] = { CORE_FILE_PATTERN, CONTEXT_FILE_PATTERN };
+ char *patterns[] = { CORE_FILE_PATTERN, CONTEXT_FILE_PATTERN };
unsigned int pattern_num = 0;
int fd_lockfile = -1;
if (p_proc == NULL)
return;
- for (pattern_num = 0; pattern_num < sizeof(patterns) / sizeof(char*); pattern_num++)
- {
+ for (pattern_num = 0; pattern_num < sizeof(patterns) / sizeof(char *); pattern_num++) {
snprintf(l_lockfilepath, sizeof(l_lockfilepath), patterns[pattern_num],
- CORE_LOCK_DIRECTORY, p_proc->timestamp, p_proc->name, p_proc->pid);
+ CORE_LOCK_DIRECTORY, p_proc->timestamp, p_proc->name, p_proc->pid);
- switch (action)
+ switch (action) {
+ case 0:
{
- case 0:
- {
- unlink(l_lockfilepath);
- break;
- }
+ unlink(l_lockfilepath);
+ break;
+ }
+
+ case 1:
+ {
+ if ((fd_lockfile = open(l_lockfilepath, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR)) >= 0) {
+ if (write(fd_lockfile, "1", 1) < 0)
+ syslog(LOG_WARNING, "Failed to write lockfile %d: %s", fd_lockfile, strerror(errno));
- case 1:
- {
- if ((fd_lockfile = open(l_lockfilepath, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR)) >= 0)
- {
- if (write(fd_lockfile, "1", 1) < 0)
- syslog(LOG_WARNING, "Failed to write lockfile %d: %s", fd_lockfile, strerror(errno));
-
- close(fd_lockfile);
- }
- else
- {
- syslog(LOG_WARNING, "Failed to open lockfile %s: %s", l_lockfilepath, strerror(errno));
- }
-
- break;
+ close(fd_lockfile);
}
+ else {
+ syslog(LOG_WARNING, "Failed to open lockfile %s: %s", l_lockfilepath, strerror(errno));
+ }
+
+ break;
+ }
- default:
- break;
+ default:
+ break;
}
}
}
diff --git a/src/core_dump_handler/dlt_cdh.h b/src/core_dump_handler/dlt_cdh.h
index ed61560..02f637c 100644
--- a/src/core_dump_handler/dlt_cdh.h
+++ b/src/core_dump_handler/dlt_cdh.h
@@ -36,18 +36,18 @@
#include "dlt_cdh_streamer.h"
-#define CORE_DIRECTORY "/var/core"
-#define CORE_TMP_DIRECTORY "/var/core_tmp"
-#define CORE_LOCK_DIRECTORY "/tmp/.core_locks"
-#define CORE_MAX_FILENAME_LENGTH 255
-#define MAX_PROC_NAME_LENGTH 32
-#define CRASH_ID_LEN 8
-#define CRASHID_FILE "/tmp/.crashid" // the file where the white screen app will read the crashid
-
-#define CORE_FILE_PATTERN "%s/core.%d.%s.%d.gz"
-#define CONTEXT_FILE_PATTERN "%s/context.%d.%s.%d.txt"
-
-#define ELF_Ehdr Elf32_Ehdr
+#define CORE_DIRECTORY "/var/core"
+#define CORE_TMP_DIRECTORY "/var/core_tmp"
+#define CORE_LOCK_DIRECTORY "/tmp/.core_locks"
+#define CORE_MAX_FILENAME_LENGTH 255
+#define MAX_PROC_NAME_LENGTH 32
+#define CRASH_ID_LEN 8
+#define CRASHID_FILE "/tmp/.crashid" /* the file where the white screen app will read the crashid */
+
+#define CORE_FILE_PATTERN "%s/core.%d.%s.%d.gz"
+#define CONTEXT_FILE_PATTERN "%s/context.%d.%s.%d.txt"
+
+#define ELF_Ehdr Elf32_Ehdr
#define ELF_Phdr Elf32_Phdr
#define ELF_Shdr Elf32_Shdr
#define ELF_Nhdr Elf32_Nhdr
@@ -71,10 +71,10 @@ typedef struct
int can_create_coredump;
file_streamer_t streamer;
- // coredump content, for crash id generation
+ /* coredump content, for crash id generation */
ELF_Ehdr m_Ehdr;
- ELF_Phdr* m_pPhdr;
- char* m_Nhdr; // buffer with all NOTE pages
+ ELF_Phdr *m_pPhdr;
+ char *m_Nhdr; /* buffer with all NOTE pages */
unsigned int m_note_page_size;
@@ -86,11 +86,11 @@ typedef struct
} proc_info_t;
-cdh_status_t get_exec_name(unsigned int p_pid_str, char* p_exec_name, int p_exec_name_maxsize);
-cdh_status_t write_proc_context(const proc_info_t*);
-cdh_status_t treat_coredump(proc_info_t* p_proc);
-cdh_status_t treat_crash_data(proc_info_t* p_proc);
-cdh_status_t move_to_core_directory(proc_info_t* p_proc);
+cdh_status_t get_exec_name(unsigned int p_pid_str, char *p_exec_name, int p_exec_name_maxsize);
+cdh_status_t write_proc_context(const proc_info_t *);
+cdh_status_t treat_coredump(proc_info_t *p_proc);
+cdh_status_t treat_crash_data(proc_info_t *p_proc);
+cdh_status_t move_to_core_directory(proc_info_t *p_proc);
cdh_status_t check_core_directory();
-#endif // #ifndef DLT_CDH_H
+#endif /* #ifndef DLT_CDH_H */
diff --git a/src/core_dump_handler/dlt_cdh_context.c b/src/core_dump_handler/dlt_cdh_context.c
index 4fb1d85..f7b8a82 100644
--- a/src/core_dump_handler/dlt_cdh_context.c
+++ b/src/core_dump_handler/dlt_cdh_context.c
@@ -35,21 +35,21 @@
#include "dlt_cdh.h"
-// Global buffer for file reading
+/* Global buffer for file reading */
char g_buffer[4096];
/* ===================================================================
- ** Method : get_exec_name(...)
- **
- ** Description : read executable filename
- **
- ** Parameters : INPUT p_pid_str pid of the process
- ** OUTPUT p_exec_name executable name
- ** INPUT p_exec_name_maxsize size of p_exec_name buffer
- **
- ** Returns : 0 if success, else -1
- ** ===================================================================*/
-cdh_status_t get_exec_name(unsigned int p_pid, char* p_exec_name, int p_exec_name_maxsize)
+** Method : get_exec_name(...)
+**
+** Description : read executable filename
+**
+** Parameters : INPUT p_pid_str pid of the process
+** OUTPUT p_exec_name executable name
+** INPUT p_exec_name_maxsize size of p_exec_name buffer
+**
+** Returns : 0 if success, else -1
+** ===================================================================*/
+cdh_status_t get_exec_name(unsigned int p_pid, char *p_exec_name, int p_exec_name_maxsize)
{
char l_exe_link[CORE_MAX_FILENAME_LENGTH] = { 0 };
char *l_name_ptr = NULL;
@@ -70,18 +70,18 @@ cdh_status_t get_exec_name(unsigned int p_pid, char* p_exec_name, int p_exec_nam
}
/* ===================================================================
- ** Method : dump_file_to(...)
- **
- ** Description : dump the content of file p_src_filename to the file descriptor p_fout
- **
- ** Parameters : INPUT p_src_filename
- ** INPUT p_fout
- **
- ** Returns : 0 if success, else -1
- ** ===================================================================*/
-cdh_status_t dump_file_to(const char* p_src_filename, FILE* p_fout)
+** Method : dump_file_to(...)
+**
+** Description : dump the content of file p_src_filename to the file descriptor p_fout
+**
+** Parameters : INPUT p_src_filename
+** INPUT p_fout
+**
+** Returns : 0 if success, else -1
+** ===================================================================*/
+cdh_status_t dump_file_to(const char *p_src_filename, FILE *p_fout)
{
- FILE* l_fin = NULL;
+ FILE *l_fin = NULL;
int bytes_read = 0;
if (p_fout == NULL)
@@ -89,32 +89,28 @@ cdh_status_t dump_file_to(const char* p_src_filename, FILE* p_fout)
fprintf(p_fout, "\n==== Dumping file <%s> ====\n", p_src_filename);
- if ((l_fin = fopen(p_src_filename, "rt")) == NULL)
- {
+ if ((l_fin = fopen(p_src_filename, "rt")) == NULL) {
syslog(LOG_ERR, "ERR opening info file '%s' for dumping [%s]",
- p_src_filename,
- strerror(errno));
+ p_src_filename,
+ strerror(errno));
fprintf(p_fout, "**error**\n");
return CDH_NOK;
}
- while ((bytes_read = fread(g_buffer, 1, sizeof(g_buffer), l_fin)) != 0)
- {
+ while ((bytes_read = fread(g_buffer, 1, sizeof(g_buffer), l_fin)) != 0) {
int i = 0;
- // changes all "\0" in the file to a "\n"
- // (needed for example for /proc/<pid>/cmdline, to keep all arguments)
+ /* changes all "\0" in the file to a "\n" */
+ /* (needed for example for /proc/<pid>/cmdline, to keep all arguments) */
for (i = 0; i < bytes_read; i++)
- {
if (g_buffer[i] == '\000')
g_buffer[i] = '\n';
- }
fwrite(g_buffer, 1, bytes_read, p_fout);
- if (ferror(p_fout))
- {
+
+ if (ferror(p_fout)) {
syslog(LOG_ERR, "Writing in context file failed [%s]", strerror(errno));
fclose(p_fout);
fclose(l_fin);
@@ -124,8 +120,7 @@ cdh_status_t dump_file_to(const char* p_src_filename, FILE* p_fout)
}
}
- if (ferror(l_fin))
- {
+ if (ferror(l_fin)) {
syslog(LOG_ERR, "reading '%s' failed [%s]", p_src_filename, strerror(errno));
fclose(l_fin);
@@ -138,42 +133,46 @@ cdh_status_t dump_file_to(const char* p_src_filename, FILE* p_fout)
return CDH_OK;
}
-//*************************************************************************************************/
-// "ls -l" implementation for /proc/<pid>/fd (at least)
-// Taken from coreutils sources, lib/filemode.c
-//
+/************************************************************************************************** / */
+/* "ls -l" implementation for /proc/<pid>/fd (at least) */
+/* Taken from coreutils sources, lib/filemode.c */
+/* */
/* Return a character indicating the type of file described by
- file mode BITS:
- '-' regular file
- 'b' block special file
- 'c' character special file
- 'C' high performance ("contiguous data") file
- 'd' directory
- 'D' door
- 'l' symbolic link
- 'm' multiplexed file (7th edition Unix; obsolete)
- 'n' network special file (HP-UX)
- 'p' fifo (named pipe)
- 'P' port
- 's' socket
- 'w' whiteout (4.4BSD)
- '?' some other file type */
+ * file mode BITS:
+ * '-' regular file
+ * 'b' block special file
+ * 'c' character special file
+ * 'C' high performance ("contiguous data") file
+ * 'd' directory
+ * 'D' door
+ * 'l' symbolic link
+ * 'm' multiplexed file (7th edition Unix; obsolete)
+ * 'n' network special file (HP-UX)
+ * 'p' fifo (named pipe)
+ * 'P' port
+ * 's' socket
+ * 'w' whiteout (4.4BSD)
+ * '?' some other file type */
static char ftypelet(mode_t bits)
{
/* These are the most common, so test for them first. */
if (S_ISREG(bits))
return '-';
+
if (S_ISDIR(bits))
return 'd';
/* Other letters standardized by POSIX 1003.1-2004. */
if (S_ISBLK(bits))
return 'b';
+
if (S_ISCHR(bits))
return 'c';
+
if (S_ISLNK(bits))
return 'l';
+
if (S_ISFIFO(bits))
return 'p';
@@ -182,18 +181,18 @@ static char ftypelet(mode_t bits)
return 's';
/* Nonstandard file types.
- if (S_ISCTG (bits))
- return 'C';
- if (S_ISDOOR (bits))
- return 'D';
- if (S_ISMPB (bits) || S_ISMPC (bits))
- return 'm';
- if (S_ISNWK (bits))
- return 'n';
- if (S_ISPORT (bits))
- return 'P';
- if (S_ISWHT (bits))
- return 'w';
+ * if (S_ISCTG (bits))
+ * return 'C';
+ * if (S_ISDOOR (bits))
+ * return 'D';
+ * if (S_ISMPB (bits) || S_ISMPC (bits))
+ * return 'm';
+ * if (S_ISNWK (bits))
+ * return 'n';
+ * if (S_ISPORT (bits))
+ * return 'P';
+ * if (S_ISWHT (bits))
+ * return 'w';
*/
return '?';
@@ -209,49 +208,47 @@ void strmode(mode_t mode, char *str)
str[2] = mode & S_IWUSR ? 'w' : '-';
str[3] = (mode & S_ISUID
? (mode & S_IXUSR ? 's' : 'S')
- :
- (mode & S_IXUSR ? 'x' : '-'));
+ :
+ (mode & S_IXUSR ? 'x' : '-'));
str[4] = mode & S_IRGRP ? 'r' : '-';
str[5] = mode & S_IWGRP ? 'w' : '-';
str[6] = (mode & S_ISGID
? (mode & S_IXGRP ? 's' : 'S')
- :
- (mode & S_IXGRP ? 'x' : '-'));
+ :
+ (mode & S_IXGRP ? 'x' : '-'));
str[7] = mode & S_IROTH ? 'r' : '-';
str[8] = mode & S_IWOTH ? 'w' : '-';
str[9] = (mode & S_ISVTX
? (mode & S_IXOTH ? 't' : 'T')
- :
- (mode & S_IXOTH ? 'x' : '-'));
+ :
+ (mode & S_IXOTH ? 'x' : '-'));
str[10] = ' ';
str[11] = '\0';
}
/* ===================================================================
- ** Method : list_dircontent_to(...)
- **
- ** Description : list the filenames in p_dirname directory to the file descriptor p_fout
- **
- ** Parameters : INPUT p_dirname
- ** INPUT p_fout
- **
- ** Returns : 0 if success, else -1
- ** ===================================================================*/
-cdh_status_t list_dircontent_to(const char* p_dirname, FILE* p_fout)
+** Method : list_dircontent_to(...)
+**
+** Description : list the filenames in p_dirname directory to the file descriptor p_fout
+**
+** Parameters : INPUT p_dirname
+** INPUT p_fout
+**
+** Returns : 0 if success, else -1
+** ===================================================================*/
+cdh_status_t list_dircontent_to(const char *p_dirname, FILE *p_fout)
{
- DIR* l_dd = NULL; // directory descriptor
- struct dirent* l_entity = NULL;
+ DIR *l_dd = NULL; /* directory descriptor */
+ struct dirent *l_entity = NULL;
- if ((l_dd = opendir(p_dirname)) == NULL)
- {
+ if ((l_dd = opendir(p_dirname)) == NULL) {
syslog(LOG_ERR, "ERR reading info dir '%s' failed [%s]", p_dirname, strerror(errno));
return CDH_NOK;
}
fprintf(p_fout, "==== Listing directory <%s> ====\n", p_dirname);
- while ((l_entity = readdir(l_dd)) != NULL)
- {
+ while ((l_entity = readdir(l_dd)) != NULL) {
char l_fullpath[CORE_MAX_FILENAME_LENGTH] = { 0 };
char l_linkpath[CORE_MAX_FILENAME_LENGTH] = { 0 };
char l_modebuf[12] = { 0 };
@@ -264,8 +261,7 @@ cdh_status_t list_dircontent_to(const char* p_dirname, FILE* p_fout)
snprintf(l_fullpath, sizeof(l_fullpath), "%s/%s", p_dirname, l_entity->d_name);
- if (lstat(l_fullpath, &l_stat) < 0)
- {
+ if (lstat(l_fullpath, &l_stat) < 0) {
syslog(LOG_ERR, "ERR lstat on '%s' failed. [%s]", l_fullpath, strerror(errno));
continue;
}
@@ -273,51 +269,49 @@ cdh_status_t list_dircontent_to(const char* p_dirname, FILE* p_fout)
strmode(l_stat.st_mode, l_modebuf);
fprintf(p_fout, "%s %ld %d %d %ld %4s",
- l_modebuf,
- l_stat.st_nlink,
- l_stat.st_uid,
- l_stat.st_gid,
- l_stat.st_size,
- l_entity->d_name);
-
- switch (l_stat.st_mode & S_IFMT)
- {
- case S_IFBLK:
- fprintf(p_fout, " [block device]\n");
+ l_modebuf,
+ l_stat.st_nlink,
+ l_stat.st_uid,
+ l_stat.st_gid,
+ l_stat.st_size,
+ l_entity->d_name);
+
+ switch (l_stat.st_mode & S_IFMT) {
+ case S_IFBLK:
+ fprintf(p_fout, " [block device]\n");
break;
- case S_IFCHR:
- fprintf(p_fout, " [character device]\n");
+ case S_IFCHR:
+ fprintf(p_fout, " [character device]\n");
break;
- case S_IFDIR:
- fprintf(p_fout, " [directory]\n");
+ case S_IFDIR:
+ fprintf(p_fout, " [directory]\n");
break;
- case S_IFIFO:
- fprintf(p_fout, " [FIFO/pipe]\n");
+ case S_IFIFO:
+ fprintf(p_fout, " [FIFO/pipe]\n");
break;
- case S_IFLNK:
- l_size = readlink(l_fullpath, l_linkpath, sizeof(l_linkpath));
- l_linkpath[l_size] = 0;
- fprintf(p_fout, " -> %s\n", l_linkpath);
+ case S_IFLNK:
+ l_size = readlink(l_fullpath, l_linkpath, sizeof(l_linkpath));
+ l_linkpath[l_size] = 0;
+ fprintf(p_fout, " -> %s\n", l_linkpath);
break;
- case S_IFREG:
- fprintf(p_fout, " [regular file]\n");
+ case S_IFREG:
+ fprintf(p_fout, " [regular file]\n");
break;
- case S_IFSOCK:
- fprintf(p_fout, " [socket]\n");
+ case S_IFSOCK:
+ fprintf(p_fout, " [socket]\n");
break;
- default:
- fprintf(p_fout, " [unknown?]\n");
+ default:
+ fprintf(p_fout, " [unknown?]\n");
break;
}
-
- } // while ( (l_entity = readdir(l_dd)) != NULL )
+ } /* while ( (l_entity = readdir(l_dd)) != NULL ) */
fprintf(p_fout, "===========================\n");
closedir(l_dd);
@@ -325,23 +319,23 @@ cdh_status_t list_dircontent_to(const char* p_dirname, FILE* p_fout)
return CDH_OK;
}
-//*************************************************************************************************/
-// END of "ls -l" implementation for /proc/<pid>/fd (at least)
-//*************************************************************************************************/
+/************************************************************************************************** / */
+/* END of "ls -l" implementation for /proc/<pid>/fd (at least) */
+/************************************************************************************************** / */
/* ===================================================================
- ** Method : write_proc_context(...)
- **
- ** Description : write the context data of the crashed process
- ** (context data coming mainly from /proc)
- **
- ** Parameters : INPUT p_proc crashed process info
- **
- ** Returns : 0 if success, else -1
- ** ===================================================================*/
-cdh_status_t write_proc_context(const proc_info_t* p_proc)
+** Method : write_proc_context(...)
+**
+** Description : write the context data of the crashed process
+** (context data coming mainly from /proc)
+**
+** Parameters : INPUT p_proc crashed process info
+**
+** Returns : 0 if success, else -1
+** ===================================================================*/
+cdh_status_t write_proc_context(const proc_info_t *p_proc)
{
- FILE* l_fout = NULL;
+ FILE *l_fout = NULL;
char l_procfile[256] = { 0 };
char l_outfilename[CORE_MAX_FILENAME_LENGTH] = { 0 };
@@ -349,21 +343,20 @@ cdh_status_t write_proc_context(const proc_info_t* p_proc)
return CDH_NOK;
snprintf(l_outfilename, sizeof(l_outfilename), CONTEXT_FILE_PATTERN,
- CORE_TMP_DIRECTORY,
- p_proc->timestamp,
- p_proc->name,
- p_proc->pid);
+ CORE_TMP_DIRECTORY,
+ p_proc->timestamp,
+ p_proc->name,
+ p_proc->pid);
- if ((l_fout = fopen(l_outfilename, "w+t")) == NULL)
- {
+ if ((l_fout = fopen(l_outfilename, "w+t")) == NULL) {
syslog(LOG_ERR, "ERR Cannot open context file '%s' [%s]", l_outfilename, strerror(errno));
return CDH_NOK;
}
-#define PROC_FILENAME(x) do{\
- snprintf(l_procfile, sizeof(l_procfile), "/proc/%d/"x,\
- p_proc->pid);\
-} while(0)
+#define PROC_FILENAME(x) do { \
+ snprintf(l_procfile, sizeof(l_procfile), "/proc/%d/"x, \
+ p_proc->pid); \
+} while (0)
fprintf(l_fout, "ProcName:%s\n", p_proc->name);
fprintf(l_fout, "ThreadName:%s\n", p_proc->threadname);
diff --git a/src/core_dump_handler/dlt_cdh_coredump.c b/src/core_dump_handler/dlt_cdh_coredump.c
index 612174b..9cbc6b0 100644
--- a/src/core_dump_handler/dlt_cdh_coredump.c
+++ b/src/core_dump_handler/dlt_cdh_coredump.c
@@ -39,46 +39,43 @@
#include "dlt_cdh.h"
-cdh_status_t read_elf_headers(proc_info_t* p_proc)
+cdh_status_t read_elf_headers(proc_info_t *p_proc)
{
int phnum = 0;
- // Read ELF header
+ /* Read ELF header */
stream_read(&p_proc->streamer, &p_proc->m_Ehdr, sizeof(p_proc->m_Ehdr));
- // Read until PROG position
+ /* Read until PROG position */
stream_move_to_offest(&p_proc->streamer, p_proc->m_Ehdr.e_phoff);
- // Read and store all program headers
- p_proc->m_pPhdr = (ELF_Phdr*) malloc(sizeof(ELF_Phdr) * p_proc->m_Ehdr.e_phnum);
- if (p_proc->m_pPhdr == NULL)
- {
+ /* Read and store all program headers */
+ p_proc->m_pPhdr = (ELF_Phdr *)malloc(sizeof(ELF_Phdr) * p_proc->m_Ehdr.e_phnum);
+
+ if (p_proc->m_pPhdr == NULL) {
syslog(LOG_ERR, "Cannot allocate Phdr memory (%d headers)", p_proc->m_Ehdr.e_phnum);
return CDH_NOK;
}
for (phnum = 0; phnum < p_proc->m_Ehdr.e_phnum; phnum++)
- {
- // Read Programm header
+ /* Read Programm header */
stream_read(&p_proc->streamer, &p_proc->m_pPhdr[phnum], sizeof(ELF_Phdr));
- }
return CDH_OK;
}
-int getNotePageIndex(proc_info_t* p_proc)
+int getNotePageIndex(proc_info_t *p_proc)
{
int i = 0;
- // Search PT_NOTE section
- for (i = 0; i < p_proc->m_Ehdr.e_phnum; i++)
- {
+ /* Search PT_NOTE section */
+ for (i = 0; i < p_proc->m_Ehdr.e_phnum; i++) {
syslog(LOG_INFO, "==Note section prog_note:%d type:0x%X offset:0x%X size:0x%X (%dbytes)",
- i,
- p_proc->m_pPhdr[i].p_type,
- p_proc->m_pPhdr[i].p_offset,
- p_proc->m_pPhdr[i].p_filesz,
- p_proc->m_pPhdr[i].p_filesz);
+ i,
+ p_proc->m_pPhdr[i].p_type,
+ p_proc->m_pPhdr[i].p_offset,
+ p_proc->m_pPhdr[i].p_filesz,
+ p_proc->m_pPhdr[i].p_filesz);
if (p_proc->m_pPhdr[i].p_type == PT_NOTE)
break;
@@ -87,34 +84,30 @@ int getNotePageIndex(proc_info_t* p_proc)
return i == p_proc->m_Ehdr.e_phnum ? CDH_NOK : i;
}
-cdh_status_t read_notes(proc_info_t* p_proc)
+cdh_status_t read_notes(proc_info_t *p_proc)
{
int prog_note = getNotePageIndex(p_proc);
-// p_proc->m_note_page_size = 0;
+/* p_proc->m_note_page_size = 0; */
p_proc->m_Nhdr = NULL;
- // note page not found, abort
- if (prog_note < 0)
- {
+ /* note page not found, abort */
+ if (prog_note < 0) {
syslog(LOG_ERR, "Cannot find note header page index");
return CDH_NOK;
}
- // Move to NOTE header position
- if (stream_move_to_offest(&p_proc->streamer, p_proc->m_pPhdr[prog_note].p_offset) != CDH_OK)
- {
+ /* Move to NOTE header position */
+ if (stream_move_to_offest(&p_proc->streamer, p_proc->m_pPhdr[prog_note].p_offset) != CDH_OK) {
syslog(LOG_ERR, "Cannot move to note header");
return CDH_NOK;
}
- if ((p_proc->m_Nhdr = (char*) malloc(p_proc->m_pPhdr[prog_note].p_filesz)) == NULL)
- {
+ if ((p_proc->m_Nhdr = (char *)malloc(p_proc->m_pPhdr[prog_note].p_filesz)) == NULL) {
syslog(LOG_ERR, "Cannot allocate Nhdr memory (note size %d bytes)", p_proc->m_pPhdr[prog_note].p_filesz);
return CDH_NOK;
}
- if (stream_read(&p_proc->streamer, p_proc->m_Nhdr, p_proc->m_pPhdr[prog_note].p_filesz) != CDH_OK)
- {
+ if (stream_read(&p_proc->streamer, p_proc->m_Nhdr, p_proc->m_pPhdr[prog_note].p_filesz) != CDH_OK) {
syslog(LOG_ERR, "Cannot read note header");
return CDH_NOK;
}
@@ -124,76 +117,68 @@ cdh_status_t read_notes(proc_info_t* p_proc)
return CDH_OK;
}
-cdh_status_t init_coredump(proc_info_t* p_proc)
+cdh_status_t init_coredump(proc_info_t *p_proc)
{
if (p_proc == NULL)
return CDH_NOK;
- if (p_proc->can_create_coredump)
- {
+ if (p_proc->can_create_coredump) {
char l_dst_filename[CORE_MAX_FILENAME_LENGTH];
snprintf(l_dst_filename, sizeof(l_dst_filename), CORE_FILE_PATTERN,
- CORE_TMP_DIRECTORY,
- p_proc->timestamp,
- p_proc->name,
- p_proc->pid);
+ CORE_TMP_DIRECTORY,
+ p_proc->timestamp,
+ p_proc->name,
+ p_proc->pid);
stream_init(&p_proc->streamer, 0, l_dst_filename);
}
- else
- {
+ else {
stream_init(&p_proc->streamer, 0, NULL);
}
return CDH_OK;
}
-cdh_status_t close_coredump(proc_info_t* p_proc)
+cdh_status_t close_coredump(proc_info_t *p_proc)
{
stream_close(&p_proc->streamer);
return CDH_OK;
}
-cdh_status_t treat_coredump(proc_info_t* p_proc)
+cdh_status_t treat_coredump(proc_info_t *p_proc)
{
cdh_status_t ret = CDH_OK;
- // open src and dest files, allocate read buffer
- if (init_coredump(p_proc) != CDH_OK)
- {
+ /* open src and dest files, allocate read buffer */
+ if (init_coredump(p_proc) != CDH_OK) {
syslog(LOG_ERR, "cannot init coredump system");
ret = CDH_NOK;
goto finished;
}
- if (read_elf_headers(p_proc) == CDH_OK)
- {
- // TODO: No NOTES here leads to crash elsewhere!!! dlt_cdh_crashid.c: around line 76
- if (read_notes(p_proc) != CDH_OK)
- {
+ if (read_elf_headers(p_proc) == CDH_OK) {
+ /* TODO: No NOTES here leads to crash elsewhere!!! dlt_cdh_crashid.c: around line 76 */
+ if (read_notes(p_proc) != CDH_OK) {
syslog(LOG_ERR, "cannot read NOTES");
ret = CDH_NOK;
goto finished;
}
}
- else
- {
- if (read_elf_headers(p_proc) != CDH_OK)
- {
- syslog(LOG_ERR, "cannot read ELF header");
- ret = CDH_NOK;
- goto finished;
- }
+ else if (read_elf_headers(p_proc) != CDH_OK) {
+ syslog(LOG_ERR, "cannot read ELF header");
+ ret = CDH_NOK;
+ goto finished;
}
- finished:
- // In all cases, we try to finish to read/compress the coredump until the end
+finished:
+
+ /* In all cases, we try to finish to read/compress the coredump until the end */
if (stream_finish(&p_proc->streamer) != CDH_OK)
syslog(LOG_ERR, "cannot finish coredump compression");
- // In all cases, let's close the files
+ /* In all cases, let's close the files */
if (close_coredump(p_proc) != CDH_OK)
syslog(LOG_ERR, "cannot close coredump system");
diff --git a/src/core_dump_handler/dlt_cdh_cpuinfo.h b/src/core_dump_handler/dlt_cdh_cpuinfo.h
index 49fc6d0..071edac 100644
--- a/src/core_dump_handler/dlt_cdh_cpuinfo.h
+++ b/src/core_dump_handler/dlt_cdh_cpuinfo.h
@@ -30,6 +30,6 @@
#include "dlt_cdh.h"
-void get_registers(prstatus_t* prstatus, cdh_registers_t* registers);
+void get_registers(prstatus_t *prstatus, cdh_registers_t *registers);
#endif /* DLT_CDH_CPUINFO_H */
diff --git a/src/core_dump_handler/dlt_cdh_crashid.c b/src/core_dump_handler/dlt_cdh_crashid.c
index 905ba8b..ffd2aba 100644
--- a/src/core_dump_handler/dlt_cdh_crashid.c
+++ b/src/core_dump_handler/dlt_cdh_crashid.c
@@ -39,21 +39,21 @@
#include "dlt_cdh_cpuinfo.h"
#ifdef HAS_CITYHASH_C
-#include "city_c.h"
+# include "city_c.h"
#endif
-//ARM32 specific
-//#define REG_FRAME_POINTER 11
-//#define REG_INSTR_POINTER 12
-//#define REG_STACK_POINTER 13
-//#define REG_LINK_REGISTER 14
-//#define REG_PROC_COUNTER 15
+/*ARM32 specific */
+/*#define REG_FRAME_POINTER 11 */
+/*#define REG_INSTR_POINTER 12 */
+/*#define REG_STACK_POINTER 13 */
+/*#define REG_LINK_REGISTER 14 */
+/*#define REG_PROC_COUNTER 15 */
#ifdef HAS_CITYHASH_C
-static cdh_status_t crashid_cityhash(proc_info_t* p_proc);
+static cdh_status_t crashid_cityhash(proc_info_t *p_proc);
#endif
-cdh_status_t get_phdr_num(proc_info_t* p_proc, unsigned int p_address, int *phdr_num)
+cdh_status_t get_phdr_num(proc_info_t *p_proc, unsigned int p_address, int *phdr_num)
{
int i = 0;
@@ -61,40 +61,35 @@ cdh_status_t get_phdr_num(proc_info_t* p_proc, unsigned int p_address, int *phdr
return CDH_NOK;
for (i = 0; i < p_proc->m_Ehdr.e_phnum; i++)
- {
- if (p_proc->m_pPhdr[i].p_vaddr < p_address
- && p_proc->m_pPhdr[i].p_vaddr + p_proc->m_pPhdr[i].p_memsz > p_address)
- {
+ if ((p_proc->m_pPhdr[i].p_vaddr < p_address)
+ && (p_proc->m_pPhdr[i].p_vaddr + p_proc->m_pPhdr[i].p_memsz > p_address)) {
*phdr_num = i;
return CDH_OK;
}
- }
*phdr_num = -1;
return CDH_NOK;
}
-// Thanks to libunwind for the following definitions, which helps to
-#define ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL))
+/* Thanks to libunwind for the following definitions, which helps to */
+#define ALIGN(x, a) (((x) + (a) - 1UL) & ~((a) - 1UL))
#define NOTE_SIZE(_hdr) (sizeof (_hdr) + ALIGN((_hdr).n_namesz, 4) + (_hdr).n_descsz)
-cdh_status_t get_crashed_registers(proc_info_t* p_proc)
+cdh_status_t get_crashed_registers(proc_info_t *p_proc)
{
- int found = CDH_NOK; // CDH_OK, when we find the page note associated to PID of crashed process
+ int found = CDH_NOK; /* CDH_OK, when we find the page note associated to PID of crashed process */
unsigned int offset = 0;
- // TODO: if no notes were found m_note_page_size was not set to 0 which leads to a crash in this loop because it is then used
- // uninitialised here => this is an x86_64 issue
- while (found != CDH_OK && offset < p_proc->m_note_page_size)
- {
- // Crash mentioned in TODO dlt_cdh_coredump.c line 163
- ELF_Nhdr* ptr_note = (ELF_Nhdr*) (p_proc->m_Nhdr + offset);
+ /* TODO: if no notes were found m_note_page_size was not set to 0 which leads to a crash in this loop because it is then used */
+ /* uninitialised here => this is an x86_64 issue */
+ while (found != CDH_OK && offset < p_proc->m_note_page_size) {
+ /* Crash mentioned in TODO dlt_cdh_coredump.c line 163 */
+ ELF_Nhdr *ptr_note = (ELF_Nhdr *)(p_proc->m_Nhdr + offset);
- if (ptr_note->n_type == NT_PRSTATUS)
- {
- // The first PRSTATUS note is the one of the crashed thread
- prstatus_t* prstatus = (prstatus_t*) ((char*) ptr_note + sizeof(ELF_Nhdr) + ALIGN(ptr_note->n_namesz, 4));
+ if (ptr_note->n_type == NT_PRSTATUS) {
+ /* The first PRSTATUS note is the one of the crashed thread */
+ prstatus_t *prstatus = (prstatus_t *)((char *)ptr_note + sizeof(ELF_Nhdr) + ALIGN(ptr_note->n_namesz, 4));
p_proc->m_crashed_pid = prstatus->pr_pid;
@@ -110,35 +105,35 @@ cdh_status_t get_crashed_registers(proc_info_t* p_proc)
#ifdef HAS_CITYHASH_C
-cdh_status_t crashid_cityhash(proc_info_t* p_proc)
+cdh_status_t crashid_cityhash(proc_info_t *p_proc)
{
-#define CRASHID_BUF_SIZE MAX_PROC_NAME_LENGTH+sizeof(uint64_t)
+# define CRASHID_BUF_SIZE MAX_PROC_NAME_LENGTH + sizeof(uint64_t)
char cityhash_in[CRASHID_BUF_SIZE];
- uint64_t cityhash_result=0;
+ uint64_t cityhash_result = 0;
memcpy(cityhash_in, p_proc->name, MAX_PROC_NAME_LENGTH);
- memcpy(cityhash_in+MAX_PROC_NAME_LENGTH, &p_proc->m_crashid_phase1, sizeof(uint64_t));
+ memcpy(cityhash_in + MAX_PROC_NAME_LENGTH, &p_proc->m_crashid_phase1, sizeof(uint64_t));
cityhash_result = CityHash64(cityhash_in, CRASHID_BUF_SIZE);
memcpy(p_proc->m_crashid, &cityhash_result, sizeof(uint64_t));
return CDH_OK;
-#undef CRASHID_BUF_SIZE
+# undef CRASHID_BUF_SIZE
}
-#endif // HAS_CITYHASH_C
+#endif /* HAS_CITYHASH_C */
-cdh_status_t create_crashid(proc_info_t* p_proc)
+cdh_status_t create_crashid(proc_info_t *p_proc)
{
uint32_t final_lr = 0;
uint32_t final_pc = 0;
int pc_phnum = 0;
int lr_phnum = 0;
- // translate address from virtual address (process point of view) to offset in the stack memory page
+ /* translate address from virtual address (process point of view) to offset in the stack memory page */
#define ADDRESS_REBASE(__x, __phdr_num) (__x - p_proc->m_pPhdr[__phdr_num].p_vaddr)
- // read value in the stack at position offset: +/- sizeof(), depends on stack growing upward or downward
-#define READ_STACK_VALUE(__offset, __type) (*(__type*)(stack_page+__offset-sizeof(__type)))
+ /* read value in the stack at position offset: +/- sizeof(), depends on stack growing upward or downward */
+#define READ_STACK_VALUE(__offset, __type) (*(__type *)(stack_page + __offset - sizeof(__type)))
get_phdr_num(p_proc, p_proc->m_registers.pc, &pc_phnum);
final_pc = ADDRESS_REBASE(p_proc->m_registers.pc, pc_phnum);
@@ -149,9 +144,9 @@ cdh_status_t create_crashid(proc_info_t* p_proc)
final_lr = ADDRESS_REBASE(p_proc->m_registers.lr, lr_phnum);
p_proc->m_crashid_phase1 = p_proc->signal << 24;
- p_proc->m_crashid_phase1 |= (uint64_t) final_lr;
+ p_proc->m_crashid_phase1 |= (uint64_t)final_lr;
p_proc->m_crashid_phase1 <<= 32;
- p_proc->m_crashid_phase1 |= (uint64_t) final_pc;
+ p_proc->m_crashid_phase1 |= (uint64_t)final_pc;
#ifdef HAS_CITYHASH_C
crashid_cityhash(p_proc);
@@ -160,44 +155,41 @@ cdh_status_t create_crashid(proc_info_t* p_proc)
#endif
syslog(LOG_INFO,
- "Crash in \"%s\", thread=\"%s\", pid=%d, crashID=%"PRIx64", based on signal=%d, PC=0x%x, caller=0x%x",
- p_proc->name,
- p_proc->threadname,
- p_proc->pid,
- *((uint64_t*) p_proc->m_crashid),
- p_proc->signal,
- final_pc, final_lr
- );
+ "Crash in \"%s\", thread=\"%s\", pid=%d, crashID=%" PRIx64 ", based on signal=%d, PC=0x%x, caller=0x%x",
+ p_proc->name,
+ p_proc->threadname,
+ p_proc->pid,
+ *((uint64_t *)p_proc->m_crashid),
+ p_proc->signal,
+ final_pc, final_lr
+ );
return CDH_OK;
}
-int write_crashid_to_filesystem(proc_info_t* p_proc)
+int write_crashid_to_filesystem(proc_info_t *p_proc)
{
- FILE* crashid_file = NULL;
+ FILE *crashid_file = NULL;
- if ((crashid_file = fopen(CRASHID_FILE, "wt")) == NULL)
- {
+ if ((crashid_file = fopen(CRASHID_FILE, "wt")) == NULL) {
syslog(LOG_ERR, "(pid=%d) cannot write crashid to %s: %s", p_proc->pid, CRASHID_FILE, strerror(errno));
return CDH_NOK;
}
- fprintf(crashid_file, "%"PRIx64, *(uint64_t*) p_proc->m_crashid);
+ fprintf(crashid_file, "%" PRIx64, *(uint64_t *)p_proc->m_crashid);
fclose(crashid_file);
return CDH_OK;
}
-cdh_status_t treat_crash_data(proc_info_t* p_proc)
+cdh_status_t treat_crash_data(proc_info_t *p_proc)
{
- if (get_crashed_registers(p_proc) != CDH_OK)
- {
+ if (get_crashed_registers(p_proc) != CDH_OK) {
syslog(LOG_ERR, "registers not found in notes");
return CDH_NOK;
}
- if (create_crashid(p_proc) != CDH_OK)
- {
+ if (create_crashid(p_proc) != CDH_OK) {
syslog(LOG_ERR, "crashid not generated");
return CDH_NOK;
}
diff --git a/src/core_dump_handler/dlt_cdh_streamer.c b/src/core_dump_handler/dlt_cdh_streamer.c
index 00b6d04..24bcde2 100644
--- a/src/core_dump_handler/dlt_cdh_streamer.c
+++ b/src/core_dump_handler/dlt_cdh_streamer.c
@@ -32,13 +32,12 @@
#include <syslog.h>
#include "dlt_cdh_streamer.h"
-#define Z_CHUNK_SZ 1024*128
+#define Z_CHUNK_SZ 1024 * 128
#define Z_MODE_STR "wb1"
-cdh_status_t stream_init(file_streamer_t* p_fs, const char* p_src_fname, const char* p_dst_fname)
+cdh_status_t stream_init(file_streamer_t *p_fs, const char *p_src_fname, const char *p_dst_fname)
{
- if (p_fs == NULL)
- {
+ if (p_fs == NULL) {
syslog(LOG_ERR, "Internal pointer error in 'stream_init'");
return CDH_NOK;
}
@@ -46,17 +45,15 @@ cdh_status_t stream_init(file_streamer_t* p_fs, const char* p_src_fname, const c
memset(p_fs, 0, sizeof(file_streamer_t));
/* Allow to not save the coredump */
- if (p_dst_fname == NULL)
- {
+ if (p_dst_fname == NULL) {
p_fs->gz_dst_file = 0;
}
- else
- {
- // Create output file
+ else {
+ /* Create output file */
p_fs->gz_dst_file = gzopen(p_dst_fname, Z_MODE_STR);
- if (p_fs->gz_dst_file == Z_NULL)
- {
- //return CDH_NOK;
+
+ if (p_fs->gz_dst_file == Z_NULL) {
+ /*return CDH_NOK; */
syslog(LOG_ERR, "Cannot open output filename <%s>. %s", p_dst_fname, strerror(errno));
p_fs->gz_dst_file = 0;
@@ -66,23 +63,17 @@ cdh_status_t stream_init(file_streamer_t* p_fs, const char* p_src_fname, const c
if (p_fs->gz_dst_file == Z_NULL)
syslog(LOG_WARNING, "The coredump will be processed, but not written");
- // Open input file
- if (p_src_fname == NULL)
- {
+ /* Open input file */
+ if (p_src_fname == NULL) {
p_fs->stream = stdin;
}
- else
- {
- if ((p_fs->stream = fopen(p_src_fname, "rb")) == NULL)
- {
- syslog(LOG_ERR, "Cannot open filename <%s>. %s", p_src_fname, strerror(errno));
- return CDH_NOK;
- }
+ else if ((p_fs->stream = fopen(p_src_fname, "rb")) == NULL) {
+ syslog(LOG_ERR, "Cannot open filename <%s>. %s", p_src_fname, strerror(errno));
+ return CDH_NOK;
}
- // Allocate read buffer
- if ((p_fs->read_buf = (unsigned char*) malloc(Z_CHUNK_SZ)) == NULL)
- {
+ /* Allocate read buffer */
+ if ((p_fs->read_buf = (unsigned char *)malloc(Z_CHUNK_SZ)) == NULL) {
syslog(LOG_ERR, "Cannot allocate %d bytes for read buffer. %s", Z_CHUNK_SZ, strerror(errno));
return CDH_NOK;
}
@@ -90,29 +81,25 @@ cdh_status_t stream_init(file_streamer_t* p_fs, const char* p_src_fname, const c
return CDH_OK;
}
-cdh_status_t stream_close(file_streamer_t* p_fs)
+cdh_status_t stream_close(file_streamer_t *p_fs)
{
- if (p_fs == NULL)
- {
+ if (p_fs == NULL) {
syslog(LOG_ERR, "Internal pointer error in 'stream_close'");
return CDH_NOK;
}
- if (p_fs->gz_dst_file != NULL)
- {
+ if (p_fs->gz_dst_file != NULL) {
gzflush(p_fs->gz_dst_file, Z_FINISH);
gzclose(p_fs->gz_dst_file);
p_fs->gz_dst_file = NULL;
}
- if (p_fs->stream != NULL)
- {
+ if (p_fs->stream != NULL) {
fclose(p_fs->stream);
p_fs->stream = NULL;
}
- if (p_fs->read_buf != NULL)
- {
+ if (p_fs->read_buf != NULL) {
free(p_fs->read_buf);
p_fs->read_buf = NULL;
}
@@ -120,24 +107,21 @@ cdh_status_t stream_close(file_streamer_t* p_fs)
return CDH_OK;
}
-cdh_status_t stream_read(file_streamer_t* p_fs, void* p_buf, unsigned int p_size)
+cdh_status_t stream_read(file_streamer_t *p_fs, void *p_buf, unsigned int p_size)
{
unsigned int byte_read = 0;
- if (p_fs == NULL)
- {
+ if (p_fs == NULL) {
syslog(LOG_ERR, "Internal pointer error in 'stream_read'");
return CDH_NOK;
}
- if (p_buf == NULL)
- {
+ if (p_buf == NULL) {
syslog(LOG_ERR, "Internal buffer pointer error in 'stream_read'");
return CDH_NOK;
}
- if ((byte_read = fread(p_buf, 1, p_size, p_fs->stream)) != p_size)
- {
+ if ((byte_read = fread(p_buf, 1, p_size, p_fs->stream)) != p_size) {
syslog(LOG_WARNING, "Cannot read %d bytes from src. %s", p_size, strerror(errno));
return CDH_NOK;
}
@@ -150,24 +134,22 @@ cdh_status_t stream_read(file_streamer_t* p_fs, void* p_buf, unsigned int p_size
return CDH_OK;
}
-int stream_finish(file_streamer_t* p_fs)
+int stream_finish(file_streamer_t *p_fs)
{
- if (p_fs == NULL || p_fs->stream == NULL)
- {
+ if ((p_fs == NULL) || (p_fs->stream == NULL)) {
syslog(LOG_ERR, "Internal pointer error in 'stream_move_ahead'");
return CDH_NOK;
}
- while (!feof(p_fs->stream))
- {
+ while (!feof(p_fs->stream)) {
size_t read_bytes = fread(p_fs->read_buf, 1, Z_CHUNK_SZ, p_fs->stream);
if (p_fs->gz_dst_file != NULL)
gzwrite(p_fs->gz_dst_file, p_fs->read_buf, read_bytes);
p_fs->offset += read_bytes;
- if (ferror(p_fs->stream))
- {
+
+ if (ferror(p_fs->stream)) {
syslog(LOG_WARNING, "Error reading from the src stream: %s", strerror(errno));
return CDH_NOK;
}
@@ -176,12 +158,11 @@ int stream_finish(file_streamer_t* p_fs)
return CDH_OK;
}
-int stream_move_to_offest(file_streamer_t* p_fs, unsigned int p_offset)
+int stream_move_to_offest(file_streamer_t *p_fs, unsigned int p_offset)
{
int bytes_to_read = 0;
- if (p_fs == NULL)
- {
+ if (p_fs == NULL) {
syslog(LOG_ERR, "Internal pointer error in 'stream_move_to_offest'");
return CDH_NOK;
}
@@ -191,23 +172,20 @@ int stream_move_to_offest(file_streamer_t* p_fs, unsigned int p_offset)
return stream_move_ahead(p_fs, bytes_to_read);
}
-int stream_move_ahead(file_streamer_t* p_fs, unsigned int p_nbbytes)
+int stream_move_ahead(file_streamer_t *p_fs, unsigned int p_nbbytes)
{
int bytes_to_read = p_nbbytes;
- if (p_fs == NULL)
- {
+ if (p_fs == NULL) {
syslog(LOG_ERR, "Internal pointer error in 'stream_move_ahead'");
return CDH_NOK;
}
- while (bytes_to_read > 0)
- {
+ while (bytes_to_read > 0) {
size_t chunk_size = bytes_to_read > Z_CHUNK_SZ ? Z_CHUNK_SZ : bytes_to_read;
size_t read_bytes = fread(p_fs->read_buf, 1, chunk_size, p_fs->stream);
- if (read_bytes != chunk_size)
- {
+ if (read_bytes != chunk_size) {
syslog(LOG_WARNING, "Cannot move ahead by %d bytes from src. Read %lu bytes", p_nbbytes, read_bytes);
return CDH_NOK;
}
@@ -223,10 +201,9 @@ int stream_move_ahead(file_streamer_t* p_fs, unsigned int p_nbbytes)
return CDH_OK;
}
-unsigned int stream_get_offset(file_streamer_t* p_fs)
+unsigned int stream_get_offset(file_streamer_t *p_fs)
{
- if (p_fs == NULL)
- {
+ if (p_fs == NULL) {
syslog(LOG_ERR, "Internal pointer error in 'stream_get_offset'");
return CDH_NOK;
}
diff --git a/src/core_dump_handler/dlt_cdh_streamer.h b/src/core_dump_handler/dlt_cdh_streamer.h
index b73688e..3c6fe2d 100644
--- a/src/core_dump_handler/dlt_cdh_streamer.h
+++ b/src/core_dump_handler/dlt_cdh_streamer.h
@@ -35,19 +35,19 @@
typedef struct
{
- FILE* stream;
+ FILE *stream;
unsigned int offset;
gzFile gz_dst_file;
- unsigned char* read_buf;
+ unsigned char *read_buf;
} file_streamer_t;
-cdh_status_t stream_init(file_streamer_t* p_fs, const char* p_src_fname, const char* p_dst_fname);
-cdh_status_t stream_close(file_streamer_t* p_fs);
-cdh_status_t stream_read(file_streamer_t* p_fs, void* p_buf, unsigned int p_size);
-cdh_status_t stream_finish(file_streamer_t* p_fs);
-cdh_status_t stream_move_to_offest(file_streamer_t* p_fs, unsigned int p_offset);
-cdh_status_t stream_move_ahead(file_streamer_t* p_fs, unsigned int p_nbbytes);
-unsigned int stream_get_offset(file_streamer_t* p_fs);
+cdh_status_t stream_init(file_streamer_t *p_fs, const char *p_src_fname, const char *p_dst_fname);
+cdh_status_t stream_close(file_streamer_t *p_fs);
+cdh_status_t stream_read(file_streamer_t *p_fs, void *p_buf, unsigned int p_size);
+cdh_status_t stream_finish(file_streamer_t *p_fs);
+cdh_status_t stream_move_to_offest(file_streamer_t *p_fs, unsigned int p_offset);
+cdh_status_t stream_move_ahead(file_streamer_t *p_fs, unsigned int p_nbbytes);
+unsigned int stream_get_offset(file_streamer_t *p_fs);
#endif /* #ifndef DLT_CDH_STREAMER_H */
diff --git a/src/core_dump_handler/i686/dlt_cdh_cpuinfo.c b/src/core_dump_handler/i686/dlt_cdh_cpuinfo.c
index 2e547a2..aee7441 100644
--- a/src/core_dump_handler/i686/dlt_cdh_cpuinfo.c
+++ b/src/core_dump_handler/i686/dlt_cdh_cpuinfo.c
@@ -27,11 +27,11 @@
#include "../dlt_cdh_cpuinfo.h"
-void get_registers(prstatus_t* prstatus, cdh_registers_t* registers)
+void get_registers(prstatus_t *prstatus, cdh_registers_t *registers)
{
- struct user_regs_struct* ptr_reg = (struct user_regs_struct*) prstatus->pr_reg;
+ struct user_regs_struct *ptr_reg = (struct user_regs_struct *)prstatus->pr_reg;
- registers->pc = ptr_reg->ecx; // [REG_PROC_COUNTER];
- registers->ip = ptr_reg->eip; // [REG_INSTR_POINTER];
- registers->lr = ptr_reg->ebp; // [REG_LINK_REGISTER];
+ registers->pc = ptr_reg->ecx; /* [REG_PROC_COUNTER]; */
+ registers->ip = ptr_reg->eip; /* [REG_INSTR_POINTER]; */
+ registers->lr = ptr_reg->ebp; /* [REG_LINK_REGISTER]; */
}
diff --git a/src/core_dump_handler/x86_64/dlt_cdh_cpuinfo.c b/src/core_dump_handler/x86_64/dlt_cdh_cpuinfo.c
index 6e526ea..f18720e 100644
--- a/src/core_dump_handler/x86_64/dlt_cdh_cpuinfo.c
+++ b/src/core_dump_handler/x86_64/dlt_cdh_cpuinfo.c
@@ -27,11 +27,11 @@
#include "../dlt_cdh_cpuinfo.h"
-void get_registers(prstatus_t* prstatus, cdh_registers_t* registers)
+void get_registers(prstatus_t *prstatus, cdh_registers_t *registers)
{
- struct user_regs_struct* ptr_reg = (struct user_regs_struct*) prstatus->pr_reg;
+ struct user_regs_struct *ptr_reg = (struct user_regs_struct *)prstatus->pr_reg;
- registers->pc = ptr_reg->rcx; // [REG_PROC_COUNTER];
- registers->ip = ptr_reg->rip; // [REG_INSTR_POINTER];
- registers->lr = ptr_reg->rsp; // [REG_LINK_REGISTER];
+ registers->pc = ptr_reg->rcx; /* [REG_PROC_COUNTER]; */
+ registers->ip = ptr_reg->rip; /* [REG_INSTR_POINTER]; */
+ registers->lr = ptr_reg->rsp; /* [REG_LINK_REGISTER]; */
}
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index e3475d4..b7766f0 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -43,12 +43,12 @@
#include <pthread.h>
#ifdef linux
-#include <sys/timerfd.h>
+# include <sys/timerfd.h>
#endif
#include <sys/stat.h>
#include <sys/time.h>
#if defined(linux) && defined(__NR_statx)
-#include <linux/stat.h>
+# include <linux/stat.h>
#endif
#include "dlt_types.h"
@@ -67,14 +67,14 @@
#include "dlt_gateway.h"
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE)
-#include "sd-daemon.h"
+# include "sd-daemon.h"
#endif
/**
- \defgroup daemon DLT Daemon
- \addtogroup daemon
- \{
-*/
+ * \defgroup daemon DLT Daemon
+ * \addtogroup daemon
+ \{
+ */
/** Global text output buffer, mainly used for creation of error/warning strings */
static char str[DLT_DAEMON_TEXTBUFSIZE];
@@ -82,7 +82,7 @@ static char str[DLT_DAEMON_TEXTBUFSIZE];
static int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose);
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
-static uint32_t watchdog_trigger_interval; // watchdog trigger interval in [s]
+static uint32_t watchdog_trigger_interval; /* watchdog trigger interval in [s] */
#endif
/* used in main event loop and signal handler */
@@ -96,10 +96,10 @@ int g_signo = 0;
void usage()
{
char version[DLT_DAEMON_TEXTBUFSIZE];
- dlt_get_version(version,DLT_DAEMON_TEXTBUFSIZE);
+ dlt_get_version(version, DLT_DAEMON_TEXTBUFSIZE);
- //printf("DLT logging daemon %s %s\n", _DLT_PACKAGE_VERSION, _DLT_PACKAGE_VERSION_STATE);
- //printf("Compile options: %s %s %s %s",_DLT_SYSTEMD_ENABLE, _DLT_SYSTEMD_WATCHDOG_ENABLE, _DLT_TEST_ENABLE, _DLT_SHM_ENABLE);
+ /*printf("DLT logging daemon %s %s\n", _DLT_PACKAGE_VERSION, _DLT_PACKAGE_VERSION_STATE); */
+ /*printf("Compile options: %s %s %s %s",_DLT_SYSTEMD_ENABLE, _DLT_SYSTEMD_WATCHDOG_ENABLE, _DLT_TEST_ENABLE, _DLT_SHM_ENABLE); */
printf("%s", version);
printf("Usage: dlt-daemon [options]\n");
printf("Options:\n");
@@ -119,18 +119,17 @@ void usage()
/**
* Option handling
*/
-int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
- {
+int option_handling(DltDaemonLocal *daemon_local, int argc, char *argv[])
+{
int c;
- if (daemon_local==0)
- {
+ if (daemon_local == 0) {
fprintf (stderr, "Invalid parameter passed to option_handling()\n");
return -1;
}
/* Initialize flags */
- memset(daemon_local,0,sizeof(DltDaemonLocal));
+ memset(daemon_local, 0, sizeof(DltDaemonLocal));
/* default values */
daemon_local->flags.port = DLT_DAEMON_TCP_PORT;
@@ -139,9 +138,7 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
opterr = 0;
while ((c = getopt (argc, argv, "hdc:t:p:")) != -1)
- {
- switch (c)
- {
+ switch (c) {
case 'd':
{
daemon_local->flags.dflag = 1;
@@ -149,7 +146,7 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
}
case 'c':
{
- strncpy(daemon_local->flags.cvalue,optarg,NAME_MAX);
+ strncpy(daemon_local->flags.cvalue, optarg, NAME_MAX);
break;
}
case 't':
@@ -160,11 +157,12 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
case 'p':
{
daemon_local->flags.port = atoi(optarg);
- if (daemon_local->flags.port == 0)
- {
- fprintf (stderr, "Invalid port `%s' specified.\n", optarg);
- return -1;
+
+ if (daemon_local->flags.port == 0) {
+ fprintf (stderr, "Invalid port `%s' specified.\n", optarg);
+ return -1;
}
+
break;
}
case 'h':
@@ -174,18 +172,13 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
}
case '?':
{
- if (optopt == 'c' || optopt == 't' || optopt == 'p')
- {
+ if ((optopt == 'c') || (optopt == 't') || (optopt == 'p'))
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
/* unknown or wrong option used, show usage information and terminate */
usage();
return -1;
@@ -196,7 +189,7 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
return -1;
}
} /* switch() */
- }
+
#ifndef DLT_USE_UNIX_SOCKET_IPC
snprintf(daemon_local->flags.userPipesDir, NAME_MAX + 1, "%s/dltpipes", dltFifoBaseDir);
@@ -205,385 +198,388 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
return 0;
- } /* option_handling() */
+} /* option_handling() */
/**
* Option file parser
*/
int option_file_parser(DltDaemonLocal *daemon_local)
{
- FILE * pFile;
- int value_length = 1024;
- char line[value_length-1];
- char token[value_length];
- char value[value_length];
+ FILE *pFile;
+ int value_length = 1024;
+ char line[value_length - 1];
+ char token[value_length];
+ char value[value_length];
char *pch;
const char *filename;
- /* set default values for configuration */
- daemon_local->flags.sharedMemorySize = DLT_SHM_SIZE;
- daemon_local->flags.sendMessageTime = 0;
- daemon_local->flags.offlineTraceDirectory[0] = 0;
- daemon_local->flags.offlineTraceFileSize = 1000000;
- daemon_local->flags.offlineTraceMaxSize = 0;
- daemon_local->flags.offlineTraceFilenameTimestampBased = 1;
- daemon_local->flags.loggingMode = DLT_LOG_TO_CONSOLE;
- daemon_local->flags.loggingLevel = LOG_INFO;
- snprintf(daemon_local->flags.loggingFilename, sizeof(daemon_local->flags.loggingFilename)-1, "%s/dlt.log", dltFifoBaseDir);
- daemon_local->flags.loggingFilename[sizeof(daemon_local->flags.loggingFilename)-1]=0;
- daemon_local->timeoutOnSend = 4;
- daemon_local->RingbufferMinSize = DLT_DAEMON_RINGBUFFER_MIN_SIZE;
- daemon_local->RingbufferMaxSize = DLT_DAEMON_RINGBUFFER_MAX_SIZE;
- daemon_local->RingbufferStepSize = DLT_DAEMON_RINGBUFFER_STEP_SIZE;
- daemon_local->daemonFifoSize = 0;
- daemon_local->flags.sendECUSoftwareVersion = 0;
- memset(daemon_local->flags.pathToECUSoftwareVersion, 0, sizeof(daemon_local->flags.pathToECUSoftwareVersion));
- daemon_local->flags.sendTimezone = 0;
- daemon_local->flags.offlineLogstorageMaxDevices = 0;
- daemon_local->flags.offlineLogstorageDirPath[0] = 0;
- daemon_local->flags.offlineLogstorageMaxDevices = 0;
- daemon_local->flags.offlineLogstorageTimestamp = 1;
- daemon_local->flags.offlineLogstorageDelimiter = '_';
- daemon_local->flags.offlineLogstorageMaxCounter = UINT_MAX;
- daemon_local->flags.offlineLogstorageMaxCounterIdx = 0;
- daemon_local->flags.offlineLogstorageCacheSize = 30000; /* 30MB */
- dlt_daemon_logstorage_set_logstorage_cache_size(
- daemon_local->flags.offlineLogstorageCacheSize);
- strncpy(daemon_local->flags.ctrlSockPath,
+ /* set default values for configuration */
+ daemon_local->flags.sharedMemorySize = DLT_SHM_SIZE;
+ daemon_local->flags.sendMessageTime = 0;
+ daemon_local->flags.offlineTraceDirectory[0] = 0;
+ daemon_local->flags.offlineTraceFileSize = 1000000;
+ daemon_local->flags.offlineTraceMaxSize = 0;
+ daemon_local->flags.offlineTraceFilenameTimestampBased = 1;
+ daemon_local->flags.loggingMode = DLT_LOG_TO_CONSOLE;
+ daemon_local->flags.loggingLevel = LOG_INFO;
+ snprintf(daemon_local->flags.loggingFilename,
+ sizeof(daemon_local->flags.loggingFilename) - 1,
+ "%s/dlt.log",
+ dltFifoBaseDir);
+ daemon_local->flags.loggingFilename[sizeof(daemon_local->flags.loggingFilename) - 1] = 0;
+ daemon_local->timeoutOnSend = 4;
+ daemon_local->RingbufferMinSize = DLT_DAEMON_RINGBUFFER_MIN_SIZE;
+ daemon_local->RingbufferMaxSize = DLT_DAEMON_RINGBUFFER_MAX_SIZE;
+ daemon_local->RingbufferStepSize = DLT_DAEMON_RINGBUFFER_STEP_SIZE;
+ daemon_local->daemonFifoSize = 0;
+ daemon_local->flags.sendECUSoftwareVersion = 0;
+ memset(daemon_local->flags.pathToECUSoftwareVersion, 0, sizeof(daemon_local->flags.pathToECUSoftwareVersion));
+ daemon_local->flags.sendTimezone = 0;
+ daemon_local->flags.offlineLogstorageMaxDevices = 0;
+ daemon_local->flags.offlineLogstorageDirPath[0] = 0;
+ daemon_local->flags.offlineLogstorageMaxDevices = 0;
+ daemon_local->flags.offlineLogstorageTimestamp = 1;
+ daemon_local->flags.offlineLogstorageDelimiter = '_';
+ daemon_local->flags.offlineLogstorageMaxCounter = UINT_MAX;
+ daemon_local->flags.offlineLogstorageMaxCounterIdx = 0;
+ daemon_local->flags.offlineLogstorageCacheSize = 30000; /* 30MB */
+ dlt_daemon_logstorage_set_logstorage_cache_size(
+ daemon_local->flags.offlineLogstorageCacheSize);
+ strncpy(daemon_local->flags.ctrlSockPath,
DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH,
sizeof(daemon_local->flags.ctrlSockPath) - 1);
#ifdef DLT_USE_UNIX_SOCKET_IPC
- snprintf(daemon_local->flags.appSockPath, DLT_IPC_PATH_MAX, "%s/dlt", DLT_USER_IPC_PATH);
- if (strlen(DLT_USER_IPC_PATH) > DLT_IPC_PATH_MAX)
- {
- fprintf(stderr,"Provided path too long...trimming it to path[%s]\n",
- daemon_local->flags.appSockPath);
- }
+ snprintf(daemon_local->flags.appSockPath, DLT_IPC_PATH_MAX, "%s/dlt", DLT_USER_IPC_PATH);
+
+ if (strlen(DLT_USER_IPC_PATH) > DLT_IPC_PATH_MAX)
+ fprintf(stderr, "Provided path too long...trimming it to path[%s]\n",
+ daemon_local->flags.appSockPath);
+
#endif
- daemon_local->flags.gatewayMode = 0;
+ daemon_local->flags.gatewayMode = 0;
strncpy(daemon_local->flags.gatewayConfigFile,
DLT_GATEWAY_CONFIG_PATH,
DLT_DAEMON_FLAG_MAX - 1);
- daemon_local->flags.autoResponseGetLogInfoOption = 7;
- daemon_local->flags.contextLogLevel = DLT_LOG_INFO;
- daemon_local->flags.contextTraceStatus = DLT_TRACE_STATUS_OFF;
- daemon_local->flags.enforceContextLLAndTS = 0; /* default is off */
-
- /* open configuration file */
- if(daemon_local->flags.cvalue[0])
- filename = daemon_local->flags.cvalue;
- else
- filename = CONFIGURATION_FILES_DIR "/dlt.conf";
- //printf("Load configuration from file: %s\n",filename);
- pFile = fopen (filename,"r");
-
- if (pFile!=NULL)
- {
- while(1)
- {
+ daemon_local->flags.autoResponseGetLogInfoOption = 7;
+ daemon_local->flags.contextLogLevel = DLT_LOG_INFO;
+ daemon_local->flags.contextTraceStatus = DLT_TRACE_STATUS_OFF;
+ daemon_local->flags.enforceContextLLAndTS = 0; /* default is off */
+
+ /* open configuration file */
+ if (daemon_local->flags.cvalue[0])
+ filename = daemon_local->flags.cvalue;
+ else
+ filename = CONFIGURATION_FILES_DIR "/dlt.conf";
+
+ /*printf("Load configuration from file: %s\n",filename); */
+ pFile = fopen (filename, "r");
+
+ if (pFile != NULL) {
+ while (1) {
/* fetch line from configuration file */
- if ( fgets (line , value_length - 1 , pFile) != NULL )
- {
- pch = strtok (line," =\r\n");
- token[0]=0;
- value[0]=0;
-
- while (pch != NULL)
- {
- if(strcmp(pch,"#")==0)
+ if (fgets (line, value_length - 1, pFile) != NULL) {
+ pch = strtok (line, " =\r\n");
+ token[0] = 0;
+ value[0] = 0;
+
+ while (pch != NULL) {
+ if (strcmp(pch, "#") == 0)
break;
- if(token[0]==0)
- {
- strncpy(token,pch,sizeof(token) - 1);
- token[sizeof(token) - 1]=0;
+ if (token[0] == 0) {
+ strncpy(token, pch, sizeof(token) - 1);
+ token[sizeof(token) - 1] = 0;
}
- else
- {
- strncpy(value,pch,sizeof(value) - 1);
- value[sizeof(value) - 1]=0;
+ else {
+ strncpy(value, pch, sizeof(value) - 1);
+ value[sizeof(value) - 1] = 0;
break;
}
pch = strtok (NULL, " =\r\n");
- }
-
- if(token[0] && value[0])
- {
- /* parse arguments here */
- if(strcmp(token,"Verbose")==0)
- {
- daemon_local->flags.vflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"PrintASCII")==0)
- {
- daemon_local->flags.aflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"PrintHex")==0)
- {
- daemon_local->flags.xflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"PrintHeadersOnly")==0)
- {
- daemon_local->flags.sflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendSerialHeader")==0)
- {
- daemon_local->flags.lflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendContextRegistration")==0)
- {
- daemon_local->flags.rflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendContextRegistrationOption")==0)
- {
- daemon_local->flags.autoResponseGetLogInfoOption = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendMessageTime")==0)
- {
- daemon_local->flags.sendMessageTime = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"RS232SyncSerialHeader")==0)
- {
- daemon_local->flags.mflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"TCPSyncSerialHeader")==0)
- {
- daemon_local->flags.nflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"RS232DeviceName")==0)
- {
- strncpy(daemon_local->flags.yvalue,value,NAME_MAX);
- daemon_local->flags.yvalue[NAME_MAX]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"RS232Baudrate")==0)
- {
- strncpy(daemon_local->flags.bvalue,value,NAME_MAX);
- daemon_local->flags.bvalue[NAME_MAX]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"ECUId")==0)
- {
- strncpy(daemon_local->flags.evalue,value,NAME_MAX);
- daemon_local->flags.evalue[NAME_MAX]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"PersistanceStoragePath")==0)
- {
- strncpy(daemon_local->flags.ivalue,value,NAME_MAX);
- daemon_local->flags.ivalue[NAME_MAX]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"LoggingMode")==0)
- {
- daemon_local->flags.loggingMode = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"LoggingLevel")==0)
- {
- daemon_local->flags.loggingLevel = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"LoggingFilename")==0)
- {
- strncpy(daemon_local->flags.loggingFilename,value,sizeof(daemon_local->flags.loggingFilename) - 1);
- daemon_local->flags.loggingFilename[sizeof(daemon_local->flags.loggingFilename) - 1]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"TimeOutOnSend")==0)
- {
- daemon_local->timeoutOnSend = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"RingbufferMinSize")==0)
- {
- sscanf(value,"%lu",&(daemon_local->RingbufferMinSize));
- }
- else if(strcmp(token,"RingbufferMaxSize")==0)
- {
- sscanf(value,"%lu",&(daemon_local->RingbufferMaxSize));
- }
- else if(strcmp(token,"RingbufferStepSize")==0)
- {
- sscanf(value,"%lu",&(daemon_local->RingbufferStepSize));
- }
- else if(strcmp(token,"DaemonFIFOSize")==0)
- {
- sscanf(value,"%lu",&(daemon_local->daemonFifoSize));
- }
- else if(strcmp(token,"SharedMemorySize")==0)
- {
- daemon_local->flags.sharedMemorySize = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"OfflineTraceDirectory")==0)
- {
- strncpy(daemon_local->flags.offlineTraceDirectory,value,sizeof(daemon_local->flags.offlineTraceDirectory) - 1);
- daemon_local->flags.offlineTraceDirectory[sizeof(daemon_local->flags.offlineTraceDirectory) - 1]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"OfflineTraceFileSize")==0)
- {
- daemon_local->flags.offlineTraceFileSize = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"OfflineTraceMaxSize")==0)
- {
- daemon_local->flags.offlineTraceMaxSize = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"OfflineTraceFileNameTimestampBased")==0)
- {
- daemon_local->flags.offlineTraceFilenameTimestampBased = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendECUSoftwareVersion")==0)
- {
- daemon_local->flags.sendECUSoftwareVersion = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"PathToECUSoftwareVersion")==0)
- {
- strncpy(daemon_local->flags.pathToECUSoftwareVersion,value,sizeof(daemon_local->flags.pathToECUSoftwareVersion) - 1);
- daemon_local->flags.pathToECUSoftwareVersion[sizeof(daemon_local->flags.pathToECUSoftwareVersion) - 1]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendTimezone")==0)
- {
- daemon_local->flags.sendTimezone = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token, "OfflineLogstorageMaxDevices") == 0)
- {
- daemon_local->flags.offlineLogstorageMaxDevices = atoi(value);
- }
- else if(strcmp(token, "OfflineLogstorageDirPath") == 0)
- {
- strncpy(daemon_local->flags.offlineLogstorageDirPath,
- value,
- sizeof(daemon_local->flags.offlineLogstorageDirPath) - 1);
- }
- else if(strcmp(token, "OfflineLogstorageTimestamp") == 0)
- {
- /* Check if set to 0, default otherwise */
- if(atoi(value) == 0)
- {
- daemon_local->flags.offlineLogstorageTimestamp = 0;
- }
- }
- else if(strcmp(token, "OfflineLogstorageDelimiter") == 0)
- {
- /* Check if valid punctuation, default otherwise*/
- if(ispunct((char)value[0]))
- {
- daemon_local->flags.offlineLogstorageDelimiter = (char)value[0];
- }
- }
- else if(strcmp(token, "OfflineLogstorageMaxCounter") == 0)
- {
- daemon_local->flags.offlineLogstorageMaxCounter = atoi(value);
- daemon_local->flags.offlineLogstorageMaxCounterIdx = strlen(value);
- }
- else if(strcmp(token, "OfflineLogstorageCacheSize") == 0)
- {
- daemon_local->flags.offlineLogstorageCacheSize =
- (unsigned int)atoi(value);
- dlt_daemon_logstorage_set_logstorage_cache_size(
- daemon_local->flags.offlineLogstorageCacheSize);
- }
- else if(strcmp(token,"ControlSocketPath") == 0)
- {
- memset(
- daemon_local->flags.ctrlSockPath,
- 0,
- DLT_DAEMON_FLAG_MAX);
- strncpy(
- daemon_local->flags.ctrlSockPath,
+ }
+
+ if (token[0] && value[0]) {
+ /* parse arguments here */
+ if (strcmp(token, "Verbose") == 0) {
+ daemon_local->flags.vflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "PrintASCII") == 0)
+ {
+ daemon_local->flags.aflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "PrintHex") == 0)
+ {
+ daemon_local->flags.xflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "PrintHeadersOnly") == 0)
+ {
+ daemon_local->flags.sflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendSerialHeader") == 0)
+ {
+ daemon_local->flags.lflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendContextRegistration") == 0)
+ {
+ daemon_local->flags.rflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendContextRegistrationOption") == 0)
+ {
+ daemon_local->flags.autoResponseGetLogInfoOption = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendMessageTime") == 0)
+ {
+ daemon_local->flags.sendMessageTime = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "RS232SyncSerialHeader") == 0)
+ {
+ daemon_local->flags.mflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "TCPSyncSerialHeader") == 0)
+ {
+ daemon_local->flags.nflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "RS232DeviceName") == 0)
+ {
+ strncpy(daemon_local->flags.yvalue, value, NAME_MAX);
+ daemon_local->flags.yvalue[NAME_MAX] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "RS232Baudrate") == 0)
+ {
+ strncpy(daemon_local->flags.bvalue, value, NAME_MAX);
+ daemon_local->flags.bvalue[NAME_MAX] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "ECUId") == 0)
+ {
+ strncpy(daemon_local->flags.evalue, value, NAME_MAX);
+ daemon_local->flags.evalue[NAME_MAX] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "PersistanceStoragePath") == 0)
+ {
+ strncpy(daemon_local->flags.ivalue, value, NAME_MAX);
+ daemon_local->flags.ivalue[NAME_MAX] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "LoggingMode") == 0)
+ {
+ daemon_local->flags.loggingMode = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "LoggingLevel") == 0)
+ {
+ daemon_local->flags.loggingLevel = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "LoggingFilename") == 0)
+ {
+ strncpy(daemon_local->flags.loggingFilename,
value,
- DLT_DAEMON_FLAG_MAX-1);
- }
- else if(strcmp(token,"GatewayMode")==0)
- {
- daemon_local->flags.gatewayMode = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"GatewayConfigFile")==0)
- {
- memset(
- daemon_local->flags.gatewayConfigFile,
- 0,
- DLT_DAEMON_FLAG_MAX);
- strncpy(
- daemon_local->flags.gatewayConfigFile,
+ sizeof(daemon_local->flags.loggingFilename) - 1);
+ daemon_local->flags.loggingFilename[sizeof(daemon_local->flags.loggingFilename) - 1] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "TimeOutOnSend") == 0)
+ {
+ daemon_local->timeoutOnSend = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "RingbufferMinSize") == 0)
+ {
+ sscanf(value, "%lu", &(daemon_local->RingbufferMinSize));
+ }
+ else if (strcmp(token, "RingbufferMaxSize") == 0)
+ {
+ sscanf(value, "%lu", &(daemon_local->RingbufferMaxSize));
+ }
+ else if (strcmp(token, "RingbufferStepSize") == 0)
+ {
+ sscanf(value, "%lu", &(daemon_local->RingbufferStepSize));
+ }
+ else if (strcmp(token, "DaemonFIFOSize") == 0)
+ {
+ sscanf(value, "%lu", &(daemon_local->daemonFifoSize));
+ }
+ else if (strcmp(token, "SharedMemorySize") == 0)
+ {
+ daemon_local->flags.sharedMemorySize = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "OfflineTraceDirectory") == 0)
+ {
+ strncpy(daemon_local->flags.offlineTraceDirectory, value,
+ sizeof(daemon_local->flags.offlineTraceDirectory) - 1);
+ daemon_local->flags.offlineTraceDirectory[sizeof(daemon_local->flags.offlineTraceDirectory) -
+ 1] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "OfflineTraceFileSize") == 0)
+ {
+ daemon_local->flags.offlineTraceFileSize = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "OfflineTraceMaxSize") == 0)
+ {
+ daemon_local->flags.offlineTraceMaxSize = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "OfflineTraceFileNameTimestampBased") == 0)
+ {
+ daemon_local->flags.offlineTraceFilenameTimestampBased = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendECUSoftwareVersion") == 0)
+ {
+ daemon_local->flags.sendECUSoftwareVersion = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "PathToECUSoftwareVersion") == 0)
+ {
+ strncpy(daemon_local->flags.pathToECUSoftwareVersion, value,
+ sizeof(daemon_local->flags.pathToECUSoftwareVersion) - 1);
+ daemon_local->flags.pathToECUSoftwareVersion[sizeof(daemon_local->flags.pathToECUSoftwareVersion)
+ - 1] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendTimezone") == 0)
+ {
+ daemon_local->flags.sendTimezone = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "OfflineLogstorageMaxDevices") == 0)
+ {
+ daemon_local->flags.offlineLogstorageMaxDevices = atoi(value);
+ }
+ else if (strcmp(token, "OfflineLogstorageDirPath") == 0)
+ {
+ strncpy(daemon_local->flags.offlineLogstorageDirPath,
value,
- DLT_DAEMON_FLAG_MAX-1);
+ sizeof(daemon_local->flags.offlineLogstorageDirPath) - 1);
+ }
+ else if (strcmp(token, "OfflineLogstorageTimestamp") == 0)
+ {
+ /* Check if set to 0, default otherwise */
+ if (atoi(value) == 0)
+ daemon_local->flags.offlineLogstorageTimestamp = 0;
+ }
+ else if (strcmp(token, "OfflineLogstorageDelimiter") == 0)
+ {
+ /* Check if valid punctuation, default otherwise*/
+ if (ispunct((char)value[0]))
+ daemon_local->flags.offlineLogstorageDelimiter = (char)value[0];
+ }
+ else if (strcmp(token, "OfflineLogstorageMaxCounter") == 0)
+ {
+ daemon_local->flags.offlineLogstorageMaxCounter = atoi(value);
+ daemon_local->flags.offlineLogstorageMaxCounterIdx = strlen(value);
+ }
+ else if (strcmp(token, "OfflineLogstorageCacheSize") == 0)
+ {
+ daemon_local->flags.offlineLogstorageCacheSize =
+ (unsigned int)atoi(value);
+ dlt_daemon_logstorage_set_logstorage_cache_size(
+ daemon_local->flags.offlineLogstorageCacheSize);
+ }
+ else if (strcmp(token, "ControlSocketPath") == 0)
+ {
+ memset(
+ daemon_local->flags.ctrlSockPath,
+ 0,
+ DLT_DAEMON_FLAG_MAX);
+ strncpy(
+ daemon_local->flags.ctrlSockPath,
+ value,
+ DLT_DAEMON_FLAG_MAX - 1);
+ }
+ else if (strcmp(token, "GatewayMode") == 0)
+ {
+ daemon_local->flags.gatewayMode = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "GatewayConfigFile") == 0)
+ {
+ memset(
+ daemon_local->flags.gatewayConfigFile,
+ 0,
+ DLT_DAEMON_FLAG_MAX);
+ strncpy(
+ daemon_local->flags.gatewayConfigFile,
+ value,
+ DLT_DAEMON_FLAG_MAX - 1);
+ }
+ else if (strcmp(token, "ContextLogLevel") == 0)
+ {
+ int const intval = atoi(value);
+
+ if ((intval >= DLT_LOG_OFF) && (intval <= DLT_LOG_VERBOSE)) {
+ daemon_local->flags.contextLogLevel = intval;
+ printf("Option: %s=%s\n", token, value);
}
- else if(strcmp(token,"ContextLogLevel")==0)
- {
- int const intval = atoi(value);
- if ( (intval >= DLT_LOG_OFF) && (intval <= DLT_LOG_VERBOSE))
- {
- daemon_local->flags.contextLogLevel = intval;
- printf("Option: %s=%s\n",token,value);
- }
- else
- {
- fprintf(stderr, "Invalid value for ContextLogLevel: %i. Must be in range [%i..%i]\n", intval, DLT_LOG_OFF, DLT_LOG_VERBOSE);
- }
+ else {
+ fprintf(stderr,
+ "Invalid value for ContextLogLevel: %i. Must be in range [%i..%i]\n",
+ intval,
+ DLT_LOG_OFF,
+ DLT_LOG_VERBOSE);
}
- else if(strcmp(token,"ContextTraceStatus")==0)
- {
- int const intval = atoi(value);
- if ( (intval >= DLT_TRACE_STATUS_OFF) && (intval <= DLT_TRACE_STATUS_ON))
- {
- daemon_local->flags.contextTraceStatus = intval;
- printf("Option: %s=%s\n",token,value);
- }
- else
- {
- fprintf(stderr, "Invalid value for ContextTraceStatus: %i. Must be in range [%i..%i]\n", intval, DLT_TRACE_STATUS_OFF, DLT_TRACE_STATUS_ON);
- }
+ }
+ else if (strcmp(token, "ContextTraceStatus") == 0)
+ {
+ int const intval = atoi(value);
+
+ if ((intval >= DLT_TRACE_STATUS_OFF) && (intval <= DLT_TRACE_STATUS_ON)) {
+ daemon_local->flags.contextTraceStatus = intval;
+ printf("Option: %s=%s\n", token, value);
}
- else if(strcmp(token,"ForceContextLogLevelAndTraceStatus")==0)
- {
- int const intval = atoi(value);
- if ( (intval >= 0) && (intval <= 1))
- {
- daemon_local->flags.enforceContextLLAndTS = intval;
- printf("Option: %s=%s\n",token,value);
- }
- else
- {
- fprintf(stderr, "Invalid value for ForceContextLogLevelAndTraceStatus: %i. Must be 0, 1\n", intval);
- }
+ else {
+ fprintf(stderr,
+ "Invalid value for ContextTraceStatus: %i. Must be in range [%i..%i]\n",
+ intval,
+ DLT_TRACE_STATUS_OFF,
+ DLT_TRACE_STATUS_ON);
+ }
+ }
+ else if (strcmp(token, "ForceContextLogLevelAndTraceStatus") == 0)
+ {
+ int const intval = atoi(value);
+
+ if ((intval >= 0) && (intval <= 1)) {
+ daemon_local->flags.enforceContextLLAndTS = intval;
+ printf("Option: %s=%s\n", token, value);
}
- else
- {
- fprintf(stderr, "Unknown option: %s=%s\n",token,value);
+ else {
+ fprintf(stderr,
+ "Invalid value for ForceContextLogLevelAndTraceStatus: %i. Must be 0, 1\n",
+ intval);
}
}
+ else {
+ fprintf(stderr, "Unknown option: %s=%s\n", token, value);
+ }
+ }
}
- else
- {
+ else {
break;
}
}
+
fclose (pFile);
}
- else
- {
- fprintf(stderr, "Cannot open configuration file: %s\n",filename);
+ else {
+ fprintf(stderr, "Cannot open configuration file: %s\n", filename);
}
return 0;
@@ -594,18 +590,16 @@ static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
{
int ret = DLT_RETURN_OK;
- if (dir == NULL)
- {
+ if (dir == NULL) {
dlt_vlog(LOG_ERR, "%s: Invalid parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
/* create dlt pipes directory */
ret = mkdir(dir,
- S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH|S_ISVTX);
+ S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_ISVTX);
- if ((ret == -1) && (errno != EEXIST))
- {
+ if ((ret == -1) && (errno != EEXIST)) {
dlt_vlog(LOG_ERR,
"FIFO user dir %s cannot be created (%s)!\n",
dir,
@@ -614,12 +608,12 @@ static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
return DLT_RETURN_ERROR;
}
- // S_ISGID cannot be set by mkdir, let's reassign right bits
+ /* S_ISGID cannot be set by mkdir, let's reassign right bits */
ret = chmod(dir,
- S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH|S_ISGID|S_ISVTX);
+ S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH | S_ISGID |
+ S_ISVTX);
- if (ret == -1)
- {
+ if (ret == -1) {
dlt_vlog(LOG_ERR,
"FIFO user dir %s cannot be chmoded (%s)!\n",
dir,
@@ -635,7 +629,7 @@ static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
char version[DLT_DAEMON_TEXTBUFSIZE];
DltDaemonLocal daemon_local;
@@ -646,20 +640,18 @@ int main(int argc, char* argv[])
memset(&daemon, 0, sizeof(DltDaemon));
/* Command line option handling */
- if ((back = option_handling(&daemon_local,argc,argv))<0)
- {
- if(back!=-2) {
+ if ((back = option_handling(&daemon_local, argc, argv)) < 0) {
+ if (back != -2)
fprintf (stderr, "option_handling() failed!\n");
- }
+
return -1;
}
/* Configuration file option handling */
- if ((back = option_file_parser(&daemon_local))<0)
- {
- if(back!=-2) {
+ if ((back = option_file_parser(&daemon_local)) < 0) {
+ if (back != -2)
fprintf (stderr, "option_file_parser() failed!\n");
- }
+
return -1;
}
@@ -669,78 +661,75 @@ int main(int argc, char* argv[])
dlt_log_init(daemon_local.flags.loggingMode);
/* Print version information */
- dlt_get_version(version,DLT_DAEMON_TEXTBUFSIZE);
+ dlt_get_version(version, DLT_DAEMON_TEXTBUFSIZE);
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"Starting DLT Daemon; %s\n", version );
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Starting DLT Daemon; %s\n", version);
dlt_log(LOG_NOTICE, str);
PRINT_FUNCTION_VERBOSE(daemon_local.flags.vflag);
#ifndef DLT_USE_UNIX_SOCKET_IPC
+
/* Make sure the parent user directory is created */
- if (dlt_mkdir_recursive(dltFifoBaseDir) != 0)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE, "Base dir %s cannot be created!\n", dltFifoBaseDir);
- dlt_log(LOG_ERR, str);
- return -1;
+ if (dlt_mkdir_recursive(dltFifoBaseDir) != 0) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Base dir %s cannot be created!\n", dltFifoBaseDir);
+ dlt_log(LOG_ERR, str);
+ return -1;
}
+
#endif
/* --- Daemon init phase 1 begin --- */
- if (dlt_daemon_local_init_p1(&daemon, &daemon_local, daemon_local.flags.vflag)==-1)
- {
- dlt_log(LOG_CRIT,"Initialization of phase 1 failed!\n");
+ if (dlt_daemon_local_init_p1(&daemon, &daemon_local, daemon_local.flags.vflag) == -1) {
+ dlt_log(LOG_CRIT, "Initialization of phase 1 failed!\n");
return -1;
}
+
/* --- Daemon init phase 1 end --- */
- if (dlt_daemon_prepare_event_handling(&daemon_local.pEvent))
- {
+ if (dlt_daemon_prepare_event_handling(&daemon_local.pEvent)) {
/* TODO: Perform clean-up */
- dlt_log(LOG_CRIT,"Initialization of event handling failed!\n");
+ dlt_log(LOG_CRIT, "Initialization of event handling failed!\n");
return -1;
}
/* --- Daemon connection init begin */
- if (dlt_daemon_local_connection_init(&daemon, &daemon_local, daemon_local.flags.vflag)==-1)
- {
- dlt_log(LOG_CRIT,"Initialization of local connections failed!\n");
+ if (dlt_daemon_local_connection_init(&daemon, &daemon_local, daemon_local.flags.vflag) == -1) {
+ dlt_log(LOG_CRIT, "Initialization of local connections failed!\n");
return -1;
}
+
/* --- Daemon connection init end */
/* --- Daemon init phase 2 begin --- */
- if (dlt_daemon_local_init_p2(&daemon, &daemon_local, daemon_local.flags.vflag)==-1)
- {
- dlt_log(LOG_CRIT,"Initialization of phase 2 failed!\n");
+ if (dlt_daemon_local_init_p2(&daemon, &daemon_local, daemon_local.flags.vflag) == -1) {
+ dlt_log(LOG_CRIT, "Initialization of phase 2 failed!\n");
return -1;
}
+
/* --- Daemon init phase 2 end --- */
- if(daemon_local.flags.offlineLogstorageDirPath[0])
- {
+ if (daemon_local.flags.offlineLogstorageDirPath[0]) {
if (dlt_daemon_logstorage_setup_internal_storage(
&daemon,
&daemon_local,
daemon_local.flags.offlineLogstorageDirPath,
daemon_local.flags.vflag) == -1)
- {
dlt_log(LOG_INFO,
"Setting up internal offline log storage failed!\n");
- }
}
- // create fd for watchdog
+ /* create fd for watchdog */
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
{
- char* watchdogUSec = getenv("WATCHDOG_USEC");
+ char *watchdogUSec = getenv("WATCHDOG_USEC");
int watchdogTimeoutSeconds = 0;
dlt_log(LOG_DEBUG, "Systemd watchdog initialization\n");
- if( watchdogUSec )
- {
- watchdogTimeoutSeconds = atoi(watchdogUSec)/2000000;
- }
+
+ if (watchdogUSec)
+ watchdogTimeoutSeconds = atoi(watchdogUSec) / 2000000;
+
watchdog_trigger_interval = watchdogTimeoutSeconds;
create_timer_fd(&daemon_local,
watchdogTimeoutSeconds,
@@ -749,21 +738,17 @@ int main(int argc, char* argv[])
}
#endif
- // create fd for timer timing packets
+ /* create fd for timer timing packets */
create_timer_fd(&daemon_local, 1, 1, DLT_TIMER_PACKET);
- // create fd for timer ecu version
- if((daemon_local.flags.sendECUSoftwareVersion > 0) ||
- (daemon_local.flags.sendTimezone > 0))
- {
+ /* create fd for timer ecu version */
+ if ((daemon_local.flags.sendECUSoftwareVersion > 0) ||
+ (daemon_local.flags.sendTimezone > 0))
create_timer_fd(&daemon_local, 60, 60, DLT_TIMER_ECU);
- }
/* initiate gateway */
- if (daemon_local.flags.gatewayMode == 1)
- {
- if (dlt_gateway_init(&daemon_local, daemon_local.flags.vflag) == -1)
- {
+ if (daemon_local.flags.gatewayMode == 1) {
+ if (dlt_gateway_init(&daemon_local, daemon_local.flags.vflag) == -1) {
dlt_log(LOG_CRIT, "Fail to create gateway\n");
return -1;
}
@@ -775,36 +760,36 @@ int main(int argc, char* argv[])
DLT_TIMER_GATEWAY);
}
- // For offline tracing we still can use the same states
- // as for socket sending. Using this trick we see the traces
- // In the offline trace AND in the socket stream.
- if(daemon_local.flags.yvalue[0])
- dlt_daemon_change_state(&daemon,DLT_DAEMON_STATE_SEND_DIRECT);
+ /* For offline tracing we still can use the same states */
+ /* as for socket sending. Using this trick we see the traces */
+ /* In the offline trace AND in the socket stream. */
+ if (daemon_local.flags.yvalue[0])
+ dlt_daemon_change_state(&daemon, DLT_DAEMON_STATE_SEND_DIRECT);
else
- dlt_daemon_change_state(&daemon,DLT_DAEMON_STATE_BUFFER);
+ dlt_daemon_change_state(&daemon, DLT_DAEMON_STATE_BUFFER);
dlt_daemon_init_user_information(&daemon,
&daemon_local.pGateway,
daemon_local.flags.gatewayMode,
daemon_local.flags.vflag);
- if (dlt_daemon_load_runtime_configuration(&daemon, daemon_local.flags.ivalue,daemon_local.flags.vflag)==-1)
- {
- dlt_log(LOG_ERR,"Could not load runtime config\n");
+ if (dlt_daemon_load_runtime_configuration(&daemon, daemon_local.flags.ivalue, daemon_local.flags.vflag) == -1) {
+ dlt_log(LOG_ERR, "Could not load runtime config\n");
return -1;
}
- dlt_daemon_log_internal(&daemon, &daemon_local, "Daemon launched. Starting to output traces...", daemon_local.flags.vflag);
+ dlt_daemon_log_internal(&daemon,
+ &daemon_local,
+ "Daemon launched. Starting to output traces...",
+ daemon_local.flags.vflag);
/* Even handling loop. */
while ((back >= 0) && (g_exit >= 0))
- {
back = dlt_daemon_handle_event(&daemon_local.pEvent,
&daemon,
&daemon_local);
- }
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"Exiting DLT daemon... [%d]", g_signo);
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Exiting DLT daemon... [%d]", g_signo);
dlt_daemon_log_internal(&daemon, &daemon_local, str, daemon_local.flags.vflag);
dlt_log(LOG_NOTICE, str);
@@ -825,8 +810,7 @@ int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
PRINT_FUNCTION_VERBOSE(verbose);
int ret = DLT_RETURN_OK;
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_local_init_p1()\n");
return -1;
}
@@ -834,50 +818,47 @@ int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE)
ret = sd_booted();
- if (ret == 0)
- {
+ if (ret == 0) {
dlt_log(LOG_CRIT, "System not booted with systemd!\n");
}
- else if(ret < 0)
+ else if (ret < 0)
{
dlt_log(LOG_CRIT, "sd_booted failed!\n");
return -1;
}
- else
- {
+ else {
dlt_log(LOG_INFO, "System booted with systemd\n");
}
+
#endif
#ifndef DLT_USE_UNIX_SOCKET_IPC
+
if (dlt_daemon_create_pipes_dir(daemon_local->flags.userPipesDir) == DLT_RETURN_ERROR)
- {
return DLT_RETURN_ERROR;
- }
+
#endif
/* Check for daemon mode */
if (daemon_local->flags.dflag)
- {
dlt_daemon_daemonize(daemon_local->flags.vflag);
- }
/* initialise structure to use DLT file */
- ret = dlt_file_init(&(daemon_local->file),daemon_local->flags.vflag);
- if (ret == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_ERR,"Could not initialize file structure\n");
+ ret = dlt_file_init(&(daemon_local->file), daemon_local->flags.vflag);
+
+ if (ret == DLT_RETURN_ERROR) {
+ dlt_log(LOG_ERR, "Could not initialize file structure\n");
/* Return value ignored, dlt daemon will exit */
- dlt_file_free(&(daemon_local->file),daemon_local->flags.vflag);
+ dlt_file_free(&(daemon_local->file), daemon_local->flags.vflag);
return ret;
}
- signal(SIGPIPE,SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, dlt_daemon_signal_handler); /* software termination signal from kill */
- signal(SIGHUP, dlt_daemon_signal_handler); /* hangup signal */
+ signal(SIGHUP, dlt_daemon_signal_handler); /* hangup signal */
signal(SIGQUIT, dlt_daemon_signal_handler);
- signal(SIGINT, dlt_daemon_signal_handler);
+ signal(SIGINT, dlt_daemon_signal_handler);
return DLT_RETURN_OK;
}
@@ -886,98 +867,91 @@ int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
{
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_local_init_p2()\n");
return -1;
}
/* Daemon data */
- if (dlt_daemon_init(daemon,daemon_local->RingbufferMinSize,daemon_local->RingbufferMaxSize,daemon_local->RingbufferStepSize, daemon_local->flags.ivalue,daemon_local->flags.contextLogLevel, daemon_local->flags.contextTraceStatus,daemon_local->flags.enforceContextLLAndTS,daemon_local->flags.vflag)==-1)
- {
- dlt_log(LOG_ERR,"Could not initialize daemon data\n");
+ if (dlt_daemon_init(daemon, daemon_local->RingbufferMinSize, daemon_local->RingbufferMaxSize,
+ daemon_local->RingbufferStepSize, daemon_local->flags.ivalue,
+ daemon_local->flags.contextLogLevel,
+ daemon_local->flags.contextTraceStatus, daemon_local->flags.enforceContextLLAndTS,
+ daemon_local->flags.vflag) == -1) {
+ dlt_log(LOG_ERR, "Could not initialize daemon data\n");
return -1;
}
/* init offline trace */
- if(((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) && daemon_local->flags.offlineTraceDirectory[0])
- {
+ if (((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) &&
+ daemon_local->flags.offlineTraceDirectory[0]) {
if (dlt_offline_trace_init(&(daemon_local->offlineTrace),
- daemon_local->flags.offlineTraceDirectory,
- daemon_local->flags.offlineTraceFileSize,
- daemon_local->flags.offlineTraceMaxSize,
- daemon_local->flags.offlineTraceFilenameTimestampBased)==-1)
- {
- dlt_log(LOG_ERR,"Could not initialize offline trace\n");
+ daemon_local->flags.offlineTraceDirectory,
+ daemon_local->flags.offlineTraceFileSize,
+ daemon_local->flags.offlineTraceMaxSize,
+ daemon_local->flags.offlineTraceFilenameTimestampBased) == -1) {
+ dlt_log(LOG_ERR, "Could not initialize offline trace\n");
return -1;
}
}
/* Init offline logstorage for MAX devices */
- if(daemon_local->flags.offlineLogstorageMaxDevices > 0)
- {
+ if (daemon_local->flags.offlineLogstorageMaxDevices > 0) {
daemon->storage_handle = malloc(sizeof(DltLogStorage) * daemon_local->flags.offlineLogstorageMaxDevices);
- if(daemon->storage_handle == NULL)
- {
- dlt_log(LOG_ERR,"Could not initialize offline logstorage\n");
+ if (daemon->storage_handle == NULL) {
+ dlt_log(LOG_ERR, "Could not initialize offline logstorage\n");
return -1;
}
+
memset(daemon->storage_handle, 0, (sizeof(DltLogStorage) * daemon_local->flags.offlineLogstorageMaxDevices));
}
/* Set ECU id of daemon */
if (daemon_local->flags.evalue[0])
- {
- dlt_set_id(daemon->ecuid,daemon_local->flags.evalue);
- }
+ dlt_set_id(daemon->ecuid, daemon_local->flags.evalue);
else
- {
- dlt_set_id(daemon->ecuid,DLT_DAEMON_ECU_ID);
- }
+ dlt_set_id(daemon->ecuid, DLT_DAEMON_ECU_ID);
/* Set flag for optional sending of serial header */
daemon->sendserialheader = daemon_local->flags.lflag;
#ifdef DLT_SHM_ENABLE
+
/* init shared memory */
- if (dlt_shm_init_server(&(daemon_local->dlt_shm),DLT_SHM_KEY,daemon_local->flags.sharedMemorySize)==-1)
- {
- dlt_log(LOG_ERR,"Could not initialize shared memory\n");
+ if (dlt_shm_init_server(&(daemon_local->dlt_shm), DLT_SHM_KEY, daemon_local->flags.sharedMemorySize) == -1) {
+ dlt_log(LOG_ERR, "Could not initialize shared memory\n");
return -1;
}
+
#endif
/* prepare main loop */
- if (dlt_message_init(&(daemon_local->msg),daemon_local->flags.vflag) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_ERR,"Could not initialize message\n");
+ if (dlt_message_init(&(daemon_local->msg), daemon_local->flags.vflag) == DLT_RETURN_ERROR) {
+ dlt_log(LOG_ERR, "Could not initialize message\n");
return -1;
}
/* configure sending timing packets */
if (daemon_local->flags.sendMessageTime)
- {
daemon->timingpackets = 1;
- }
/* Binary semaphore for thread */
- if (sem_init(&dlt_daemon_mutex, 0, 1)==-1)
- {
- dlt_log(LOG_ERR,"Could not initialize binary semaphore\n");
+ if (sem_init(&dlt_daemon_mutex, 0, 1) == -1) {
+ dlt_log(LOG_ERR, "Could not initialize binary semaphore\n");
return -1;
}
/* Get ECU version info from a file. If it fails, use dlt_version as fallback. */
- if(dlt_daemon_local_ecu_version_init(daemon, daemon_local, daemon_local->flags.vflag) < 0)
- {
+ if (dlt_daemon_local_ecu_version_init(daemon, daemon_local, daemon_local->flags.vflag) < 0) {
daemon->ECUVersionString = malloc(DLT_DAEMON_TEXTBUFSIZE);
- if(daemon->ECUVersionString==0)
- {
- dlt_log(LOG_WARNING,"Could not allocate memory for version string\n");
+
+ if (daemon->ECUVersionString == 0) {
+ dlt_log(LOG_WARNING, "Could not allocate memory for version string\n");
return -1;
}
- dlt_get_version(daemon->ECUVersionString,DLT_DAEMON_TEXTBUFSIZE);
+
+ dlt_get_version(daemon->ECUVersionString, DLT_DAEMON_TEXTBUFSIZE);
}
return 0;
@@ -989,13 +963,12 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
/* open serial connection */
int fd = -1;
- if (daemon_local->flags.yvalue[0] == '\0') {
+ if (daemon_local->flags.yvalue[0] == '\0')
return 0;
- }
fd = open(daemon_local->flags.yvalue, O_RDWR);
- if (fd < 0)
- {
+
+ if (fd < 0) {
snprintf(str,
DLT_DAEMON_TEXTBUFSIZE,
"Failed to open serial device %s\n",
@@ -1006,19 +979,15 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
return -1;
}
- if (isatty(fd))
- {
+ if (isatty(fd)) {
int speed = DLT_DAEMON_SERIAL_DEFAULT_BAUDRATE;
if (daemon_local->flags.bvalue[0])
- {
speed = atoi(daemon_local->flags.bvalue);
- }
daemon_local->baudrate = dlt_convert_serial_speed(speed);
- if (dlt_setup_serial(fd, daemon_local->baudrate) < 0)
- {
+ if (dlt_setup_serial(fd, daemon_local->baudrate) < 0) {
close(fd);
daemon_local->flags.yvalue[0] = 0;
@@ -1033,12 +1002,9 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
}
if (daemon_local->flags.vflag)
- {
dlt_log(LOG_DEBUG, "Serial init done\n");
- }
}
- else
- {
+ else {
close(fd);
fprintf(stderr,
"Device is not a serial device, device = %s (%s) \n",
@@ -1070,9 +1036,9 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
const char *tmpFifo = daemon_local->flags.daemonFifoName;
unlink(tmpFifo);
- ret=mkfifo(tmpFifo, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
- if (ret == -1)
- {
+ ret = mkfifo(tmpFifo, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+
+ if (ret == -1) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"FIFO user %s cannot be created (%s)!\n",
@@ -1083,8 +1049,8 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
} /* if */
fd = open(tmpFifo, O_RDWR);
- if (fd == -1)
- {
+
+ if (fd == -1) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"FIFO user %s cannot be opened (%s)!\n",
@@ -1094,25 +1060,21 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
return -1;
} /* if */
- if (daemon_local->daemonFifoSize != 0)
- {
+ if (daemon_local->daemonFifoSize != 0) {
/* Set Daemon FIFO size */
- if (fcntl(fd, F_SETPIPE_SZ , daemon_local->daemonFifoSize) == -1)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"set FIFO size error: %s\n",strerror(errno));
+ if (fcntl(fd, F_SETPIPE_SZ, daemon_local->daemonFifoSize) == -1) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "set FIFO size error: %s\n", strerror(errno));
dlt_log(LOG_ERR, str);
}
}
/* Get Daemon FIFO size */
- if ((fifo_size = fcntl(fd, F_GETPIPE_SZ , 0)) == -1)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"get FIFO size error: %s\n",strerror(errno));
+ if ((fifo_size = fcntl(fd, F_GETPIPE_SZ, 0)) == -1) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "get FIFO size error: %s\n", strerror(errno));
dlt_log(LOG_ERR, str);
}
- else
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"FIFO size: %d\n",fifo_size);
+ else {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "FIFO size: %d\n", fifo_size);
dlt_log(LOG_INFO, str);
}
@@ -1138,8 +1100,7 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: Invalid function parameters\n",
@@ -1153,51 +1114,49 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
/* create and open socket to receive incoming connections from user application
* socket access permission set to srw-rw-rw- (666) */
mask = S_IXUSR | S_IXGRP | S_IXOTH;
+
if (dlt_daemon_unix_socket_open(&fd,
daemon_local->flags.appSockPath,
SOCK_STREAM,
- mask) == DLT_RETURN_OK)
- {
+ mask) == DLT_RETURN_OK) {
if (dlt_connection_create(daemon_local,
&daemon_local->pEvent,
fd,
POLLIN,
- DLT_CONNECTION_APP_CONNECT))
- {
+ DLT_CONNECTION_APP_CONNECT)) {
dlt_log(LOG_CRIT, "Could not initialize app socket.\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
dlt_log(LOG_CRIT, "Could not initialize app socket.\n");
return DLT_RETURN_ERROR;
}
+
#else
- if (dlt_daemon_init_fifo(daemon_local))
- {
+
+ if (dlt_daemon_init_fifo(daemon_local)) {
dlt_log(LOG_ERR, "Unable to initialize fifo.\n");
return DLT_RETURN_ERROR;
}
+
#endif
/* create and open socket to receive incoming connections from client */
daemon_local->client_connections = 0;
- if (dlt_daemon_socket_open(&fd, daemon_local->flags.port) == DLT_RETURN_OK)
- {
+
+ if (dlt_daemon_socket_open(&fd, daemon_local->flags.port) == DLT_RETURN_OK) {
if (dlt_connection_create(daemon_local,
&daemon_local->pEvent,
fd,
POLLIN,
- DLT_CONNECTION_CLIENT_CONNECT))
- {
- dlt_log(LOG_ERR,"Could not initialize main socket.\n");
+ DLT_CONNECTION_CLIENT_CONNECT)) {
+ dlt_log(LOG_ERR, "Could not initialize main socket.\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
- dlt_log(LOG_ERR,"Could not initialize main socket.\n");
+ else {
+ dlt_log(LOG_ERR, "Could not initialize main socket.\n");
return DLT_RETURN_ERROR;
}
@@ -1205,31 +1164,28 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
* control application
* socket access permission set to srw-rw---- (660) */
mask = S_IXUSR | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
+
if (dlt_daemon_unix_socket_open(&fd,
daemon_local->flags.ctrlSockPath,
SOCK_STREAM,
- mask) == DLT_RETURN_OK)
- {
+ mask) == DLT_RETURN_OK) {
if (dlt_connection_create(daemon_local,
&daemon_local->pEvent,
fd,
POLLIN,
- DLT_CONNECTION_CONTROL_CONNECT))
- {
+ DLT_CONNECTION_CONTROL_CONNECT)) {
dlt_log(LOG_ERR, "Could not initialize control socket.\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Could not initialize control socket.\n");
return DLT_RETURN_ERROR;
}
/* Init serial */
- if (dlt_daemon_init_serial(daemon_local) < 0)
- {
- dlt_log(LOG_ERR,"Could not initialize daemon data\n");
+ if (dlt_daemon_init_serial(daemon_local) < 0) {
+ dlt_log(LOG_ERR, "Could not initialize daemon data\n");
return DLT_RETURN_ERROR;
}
@@ -1238,8 +1194,8 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
{
- char *version = NULL;
- FILE *f = NULL;
+ char *version = NULL;
+ FILE *f = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
@@ -1248,8 +1204,8 @@ int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_
/* Open the file. Bail out if error occurs */
f = fopen(daemon_local->flags.pathToECUSoftwareVersion, "r");
- if(f == NULL)
- {
+
+ if (f == NULL) {
/* Error level notice, because this might be deliberate choice */
dlt_log(LOG_NOTICE, "Failed to open ECU Software version file.\n");
return -1;
@@ -1258,8 +1214,8 @@ int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_
/* Get the file size. Bail out if stat fails. */
int fd = fileno(f);
struct stat s_buf;
- if(fstat(fd, &s_buf) < 0)
- {
+
+ if (fstat(fd, &s_buf) < 0) {
dlt_log(LOG_WARNING, "Failed to stat ECU Software version file.\n");
fclose(f);
return -1;
@@ -1268,8 +1224,8 @@ int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_
/* Bail out if file is too large. Use DLT_DAEMON_TEXTBUFSIZE max.
* Reserve one byte for trailing '\0' */
off_t size = s_buf.st_size;
- if(size >= DLT_DAEMON_TEXTBUFSIZE)
- {
+
+ if (size >= DLT_DAEMON_TEXTBUFSIZE) {
dlt_log(LOG_WARNING, "Too large file for ECU version.\n");
fclose(f);
return -1;
@@ -1277,32 +1233,34 @@ int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_
/* Allocate permanent buffer for version info */
version = malloc(size + 1);
- if(version==0)
- {
+
+ if (version == 0) {
dlt_log(LOG_WARNING, "Cannot allocate memory for ECU version.\n");
fclose(f);
return -1;
}
+
off_t offset = 0;
- while(!feof(f))
- {
+
+ while (!feof(f)) {
offset += fread(version + offset, 1, size, f);
- if(ferror(f))
- {
+
+ if (ferror(f)) {
dlt_log(LOG_WARNING, "Failed to read ECU Software version file.\n");
free(version);
fclose(f);
return -1;
}
- if(offset > size)
- {
+
+ if (offset > size) {
dlt_log(LOG_WARNING, "Too long file for ECU Software version info.\n");
free(version);
fclose(f);
return -1;
}
}
- version[offset] = '\0';//append null termination at end of version string
+
+ version[offset] = '\0';/*append null termination at end of version string */
daemon->ECUVersionString = version;
fclose(f);
return 0;
@@ -1312,8 +1270,7 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
{
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_local_cleanup()\n");
return;
}
@@ -1321,14 +1278,14 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
/* Don't receive event anymore */
dlt_event_handler_cleanup_connections(&daemon_local->pEvent);
- dlt_message_free(&(daemon_local->msg),daemon_local->flags.vflag);
+ dlt_message_free(&(daemon_local->msg), daemon_local->flags.vflag);
/* free shared memory */
- if(daemon_local->flags.offlineTraceDirectory[0])
+ if (daemon_local->flags.offlineTraceDirectory[0])
dlt_offline_trace_free(&(daemon_local->offlineTrace));
/* Ignore result */
- dlt_file_free(&(daemon_local->file),daemon_local->flags.vflag);
+ dlt_file_free(&(daemon_local->file), daemon_local->flags.vflag);
/* Try to delete existing pipe, ignore result of unlink() */
unlink(daemon_local->flags.daemonFifoName);
@@ -1338,8 +1295,7 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
dlt_shm_free_server(&(daemon_local->dlt_shm));
#endif
- if (daemon_local->flags.offlineLogstorageMaxDevices > 0)
- {
+ if (daemon_local->flags.offlineLogstorageMaxDevices > 0) {
/* disconnect all logstorage devices */
dlt_daemon_logstorage_cleanup(daemon,
daemon_local,
@@ -1349,9 +1305,7 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
}
if (daemon->ECUVersionString != NULL)
- {
free(daemon->ECUVersionString);
- }
unlink(daemon_local->flags.ctrlSockPath);
@@ -1359,7 +1313,7 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
void dlt_daemon_exit_trigger()
{
- char tmp[PATH_MAX + 1] = {0};
+ char tmp[PATH_MAX + 1] = { 0 };
snprintf(tmp, PATH_MAX, "%s/dlt", dltFifoBaseDir);
(void)unlink(tmp);
@@ -1371,8 +1325,8 @@ void dlt_daemon_exit_trigger()
void dlt_daemon_signal_handler(int sig)
{
g_signo = sig;
- switch (sig)
- {
+
+ switch (sig) {
case SIGHUP:
case SIGTERM:
case SIGINT:
@@ -1390,6 +1344,7 @@ void dlt_daemon_signal_handler(int sig)
break;
}
} /* switch */
+
} /* dlt_daemon_signal_handler() */
void dlt_daemon_daemonize(int verbose)
@@ -1402,48 +1357,41 @@ void dlt_daemon_daemonize(int verbose)
dlt_log(LOG_NOTICE, "Daemon mode\n");
/* Daemonize */
- i=fork();
- if (i<0)
- {
+ i = fork();
+
+ if (i < 0) {
dlt_log(LOG_CRIT, "Unable to fork(), exiting DLT daemon\n");
exit(-1); /* fork error */
}
- if (i>0)
- {
+ if (i > 0)
exit(0); /* parent exits */
- }
+
/* child (daemon) continues */
/* Process independency */
- /* obtain a new process group */
- if (setsid()==-1)
- {
+ /* obtain a new process group */
+ if (setsid() == -1) {
dlt_log(LOG_CRIT, "setsid() failed, exiting DLT daemon\n");
exit(-1); /* fork error */
}
/* Open standard descriptors stdin, stdout, stderr */
fd = open("/dev/null", O_RDWR);
- if (fd != -1)
- {
+
+ if (fd != -1) {
/* Redirect STDOUT to /dev/null */
if (dup2(fd, STDOUT_FILENO) < 0)
- {
dlt_vlog(LOG_WARNING, "Failed to direct stdout to /dev/null. Error: %s\n", strerror(errno));
- }
/* Redirect STDERR to /dev/null */
if (dup2(fd, STDERR_FILENO) < 0)
- {
dlt_vlog(LOG_WARNING, "Failed to direct stderr to /dev/null. Error: %s\n", strerror(errno));
- }
close(fd);
}
- else
- {
+ else {
dlt_log(LOG_CRIT, "Error opening /dev/null, exiting DLT daemon\n");
exit(-1); /* fork error */
}
@@ -1453,27 +1401,25 @@ void dlt_daemon_daemonize(int verbose)
/* Change to root directory */
if (chdir("/") < 0)
- {
dlt_log(LOG_WARNING, "Failed to chdir to root\n");
- }
/* Catch signals */
- signal(SIGCHLD,SIG_IGN); /* ignore child */
- signal(SIGTSTP,SIG_IGN); /* ignore tty signals */
- signal(SIGTTOU,SIG_IGN);
- signal(SIGTTIN,SIG_IGN);
+ signal(SIGCHLD, SIG_IGN); /* ignore child */
+ signal(SIGTSTP, SIG_IGN); /* ignore tty signals */
+ signal(SIGTTOU, SIG_IGN);
+ signal(SIGTTIN, SIG_IGN);
} /* dlt_daemon_daemonize() */
/* This function logs str to the configured output sink (socket, serial, offline trace).
- To avoid recursion this function must be called only from DLT highlevel functions.
- E. g. calling it to output a failure when the open of the offline trace file fails
- would cause an endless loop because dlt_daemon_log_internal() would itself again try
- to open the offline trace file.
- This is a dlt-daemon only function. The libdlt has no equivalent function available. */
+ * To avoid recursion this function must be called only from DLT highlevel functions.
+ * E. g. calling it to output a failure when the open of the offline trace file fails
+ * would cause an endless loop because dlt_daemon_log_internal() would itself again try
+ * to open the offline trace file.
+ * This is a dlt-daemon only function. The libdlt has no equivalent function available. */
int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose)
{
- DltMessage msg = {0};
+ DltMessage msg = { 0 };
static uint8_t uiMsgCount = 0;
DltStandardHeaderExtra *pStandardExtra = NULL;
uint32_t uiType;
@@ -1483,41 +1429,47 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
PRINT_FUNCTION_VERBOSE(verbose);
- // Set storageheader
+ /* Set storageheader */
msg.storageheader = (DltStorageHeader *)(msg.headerbuffer);
dlt_set_storageheader(msg.storageheader, daemon->ecuid);
- // Set standardheader
+ /* Set standardheader */
msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
- msg.standardheader->htyp = DLT_HTYP_UEH | DLT_HTYP_WEID | DLT_HTYP_WSID | DLT_HTYP_WTMS | DLT_HTYP_PROTOCOL_VERSION1;
+ msg.standardheader->htyp = DLT_HTYP_UEH | DLT_HTYP_WEID | DLT_HTYP_WSID | DLT_HTYP_WTMS |
+ DLT_HTYP_PROTOCOL_VERSION1;
msg.standardheader->mcnt = uiMsgCount++;
- uiExtraSize = DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp)+(DLT_IS_HTYP_UEH(msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
+ uiExtraSize = DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp) +
+ (DLT_IS_HTYP_UEH(msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + uiExtraSize;
- // Set extraheader
- pStandardExtra = (DltStandardHeaderExtra *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader));
+ /* Set extraheader */
+ pStandardExtra =
+ (DltStandardHeaderExtra *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader));
dlt_set_id(pStandardExtra->ecu, daemon->ecuid);
pStandardExtra->tmsp = DLT_HTOBE_32(dlt_uptime());
pStandardExtra->seid = DLT_HTOBE_32(getpid());
- // Set extendedheader
- msg.extendedheader = (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
- msg.extendedheader->msin = DLT_MSIN_VERB | (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT) | ((DLT_LOG_INFO << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN);
+ /* Set extendedheader */
+ msg.extendedheader =
+ (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+ msg.extendedheader->msin = DLT_MSIN_VERB | (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT) |
+ ((DLT_LOG_INFO << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN);
msg.extendedheader->noar = 1;
dlt_set_id(msg.extendedheader->apid, "DLTD");
dlt_set_id(msg.extendedheader->ctid, "INTM");
- // Set payload data...
+ /* Set payload data... */
uiType = DLT_TYPE_INFO_STRG;
uiSize = strlen(str) + 1;
msg.datasize = sizeof(uint32_t) + sizeof(uint16_t) + uiSize;
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
msg.databuffersize = msg.datasize;
- if (msg.databuffer==0)
- {
- dlt_log(LOG_WARNING,"Can't allocate buffer for get log info message\n");
+
+ if (msg.databuffer == 0) {
+ dlt_log(LOG_WARNING, "Can't allocate buffer for get log info message\n");
return -1;
}
@@ -1529,33 +1481,30 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
memcpy((uint8_t *)(msg.databuffer + msg.datasize), str, uiSize);
msg.datasize += uiSize;
- // Calc lengths
+ /* Calc lengths */
msg.standardheader->len = DLT_HTOBE_16(msg.headersize - sizeof(DltStorageHeader) + msg.datasize);
- // Sending data...
+ /* Sending data... */
{
/* check if overflow occurred */
- if(daemon->overflow_counter)
- {
- if(dlt_daemon_send_message_overflow(daemon,daemon_local,verbose)==0)
- {
- sprintf(str,"%u messages discarded!\n",daemon->overflow_counter);
- dlt_log(LOG_WARNING, str);
- daemon->overflow_counter=0;
+ if (daemon->overflow_counter) {
+ if (dlt_daemon_send_message_overflow(daemon, daemon_local, verbose) == 0) {
+ sprintf(str, "%u messages discarded!\n", daemon->overflow_counter);
+ dlt_log(LOG_WARNING, str);
+ daemon->overflow_counter = 0;
}
}
/* look if TCP connection to client is available */
- if((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
- {
-
- if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,msg.headerbuffer,sizeof(DltStorageHeader),msg.headerbuffer+sizeof(DltStorageHeader),msg.headersize-sizeof(DltStorageHeader),
- msg.databuffer,msg.datasize,verbose)))
- {
- if(ret == DLT_DAEMON_ERROR_BUFFER_FULL)
- {
+ if ((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) {
+
+ if ((ret =
+ dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, msg.headerbuffer,
+ sizeof(DltStorageHeader), msg.headerbuffer + sizeof(DltStorageHeader),
+ msg.headersize - sizeof(DltStorageHeader),
+ msg.databuffer, msg.datasize, verbose))) {
+ if (ret == DLT_DAEMON_ERROR_BUFFER_FULL)
daemon->overflow_counter++;
- }
}
}
}
@@ -1578,8 +1527,7 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_client_connect()\n");
@@ -1588,10 +1536,10 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
/* event from TCP server socket, new connection */
cli_size = sizeof(cli);
- if ((in_sock = accept(receiver->fd,&cli, &cli_size)) < 0)
- {
+
+ if ((in_sock = accept(receiver->fd, &cli, &cli_size)) < 0) {
dlt_vlog(LOG_ERR, "accept() for socket %d failed: %s\n", receiver->fd, strerror(errno));
- return -1 ;
+ return -1;
}
/* check if file file descriptor was already used, and make it invalid if it
@@ -1604,27 +1552,25 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
struct timeval timeout_send;
timeout_send.tv_sec = daemon_local->timeoutOnSend;
timeout_send.tv_usec = 0;
+
if (setsockopt (in_sock,
SOL_SOCKET,
SO_SNDTIMEO,
(char *)&timeout_send,
sizeof(timeout_send)) < 0)
- {
dlt_log(LOG_WARNING, "setsockopt failed\n");
- }
if (dlt_connection_create(daemon_local,
- &daemon_local->pEvent,
- in_sock,
- POLLIN,
- DLT_CONNECTION_CLIENT_MSG_TCP))
- {
+ &daemon_local->pEvent,
+ in_sock,
+ POLLIN,
+ DLT_CONNECTION_CLIENT_MSG_TCP)) {
dlt_log(LOG_ERR, "Failed to register new client. \n");
/* TODO: Perform clean-up */
return -1;
}
- // send connection info about connected
+ /* send connection info about connected */
dlt_daemon_control_message_connection_info(in_sock,
daemon,
daemon_local,
@@ -1632,24 +1578,19 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
"",
verbose);
- // send ecu version string
- if (daemon_local->flags.sendECUSoftwareVersion > 0)
- {
+ /* send ecu version string */
+ if (daemon_local->flags.sendECUSoftwareVersion > 0) {
if (daemon_local->flags.sendECUSoftwareVersion > 0)
- {
dlt_daemon_control_get_software_version(DLT_DAEMON_SEND_TO_ALL,
daemon,
daemon_local,
daemon_local->flags.vflag);
- }
if (daemon_local->flags.sendTimezone > 0)
- {
dlt_daemon_control_message_timezone(DLT_DAEMON_SEND_TO_ALL,
daemon,
daemon_local,
daemon_local->flags.vflag);
- }
}
snprintf(local_str,
@@ -1660,22 +1601,20 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
dlt_log(LOG_DEBUG, local_str);
dlt_daemon_log_internal(daemon, daemon_local, local_str, daemon_local->flags.vflag);
- if (daemon_local->client_connections == 1)
- {
+ if (daemon_local->client_connections == 1) {
if (daemon_local->flags.vflag)
- {
dlt_log(LOG_DEBUG, "Send ring-buffer to client\n");
- }
+
dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_BUFFER);
- if (dlt_daemon_send_ringbuffer_to_client(daemon, daemon_local, verbose)==-1)
- {
- dlt_log(LOG_WARNING,"Can't send contents of ringbuffer to clients\n");
+
+ if (dlt_daemon_send_ringbuffer_to_client(daemon, daemon_local, verbose) == -1) {
+ dlt_log(LOG_WARNING, "Can't send contents of ringbuffer to clients\n");
return -1;
}
/* send new log state to all applications */
daemon->connectionState = 1;
- dlt_daemon_user_send_all_log_state(daemon,verbose);
+ dlt_daemon_user_send_all_log_state(daemon, verbose);
}
return 0;
@@ -1686,13 +1625,12 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
DltReceiver *receiver,
int verbose)
{
- int bytes_to_be_removed=0;
+ int bytes_to_be_removed = 0;
int must_close_socket = -1;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_client_messages()\n");
@@ -1700,8 +1638,8 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
}
must_close_socket = dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET);
- if (must_close_socket < 0)
- {
+
+ if (must_close_socket < 0) {
dlt_daemon_close_socket(receiver->fd,
daemon,
daemon_local,
@@ -1712,51 +1650,43 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
/* Process all received messages */
while (dlt_message_read(&(daemon_local->msg),
- (uint8_t*)receiver->buf,
+ (uint8_t *)receiver->buf,
receiver->bytesRcvd,
daemon_local->flags.nflag,
- daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK)
- {
+ daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
/* Check for control message */
- if (0 < receiver->fd &&
+ if ((0 < receiver->fd) &&
DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg)))
- {
dlt_daemon_client_process_control(receiver->fd,
daemon,
daemon_local,
&(daemon_local->msg),
daemon_local->flags.vflag);
- }
bytes_to_be_removed = daemon_local->msg.headersize +
- daemon_local->msg.datasize -
- sizeof(DltStorageHeader);
+ daemon_local->msg.datasize -
+ sizeof(DltStorageHeader);
+
if (daemon_local->msg.found_serialheader)
- {
bytes_to_be_removed += sizeof(dltSerialHeader);
- }
+
if (daemon_local->msg.resync_offset)
- {
bytes_to_be_removed += daemon_local->msg.resync_offset;
- }
- if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1)
- {
+ if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1) {
dlt_log(LOG_WARNING,
"Can't remove bytes from receiver for sockets\n");
return -1;
}
-
} /* while */
- if (dlt_receiver_move_to_begin(receiver) == -1)
- {
+ if (dlt_receiver_move_to_begin(receiver) == -1) {
dlt_log(LOG_WARNING,
"Can't move bytes to beginning of receiver buffer for sockets\n");
return -1;
}
- if (must_close_socket == 0) {
+ if (must_close_socket == 0)
/* FIXME: Why the hell do we need to close the socket
* on control message reception ??
*/
@@ -1764,7 +1694,6 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
daemon,
daemon_local,
verbose);
- }
return 0;
}
@@ -1774,20 +1703,18 @@ int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
DltReceiver *receiver,
int verbose)
{
- int bytes_to_be_removed=0;
+ int bytes_to_be_removed = 0;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_client_messages_serial()\n");
return -1;
}
- if (dlt_receiver_receive(receiver, DLT_RECEIVE_FD) <= 0)
- {
+ if (dlt_receiver_receive(receiver, DLT_RECEIVE_FD) <= 0) {
dlt_log(LOG_WARNING,
"dlt_receiver_receive_fd() for messages from serial interface "
"failed!\n");
@@ -1796,50 +1723,41 @@ int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
/* Process all received messages */
while (dlt_message_read(&(daemon_local->msg),
- (uint8_t*)receiver->buf,
+ (uint8_t *)receiver->buf,
receiver->bytesRcvd,
daemon_local->flags.mflag,
- daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK)
- {
+ daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
/* Check for control message */
- if (DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg)))
- {
+ if (DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg))) {
if (dlt_daemon_client_process_control(receiver->fd,
daemon,
daemon_local,
&(daemon_local->msg),
daemon_local->flags.vflag)
- == -1)
- {
+ == -1) {
dlt_log(LOG_WARNING, "Can't process control messages\n");
return -1;
}
}
bytes_to_be_removed = daemon_local->msg.headersize +
- daemon_local->msg.datasize -
- sizeof(DltStorageHeader);
+ daemon_local->msg.datasize -
+ sizeof(DltStorageHeader);
if (daemon_local->msg.found_serialheader)
- {
bytes_to_be_removed += sizeof(dltSerialHeader);
- }
+
if (daemon_local->msg.resync_offset)
- {
bytes_to_be_removed += daemon_local->msg.resync_offset;
- }
- if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1)
- {
+ if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1) {
dlt_log(LOG_WARNING,
"Can't remove bytes from receiver for serial connection\n");
return -1;
}
-
} /* while */
- if (dlt_receiver_move_to_begin(receiver) == -1)
- {
+ if (dlt_receiver_move_to_begin(receiver) == -1) {
dlt_log(LOG_WARNING,
"Can't move bytes to beginning of receiver buffer for serial "
"connection\n");
@@ -1850,10 +1768,10 @@ int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
}
int dlt_daemon_process_control_connect(
- DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltReceiver *receiver,
- int verbose)
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *receiver,
+ int verbose)
{
socklen_t ctrl_size;
struct sockaddr_un ctrl;
@@ -1861,8 +1779,7 @@ int dlt_daemon_process_control_connect(
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_control_connect()\n");
@@ -1871,10 +1788,10 @@ int dlt_daemon_process_control_connect(
/* event from UNIX server socket, new connection */
ctrl_size = sizeof(ctrl);
- if ((in_sock = accept(receiver->fd, &ctrl, &ctrl_size)) < 0)
- {
+
+ if ((in_sock = accept(receiver->fd, &ctrl, &ctrl_size)) < 0) {
dlt_vlog(LOG_ERR, "accept() on UNIX control socket %d failed: %s\n", receiver->fd, strerror(errno));
- return -1 ;
+ return -1;
}
/* check if file file descriptor was already used, and make it invalid if it
@@ -1884,19 +1801,17 @@ int dlt_daemon_process_control_connect(
dlt_daemon_contexts_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
if (dlt_connection_create(daemon_local,
- &daemon_local->pEvent,
- in_sock,
- POLLIN,
- DLT_CONNECTION_CONTROL_MSG))
- {
+ &daemon_local->pEvent,
+ in_sock,
+ POLLIN,
+ DLT_CONNECTION_CONTROL_MSG)) {
dlt_log(LOG_ERR, "Failed to register new client. \n");
/* TODO: Perform clean-up */
return -1;
}
- if (verbose)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,
+ if (verbose) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE,
"New connection to control client established\n");
dlt_log(LOG_INFO, str);
}
@@ -1906,10 +1821,10 @@ int dlt_daemon_process_control_connect(
#ifdef DLT_USE_UNIX_SOCKET_IPC
int dlt_daemon_process_app_connect(
- DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltReceiver *receiver,
- int verbose)
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *receiver,
+ int verbose)
{
socklen_t app_size;
struct sockaddr_un app;
@@ -1917,41 +1832,38 @@ int dlt_daemon_process_app_connect(
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_vlog(LOG_ERR,
- "%s: Invalid parameters\n",
- __func__);
+ "%s: Invalid parameters\n",
+ __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
/* event from UNIX server socket, new connection */
app_size = sizeof(app);
- if ((in_sock = accept(receiver->fd, &app, &app_size)) < 0)
- {
+
+ if ((in_sock = accept(receiver->fd, &app, &app_size)) < 0) {
dlt_vlog(LOG_ERR, "accept() on UNIX socket %d failed: %s\n", receiver->fd, strerror(errno));
- return -1 ;
+ return -1;
}
/* check if file file descriptor was already used, and make it invalid if it
* is reused. This prevents sending messages to wrong file descriptor */
dlt_daemon_applications_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
- dlt_daemon_contexts_invalidate_fd(daemon,daemon->ecuid, in_sock, verbose);
+ dlt_daemon_contexts_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
if (dlt_connection_create(daemon_local,
- &daemon_local->pEvent,
- in_sock,
- POLLIN,
- DLT_CONNECTION_APP_MSG))
- {
+ &daemon_local->pEvent,
+ in_sock,
+ POLLIN,
+ DLT_CONNECTION_APP_MSG)) {
dlt_log(LOG_ERR, "Failed to register new application. \n");
close(in_sock);
return -1;
}
- if (verbose)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,
+ if (verbose) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE,
"New connection to application established\n");
dlt_log(LOG_INFO, str);
}
@@ -1961,25 +1873,23 @@ int dlt_daemon_process_app_connect(
#endif
int dlt_daemon_process_control_messages(
- DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltReceiver *receiver,
- int verbose)
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *receiver,
+ int verbose)
{
- int bytes_to_be_removed=0;
+ int bytes_to_be_removed = 0;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_control_messages()\n");
return -1;
}
- if (dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET) <= 0)
- {
+ if (dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET) <= 0) {
dlt_daemon_close_socket(receiver->fd,
daemon,
daemon_local,
@@ -1993,47 +1903,38 @@ int dlt_daemon_process_control_messages(
/* Process all received messages */
while (dlt_message_read(
- &(daemon_local->msg),
- (uint8_t*)receiver->buf,
- receiver->bytesRcvd,
- daemon_local->flags.nflag,
- daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK)
- {
+ &(daemon_local->msg),
+ (uint8_t *)receiver->buf,
+ receiver->bytesRcvd,
+ daemon_local->flags.nflag,
+ daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
/* Check for control message */
- if (receiver->fd > 0 &&
+ if ((receiver->fd > 0) &&
DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg)))
- {
dlt_daemon_client_process_control(receiver->fd,
- daemon,daemon_local,
+ daemon, daemon_local,
&(daemon_local->msg),
daemon_local->flags.vflag);
- }
bytes_to_be_removed = daemon_local->msg.headersize +
- daemon_local->msg.datasize -
- sizeof(DltStorageHeader);
+ daemon_local->msg.datasize -
+ sizeof(DltStorageHeader);
if (daemon_local->msg.found_serialheader)
- {
bytes_to_be_removed += sizeof(dltSerialHeader);
- }
+
if (daemon_local->msg.resync_offset)
- {
bytes_to_be_removed += daemon_local->msg.resync_offset;
- }
- if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1)
- {
+ if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1) {
dlt_log(LOG_WARNING,
"Can't remove bytes from receiver for sockets\n");
return -1;
}
-
} /* while */
- if (dlt_receiver_move_to_begin(receiver) == -1)
- {
- dlt_log(LOG_WARNING,"Can't move bytes to beginning of receiver buffer for sockets\n");
+ if (dlt_receiver_move_to_begin(receiver) == -1) {
+ dlt_log(LOG_WARNING, "Can't move bytes to beginning of receiver buffer for sockets\n");
return -1;
}
@@ -2046,7 +1947,7 @@ static int dlt_daemon_process_user_message_not_sup(DltDaemon *daemon,
int verbose)
{
char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
- DltUserHeader *userheader = (DltUserHeader*) (receiver->buf);
+ DltUserHeader *userheader = (DltUserHeader *)(receiver->buf);
(void)daemon;
(void)daemon_local;
@@ -2060,10 +1961,8 @@ static int dlt_daemon_process_user_message_not_sup(DltDaemon *daemon,
/* remove user header */
if (dlt_receiver_remove(receiver, sizeof(DltUserHeader)) == -1)
- {
dlt_log(LOG_WARNING,
"Can't remove bytes from receiver for user messages\n");
- }
return -1;
}
@@ -2104,8 +2003,7 @@ int dlt_daemon_process_user_messages(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_user_messages()\n");
@@ -2114,8 +2012,8 @@ int dlt_daemon_process_user_messages(DltDaemon *daemon,
#ifdef DLT_USE_UNIX_SOCKET_IPC
recv = dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET);
- if (recv <= 0)
- {
+
+ if (recv <= 0) {
dlt_daemon_close_socket(receiver->fd,
daemon,
daemon_local,
@@ -2123,66 +2021,54 @@ int dlt_daemon_process_user_messages(DltDaemon *daemon,
receiver->fd = -1;
return 0;
}
+
#else
recv = dlt_receiver_receive(receiver, DLT_RECEIVE_FD);
- if (recv < 0)
- {
+
+ if (recv < 0) {
dlt_log(LOG_WARNING,
"dlt_receiver_receive_fd() for user messages failed!\n");
return -1;
}
+
#endif
/* look through buffer as long as data is in there */
- while ((receiver->bytesRcvd >= min_size) && run_loop)
- {
+ while ((receiver->bytesRcvd >= min_size) && run_loop) {
dlt_daemon_process_user_message_func func = NULL;
offset = 0;
userheader = (DltUserHeader *)(receiver->buf + offset);
while (!dlt_user_check_userheader(userheader) &&
- (offset + min_size <= receiver->bytesRcvd))
- /* resync if necessary */
- {
+ (offset + min_size <= receiver->bytesRcvd)) {
+ /* resync if necessary */
offset++;
userheader = (DltUserHeader *)(receiver->buf + offset);
}
/* Check for user header pattern */
if (!dlt_user_check_userheader(userheader))
- {
break;
- }
/* Set new start offset */
if (offset > 0)
- {
dlt_receiver_remove(receiver, offset);
- }
-
if (userheader->message >= DLT_USER_MESSAGE_NOT_SUPPORTED)
- {
func = dlt_daemon_process_user_message_not_sup;
- }
else
- {
func = process_user_func[userheader->message];
- }
if (func(daemon,
daemon_local,
receiver,
daemon_local->flags.vflag) == -1)
- {
run_loop = 0;
- }
}
/* keep not read data in buffer */
- if (dlt_receiver_move_to_begin(receiver) == -1)
- {
+ if (dlt_receiver_move_to_begin(receiver) == -1) {
dlt_log(LOG_WARNING,
"Can't move bytes to beginning of receiver buffer for user "
"messages\n");
@@ -2203,8 +2089,7 @@ int dlt_daemon_process_user_message_overflow(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Invalid function parameters used for %s\n",
@@ -2218,24 +2103,20 @@ int dlt_daemon_process_user_message_overflow(DltDaemon *daemon,
&userpayload,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
/* Store in daemon, that a message buffer overflow has occured */
/* look if TCP connection to client is available or it least message can be put into buffer */
- if(dlt_daemon_control_message_buffer_overflow(DLT_DAEMON_SEND_TO_ALL,
- daemon,
- daemon_local,
- userpayload.overflow_counter,
- userpayload.apid,
- verbose))
- {
+ if (dlt_daemon_control_message_buffer_overflow(DLT_DAEMON_SEND_TO_ALL,
+ daemon,
+ daemon_local,
+ userpayload.overflow_counter,
+ userpayload.apid,
+ verbose))
/* there was an error when storing message */
/* add the counter of lost messages to the daemon counter */
daemon->overflow_counter += userpayload.overflow_counter;
- }
return 0;
}
@@ -2245,17 +2126,17 @@ int dlt_daemon_send_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_l
int ret;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_process_user_message_overflow()\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
/* Store in daemon, that a message buffer overflow has occured */
- if((ret=dlt_daemon_control_message_buffer_overflow(DLT_DAEMON_SEND_TO_ALL, daemon,daemon_local,daemon->overflow_counter,"", verbose)))
- {
+ if ((ret =
+ dlt_daemon_control_message_buffer_overflow(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local,
+ daemon->overflow_counter,
+ "", verbose)))
return ret;
- }
return DLT_DAEMON_ERROR_OK;
}
@@ -2277,8 +2158,7 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Invalid function parameters used for %s\n",
@@ -2296,15 +2176,14 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
&userapp,
len,
DLT_RCV_SKIP_HEADER);
+
if (to_remove < 0)
- {
/* Not enough bytes received */
return -1;
- }
len = userapp.description_length;
- if (len > DLT_DAEMON_DESCSIZE)
- {
+
+ if (len > DLT_DAEMON_DESCSIZE) {
len = DLT_DAEMON_DESCSIZE;
dlt_log(LOG_WARNING, "Application description exceeds limit\n");
}
@@ -2312,8 +2191,7 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
/* adjust buffer pointer */
rec->buf += to_remove + sizeof(DltUserHeader);
- if (dlt_receiver_check_and_get(rec, description, len, DLT_RCV_NONE) < 0)
- {
+ if (dlt_receiver_check_and_get(rec, description, len, DLT_RCV_NONE) < 0) {
dlt_log(LOG_ERR, "Unable to get application description\n");
/* in case description was not readable, set dummy description */
strncpy(description, "Unknown", sizeof("Unknown"));
@@ -2329,17 +2207,16 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
rec->buf = origin;
/* We can now remove data. */
- if (dlt_receiver_remove(rec, to_remove) != DLT_RETURN_OK)
- {
- dlt_log(LOG_WARNING,"Can't remove bytes from receiver\n");
+ if (dlt_receiver_remove(rec, to_remove) != DLT_RETURN_OK) {
+ dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
return -1;
}
old_application = dlt_daemon_application_find(daemon, userapp.apid, daemon->ecuid, verbose);
+
if (old_application != NULL)
- {
old_pid = old_application->pid;
- }
+
application = dlt_daemon_application_add(daemon,
userapp.apid,
userapp.pid,
@@ -2351,32 +2228,27 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
/* send log state to new application */
dlt_daemon_user_send_log_state(daemon, application, verbose);
- if (application == NULL)
- {
+ if (application == NULL) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Can't add ApplicationID '%.4s' for PID %d\n",
userapp.apid,
userapp.pid);
- dlt_log(LOG_WARNING,local_str);
+ dlt_log(LOG_WARNING, local_str);
return -1;
}
- else
- {
- if (old_pid != application->pid)
- {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "ApplicationID '%.4s' registered for PID %d, Description=%s\n",
- application->apid,
- application->pid,
- application->application_description);
- dlt_daemon_log_internal(daemon,
- daemon_local,
- local_str,
- daemon_local->flags.vflag);
- dlt_log(LOG_DEBUG, local_str);
- }
+ else if (old_pid != application->pid) {
+ snprintf(local_str,
+ DLT_DAEMON_TEXTBUFSIZE,
+ "ApplicationID '%.4s' registered for PID %d, Description=%s\n",
+ application->apid,
+ application->pid,
+ application->application_description);
+ dlt_daemon_log_internal(daemon,
+ daemon_local,
+ local_str,
+ daemon_local->flags.vflag);
+ dlt_log(LOG_DEBUG, local_str);
}
return 0;
@@ -2401,8 +2273,7 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Invalid function parameters used for %s\n",
@@ -2421,15 +2292,12 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
DLT_RCV_SKIP_HEADER);
if (to_remove < 0)
- {
/* Not enough bytes received */
return -1;
- }
len = userctxt.description_length;
- if (len > DLT_DAEMON_DESCSIZE)
- {
+ if (len > DLT_DAEMON_DESCSIZE) {
dlt_vlog(LOG_WARNING, "Context description exceeds limit: %d\n", len);
len = DLT_DAEMON_DESCSIZE;
}
@@ -2437,8 +2305,7 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
/* adjust buffer pointer */
rec->buf += to_remove + sizeof(DltUserHeader);
- if (dlt_receiver_check_and_get(rec, description, len, DLT_RCV_NONE) < 0)
- {
+ if (dlt_receiver_check_and_get(rec, description, len, DLT_RCV_NONE) < 0) {
dlt_log(LOG_ERR, "Unable to get context description\n");
/* in case description was not readable, set dummy description */
strncpy(description, "Unknown", sizeof("Unknown"));
@@ -2454,9 +2321,8 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
rec->buf = origin;
/* We can now remove data. */
- if (dlt_receiver_remove(rec, to_remove) != DLT_RETURN_OK)
- {
- dlt_log(LOG_WARNING,"Can't remove bytes from receiver\n");
+ if (dlt_receiver_remove(rec, to_remove) != DLT_RETURN_OK) {
+ dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
return -1;
}
@@ -2465,8 +2331,7 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
daemon->ecuid,
verbose);
- if (application == 0)
- {
+ if (application == 0) {
dlt_vlog(LOG_WARNING,
"ApID '%.4s' not found for new ContextID '%.4s' in %s\n",
userctxt.apid,
@@ -2477,34 +2342,24 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
}
/* Set log level */
- if (userctxt.log_level == DLT_USER_LOG_LEVEL_NOT_SET)
- {
+ if (userctxt.log_level == DLT_USER_LOG_LEVEL_NOT_SET) {
userctxt.log_level = DLT_LOG_DEFAULT;
}
else
- {
- /* Plausibility check */
- if ((userctxt.log_level < DLT_LOG_DEFAULT) ||
- (userctxt.log_level > DLT_LOG_VERBOSE))
- {
- return -1;
- }
- }
+ /* Plausibility check */
+ if ((userctxt.log_level < DLT_LOG_DEFAULT) ||
+ (userctxt.log_level > DLT_LOG_VERBOSE))
+ return -1;
/* Set trace status */
- if (userctxt.trace_status == DLT_USER_TRACE_STATUS_NOT_SET)
- {
+ if (userctxt.trace_status == DLT_USER_TRACE_STATUS_NOT_SET) {
userctxt.trace_status = DLT_TRACE_STATUS_DEFAULT;
}
else
- {
- /* Plausibility check */
- if ((userctxt.trace_status < DLT_TRACE_STATUS_DEFAULT) ||
- (userctxt.trace_status > DLT_TRACE_STATUS_ON))
- {
- return -1;
- }
- }
+ /* Plausibility check */
+ if ((userctxt.trace_status < DLT_TRACE_STATUS_DEFAULT) ||
+ (userctxt.trace_status > DLT_TRACE_STATUS_ON))
+ return -1;
context = dlt_daemon_context_add(daemon,
userctxt.apid,
@@ -2517,8 +2372,7 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
daemon->ecuid,
verbose);
- if (context==0)
- {
+ if (context == 0) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Can't add ContextID '%.4s' for ApID '%.4s'\n in %s",
@@ -2528,80 +2382,72 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
dlt_log(LOG_WARNING, local_str);
return -1;
}
- else
- {
+ else {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"ContextID '%.4s' registered for ApID '%.4s', Description=%s\n",
context->ctid,
context->apid,
context->context_description);
+
if (verbose)
- {
dlt_daemon_log_internal(daemon, daemon_local, local_str, verbose);
- }
+
dlt_log(LOG_DEBUG, local_str);
}
- if(daemon_local->flags.offlineLogstorageMaxDevices)
- {
+ if (daemon_local->flags.offlineLogstorageMaxDevices)
/* Store log level set for offline logstorage into context structure*/
context->storage_log_level =
dlt_daemon_logstorage_get_loglevel(daemon,
daemon_local->flags.offlineLogstorageMaxDevices,
userctxt.apid,
userctxt.ctid);
- }
else
- {
context->storage_log_level = DLT_LOG_DEFAULT;
- }
+
/* Create automatic get log info response for registered context */
- if (daemon_local->flags.rflag)
- {
+ if (daemon_local->flags.rflag) {
/* Prepare request for get log info with one application and one context */
- if (dlt_message_init(&msg, verbose)==-1)
- {
- dlt_log(LOG_WARNING,"Can't initialize message");
+ if (dlt_message_init(&msg, verbose) == -1) {
+ dlt_log(LOG_WARNING, "Can't initialize message");
return -1;
}
msg.datasize = sizeof(DltServiceGetLogInfoRequest);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
- dlt_log(LOG_WARNING,"Can't allocate buffer for get log info message\n");
+
+ if (msg.databuffer == 0) {
+ dlt_log(LOG_WARNING, "Can't allocate buffer for get log info message\n");
return -1;
}
- req = (DltServiceGetLogInfoRequest*) msg.databuffer;
+ req = (DltServiceGetLogInfoRequest *)msg.databuffer;
req->service_id = DLT_SERVICE_ID_GET_LOG_INFO;
req->options = daemon_local->flags.autoResponseGetLogInfoOption;
dlt_set_id(req->apid, userctxt.apid);
dlt_set_id(req->ctid, userctxt.ctid);
- dlt_set_id(req->com,"remo");
+ dlt_set_id(req->com, "remo");
- dlt_daemon_control_get_log_info(DLT_DAEMON_SEND_TO_ALL , daemon,daemon_local, &msg, verbose);
+ dlt_daemon_control_get_log_info(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, &msg, verbose);
dlt_message_free(&msg, verbose);
}
- if (context->user_handle >= DLT_FD_MINIMUM)
- {
- if ((userctxt.log_level == DLT_LOG_DEFAULT) || (userctxt.trace_status == DLT_TRACE_STATUS_DEFAULT))
- {
+ if (context->user_handle >= DLT_FD_MINIMUM) {
+ if ((userctxt.log_level == DLT_LOG_DEFAULT) || (userctxt.trace_status == DLT_TRACE_STATUS_DEFAULT)) {
/* This call also replaces the default values with the values defined for default */
- if (dlt_daemon_user_send_log_level(daemon, context, verbose)==-1)
- {
+ if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1) {
dlt_vlog(LOG_WARNING, "Can't send current log level as response to %s for (%.4s;%.4s)\n",
__func__,
context->apid,
@@ -2629,8 +2475,7 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
dlt_vlog(LOG_ERR,
"Invalid function parameters used for %s\n",
__func__);
@@ -2641,19 +2486,15 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
&userapp,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return -1;
- }
- if (user_list->num_applications > 0)
- {
+ if (user_list->num_applications > 0) {
/* Delete this application and all corresponding contexts
* for this application from internal table.
*/
@@ -2662,26 +2503,22 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
daemon->ecuid,
verbose);
- if (application)
- {
+ if (application) {
/* Calculate start offset within contexts[] */
- offset_base=0;
+ offset_base = 0;
+
for (i = 0; i < (application - (user_list->applications)); i++)
- {
offset_base += user_list->applications[i].num_contexts;
- }
- for (i = (application->num_contexts) - 1; i >= 0; i--)
- {
+ for (i = (application->num_contexts) - 1; i >= 0; i--) {
context = &(user_list->contexts[offset_base + i]);
- if (context)
- {
+
+ if (context) {
/* Delete context */
if (dlt_daemon_context_del(daemon,
context,
daemon->ecuid,
- verbose) == -1)
- {
+ verbose) == -1) {
dlt_vlog(LOG_WARNING,
"Can't delete CtID '%.4s' for ApID '%.4s' in %s\n",
context->ctid,
@@ -2696,16 +2533,14 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
if (dlt_daemon_application_del(daemon,
application,
daemon->ecuid,
- verbose) == -1)
- {
+ verbose) == -1) {
dlt_vlog(LOG_WARNING,
"Can't delete ApID '%.4s' in %s\n",
application->apid,
__func__);
return -1;
}
- else
- {
+ else {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Unregistered ApID '%.4s'\n",
@@ -2734,8 +2569,7 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
dlt_vlog(LOG_ERR,
"Invalid function parameters used for %s\n",
__func__);
@@ -2747,10 +2581,8 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
&userctxt,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
context = dlt_daemon_context_find(daemon,
userctxt.apid,
@@ -2758,11 +2590,9 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
daemon->ecuid,
verbose);
- if (context)
- {
+ if (context) {
/* Delete this connection entry from internal table*/
- if (dlt_daemon_context_del(daemon, context, daemon->ecuid, verbose) == -1)
- {
+ if (dlt_daemon_context_del(daemon, context, daemon->ecuid, verbose) == -1) {
dlt_vlog(LOG_WARNING,
"Can't delete CtID '%.4s' for ApID '%.4s' in %s\n",
userctxt.ctid,
@@ -2770,27 +2600,25 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
__func__);
return -1;
}
- else
- {
+ else {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Unregistered CtID '%.4s' for ApID '%.4s'\n",
userctxt.ctid,
userctxt.apid);
+
if (verbose)
- {
dlt_daemon_log_internal(daemon,
daemon_local,
local_str,
verbose);
- }
+
dlt_log(LOG_DEBUG, local_str);
}
}
/* Create automatic unregister context response for unregistered context */
if (daemon_local->flags.rflag)
- {
dlt_daemon_control_message_unregister_context(DLT_DAEMON_SEND_TO_ALL,
daemon,
daemon_local,
@@ -2798,7 +2626,6 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
userctxt.ctid,
"remo",
verbose);
- }
return 0;
}
@@ -2815,42 +2642,39 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_process_user_message_log()\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
ret = dlt_message_read(&(daemon_local->msg),
- (unsigned char*)rec->buf + sizeof(DltUserHeader),
+ (unsigned char *)rec->buf + sizeof(DltUserHeader),
rec->bytesRcvd - sizeof(DltUserHeader),
0,
verbose);
- if(ret!=DLT_MESSAGE_ERROR_OK)
- {
- if(ret!=DLT_MESSAGE_ERROR_SIZE)
- {
+
+ if (ret != DLT_MESSAGE_ERROR_OK) {
+ if (ret != DLT_MESSAGE_ERROR_SIZE)
/* This is a normal usecase: The daemon reads the data in 10kb chunks.
- Thus the last trace in this chunk is probably not complete and will be completed
- with the next chunk read. This happens always when the FIFO is filled with more than 10kb before
- the daemon is able to read from the FIFO.
- Thus the loglevel of this message is set to DEBUG.
- A cleaner solution would be to check more in detail whether the message is not complete (normal usecase)
- or the headers are corrupted (error case). */
- dlt_log(LOG_DEBUG,"Can't read messages from receiver\n");
- }
+ * Thus the last trace in this chunk is probably not complete and will be completed
+ * with the next chunk read. This happens always when the FIFO is filled with more than 10kb before
+ * the daemon is able to read from the FIFO.
+ * Thus the loglevel of this message is set to DEBUG.
+ * A cleaner solution would be to check more in detail whether the message is not complete (normal usecase)
+ * or the headers are corrupted (error case). */
+ dlt_log(LOG_DEBUG, "Can't read messages from receiver\n");
+
return DLT_DAEMON_ERROR_UNKNOWN;
}
/* set overwrite ecu id */
- if ((daemon_local->flags.evalue[0]) && (strncmp(daemon_local->msg.headerextra.ecu,DLT_DAEMON_ECU_ID,4)==0))
- {
+ if ((daemon_local->flags.evalue[0]) && (strncmp(daemon_local->msg.headerextra.ecu, DLT_DAEMON_ECU_ID, 4) == 0)) {
/* Set header extra parameters */
- dlt_set_id(daemon_local->msg.headerextra.ecu, daemon->ecuid );
- //msg.headerextra.seid = 0;
- if (dlt_message_set_extraparameters(&(daemon_local->msg),0) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"Can't set message extra parameters in process user message log\n");
+ dlt_set_id(daemon_local->msg.headerextra.ecu, daemon->ecuid);
+
+ /*msg.headerextra.seid = 0; */
+ if (dlt_message_set_extraparameters(&(daemon_local->msg), 0) == DLT_RETURN_ERROR) {
+ dlt_log(LOG_WARNING, "Can't set message extra parameters in process user message log\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
@@ -2859,81 +2683,67 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
}
/* prepare storage header */
- if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp))
- {
- if (dlt_set_storageheader(daemon_local->msg.storageheader,daemon_local->msg.headerextra.ecu) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"Can't set storage header in process user message log\n");
+ if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp)) {
+ if (dlt_set_storageheader(daemon_local->msg.storageheader,
+ daemon_local->msg.headerextra.ecu) == DLT_RETURN_ERROR) {
+ dlt_log(LOG_WARNING, "Can't set storage header in process user message log\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
}
- else
- {
- if (dlt_set_storageheader(daemon_local->msg.storageheader,daemon->ecuid) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"Can't set storage header in process user message log\n");
- return DLT_DAEMON_ERROR_UNKNOWN;
- }
+ else if (dlt_set_storageheader(daemon_local->msg.storageheader, daemon->ecuid) == DLT_RETURN_ERROR) {
+ dlt_log(LOG_WARNING, "Can't set storage header in process user message log\n");
+ return DLT_DAEMON_ERROR_UNKNOWN;
}
{
/* if no filter set or filter is matching display message */
- if (daemon_local->flags.xflag)
- {
- if (dlt_message_print_hex(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_hex() failed!\n");
- }
+ if (daemon_local->flags.xflag) {
+ if (dlt_message_print_hex(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == DLT_RETURN_ERROR)
+ dlt_log(LOG_WARNING, "dlt_message_print_hex() failed!\n");
} /* if */
else if (daemon_local->flags.aflag)
{
- if (dlt_message_print_ascii(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_ascii() failed!\n");
- }
+ if (dlt_message_print_ascii(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == DLT_RETURN_ERROR)
+ dlt_log(LOG_WARNING, "dlt_message_print_ascii() failed!\n");
} /* if */
else if (daemon_local->flags.sflag)
{
- if (dlt_message_print_header(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_header() failed!\n");
- }
+ if (dlt_message_print_header(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == DLT_RETURN_ERROR)
+ dlt_log(LOG_WARNING, "dlt_message_print_header() failed!\n");
+
/* print message header only */
} /* if */
-
/* check if overflow occurred */
- if(daemon->overflow_counter)
- {
- if(dlt_daemon_send_message_overflow(daemon,daemon_local,verbose)==0)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"%u messages discarded!\n",daemon->overflow_counter);
+ if (daemon->overflow_counter) {
+ if (dlt_daemon_send_message_overflow(daemon, daemon_local, verbose) == 0) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "%u messages discarded!\n", daemon->overflow_counter);
dlt_log(LOG_WARNING, str);
- daemon->overflow_counter=0;
+ daemon->overflow_counter = 0;
}
}
/* send message to client or write to log file */
- if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,daemon_local->msg.headerbuffer,sizeof(DltStorageHeader),daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader),
- daemon_local->msg.databuffer,daemon_local->msg.datasize,verbose)))
- {
- if(ret == DLT_DAEMON_ERROR_BUFFER_FULL)
- {
+ if ((ret =
+ dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, daemon_local->msg.headerbuffer,
+ sizeof(DltStorageHeader),
+ daemon_local->msg.headerbuffer + sizeof(DltStorageHeader),
+ daemon_local->msg.headersize - sizeof(DltStorageHeader),
+ daemon_local->msg.databuffer, daemon_local->msg.datasize, verbose))) {
+ if (ret == DLT_DAEMON_ERROR_BUFFER_FULL)
daemon->overflow_counter++;
- }
}
-
}
+
/* keep not read data in buffer */
- bytes_to_be_removed = daemon_local->msg.headersize+daemon_local->msg.datasize-sizeof(DltStorageHeader)+sizeof(DltUserHeader);
+ bytes_to_be_removed = daemon_local->msg.headersize + daemon_local->msg.datasize - sizeof(DltStorageHeader) +
+ sizeof(DltUserHeader);
+
if (daemon_local->msg.found_serialheader)
- {
bytes_to_be_removed += sizeof(dltSerialHeader);
- }
- if (dlt_receiver_remove(rec, bytes_to_be_removed) == -1)
- {
- dlt_log(LOG_WARNING,"Can't remove bytes from receiver\n");
+ if (dlt_receiver_remove(rec, bytes_to_be_removed) == -1) {
+ dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
@@ -2941,14 +2751,14 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
}
#ifdef DLT_SHM_ENABLE
-#define DLT_SHM_RCV_BUFFER_SIZE 10000
+# define DLT_SHM_RCV_BUFFER_SIZE 10000
int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
DltReceiver *rec,
int verbose)
{
char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
- int j,sent,third_value;
+ int j, sent, third_value;
ssize_t ret;
uint8_t *rcv_buffer = NULL;
int size;
@@ -2959,8 +2769,7 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Invalid function parameters used for %s\n",
@@ -2972,8 +2781,7 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
rcv_buffer = calloc(1, DLT_SHM_RCV_BUFFER_SIZE);
- if (!rcv_buffer)
- {
+ if (!rcv_buffer) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"No memory to allocate receiver buffer in %s.\n",
@@ -2987,110 +2795,97 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
memset(&userheader, 0, len);
if (dlt_receiver_check_and_get(rec, &userheader, len, DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
- //dlt_shm_status(&(daemon_local->dlt_shm));
- while (1)
- {
+ /*dlt_shm_status(&(daemon_local->dlt_shm)); */
+ while (1) {
/* log message in SHM */
size = dlt_shm_copy(&(daemon_local->dlt_shm),
rcv_buffer,
DLT_SHM_RCV_BUFFER_SIZE);
- if(size <= 0)
+
+ if (size <= 0)
break;
- if (dlt_message_read(&(daemon_local->msg),rcv_buffer,size,0,verbose)!=0) {
- break;
- dlt_log(LOG_WARNING,"Can't read messages from shm\n");
- return -1;
- }
-
- /* set overwrite ecu id */
- if ((daemon_local->flags.evalue[0]) && (strncmp(daemon_local->msg.headerextra.ecu,DLT_DAEMON_ECU_ID,4)==0))
- {
- /* Set header extra parameters */
- dlt_set_id(daemon_local->msg.headerextra.ecu, daemon->ecuid );
- //msg.headerextra.seid = 0;
- if (dlt_message_set_extraparameters(&(daemon_local->msg),0)==-1)
- {
- dlt_log(LOG_WARNING,"Can't set message extra parameters in process user message log\n");
- dlt_shm_remove(&(daemon_local->dlt_shm));
- return -1;
- }
-
- /* Correct value of timestamp, this was changed by dlt_message_set_extraparameters() */
- daemon_local->msg.headerextra.tmsp = DLT_BETOH_32(daemon_local->msg.headerextra.tmsp);
- }
-
- /* prepare storage header */
- if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp))
- {
- if (dlt_set_storageheader(daemon_local->msg.storageheader,daemon_local->msg.headerextra.ecu)==-1)
- {
- dlt_log(LOG_WARNING,"Can't set storage header in process user message log\n");
- dlt_shm_remove(&(daemon_local->dlt_shm));
- return -1;
- }
- }
- else
- {
- if (dlt_set_storageheader(daemon_local->msg.storageheader,daemon->ecuid)==-1)
- {
- dlt_log(LOG_WARNING,"Can't set storage header in process user message log\n");
- dlt_shm_remove(&(daemon_local->dlt_shm));
- return -1;
- }
- }
-
- /* display message */
- if (daemon_local->flags.xflag)
- {
- if (dlt_message_print_hex(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_hex() failed!\n");
- }
- } /* if */
- else if (daemon_local->flags.aflag)
- {
- if (dlt_message_print_ascii(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_ascii() failed!\n");
- }
- } /* if */
- else if (daemon_local->flags.sflag)
- {
- if (dlt_message_print_header(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_header() failed!\n");
- }
- /* print message header only */
- } /* if */
-
- sent=0;
-
- /* write message to offline trace */
- if(daemon_local->flags.offlineTraceDirectory[0])
- {
- dlt_offline_trace_write(&(daemon_local->offlineTrace),daemon_local->msg.headerbuffer,daemon_local->msg.headersize,
- daemon_local->msg.databuffer,daemon_local->msg.datasize,0,0);
- sent = 1;
- }
+ if (dlt_message_read(&(daemon_local->msg), rcv_buffer, size, 0, verbose) != 0) {
+ break;
+ dlt_log(LOG_WARNING, "Can't read messages from shm\n");
+ return -1;
+ }
+
+ /* set overwrite ecu id */
+ if ((daemon_local->flags.evalue[0]) &&
+ (strncmp(daemon_local->msg.headerextra.ecu, DLT_DAEMON_ECU_ID, 4) == 0)) {
+ /* Set header extra parameters */
+ dlt_set_id(daemon_local->msg.headerextra.ecu, daemon->ecuid);
+
+ /*msg.headerextra.seid = 0; */
+ if (dlt_message_set_extraparameters(&(daemon_local->msg), 0) == -1) {
+ dlt_log(LOG_WARNING, "Can't set message extra parameters in process user message log\n");
+ dlt_shm_remove(&(daemon_local->dlt_shm));
+ return -1;
+ }
+
+ /* Correct value of timestamp, this was changed by dlt_message_set_extraparameters() */
+ daemon_local->msg.headerextra.tmsp = DLT_BETOH_32(daemon_local->msg.headerextra.tmsp);
+ }
+
+ /* prepare storage header */
+ if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp)) {
+ if (dlt_set_storageheader(daemon_local->msg.storageheader, daemon_local->msg.headerextra.ecu) == -1) {
+ dlt_log(LOG_WARNING, "Can't set storage header in process user message log\n");
+ dlt_shm_remove(&(daemon_local->dlt_shm));
+ return -1;
+ }
+ }
+ else if (dlt_set_storageheader(daemon_local->msg.storageheader, daemon->ecuid) == -1) {
+ dlt_log(LOG_WARNING, "Can't set storage header in process user message log\n");
+ dlt_shm_remove(&(daemon_local->dlt_shm));
+ return -1;
+ }
+
+ /* display message */
+ if (daemon_local->flags.xflag) {
+ if (dlt_message_print_hex(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == -1)
+ dlt_log(LOG_WARNING, "dlt_message_print_hex() failed!\n");
+ } /* if */
+ else if (daemon_local->flags.aflag)
+ {
+ if (dlt_message_print_ascii(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == -1)
+ dlt_log(LOG_WARNING, "dlt_message_print_ascii() failed!\n");
+ } /* if */
+ else if (daemon_local->flags.sflag)
+ {
+ if (dlt_message_print_header(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == -1)
+ dlt_log(LOG_WARNING, "dlt_message_print_header() failed!\n");
+
+ /* print message header only */
+ } /* if */
+
+ sent = 0;
+
+ /* write message to offline trace */
+ if (daemon_local->flags.offlineTraceDirectory[0]) {
+ dlt_offline_trace_write(&(daemon_local->offlineTrace),
+ daemon_local->msg.headerbuffer,
+ daemon_local->msg.headersize,
+ daemon_local->msg.databuffer,
+ daemon_local->msg.datasize,
+ 0,
+ 0);
+ sent = 1;
+ }
sent = dlt_daemon_client_send_all(daemon, daemon_local, verbose);
/* Message was not sent to client, so store it in client ringbuffer */
- if (sent == 1)
- {
- if(userheader.message == DLT_USER_MESSAGE_LOG_SHM) {
+ if (sent == 1) {
+ if (userheader.message == DLT_USER_MESSAGE_LOG_SHM)
/* dlt message was sent, remove from buffer if log message from shm */
dlt_shm_remove(&(daemon_local->dlt_shm));
- }
}
- else
- {
+ else {
/* dlt message was not sent, keep in buffer */
break;
}
@@ -3098,7 +2893,7 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
return 0;
}
-#undef DLT_SHM_RCV_BUFFER_SIZE
+# undef DLT_SHM_RCV_BUFFER_SIZE
#endif
int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
@@ -3112,12 +2907,11 @@ int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
DltDaemonContext *context;
int i, offset_base;
int8_t old_log_level, old_trace_status;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
dlt_vlog(LOG_ERR,
"Invalid function parameters used for %s\n",
__func__);
@@ -3125,42 +2919,37 @@ int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
}
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return DLT_RETURN_ERROR;
- }
memset(&userctxt, 0, len);
+
if (dlt_receiver_check_and_get(rec,
&userctxt,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return DLT_RETURN_ERROR;
- }
- if (user_list->num_applications > 0)
- {
+ if (user_list->num_applications > 0) {
/* Get all contexts with application id matching the received application id */
application = dlt_daemon_application_find(daemon,
userctxt.apid,
daemon->ecuid,
verbose);
- if (application)
- {
+
+ if (application) {
/* Calculate start offset within contexts[] */
- offset_base=0;
+ offset_base = 0;
+
for (i = 0; i < (application - (user_list->applications)); i++)
- {
offset_base += user_list->applications[i].num_contexts;
- }
- for (i = 0; i < application->num_contexts; i++)
- {
+ for (i = 0; i < application->num_contexts; i++) {
context = &(user_list->contexts[offset_base + i]);
- if (context)
- {
+
+ if (context) {
old_log_level = context->log_level;
context->log_level = userctxt.log_level; /* No endianess conversion necessary*/
@@ -3171,8 +2960,7 @@ int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
if ((context->user_handle >= DLT_FD_MINIMUM) &&
(dlt_daemon_user_send_log_level(daemon,
context,
- verbose) != 0))
- {
+ verbose) != 0)) {
context->log_level = old_log_level;
context->trace_status = old_trace_status;
}
@@ -3194,21 +2982,19 @@ int dlt_daemon_process_user_message_log_mode(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_process_log_mode()\n");
return -1;
}
memset(&userctxt, 0, len);
+
if (dlt_receiver_check_and_get(rec,
&userctxt,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
/* set the new log mode */
daemon->mode = userctxt.log_mode;
@@ -3229,8 +3015,7 @@ int dlt_daemon_process_user_message_marker(DltDaemon *daemon,
DltUserControlMsgLogMode userctxt;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Invalid function parameters used for %s\n",
@@ -3241,17 +3026,16 @@ int dlt_daemon_process_user_message_marker(DltDaemon *daemon,
}
memset(&userctxt, 0, len);
+
if (dlt_receiver_check_and_get(rec,
&userctxt,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
/* Create automatic unregister context response for unregistered context */
- dlt_daemon_control_message_marker(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,verbose);
+ dlt_daemon_control_message_marker(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, verbose);
return 0;
}
@@ -3267,49 +3051,48 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_send_ringbuffer_to_client()\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
- if(dlt_buffer_get_message_count(&(daemon->client_ringbuffer)) <= 0)
- {
+ if (dlt_buffer_get_message_count(&(daemon->client_ringbuffer)) <= 0) {
dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_DIRECT);
return DLT_DAEMON_ERROR_OK;
}
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
- if(sd_notify(0, "WATCHDOG=1") < 0)
- {
+
+ if (sd_notify(0, "WATCHDOG=1") < 0)
dlt_log(LOG_WARNING, "Could not reset systemd watchdog\n");
- }
+
curr_time = dlt_uptime();
#endif
- while ( (length = dlt_buffer_copy(&(daemon->client_ringbuffer), data, sizeof(data)) ) > 0)
- {
+
+ while ((length = dlt_buffer_copy(&(daemon->client_ringbuffer), data, sizeof(data))) > 0) {
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
- if ((dlt_uptime() - curr_time) / 10000 >= watchdog_trigger_interval)
- {
- if(sd_notify(0, "WATCHDOG=1") < 0)
- {
+
+ if ((dlt_uptime() - curr_time) / 10000 >= watchdog_trigger_interval) {
+ if (sd_notify(0, "WATCHDOG=1") < 0)
dlt_log(LOG_WARNING, "Could not reset systemd watchdog\n");
- }
+
curr_time = dlt_uptime();
}
+
#endif
- if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_FORCE,daemon,daemon_local,0,0,data,length,0,0,verbose)))
- {
+ if ((ret =
+ dlt_daemon_client_send(DLT_DAEMON_SEND_FORCE, daemon, daemon_local, 0, 0, data, length, 0, 0,
+ verbose)))
return ret;
- }
+
dlt_buffer_remove(&(daemon->client_ringbuffer));
- if(daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)
- dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_SEND_BUFFER);
- if(dlt_buffer_get_message_count(&(daemon->client_ringbuffer)) <= 0)
- {
- dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_SEND_DIRECT);
+ if (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)
+ dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_BUFFER);
+
+ if (dlt_buffer_get_message_count(&(daemon->client_ringbuffer)) <= 0) {
+ dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_DIRECT);
return DLT_DAEMON_ERROR_OK;
}
}
@@ -3318,8 +3101,8 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem
}
static char dlt_timer_conn_types[DLT_TIMER_UNKNOWN + 1] = {
- [DLT_TIMER_PACKET] = DLT_CONNECTION_ONE_S_TIMER,
- [DLT_TIMER_ECU] = DLT_CONNECTION_SIXTY_S_TIMER,
+ [DLT_TIMER_PACKET] = DLT_CONNECTION_ONE_S_TIMER,
+ [DLT_TIMER_ECU] = DLT_CONNECTION_SIXTY_S_TIMER,
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
[DLT_TIMER_SYSTEMD] = DLT_CONNECTION_SYSTEMD_TIMER,
#endif
@@ -3328,8 +3111,8 @@ static char dlt_timer_conn_types[DLT_TIMER_UNKNOWN + 1] = {
};
static char dlt_timer_names[DLT_TIMER_UNKNOWN + 1][32] = {
- [DLT_TIMER_PACKET] = "Timing packet",
- [DLT_TIMER_ECU] = "ECU version",
+ [DLT_TIMER_PACKET] = "Timing packet",
+ [DLT_TIMER_ECU] = "ECU version",
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
[DLT_TIMER_SYSTEMD] = "Systemd watchdog",
#endif
@@ -3353,17 +3136,16 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
timer_name = dlt_timer_names[timer_id];
- if(daemon_local == NULL)
- {
+ if (daemon_local == NULL) {
dlt_log(DLT_LOG_ERROR, "Daemaon local structure is NULL");
return -1;
}
- if(period_sec > 0) {
+ if (period_sec > 0) {
#ifdef linux
local_fd = timerfd_create(CLOCK_MONOTONIC, 0);
- if( local_fd < 0)
- {
+
+ if (local_fd < 0) {
snprintf(str,
sizeof(str),
"<%s> timerfd_create failed: %s\n",
@@ -3377,8 +3159,7 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
l_timer_spec.it_value.tv_sec = starts_in;
l_timer_spec.it_value.tv_nsec = 0;
- if( timerfd_settime(local_fd, 0, &l_timer_spec, NULL) < 0)
- {
+ if (timerfd_settime(local_fd, 0, &l_timer_spec, NULL) < 0) {
snprintf(str,
sizeof(str),
"<%s> timerfd_settime failed: %s\n",
@@ -3387,10 +3168,11 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
dlt_log(LOG_WARNING, str);
local_fd = -1;
}
+
#endif
}
else {
- // timer not activated via the service file
+ /* timer not activated via the service file */
snprintf(str, sizeof(str), "<%s> not set: period=0\n", timer_name);
dlt_log(LOG_INFO, str);
local_fd = -1;
@@ -3399,8 +3181,7 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
/* If fully initialized we are done.
* Event handling registration is done later on with other connections.
*/
- if(local_fd > 0)
- {
+ if (local_fd > 0) {
snprintf(str,
sizeof(str),
"<%s> initialized with %d timer\n",
@@ -3423,32 +3204,34 @@ int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_
PRINT_FUNCTION_VERBOSE(verbose);
- if((daemon_local == NULL)|| (daemon == NULL))
- {
+ if ((daemon_local == NULL) || (daemon == NULL)) {
dlt_log(LOG_ERR, "dlt_daemon_close_socket: Invalid input parmeters\n");
return -1;
}
/* Closure is done while unregistering has for any connection */
dlt_event_handler_unregister_connection(&daemon_local->pEvent,
- daemon_local,
- sock);
+ daemon_local,
+ sock);
-
- if(daemon_local->client_connections==0)
- {
+ if (daemon_local->client_connections == 0) {
/* send new log state to all applications */
daemon->connectionState = 0;
- dlt_daemon_user_send_all_log_state(daemon,verbose);
+ dlt_daemon_user_send_all_log_state(daemon, verbose);
- // For offline tracing we still can use the same states
- // as for socket sending. Using this trick we see the traces
- // In the offline trace AND in the socket stream.
- if(daemon_local->flags.yvalue[0] == 0)
- dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_BUFFER);
+ /* For offline tracing we still can use the same states */
+ /* as for socket sending. Using this trick we see the traces */
+ /* In the offline trace AND in the socket stream. */
+ if (daemon_local->flags.yvalue[0] == 0)
+ dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER);
}
- dlt_daemon_control_message_connection_info(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,DLT_CONNECTION_STATUS_DISCONNECTED,"",verbose);
+ dlt_daemon_control_message_connection_info(DLT_DAEMON_SEND_TO_ALL,
+ daemon,
+ daemon_local,
+ DLT_CONNECTION_STATUS_DISCONNECTED,
+ "",
+ verbose);
snprintf(local_str, DLT_DAEMON_TEXTBUFSIZE,
"Client connection #%d closed. Total Clients : %d\n",
@@ -3461,5 +3244,5 @@ int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_
}
/**
- \}
-*/
+ \}
+ */
diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h
index 3370680..c813b42 100644
--- a/src/daemon/dlt-daemon.h
+++ b/src/daemon/dlt-daemon.h
@@ -100,21 +100,21 @@ typedef struct
char yvalue[NAME_MAX + 1]; /**< (String: Devicename) Additional support for serial device */
char ivalue[NAME_MAX + 1]; /**< (String: Directory) Directory where to store the persistant configuration (Default: /tmp) */
char cvalue[NAME_MAX + 1]; /**< (String: Directory) Filename of DLT configuration file (Default: /etc/dlt.conf) */
- int sharedMemorySize; /**< (int) Size of shared memory (Default: 100000) */
- int sendMessageTime; /**< (Boolean) Send periodic Message Time if client is connected (Default: 0) */
+ int sharedMemorySize; /**< (int) Size of shared memory (Default: 100000) */
+ int sendMessageTime; /**< (Boolean) Send periodic Message Time if client is connected (Default: 0) */
char offlineTraceDirectory[DLT_DAEMON_FLAG_MAX]; /**< (String: Directory) Store DLT messages to local directory (Default: /etc/dlt.conf) */
- int offlineTraceFileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */
- int offlineTraceMaxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */
- int offlineTraceFilenameTimestampBased; /**< (int) timestamp based or index based (Default: 1 Timestamp based) */
- int loggingMode; /**< (int) The logging console for internal logging of dlt-daemon (Default: 0) */
- int loggingLevel; /**< (int) The logging level for internal logging of dlt-daemon (Default: 6) */
+ int offlineTraceFileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */
+ int offlineTraceMaxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */
+ int offlineTraceFilenameTimestampBased; /**< (int) timestamp based or index based (Default: 1 Timestamp based) */
+ int loggingMode; /**< (int) The logging console for internal logging of dlt-daemon (Default: 0) */
+ int loggingLevel; /**< (int) The logging level for internal logging of dlt-daemon (Default: 6) */
char loggingFilename[DLT_DAEMON_FLAG_MAX]; /**< (String: Filename) The logging filename if internal logging mode is log to file (Default: /tmp/log) */
- int sendECUSoftwareVersion; /**< (Boolean) Send ECU software version perdiodically */
+ int sendECUSoftwareVersion; /**< (Boolean) Send ECU software version perdiodically */
char pathToECUSoftwareVersion[DLT_DAEMON_FLAG_MAX]; /**< (String: Filename) The file from which to read the ECU version from. */
- int sendTimezone; /**< (Boolean) Send Timezone perdiodically */
- int offlineLogstorageMaxDevices; /**< (int) Maximum devices to be used as offline logstorage devices */
+ int sendTimezone; /**< (Boolean) Send Timezone perdiodically */
+ int offlineLogstorageMaxDevices; /**< (int) Maximum devices to be used as offline logstorage devices */
char offlineLogstorageDirPath[DLT_MOUNT_PATH_MAX]; /**< (String: Directory) DIR path to store offline logs */
- int offlineLogstorageTimestamp; /**< (int) Append timestamp in offline logstorage filename */
+ int offlineLogstorageTimestamp; /**< (int) Append timestamp in offline logstorage filename */
char offlineLogstorageDelimiter; /**< (char) Append delimeter character in offline logstorage filename */
unsigned int offlineLogstorageMaxCounter; /**< (int) Maximum offline logstorage file counter index until wraparound */
unsigned int offlineLogstorageMaxCounterIdx; /**< (int) String len of offlineLogstorageMaxCounter*/
@@ -125,14 +125,14 @@ typedef struct
char userPipesDir[NAME_MAX + 1]; /**< (String: Directory) directory where dltpipes reside (Default: /tmp/dltpipes) */
#endif
char daemonFifoName[NAME_MAX + 1]; /**< (String: Filename) name of local fifo (Default: /tmp/dlt) */
- unsigned int port; /**< port number */
+ unsigned int port; /**< port number */
char ctrlSockPath[DLT_DAEMON_FLAG_MAX]; /**< Path to Control socket */
int gatewayMode; /**< (Boolean) Gateway Mode */
char gatewayConfigFile[DLT_DAEMON_FLAG_MAX]; /**< Gateway config file path */
- int autoResponseGetLogInfoOption; /**< (int) The Option of automatic get log info response during context registration. (Default: 7)*/
- int contextLogLevel; /**< (int) log level sent to context if registered with default log-level or if enforced*/
- int contextTraceStatus; /**< (int) trace status sent to context if registered with default trace status or if enforced*/
- int enforceContextLLAndTS; /**< (Boolean) Enforce log-level, trace-status not to exceed contextLogLevel, contextTraceStatus */
+ int autoResponseGetLogInfoOption; /**< (int) The Option of automatic get log info response during context registration. (Default: 7)*/
+ int contextLogLevel; /**< (int) log level sent to context if registered with default log-level or if enforced*/
+ int contextTraceStatus; /**< (int) trace status sent to context if registered with default trace status or if enforced*/
+ int enforceContextLLAndTS; /**< (Boolean) Enforce log-level, trace-status not to exceed contextLogLevel, contextTraceStatus */
} DltDaemonFlags;
/**
* The global parameters of a dlt daemon.
@@ -189,7 +189,10 @@ void dlt_daemon_exit_trigger();
void dlt_daemon_signal_handler(int sig);
int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *revc, int verbose);
-int dlt_daemon_process_client_messages_serial(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
+int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *recv,
+ int verbose);
int dlt_daemon_process_user_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
int dlt_daemon_process_one_s_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
@@ -199,28 +202,54 @@ int dlt_daemon_process_control_connect(DltDaemon *daemon, DltDaemonLocal *daemon
#ifdef DLT_USE_UNIX_SOCKET_IPC
int dlt_daemon_process_app_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
#endif
-int dlt_daemon_process_control_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
+int dlt_daemon_process_control_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv,
+ int verbose);
-typedef int (*dlt_daemon_process_user_message_func)(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
+typedef int (*dlt_daemon_process_user_message_func)(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec,
+ int verbose);
-int dlt_daemon_process_user_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
+int dlt_daemon_process_user_message_overflow(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
int dlt_daemon_send_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
-int dlt_daemon_process_user_message_register_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
-int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
-int dlt_daemon_process_user_message_register_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
-int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
+int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
+int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
+int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
+int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
#ifdef DLT_SHM_ENABLE
-int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
+int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
#endif
-int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
-int dlt_daemon_process_user_message_marker(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
+int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
+int dlt_daemon_process_user_message_marker(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
void dlt_daemon_timingpacket_thread(void *ptr);
void dlt_daemon_ecu_version_thread(void *ptr);
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
- void dlt_daemon_systemd_watchdog_thread(void *ptr);
+void dlt_daemon_systemd_watchdog_thread(void *ptr);
#endif
int create_timer_fd(DltDaemonLocal *daemon_local, int period_sec, int starts_in, DltTimers timer);
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c
index 55b775b..55afd7c 100644
--- a/src/daemon/dlt_daemon_client.c
+++ b/src/daemon/dlt_daemon_client.c
@@ -25,7 +25,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_daemon_client.c
-*/
+ */
#include <netdb.h>
#include <ctype.h>
@@ -42,16 +42,16 @@
#include <pthread.h>
#ifdef linux
-#include <sys/timerfd.h>
+# include <sys/timerfd.h>
#endif
#include <sys/stat.h>
#include <sys/time.h>
#if defined(linux) && defined(__NR_statx)
-#include <linux/stat.h>
+# include <linux/stat.h>
#endif
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
-#include <systemd/sd-daemon.h>
+# include <systemd/sd-daemon.h>
#endif
#include "dlt_types.h"
@@ -79,10 +79,10 @@ static char str[DLT_DAEMON_TEXTBUFSIZE];
* @param context_log The default log level (or) trace status
*
* @return The log level if requested log level is lower or equal to ContextLogLevel
-*/
+ */
static inline int8_t getStatus(uint8_t request_log, int context_log)
{
- return (request_log <= context_log)? request_log : context_log;
+ return (request_log <= context_log) ? request_log : context_log;
}
/** @brief Sends up to 2 messages to all the clients.
@@ -103,9 +103,9 @@ static inline int8_t getStatus(uint8_t request_log, int context_log)
*/
static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
- void* data1,
+ void *data1,
int size1,
- void* data2,
+ void *data2,
int size2,
int verbose)
{
@@ -115,8 +115,7 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
(DLT_CON_MASK_CLIENT_MSG_TCP | DLT_CON_MASK_CLIENT_MSG_SERIAL);
uint8_t *tmp_buffer = NULL;
- if ((daemon == NULL) || (daemon_local == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL)) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return 0;
}
@@ -128,50 +127,48 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
* can be affect between each iteration, but
* dlt_daemon_close_socket may call us too ...
*/
- for (j = 0; ((j < daemon_local->client_connections) && (temp != NULL)); j++)
- {
+ for (j = 0; ((j < daemon_local->client_connections) && (temp != NULL)); j++) {
int ret = 0;
DLT_DAEMON_SEM_LOCK();
DltConnection *next = dlt_connection_get_next(temp->next, type_mask);
ret = dlt_connection_send_multiple(temp,
- data1,
- size1,
- data2,
- size2,
- daemon->sendserialheader);
+ data1,
+ size1,
+ data2,
+ size2,
+ daemon->sendserialheader);
DLT_DAEMON_SEM_FREE();
if ((ret != DLT_DAEMON_ERROR_OK) &&
- (DLT_CONNECTION_CLIENT_MSG_TCP == temp->type))
- {
- if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL)
- {
- if (temp->receiver->bytes_sent < (size1 + size2))
- {
- tmp_buffer = (uint8_t*)calloc(size1 + size2, sizeof(uint8_t));
-
- if (tmp_buffer == NULL)
- {
+ (DLT_CONNECTION_CLIENT_MSG_TCP == temp->type)) {
+ if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) {
+ if (temp->receiver->bytes_sent < (size1 + size2)) {
+ tmp_buffer = (uint8_t *)calloc(size1 + size2, sizeof(uint8_t));
+
+ if (tmp_buffer == NULL) {
dlt_vlog(LOG_ERR, "%s: Memory allocation failed.\n", __func__);
return 0;
}
+
memcpy(tmp_buffer, data1, size1);
memcpy(tmp_buffer + size1, data2, size2);
DLT_DAEMON_SEM_LOCK();
+
/* Store message in history buffer */
if (dlt_buffer_push3(&(daemon->client_ringbuffer),
tmp_buffer + temp->receiver->bytes_sent,
(size1 + size2 - temp->receiver->bytes_sent),
- 0, 0, 0, 0) < DLT_RETURN_OK)
- {
+ 0, 0, 0, 0) < DLT_RETURN_OK) {
dlt_vlog(LOG_DEBUG, "%s: Buffer is full! Message discarded.\n", __func__);
dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL);
}
+
free(tmp_buffer);
DLT_DAEMON_SEM_FREE();
}
}
+
dlt_daemon_close_socket(temp->receiver->fd,
daemon,
daemon_local,
@@ -179,16 +176,12 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
}
if (ret != DLT_DAEMON_ERROR_OK)
- {
dlt_vlog(LOG_WARNING, "%s: send dlt message failed\n", __func__);
- }
else
- {
/* If sent to at least one client,
* then do not store in ring buffer
*/
sent = 1;
- }
temp = next;
} /* for */
@@ -213,8 +206,7 @@ int dlt_daemon_client_send_all(DltDaemon *daemon,
int ret = 0;
char local_str[DLT_DAEMON_TEXTBUFSIZE];
- if ((daemon == NULL) || (daemon_local == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: Invalid parameters\n",
@@ -234,77 +226,81 @@ int dlt_daemon_client_send_all(DltDaemon *daemon,
DLT_DAEMON_SEM_FREE();
ret = dlt_daemon_client_send_all_multiple(daemon,
- daemon_local,
- msg1,
- msg1_sz,
- msg2,
- msg2_sz,
- verbose);
+ daemon_local,
+ msg1,
+ msg1_sz,
+ msg2,
+ msg2_sz,
+ verbose);
return ret;
}
-int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_local,void* storage_header,int storage_header_size,void* data1,int size1,void* data2,int size2,int verbose)
+int dlt_daemon_client_send(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ void *storage_header,
+ int storage_header_size,
+ void *data1,
+ int size1,
+ void *data2,
+ int size2,
+ int verbose)
{
- int sent,ret;
+ int sent, ret;
- if (sock!=DLT_DAEMON_SEND_TO_ALL && sock!=DLT_DAEMON_SEND_FORCE)
- {
+ if ((sock != DLT_DAEMON_SEND_TO_ALL) && (sock != DLT_DAEMON_SEND_FORCE)) {
/* Send message to specific socket */
- if (isatty(sock))
- {
+ if (isatty(sock)) {
DLT_DAEMON_SEM_LOCK();
- if((ret=dlt_daemon_serial_send(sock,data1,size1,data2,size2,daemon->sendserialheader)))
- {
+ if ((ret = dlt_daemon_serial_send(sock, data1, size1, data2, size2, daemon->sendserialheader))) {
DLT_DAEMON_SEM_FREE();
- dlt_log(LOG_WARNING,"dlt_daemon_client_send: serial send dlt message failed\n");
+ dlt_log(LOG_WARNING, "dlt_daemon_client_send: serial send dlt message failed\n");
return ret;
- }
+ }
DLT_DAEMON_SEM_FREE();
}
- else
- {
+ else {
DLT_DAEMON_SEM_LOCK();
- if((ret=dlt_daemon_socket_send(sock,data1,size1,data2,size2,daemon->sendserialheader)))
- {
+ if ((ret = dlt_daemon_socket_send(sock, data1, size1, data2, size2, daemon->sendserialheader))) {
DLT_DAEMON_SEM_FREE();
- dlt_log(LOG_WARNING,"dlt_daemon_client_send: socket send dlt message failed\n");
+ dlt_log(LOG_WARNING, "dlt_daemon_client_send: socket send dlt message failed\n");
return ret;
}
DLT_DAEMON_SEM_FREE();
}
+
return DLT_DAEMON_ERROR_OK;
}
- /* write message to offline trace */
- // In the SEND_BUFFER state we must skip offline tracing because the offline traces
- // are going without buffering directly to the offline trace. Thus we have to filter out
- // the traces that are coming from the buffer.
- if ((sock!=DLT_DAEMON_SEND_FORCE) && (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER))
- {
- if(((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
- && daemon_local->flags.offlineTraceDirectory[0])
- {
- if(dlt_offline_trace_write(&(daemon_local->offlineTrace),storage_header,storage_header_size,data1,size1,data2,size2))
- {
- static int error_dlt_offline_trace_write_failed = 0;
- if(!error_dlt_offline_trace_write_failed)
- {
- dlt_log(LOG_ERR,"dlt_daemon_client_send: dlt_offline_trace_write failed!\n");
- error_dlt_offline_trace_write_failed = 1;
+ /* write message to offline trace */
+ /* In the SEND_BUFFER state we must skip offline tracing because the offline traces */
+ /* are going without buffering directly to the offline trace. Thus we have to filter out */
+ /* the traces that are coming from the buffer. */
+ if ((sock != DLT_DAEMON_SEND_FORCE) && (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)) {
+ if (((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
+ && daemon_local->flags.offlineTraceDirectory[0]) {
+ if (dlt_offline_trace_write(&(daemon_local->offlineTrace), storage_header, storage_header_size, data1,
+ size1, data2, size2)) {
+ static int error_dlt_offline_trace_write_failed = 0;
+
+ if (!error_dlt_offline_trace_write_failed) {
+ dlt_log(LOG_ERR, "dlt_daemon_client_send: dlt_offline_trace_write failed!\n");
+ error_dlt_offline_trace_write_failed = 1;
}
- //return DLT_DAEMON_ERROR_WRITE_FAILED;
- }
- }
+
+ /*return DLT_DAEMON_ERROR_WRITE_FAILED; */
+ }
+ }
+
/* write messages to offline logstorage only if there is an extended header set
* this need to be checked because the function is dlt_daemon_client_send is called by
* newly introduced dlt_daemon_log_internal */
- if(daemon_local->flags.offlineLogstorageMaxDevices > 0)
- {
+ if (daemon_local->flags.offlineLogstorageMaxDevices > 0)
dlt_daemon_logstorage_write(daemon,
&daemon_local->flags,
storage_header,
@@ -313,14 +309,11 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc
size1,
data2,
size2);
- }
- }
+ }
- /* send messages to daemon socket */
- if((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
- {
- if ((sock==DLT_DAEMON_SEND_FORCE) || (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT))
- {
+ /* send messages to daemon socket */
+ if ((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) {
+ if ((sock == DLT_DAEMON_SEND_FORCE) || (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT)) {
sent = dlt_daemon_client_send_all_multiple(daemon,
daemon_local,
data1,
@@ -329,28 +322,28 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc
size2,
verbose);
- if((sock==DLT_DAEMON_SEND_FORCE) && !sent)
- {
- return DLT_DAEMON_ERROR_SEND_FAILED;
- }
- }
+ if ((sock == DLT_DAEMON_SEND_FORCE) && !sent)
+ return DLT_DAEMON_ERROR_SEND_FAILED;
+ }
}
/* Message was not sent to client, so store it in client ringbuffer */
- if ((sock!=DLT_DAEMON_SEND_FORCE) && (daemon->state == DLT_DAEMON_STATE_BUFFER || daemon->state == DLT_DAEMON_STATE_SEND_BUFFER || daemon->state == DLT_DAEMON_STATE_BUFFER_FULL))
- {
- if(daemon->state == DLT_DAEMON_STATE_BUFFER_FULL)
- return DLT_DAEMON_ERROR_BUFFER_FULL;
+ if ((sock != DLT_DAEMON_SEND_FORCE) &&
+ ((daemon->state == DLT_DAEMON_STATE_BUFFER) || (daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
+ (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL))) {
+ if (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL)
+ return DLT_DAEMON_ERROR_BUFFER_FULL;
DLT_DAEMON_SEM_LOCK();
+
/* Store message in history buffer */
- if (dlt_buffer_push3(&(daemon->client_ringbuffer),data1,size1,data2,size2,0, 0) < DLT_RETURN_OK)
- {
- DLT_DAEMON_SEM_FREE();
- dlt_log(LOG_DEBUG,"dlt_daemon_client_send: Buffer is full! Message discarded.\n");
- dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_BUFFER_FULL);
- return DLT_DAEMON_ERROR_BUFFER_FULL;
- }
+ if (dlt_buffer_push3(&(daemon->client_ringbuffer), data1, size1, data2, size2, 0, 0) < DLT_RETURN_OK) {
+ DLT_DAEMON_SEM_FREE();
+ dlt_log(LOG_DEBUG, "dlt_daemon_client_send: Buffer is full! Message discarded.\n");
+ dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL);
+ return DLT_DAEMON_ERROR_BUFFER_FULL;
+ }
+
DLT_DAEMON_SEM_FREE();
}
@@ -358,136 +351,133 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc
}
-int dlt_daemon_client_send_control_message( int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, char* appid, char* ctid, int verbose)
+int dlt_daemon_client_send_control_message(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ char *appid,
+ char *ctid,
+ int verbose)
{
- int ret;
+ int ret;
int32_t len;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (msg==0) || (appid==0) || (ctid==0))
- {
+ if ((daemon == 0) || (msg == 0) || (appid == 0) || (ctid == 0))
return DLT_DAEMON_ERROR_UNKNOWN;
- }
/* prepare storage header */
- msg->storageheader = (DltStorageHeader*)msg->headerbuffer;
+ msg->storageheader = (DltStorageHeader *)msg->headerbuffer;
- if (dlt_set_storageheader(msg->storageheader,daemon->ecuid) == DLT_RETURN_ERROR)
- {
- return DLT_DAEMON_ERROR_UNKNOWN;
- }
+ if (dlt_set_storageheader(msg->storageheader, daemon->ecuid) == DLT_RETURN_ERROR)
+ return DLT_DAEMON_ERROR_UNKNOWN;
/* prepare standard header */
- msg->standardheader = (DltStandardHeader*)(msg->headerbuffer + sizeof(DltStorageHeader));
- msg->standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1 ;
+ msg->standardheader = (DltStandardHeader *)(msg->headerbuffer + sizeof(DltStorageHeader));
+ msg->standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
-#if (BYTE_ORDER==BIG_ENDIAN)
- msg->standardheader->htyp = ( msg->standardheader->htyp | DLT_HTYP_MSBF);
+#if (BYTE_ORDER == BIG_ENDIAN)
+ msg->standardheader->htyp = (msg->standardheader->htyp | DLT_HTYP_MSBF);
#endif
msg->standardheader->mcnt = 0;
/* Set header extra parameters */
- dlt_set_id(msg->headerextra.ecu,daemon->ecuid);
+ dlt_set_id(msg->headerextra.ecu, daemon->ecuid);
- //msg->headerextra.seid = 0;
+ /*msg->headerextra.seid = 0; */
msg->headerextra.tmsp = dlt_uptime();
dlt_message_set_extraparameters(msg, verbose);
/* prepare extended header */
- msg->extendedheader = (DltExtendedHeader*)(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+ msg->extendedheader =
+ (DltExtendedHeader *)(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
msg->extendedheader->msin = DLT_MSIN_CONTROL_RESPONSE;
msg->extendedheader->noar = 1; /* number of arguments */
- if (strcmp(appid,"")==0)
- {
- dlt_set_id(msg->extendedheader->apid,DLT_DAEMON_CTRL_APID); /* application id */
- }
+
+ if (strcmp(appid, "") == 0)
+ dlt_set_id(msg->extendedheader->apid, DLT_DAEMON_CTRL_APID); /* application id */
else
- {
dlt_set_id(msg->extendedheader->apid, appid);
- }
- if (strcmp(ctid,"")==0)
- {
- dlt_set_id(msg->extendedheader->ctid,DLT_DAEMON_CTRL_CTID); /* context id */
- }
+
+ if (strcmp(ctid, "") == 0)
+ dlt_set_id(msg->extendedheader->ctid, DLT_DAEMON_CTRL_CTID); /* context id */
else
- {
dlt_set_id(msg->extendedheader->ctid, ctid);
- }
/* prepare length information */
- msg->headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp);
+ msg->headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp);
- len=msg->headersize - sizeof(DltStorageHeader) + msg->datasize;
- if (len>UINT16_MAX)
- {
- dlt_log(LOG_WARNING,"Huge control message discarded!\n");
+ len = msg->headersize - sizeof(DltStorageHeader) + msg->datasize;
+
+ if (len > UINT16_MAX) {
+ dlt_log(LOG_WARNING, "Huge control message discarded!\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
msg->standardheader->len = DLT_HTOBE_16(((uint16_t)len));
- if((ret=dlt_daemon_client_send(sock,daemon,daemon_local,msg->headerbuffer,sizeof(DltStorageHeader),msg->headerbuffer+sizeof(DltStorageHeader),msg->headersize-sizeof(DltStorageHeader),
- msg->databuffer,msg->datasize,verbose)))
- {
- dlt_log(LOG_DEBUG,"dlt_daemon_control_send_control_message: DLT message send to all failed!.\n");
- return ret;
- }
+ if ((ret =
+ dlt_daemon_client_send(sock, daemon, daemon_local, msg->headerbuffer, sizeof(DltStorageHeader),
+ msg->headerbuffer + sizeof(DltStorageHeader),
+ msg->headersize - sizeof(DltStorageHeader),
+ msg->databuffer, msg->datasize, verbose))) {
+ dlt_log(LOG_DEBUG, "dlt_daemon_control_send_control_message: DLT message send to all failed!.\n");
+ return ret;
+ }
return DLT_DAEMON_ERROR_OK;
}
-int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+int dlt_daemon_client_process_control(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
- uint32_t id,id_tmp=0;
+ uint32_t id, id_tmp = 0;
DltStandardHeaderExtra extra;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || daemon_local == NULL|| msg == NULL)
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL))
return -1;
- }
if (msg->datasize < (int32_t)sizeof(uint32_t))
- {
return -1;
- }
extra = msg->headerextra;
/* check if the message needs to be forwarded */
- if (daemon_local->flags.gatewayMode == 1)
- {
+ if (daemon_local->flags.gatewayMode == 1) {
if (strcmp(daemon_local->flags.evalue, extra.ecu) != 0)
- {
return dlt_gateway_forward_control_message(&daemon_local->pGateway,
daemon_local,
msg,
extra.ecu,
verbose);
- }
}
- id_tmp = *((uint32_t*)(msg->databuffer));
- id=DLT_ENDIAN_GET_32(msg->standardheader->htyp ,id_tmp);
- if ((id > 0) && (id < DLT_SERVICE_ID_CALLSW_CINJECTION))
- {
+ id_tmp = *((uint32_t *)(msg->databuffer));
+ id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+
+ if ((id > 0) && (id < DLT_SERVICE_ID_CALLSW_CINJECTION)) {
/* Control message handling */
- switch (id)
- {
+ switch (id) {
case DLT_SERVICE_ID_SET_LOG_LEVEL:
{
- dlt_daemon_control_set_log_level(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_set_log_level(sock, daemon, daemon_local, msg, verbose);
break;
}
case DLT_SERVICE_ID_SET_TRACE_STATUS:
{
- dlt_daemon_control_set_trace_status(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_set_trace_status(sock, daemon, daemon_local, msg, verbose);
break;
}
case DLT_SERVICE_ID_GET_LOG_INFO:
@@ -502,100 +492,157 @@ int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLoca
}
case DLT_SERVICE_ID_STORE_CONFIG:
{
- if (dlt_daemon_applications_save(daemon, daemon->runtime_application_cfg, verbose)==0)
- {
- if (dlt_daemon_contexts_save(daemon, daemon->runtime_context_cfg, verbose)==0)
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ if (dlt_daemon_applications_save(daemon, daemon->runtime_application_cfg, verbose) == 0) {
+ if (dlt_daemon_contexts_save(daemon, daemon->runtime_context_cfg, verbose) == 0) {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK,
+ verbose);
}
- else
- {
+ else {
/* Delete saved files */
- dlt_daemon_control_reset_to_factory_default(daemon, daemon->runtime_application_cfg, daemon->runtime_context_cfg, daemon_local->flags.contextLogLevel, daemon_local->flags.contextTraceStatus, daemon_local->flags.enforceContextLLAndTS, verbose);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ dlt_daemon_control_reset_to_factory_default(daemon,
+ daemon->runtime_application_cfg,
+ daemon->runtime_context_cfg,
+ daemon_local->flags.contextLogLevel,
+ daemon_local->flags.contextTraceStatus,
+ daemon_local->flags.enforceContextLLAndTS,
+ verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
}
}
- else
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
}
+
break;
}
case DLT_SERVICE_ID_RESET_TO_FACTORY_DEFAULT:
{
- dlt_daemon_control_reset_to_factory_default(daemon, daemon->runtime_application_cfg, daemon->runtime_context_cfg, daemon_local->flags.contextLogLevel, daemon_local->flags.contextTraceStatus, daemon_local->flags.enforceContextLLAndTS, verbose);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_reset_to_factory_default(daemon,
+ daemon->runtime_application_cfg,
+ daemon->runtime_context_cfg,
+ daemon_local->flags.contextLogLevel,
+ daemon_local->flags.contextTraceStatus,
+ daemon_local->flags.enforceContextLLAndTS,
+ verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
break;
}
case DLT_SERVICE_ID_SET_COM_INTERFACE_STATUS:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_COM_INTERFACE_MAX_BANDWIDTH:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_VERBOSE_MODE:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_MESSAGE_FILTERING:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_TIMING_PACKETS:
{
- dlt_daemon_control_set_timing_packets(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_set_timing_packets(sock, daemon, daemon_local, msg, verbose);
break;
}
case DLT_SERVICE_ID_GET_LOCAL_TIME:
{
/* Send response with valid timestamp (TMSP) field */
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
break;
}
case DLT_SERVICE_ID_USE_ECU_ID:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_USE_SESSION_ID:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_USE_TIMESTAMP:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_USE_EXTENDED_HEADER:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL:
{
- dlt_daemon_control_set_default_log_level(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_set_default_log_level(sock, daemon, daemon_local, msg, verbose);
break;
}
case DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS:
{
- dlt_daemon_control_set_default_trace_status(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_set_default_trace_status(sock, daemon, daemon_local, msg, verbose);
break;
}
case DLT_SERVICE_ID_GET_SOFTWARE_VERSION:
{
- dlt_daemon_control_get_software_version(sock, daemon, daemon_local, verbose);
+ dlt_daemon_control_get_software_version(sock, daemon, daemon_local, verbose);
break;
}
case DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW:
{
- dlt_daemon_control_message_buffer_overflow(sock, daemon, daemon_local, daemon->overflow_counter,"",verbose);
+ dlt_daemon_control_message_buffer_overflow(sock, daemon, daemon_local, daemon->overflow_counter, "",
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_ALL_LOG_LEVEL:
@@ -625,22 +672,26 @@ int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLoca
case DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS:
{
dlt_daemon_control_passive_node_connect_status(sock,
- daemon,
- daemon_local,
- verbose);
+ daemon,
+ daemon_local,
+ verbose);
break;
}
default:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
}
}
- else
- {
+ else {
/* Injection handling */
- dlt_daemon_control_callsw_cinjection(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_callsw_cinjection(sock, daemon, daemon_local, msg, verbose);
}
return 0;
@@ -650,194 +701,213 @@ void dlt_daemon_control_get_software_version(int sock, DltDaemon *daemon, DltDae
{
DltMessage msg;
uint32_t len;
- DltServiceGetSoftwareVersionResponse *resp;
+ DltServiceGetSoftwareVersionResponse *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_SOFTWARE_VERSION, DLT_SERVICE_RESPONSE_ERROR, verbose);
- return;
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_SOFTWARE_VERSION,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
+ return;
}
/* prepare payload of data */
len = strlen(daemon->ECUVersionString);
msg.datasize = sizeof(DltServiceGetSoftwareVersionResponse) + len;
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_SOFTWARE_VERSION, DLT_SERVICE_RESPONSE_ERROR, verbose);
+
+ if (msg.databuffer == 0) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_SOFTWARE_VERSION,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
- resp = (DltServiceGetSoftwareVersionResponse*) msg.databuffer;
+ resp = (DltServiceGetSoftwareVersionResponse *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_GET_SOFTWARE_VERSION;
resp->status = DLT_SERVICE_RESPONSE_OK;
resp->length = len;
- memcpy(msg.databuffer+sizeof(DltServiceGetSoftwareVersionResponse),daemon->ECUVersionString,len);
+ memcpy(msg.databuffer + sizeof(DltServiceGetSoftwareVersionResponse), daemon->ECUVersionString, len);
/* send message */
- dlt_daemon_client_send_control_message(sock, daemon,daemon_local, &msg,"","", verbose);
+ dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
}
void dlt_daemon_control_get_default_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
{
DltMessage msg;
- DltServiceGetDefaultLogLevelResponse *resp;
+ DltServiceGetDefaultLogLevelResponse *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
msg.datasize = sizeof(DltServiceGetDefaultLogLevelResponse);
- if (msg.databuffer && (msg.databuffersize<msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL, DLT_SERVICE_RESPONSE_ERROR, verbose);
+
+ if (msg.databuffer == 0) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
- resp = (DltServiceGetDefaultLogLevelResponse*) msg.databuffer;
+ resp = (DltServiceGetDefaultLogLevelResponse *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL;
resp->status = DLT_SERVICE_RESPONSE_OK;
resp->log_level = daemon->default_log_level;
/* send message */
- dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose);
+ dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
}
-void dlt_daemon_control_get_log_info(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_get_log_info(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
DltServiceGetLogInfoRequest *req;
DltMessage resp;
- DltDaemonContext *context=0;
- DltDaemonApplication *application=0;
+ DltDaemonContext *context = 0;
+ DltDaemonApplication *application = 0;
- int num_applications=0, num_contexts=0;
- uint16_t count_app_ids=0, count_con_ids=0;
+ int num_applications = 0, num_contexts = 0;
+ uint16_t count_app_ids = 0, count_con_ids = 0;
-#if (DLT_DEBUG_GETLOGINFO==1)
+#if (DLT_DEBUG_GETLOGINFO == 1)
char buf[255];
#endif
- int32_t i,j,offset=0;
- char *apid=0;
- int8_t ll,ts;
+ int32_t i, j, offset = 0;
+ char *apid = 0;
+ int8_t ll, ts;
uint16_t len;
int8_t value;
- int32_t sizecont=0;
+ int32_t sizecont = 0;
int offset_base;
uint32_t sid;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceGetLogInfoRequest)) < 0)
- {
return;
- }
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
/* prepare pointer to message request */
- req = (DltServiceGetLogInfoRequest*) (msg->databuffer);
+ req = (DltServiceGetLogInfoRequest *)(msg->databuffer);
/* initialise new message */
- if (dlt_message_init(&resp,0) == DLT_RETURN_ERROR)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_LOG_INFO, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ if (dlt_message_init(&resp, 0) == DLT_RETURN_ERROR) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_LOG_INFO,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
/* check request */
- if ((req->options < 3 ) || (req->options>7))
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_LOG_INFO, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ if ((req->options < 3) || (req->options > 7)) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_LOG_INFO,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
- if (req->apid[0]!='\0')
- {
+ if (req->apid[0] != '\0') {
application = dlt_daemon_application_find(daemon,
req->apid,
daemon->ecuid,
verbose);
- if (application)
- {
+
+ if (application) {
num_applications = 1;
- if (req->ctid[0]!='\0')
- {
+
+ if (req->ctid[0] != '\0') {
context = dlt_daemon_context_find(daemon,
req->apid,
req->ctid,
daemon->ecuid,
verbose);
- num_contexts = ((context)?1:0);
+ num_contexts = ((context) ? 1 : 0);
}
- else
- {
+ else {
num_contexts = application->num_contexts;
}
}
- else
- {
+ else {
num_applications = 0;
num_contexts = 0;
}
}
- else
- {
+ else {
/* Request all applications and contexts */
num_applications = user_list->num_applications;
num_contexts = user_list->num_contexts;
@@ -851,161 +921,134 @@ void dlt_daemon_control_get_log_info(int sock, DltDaemon *daemon, DltDaemonLocal
sizecont = sizeof(uint32_t) /* context_id */;
/* Add additional size for response of Mode 4, 6, 7 */
- if ((req->options==4) || (req->options==6) || (req->options==7))
- {
+ if ((req->options == 4) || (req->options == 6) || (req->options == 7))
sizecont += sizeof(int8_t); /* log level */
- }
/* Add additional size for response of Mode 5, 6, 7 */
- if ((req->options==5) || (req->options==6) || (req->options==7))
- {
- sizecont+= sizeof(int8_t); /* trace status */
- }
+ if ((req->options == 5) || (req->options == 6) || (req->options == 7))
+ sizecont += sizeof(int8_t); /* trace status */
- resp.datasize+= (num_applications * (sizeof(uint32_t) /* app_id */ + sizeof(uint16_t) /* count_con_ids */)) +
- (num_contexts * sizecont);
+ resp.datasize += (num_applications * (sizeof(uint32_t) /* app_id */ + sizeof(uint16_t) /* count_con_ids */)) +
+ (num_contexts * sizecont);
- resp.datasize+= sizeof(uint16_t) /* count_app_ids */;
+ resp.datasize += sizeof(uint16_t) /* count_app_ids */;
/* Add additional size for response of Mode 7 */
- if (req->options==7)
- {
- if (req->apid[0]!='\0')
- {
- if (req->ctid[0]!='\0')
- {
+ if (req->options == 7) {
+ if (req->apid[0] != '\0') {
+ if (req->ctid[0] != '\0') {
/* One application, one context */
- // context = dlt_daemon_context_find(daemon, req->apid, req->ctid, verbose);
- if (context)
- {
- resp.datasize+=sizeof(uint16_t) /* len_context_description */;
- if (context->context_description!=0)
- {
- resp.datasize+=strlen(context->context_description); /* context_description */
- }
+ /* context = dlt_daemon_context_find(daemon, req->apid, req->ctid, verbose); */
+ if (context) {
+ resp.datasize += sizeof(uint16_t) /* len_context_description */;
+
+ if (context->context_description != 0)
+ resp.datasize += strlen(context->context_description); /* context_description */
}
}
else
- {
- /* One application, all contexts */
- if ((user_list->applications) && (application))
- {
- /* Calculate start offset within contexts[] */
- offset_base=0;
- for (i = 0; i < (application - (user_list->applications)); i++)
- {
- offset_base += user_list->applications[i].num_contexts;
- }
+ /* One application, all contexts */
+ if ((user_list->applications) && (application)) {
+ /* Calculate start offset within contexts[] */
+ offset_base = 0;
- /* Iterate over all contexts belonging to this application */
- for (j=0;j<application->num_contexts;j++)
- {
+ for (i = 0; i < (application - (user_list->applications)); i++)
+ offset_base += user_list->applications[i].num_contexts;
- context = &(user_list->contexts[offset_base + j]);
- if (context)
- {
- resp.datasize+=sizeof(uint16_t) /* len_context_description */;
- if (context->context_description!=0)
- {
- resp.datasize+=strlen(context->context_description); /* context_description */
- }
- }
+ /* Iterate over all contexts belonging to this application */
+ for (j = 0; j < application->num_contexts; j++) {
+
+ context = &(user_list->contexts[offset_base + j]);
+
+ if (context) {
+ resp.datasize += sizeof(uint16_t) /* len_context_description */;
+
+ if (context->context_description != 0)
+ resp.datasize += strlen(context->context_description); /* context_description */
}
}
}
/* Space for application description */
- if (application)
- {
- resp.datasize+=sizeof(uint16_t) /* len_app_description */;
- if (application->application_description!=0)
- {
- resp.datasize+=strlen(application->application_description); /* app_description */
- }
+ if (application) {
+ resp.datasize += sizeof(uint16_t) /* len_app_description */;
+
+ if (application->application_description != 0)
+ resp.datasize += strlen(application->application_description); /* app_description */
}
}
- else
- {
+ else {
/* All applications, all contexts */
- for (i = 0; i < user_list->num_contexts; i++)
- {
- resp.datasize+=sizeof(uint16_t) /* len_context_description */;
+ for (i = 0; i < user_list->num_contexts; i++) {
+ resp.datasize += sizeof(uint16_t) /* len_context_description */;
+
if (user_list->contexts[i].context_description != 0)
- {
resp.datasize +=
- strlen(user_list->contexts[i].context_description);
- }
+ strlen(user_list->contexts[i].context_description);
}
- for (i = 0; i < user_list->num_applications; i++)
- {
+ for (i = 0; i < user_list->num_applications; i++) {
resp.datasize += sizeof(uint16_t) /* len_app_description */;
+
if (user_list->applications[i].application_description != 0)
- {
resp.datasize += strlen(user_list->applications[i].application_description); /* app_description */
- }
}
}
}
if (verbose)
- {
dlt_vlog(LOG_DEBUG,
"Allocate %d bytes for response msg databuffer\n",
resp.datasize);
- }
/* Allocate buffer for response message */
- resp.databuffer = (uint8_t *) malloc(resp.datasize);
+ resp.databuffer = (uint8_t *)malloc(resp.datasize);
resp.databuffersize = resp.datasize;
- if (resp.databuffer==0)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_LOG_INFO, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ if (resp.databuffer == 0) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_LOG_INFO,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
- memset(resp.databuffer,0,resp.datasize);
+
+ memset(resp.databuffer, 0, resp.datasize);
/* Preparation finished */
/* Prepare response */
sid = DLT_SERVICE_ID_GET_LOG_INFO;
- memcpy(resp.databuffer,&sid,sizeof(uint32_t));
- offset+=sizeof(uint32_t);
+ memcpy(resp.databuffer, &sid, sizeof(uint32_t));
+ offset += sizeof(uint32_t);
- value = (((num_applications!=0)&&(num_contexts!=0))?req->options:8); /* 8 = no matching context found */
+ value = (((num_applications != 0) && (num_contexts != 0)) ? req->options : 8); /* 8 = no matching context found */
- memcpy(resp.databuffer+offset,&value,sizeof(int8_t));
- offset+=sizeof(int8_t);
+ memcpy(resp.databuffer + offset, &value, sizeof(int8_t));
+ offset += sizeof(int8_t);
count_app_ids = num_applications;
- if (count_app_ids!=0)
- {
- memcpy(resp.databuffer+offset,&count_app_ids,sizeof(uint16_t));
- offset+=sizeof(uint16_t);
+ if (count_app_ids != 0) {
+ memcpy(resp.databuffer + offset, &count_app_ids, sizeof(uint16_t));
+ offset += sizeof(uint16_t);
-#if (DLT_DEBUG_GETLOGINFO==1)
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"#apid: %d \n", count_app_ids);
+#if (DLT_DEBUG_GETLOGINFO == 1)
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "#apid: %d \n", count_app_ids);
dlt_log(LOG_DEBUG, str);
#endif
- for (i=0;i<count_app_ids;i++)
- {
- if (req->apid[0]!='\0')
- {
+ for (i = 0; i < count_app_ids; i++) {
+ if (req->apid[0] != '\0') {
apid = req->apid;
}
- else
- {
+ else {
if (user_list->applications)
- {
apid = user_list->applications[i].apid;
- }
else
- {
/* This should never occur! */
- apid=0;
- }
+ apid = 0;
}
application = dlt_daemon_application_find(daemon,
@@ -1013,349 +1056,345 @@ void dlt_daemon_control_get_log_info(int sock, DltDaemon *daemon, DltDaemonLocal
daemon->ecuid,
verbose);
- if (application)
- {
+ if (application) {
/* Calculate start offset within contexts[] */
- offset_base=0;
- for (j = 0; j < (application-(user_list->applications)); j++)
- {
+ offset_base = 0;
+
+ for (j = 0; j < (application - (user_list->applications)); j++)
offset_base += user_list->applications[j].num_contexts;
- }
- dlt_set_id((char*)(resp.databuffer + offset), apid);
+ dlt_set_id((char *)(resp.databuffer + offset), apid);
offset += sizeof(ID4);
-#if (DLT_DEBUG_GETLOGINFO==1)
+#if (DLT_DEBUG_GETLOGINFO == 1)
dlt_print_id(buf, apid);
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"apid: %s\n",buf);
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "apid: %s\n", buf);
dlt_log(LOG_DEBUG, str);
#endif
if (req->apid[0] != '\0')
- {
count_con_ids = num_contexts;
- }
else
- {
count_con_ids = application->num_contexts;
- }
- memcpy(resp.databuffer + offset,&count_con_ids, sizeof(uint16_t));
+ memcpy(resp.databuffer + offset, &count_con_ids, sizeof(uint16_t));
offset += sizeof(uint16_t);
-#if (DLT_DEBUG_GETLOGINFO==1)
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"#ctid: %d \n", count_con_ids);
+#if (DLT_DEBUG_GETLOGINFO == 1)
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "#ctid: %d \n", count_con_ids);
dlt_log(LOG_DEBUG, str);
#endif
- for (j = 0;j < count_con_ids; j++)
- {
-#if (DLT_DEBUG_GETLOGINFO==1)
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"j: %d \n",j);
+ for (j = 0; j < count_con_ids; j++) {
+#if (DLT_DEBUG_GETLOGINFO == 1)
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "j: %d \n", j);
dlt_log(LOG_DEBUG, str);
#endif
+
if (!((count_con_ids == 1) && (req->apid[0] != '\0') &&
- (req->ctid[0] != '\0')))
- {
+ (req->ctid[0] != '\0')))
context = &(user_list->contexts[offset_base + j]);
- }
+
/* else: context was already searched and found
- (one application (found) with one context (found))*/
+ * (one application (found) with one context (found))*/
if ((context) &&
- ((req->ctid[0]=='\0') || ((req->ctid[0]!='\0') &&
- (memcmp(context->ctid,req->ctid,DLT_ID_SIZE)==0)))
- )
- {
- dlt_set_id((char*)(resp.databuffer+offset), context->ctid);
+ ((req->ctid[0] == '\0') || ((req->ctid[0] != '\0') &&
+ (memcmp(context->ctid, req->ctid, DLT_ID_SIZE) == 0)))
+ ) {
+ dlt_set_id((char *)(resp.databuffer + offset), context->ctid);
offset += sizeof(ID4);
-#if (DLT_DEBUG_GETLOGINFO==1)
+#if (DLT_DEBUG_GETLOGINFO == 1)
dlt_print_id(buf, context->ctid);
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"ctid: %s \n",buf);
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "ctid: %s \n", buf);
dlt_log(LOG_DEBUG, str);
#endif
/* Mode 4, 6, 7 */
- if ((req->options==4) || (req->options==6) || (req->options==7))
- {
- ll=context->log_level;
- memcpy(resp.databuffer+offset,&ll,sizeof(int8_t));
- offset+=sizeof(int8_t);
+ if ((req->options == 4) || (req->options == 6) || (req->options == 7)) {
+ ll = context->log_level;
+ memcpy(resp.databuffer + offset, &ll, sizeof(int8_t));
+ offset += sizeof(int8_t);
}
/* Mode 5, 6, 7 */
- if ((req->options==5) || (req->options==6) || (req->options==7))
- {
- ts=context->trace_status;
- memcpy(resp.databuffer+offset,&ts,sizeof(int8_t));
- offset+=sizeof(int8_t);
+ if ((req->options == 5) || (req->options == 6) || (req->options == 7)) {
+ ts = context->trace_status;
+ memcpy(resp.databuffer + offset, &ts, sizeof(int8_t));
+ offset += sizeof(int8_t);
}
/* Mode 7 */
- if (req->options==7)
- {
- if (context->context_description)
- {
+ if (req->options == 7) {
+ if (context->context_description) {
len = strlen(context->context_description);
- memcpy(resp.databuffer+offset,&len,sizeof(uint16_t));
- offset+=sizeof(uint16_t);
- memcpy(resp.databuffer+offset,context->context_description,strlen(context->context_description));
- offset+=strlen(context->context_description);
+ memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+ offset += sizeof(uint16_t);
+ memcpy(resp.databuffer + offset, context->context_description,
+ strlen(context->context_description));
+ offset += strlen(context->context_description);
}
- else
- {
+ else {
len = 0;
- memcpy(resp.databuffer+offset,&len,sizeof(uint16_t));
- offset+=sizeof(uint16_t);
+ memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+ offset += sizeof(uint16_t);
}
}
-#if (DLT_DEBUG_GETLOGINFO==1)
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"ll=%d ts=%d \n",(int32_t)ll,(int32_t)ts);
+#if (DLT_DEBUG_GETLOGINFO == 1)
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "ll=%d ts=%d \n", (int32_t)ll, (int32_t)ts);
dlt_log(LOG_DEBUG, str);
#endif
}
-#if (DLT_DEBUG_GETLOGINFO==1)
- dlt_log(LOG_DEBUG,"\n");
+#if (DLT_DEBUG_GETLOGINFO == 1)
+ dlt_log(LOG_DEBUG, "\n");
#endif
}
/* Mode 7 */
- if (req->options==7)
- {
- if (application->application_description)
- {
+ if (req->options == 7) {
+ if (application->application_description) {
len = strlen(application->application_description);
- memcpy(resp.databuffer+offset,&len,sizeof(uint16_t));
- offset+=sizeof(uint16_t);
- memcpy(resp.databuffer+offset,application->application_description,strlen(application->application_description));
- offset+=strlen(application->application_description);
+ memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+ offset += sizeof(uint16_t);
+ memcpy(resp.databuffer + offset, application->application_description,
+ strlen(application->application_description));
+ offset += strlen(application->application_description);
}
- else
- {
+ else {
len = 0;
- memcpy(resp.databuffer+offset,&len,sizeof(uint16_t));
- offset+=sizeof(uint16_t);
+ memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+ offset += sizeof(uint16_t);
}
}
} /* if (application) */
+
} /* for (i=0;i<count_app_ids;i++) */
+
} /* if (count_app_ids!=0) */
- dlt_set_id((char*)(resp.databuffer+offset),DLT_DAEMON_REMO_STRING);
+ dlt_set_id((char *)(resp.databuffer + offset), DLT_DAEMON_REMO_STRING);
/* send message */
- dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&resp,"","", verbose);
+ dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &resp, "", "", verbose);
/* free message */
- dlt_message_free(&resp,0);
+ dlt_message_free(&resp, 0);
}
-int dlt_daemon_control_message_buffer_overflow(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, unsigned int overflow_counter,char* apid, int verbose)
+int dlt_daemon_control_message_buffer_overflow(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ unsigned int overflow_counter,
+ char *apid,
+ int verbose)
{
- int ret;
+ int ret;
DltMessage msg;
- DltServiceMessageBufferOverflowResponse *resp;
+ DltServiceMessageBufferOverflowResponse *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return DLT_DAEMON_ERROR_UNKNOWN;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW, DLT_SERVICE_RESPONSE_ERROR, verbose);
- return DLT_DAEMON_ERROR_UNKNOWN;
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
+ return DLT_DAEMON_ERROR_UNKNOWN;
}
/* prepare payload of data */
msg.datasize = sizeof(DltServiceMessageBufferOverflowResponse);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return DLT_DAEMON_ERROR_UNKNOWN;
- }
- resp = (DltServiceMessageBufferOverflowResponse*) msg.databuffer;
+ resp = (DltServiceMessageBufferOverflowResponse *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW;
resp->status = DLT_SERVICE_RESPONSE_OK;
resp->overflow = DLT_MESSAGE_BUFFER_OVERFLOW;
- resp->overflow_counter = overflow_counter;
+ resp->overflow_counter = overflow_counter;
/* send message */
- if((ret=dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,apid,"", verbose)))
- {
- dlt_message_free(&msg,0);
- return ret;
+ if ((ret = dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, apid, "", verbose))) {
+ dlt_message_free(&msg, 0);
+ return ret;
}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return DLT_DAEMON_ERROR_OK;
}
-void dlt_daemon_control_service_response( int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, uint32_t service_id, int8_t status , int verbose)
+void dlt_daemon_control_service_response(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ uint32_t service_id,
+ int8_t status,
+ int verbose)
{
DltMessage msg;
DltServiceResponse *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- return;
- }
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+ return;
/* prepare payload of data */
msg.datasize = sizeof(DltServiceResponse);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return;
- }
- resp = (DltServiceResponse*) msg.databuffer;
+ resp = (DltServiceResponse *)msg.databuffer;
resp->service_id = service_id;
resp->status = status;
/* send message */
- dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose);
+ dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
}
-int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, char* apid, char* ctid, char* comid, int verbose)
+int dlt_daemon_control_message_unregister_context(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ char *apid,
+ char *ctid,
+ char *comid,
+ int verbose)
{
DltMessage msg;
DltServiceUnregisterContext *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return -1;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- return -1;
- }
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+ return -1;
/* prepare payload of data */
msg.datasize = sizeof(DltServiceUnregisterContext);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return -1;
- }
- resp = (DltServiceUnregisterContext*) msg.databuffer;
+ resp = (DltServiceUnregisterContext *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_UNREGISTER_CONTEXT;
resp->status = DLT_SERVICE_RESPONSE_OK;
- dlt_set_id(resp->apid, apid);
- dlt_set_id(resp->ctid, ctid);
- dlt_set_id(resp->comid, comid);
+ dlt_set_id(resp->apid, apid);
+ dlt_set_id(resp->ctid, ctid);
+ dlt_set_id(resp->comid, comid);
/* send message */
- if(dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose))
- {
- dlt_message_free(&msg,0);
- return -1;
+ if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+ dlt_message_free(&msg, 0);
+ return -1;
}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return 0;
}
-int dlt_daemon_control_message_connection_info(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, uint8_t state, char* comid, int verbose)
+int dlt_daemon_control_message_connection_info(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ uint8_t state,
+ char *comid,
+ int verbose)
{
DltMessage msg;
DltServiceConnectionInfo *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return -1;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- return -1;
- }
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+ return -1;
/* prepare payload of data */
msg.datasize = sizeof(DltServiceConnectionInfo);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return -1;
- }
- resp = (DltServiceConnectionInfo*) msg.databuffer;
+ resp = (DltServiceConnectionInfo *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_CONNECTION_INFO;
resp->status = DLT_SERVICE_RESPONSE_OK;
resp->state = state;
dlt_set_id(resp->comid, comid);
/* send message */
- if(dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose))
- {
- dlt_message_free(&msg,0);
- return -1;
+ if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+ dlt_message_free(&msg, 0);
+ return -1;
}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return 0;
}
@@ -1367,54 +1406,49 @@ int dlt_daemon_control_message_timezone(int sock, DltDaemon *daemon, DltDaemonLo
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return -1;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- return -1;
- }
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+ return -1;
/* prepare payload of data */
msg.datasize = sizeof(DltServiceTimezone);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return -1;
- }
- resp = (DltServiceTimezone*) msg.databuffer;
+ resp = (DltServiceTimezone *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_TIMEZONE;
resp->status = DLT_SERVICE_RESPONSE_OK;
- time_t t = time(NULL);
- struct tm lt;
- localtime_r(&t, &lt);
+ time_t t = time(NULL);
+ struct tm lt;
+ localtime_r(&t, &lt);
#if !defined(__CYGWIN__)
- resp->timezone = (int32_t) lt.tm_gmtoff;
+ resp->timezone = (int32_t)lt.tm_gmtoff;
#endif
- resp->isdst = (uint8_t) lt.tm_isdst;
+ resp->isdst = (uint8_t)lt.tm_isdst;
/* send message */
- if(dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose))
- {
- dlt_message_free(&msg,0);
- return -1;
+ if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+ dlt_message_free(&msg, 0);
+ return -1;
}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return 0;
}
@@ -1426,98 +1460,92 @@ int dlt_daemon_control_message_marker(int sock, DltDaemon *daemon, DltDaemonLoca
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return -1;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- return -1;
- }
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+ return -1;
/* prepare payload of data */
msg.datasize = sizeof(DltServiceMarker);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return -1;
- }
- resp = (DltServiceMarker*) msg.databuffer;
+ resp = (DltServiceMarker *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_MARKER;
resp->status = DLT_SERVICE_RESPONSE_OK;
/* send message */
- if(dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose))
- {
- dlt_message_free(&msg,0);
- return -1;
+ if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+ dlt_message_free(&msg, 0);
+ return -1;
}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return 0;
}
-void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_callsw_cinjection(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
- char apid[DLT_ID_SIZE],ctid[DLT_ID_SIZE];
- uint32_t id=0,id_tmp=0;
+ char apid[DLT_ID_SIZE], ctid[DLT_ID_SIZE];
+ uint32_t id = 0, id_tmp = 0;
uint8_t *ptr;
DltDaemonContext *context;
- int32_t data_length_inject=0;
- uint32_t data_length_inject_tmp=0;
+ int32_t data_length_inject = 0;
+ uint32_t data_length_inject_tmp = 0;
- int32_t datalength;
+ int32_t datalength;
- DltUserHeader userheader;
- DltUserControlMsgInjection usercontext;
- uint8_t *userbuffer;
+ DltUserHeader userheader;
+ DltUserControlMsgInjection usercontext;
+ uint8_t *userbuffer;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
datalength = msg->datasize;
ptr = msg->databuffer;
- DLT_MSG_READ_VALUE(id_tmp,ptr,datalength,uint32_t); /* Get service id */
- id=DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+ DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t); /* Get service id */
+ id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
- if ((id>=DLT_DAEMON_INJECTION_MIN) && (id<=DLT_DAEMON_INJECTION_MAX))
- {
+ if ((id >= DLT_DAEMON_INJECTION_MIN) && (id <= DLT_DAEMON_INJECTION_MAX)) {
/* This a a real SW-C injection call */
- data_length_inject=0;
- data_length_inject_tmp=0;
+ data_length_inject = 0;
+ data_length_inject_tmp = 0;
- DLT_MSG_READ_VALUE(data_length_inject_tmp,ptr,datalength,uint32_t); /* Get data length */
- data_length_inject=DLT_ENDIAN_GET_32(msg->standardheader->htyp, data_length_inject_tmp);
+ DLT_MSG_READ_VALUE(data_length_inject_tmp, ptr, datalength, uint32_t); /* Get data length */
+ data_length_inject = DLT_ENDIAN_GET_32(msg->standardheader->htyp, data_length_inject_tmp);
/* Get context handle for apid, ctid (and seid) */
/* Warning: seid is ignored in this implementation! */
- if (DLT_IS_HTYP_UEH(msg->standardheader->htyp))
- {
+ if (DLT_IS_HTYP_UEH(msg->standardheader->htyp)) {
dlt_set_id(apid, msg->extendedheader->apid);
dlt_set_id(ctid, msg->extendedheader->ctid);
}
- else
- {
+ else {
/* No extended header, and therefore no apid and ctid available */
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
return;
}
@@ -1528,73 +1556,73 @@ void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltDaemon
daemon->ecuid,
verbose);
- if (context==0)
- {
- // dlt_log(LOG_INFO,"No context found!\n");
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ if (context == 0) {
+ /* dlt_log(LOG_INFO,"No context found!\n"); */
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
return;
}
/* Send user message to handle, specified in context */
- if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_INJECTION) < DLT_RETURN_OK)
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
- return;
- }
-
- usercontext.log_level_pos = context->log_level_pos;
-
- if (data_length_inject > msg->databuffersize)
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
- return;
- }
-
- userbuffer = malloc(data_length_inject);
-
- if (userbuffer==0)
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
- return;
- }
-
- usercontext.data_length_inject = data_length_inject;
- usercontext.service_id = id;
-
- memcpy(userbuffer,ptr,data_length_inject); /* Copy received injection to send buffer */
-
- /* write to FIFO */
- DltReturnValue ret =
- dlt_user_log_out3(context->user_handle, &(userheader), sizeof(DltUserHeader),
- &(usercontext), sizeof(DltUserControlMsgInjection),
- userbuffer, data_length_inject);
- if (ret < DLT_RETURN_OK)
- {
- if (ret == DLT_RETURN_PIPE_ERROR)
- {
- /* Close connection */
- close(context->user_handle);
- context->user_handle=DLT_FD_INIT;
- }
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
- }
- else
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
- }
-
- free(userbuffer);
- userbuffer=0;
+ if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_INJECTION) < DLT_RETURN_OK) {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ return;
+ }
+
+ usercontext.log_level_pos = context->log_level_pos;
+
+ if (data_length_inject > msg->databuffersize) {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ return;
+ }
+
+ userbuffer = malloc(data_length_inject);
+
+ if (userbuffer == 0) {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ return;
+ }
+
+ usercontext.data_length_inject = data_length_inject;
+ usercontext.service_id = id;
+
+ memcpy(userbuffer, ptr, data_length_inject); /* Copy received injection to send buffer */
+
+ /* write to FIFO */
+ DltReturnValue ret =
+ dlt_user_log_out3(context->user_handle, &(userheader), sizeof(DltUserHeader),
+ &(usercontext), sizeof(DltUserControlMsgInjection),
+ userbuffer, data_length_inject);
+
+ if (ret < DLT_RETURN_OK) {
+ if (ret == DLT_RETURN_PIPE_ERROR) {
+ /* Close connection */
+ close(context->user_handle);
+ context->user_handle = DLT_FD_INIT;
+ }
+
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ }
+ else {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ }
+
+ free(userbuffer);
+ userbuffer = 0;
}
- else
- {
+ else {
/* Invalid ID */
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
}
}
-void dlt_daemon_send_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltDaemonContext *context,int8_t loglevel, int verbose)
+void dlt_daemon_send_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltDaemonContext *context,
+ int8_t loglevel,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
@@ -1605,17 +1633,14 @@ void dlt_daemon_send_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daem
context->log_level = loglevel; /* No endianess conversion necessary*/
if ((context->user_handle >= DLT_FD_MINIMUM) &&
- (dlt_daemon_user_send_log_level(daemon, context, verbose)==0))
- {
+ (dlt_daemon_user_send_log_level(daemon, context, verbose) == 0)) {
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Log level could not be sent!\n");
context->log_level = old_log_level;
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
-
}
void dlt_daemon_find_multiple_context_and_send_log_level(int sock,
@@ -1631,102 +1656,116 @@ void dlt_daemon_find_multiple_context_and_send_log_level(int sock,
int count = 0;
DltDaemonContext *context = NULL;
- char src_str[DLT_ID_SIZE +1] = {0};
+ char src_str[DLT_ID_SIZE + 1] = { 0 };
int8_t ret = 0;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
- if (daemon == 0)
- {
+ if (daemon == 0) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return;
}
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
- for (count = 0; count < user_list->num_contexts; count++)
- {
+ for (count = 0; count < user_list->num_contexts; count++) {
context = &(user_list->contexts[count]);
- if (context)
- {
+ if (context) {
if (app_flag == 1)
- {
strncpy(src_str, context->apid, DLT_ID_SIZE);
- }
else
- {
strncpy(src_str, context->ctid, DLT_ID_SIZE);
- }
+
ret = strncmp(src_str, str, len);
+
if (ret == 0)
- {
dlt_daemon_send_log_level(sock, daemon, daemon_local, context, loglevel, verbose);
- }
else if ((ret > 0) && (app_flag == 1))
- {
break;
- }
else
- {
continue;
- }
}
}
}
-void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
- char apid[DLT_ID_SIZE+1] = {0};
- char ctid[DLT_ID_SIZE+1] = {0};
+ char apid[DLT_ID_SIZE + 1] = { 0 };
+ char ctid[DLT_ID_SIZE + 1] = { 0 };
DltServiceSetLogLevel *req = NULL;
DltDaemonContext *context = NULL;
int8_t appid_length = 0;
int8_t ctxtid_length = 0;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetLogLevel*) (msg->databuffer);
+ req = (DltServiceSetLogLevel *)(msg->databuffer);
+
if (daemon_local->flags.enforceContextLLAndTS)
- {
req->log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
- }
dlt_set_id(apid, req->apid);
dlt_set_id(ctid, req->ctid);
appid_length = strlen(apid);
ctxtid_length = strlen(ctid);
- if ((appid_length != 0) && (apid[appid_length-1] == '*') && (ctid[0] == 0)) /*appid provided having '*' in it and ctid is null*/
- {
- dlt_daemon_find_multiple_context_and_send_log_level(sock, daemon, daemon_local, 1, apid, appid_length-1, req->log_level, verbose);
- }
- else if ((ctxtid_length != 0) && (ctid[ctxtid_length-1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and appid is null*/
- {
- dlt_daemon_find_multiple_context_and_send_log_level(sock, daemon, daemon_local, 0, ctid, ctxtid_length-1, req->log_level, verbose);
- }
- else if ((appid_length != 0) && (apid[appid_length-1] != '*') && (ctid[0] == 0)) /*only app id case*/
- {
- dlt_daemon_find_multiple_context_and_send_log_level(sock, daemon, daemon_local, 1, apid, DLT_ID_SIZE, req->log_level, verbose);
- }
- else if ((ctxtid_length != 0) && (ctid[ctxtid_length-1] != '*') && (apid[0] == 0)) /*only context id case*/
- {
- dlt_daemon_find_multiple_context_and_send_log_level(sock, daemon, daemon_local, 0, ctid, DLT_ID_SIZE, req->log_level, verbose);
- }
- else
- {
+
+ if ((appid_length != 0) && (apid[appid_length - 1] == '*') && (ctid[0] == 0)) { /*appid provided having '*' in it and ctid is null*/
+ dlt_daemon_find_multiple_context_and_send_log_level(sock,
+ daemon,
+ daemon_local,
+ 1,
+ apid,
+ appid_length - 1,
+ req->log_level,
+ verbose);
+ }
+ else if ((ctxtid_length != 0) && (ctid[ctxtid_length - 1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and appid is null*/
+ {
+ dlt_daemon_find_multiple_context_and_send_log_level(sock,
+ daemon,
+ daemon_local,
+ 0,
+ ctid,
+ ctxtid_length - 1,
+ req->log_level,
+ verbose);
+ }
+ else if ((appid_length != 0) && (apid[appid_length - 1] != '*') && (ctid[0] == 0)) /*only app id case*/
+ {
+ dlt_daemon_find_multiple_context_and_send_log_level(sock,
+ daemon,
+ daemon_local,
+ 1,
+ apid,
+ DLT_ID_SIZE,
+ req->log_level,
+ verbose);
+ }
+ else if ((ctxtid_length != 0) && (ctid[ctxtid_length - 1] != '*') && (apid[0] == 0)) /*only context id case*/
+ {
+ dlt_daemon_find_multiple_context_and_send_log_level(sock,
+ daemon,
+ daemon_local,
+ 0,
+ ctid,
+ DLT_ID_SIZE,
+ req->log_level,
+ verbose);
+ }
+ else {
context = dlt_daemon_context_find(daemon,
apid,
ctid,
@@ -1734,14 +1773,18 @@ void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLoca
verbose);
/* Set log level */
- if (context!=0)
- {
+ if (context != 0) {
dlt_daemon_send_log_level(sock, daemon, daemon_local, context, req->log_level, verbose);
}
- else
- {
- dlt_vlog(LOG_ERR, "Could not set log level: %d. Context [%.4s:%.4s] not found:", req->log_level, apid, ctid);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, DLT_SERVICE_ID_SET_LOG_LEVEL, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_vlog(LOG_ERR, "Could not set log level: %d. Context [%.4s:%.4s] not found:", req->log_level, apid,
+ ctid);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_SET_LOG_LEVEL,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
}
}
}
@@ -1763,12 +1806,10 @@ void dlt_daemon_send_trace_status(int sock,
context->trace_status = tracestatus; /* No endianess conversion necessary*/
if ((context->user_handle >= DLT_FD_MINIMUM) &&
- (dlt_daemon_user_send_log_level(daemon, context, verbose)==0))
- {
+ (dlt_daemon_user_send_log_level(daemon, context, verbose) == 0)) {
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Trace status could not be sent!\n");
context->trace_status = old_trace_status;
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
@@ -1788,158 +1829,181 @@ void dlt_daemon_find_multiple_context_and_send_trace_status(int sock,
int count = 0;
DltDaemonContext *context = NULL;
- char src_str[DLT_ID_SIZE +1] = {0};
+ char src_str[DLT_ID_SIZE + 1] = { 0 };
int8_t ret = 0;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
- if (daemon == 0)
- {
+ if (daemon == 0) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return;
}
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
- for (count = 0; count < user_list->num_contexts; count++)
- {
+ for (count = 0; count < user_list->num_contexts; count++) {
context = &(user_list->contexts[count]);
- if (context)
- {
+ if (context) {
if (app_flag == 1)
- {
strncpy(src_str, context->apid, DLT_ID_SIZE);
- }
else
- {
strncpy(src_str, context->ctid, DLT_ID_SIZE);
- }
+
ret = strncmp(src_str, str, len);
+
if (ret == 0)
- {
dlt_daemon_send_trace_status(sock, daemon, daemon_local, context, tracestatus, verbose);
- }
else if ((ret > 0) && (app_flag == 1))
- {
break;
- }
else
- {
continue;
- }
}
}
}
-void dlt_daemon_control_set_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
- char apid[DLT_ID_SIZE+1] = {0};
- char ctid[DLT_ID_SIZE+1] = {0};
+ char apid[DLT_ID_SIZE + 1] = { 0 };
+ char ctid[DLT_ID_SIZE + 1] = { 0 };
DltServiceSetLogLevel *req = NULL;
DltDaemonContext *context = NULL;
int8_t appid_length = 0;
int8_t ctxtid_length = 0;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetLogLevel*) (msg->databuffer);
+ req = (DltServiceSetLogLevel *)(msg->databuffer);
+
if (daemon_local->flags.enforceContextLLAndTS)
- {
req->log_level = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
- }
dlt_set_id(apid, req->apid);
dlt_set_id(ctid, req->ctid);
appid_length = strlen(apid);
ctxtid_length = strlen(ctid);
- if ((appid_length != 0) && (apid[appid_length-1] == '*') && (ctid[0] == 0)) /*appid provided having '*' in it and ctid is null*/
- {
- dlt_daemon_find_multiple_context_and_send_trace_status(sock, daemon, daemon_local, 1, apid, appid_length-1, req->log_level, verbose);
- }
- else if ((ctxtid_length != 0) && (ctid[ctxtid_length-1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and appid is null*/
- {
- dlt_daemon_find_multiple_context_and_send_trace_status(sock, daemon, daemon_local, 0, ctid, ctxtid_length-1, req->log_level, verbose);
- }
- else if ((appid_length != 0) && (apid[appid_length-1] != '*') && (ctid[0] == 0)) /*only app id case*/
- {
- dlt_daemon_find_multiple_context_and_send_trace_status(sock, daemon, daemon_local, 1, apid, DLT_ID_SIZE, req->log_level, verbose);
- }
- else if ((ctxtid_length != 0) && (ctid[ctxtid_length-1] != '*') && (apid[0] == 0)) /*only context id case*/
- {
- dlt_daemon_find_multiple_context_and_send_trace_status(sock, daemon, daemon_local, 0, ctid, DLT_ID_SIZE, req->log_level, verbose);
- }
- else
- {
- context=dlt_daemon_context_find(daemon, apid, ctid, daemon->ecuid, verbose);
+ if ((appid_length != 0) && (apid[appid_length - 1] == '*') && (ctid[0] == 0)) { /*appid provided having '*' in it and ctid is null*/
+ dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+ daemon,
+ daemon_local,
+ 1,
+ apid,
+ appid_length - 1,
+ req->log_level,
+ verbose);
+ }
+ else if ((ctxtid_length != 0) && (ctid[ctxtid_length - 1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and appid is null*/
+
+ {
+ dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+ daemon,
+ daemon_local,
+ 0,
+ ctid,
+ ctxtid_length - 1,
+ req->log_level,
+ verbose);
+ }
+ else if ((appid_length != 0) && (apid[appid_length - 1] != '*') && (ctid[0] == 0)) /*only app id case*/
+ {
+ dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+ daemon,
+ daemon_local,
+ 1,
+ apid,
+ DLT_ID_SIZE,
+ req->log_level,
+ verbose);
+ }
+ else if ((ctxtid_length != 0) && (ctid[ctxtid_length - 1] != '*') && (apid[0] == 0)) /*only context id case*/
+ {
+ dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+ daemon,
+ daemon_local,
+ 0,
+ ctid,
+ DLT_ID_SIZE,
+ req->log_level,
+ verbose);
+ }
+ else {
+ context = dlt_daemon_context_find(daemon, apid, ctid, daemon->ecuid, verbose);
/* Set trace status */
- if (context!=0)
- {
+ if (context != 0) {
dlt_daemon_send_trace_status(sock, daemon, daemon_local, context, req->log_level, verbose);
}
- else
- {
- dlt_vlog(LOG_ERR, "Could not set trace status: %d. Context [%.4s:%.4s] not found:", req->log_level, apid, ctid);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, DLT_SERVICE_ID_SET_LOG_LEVEL, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_vlog(LOG_ERR,
+ "Could not set trace status: %d. Context [%.4s:%.4s] not found:",
+ req->log_level,
+ apid,
+ ctid);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_SET_LOG_LEVEL,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
}
}
}
-void dlt_daemon_control_set_default_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_default_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
DltServiceSetDefaultLogLevel *req;
- int32_t id=DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL;
+ int32_t id = DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetDefaultLogLevel*) (msg->databuffer);
+ req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
/* No endianess conversion necessary */
if (/*(req->log_level>=0) &&*/
- (req->log_level<=DLT_LOG_VERBOSE))
- {
+ (req->log_level <= DLT_LOG_VERBOSE)) {
if (daemon_local->flags.enforceContextLLAndTS)
- daemon->default_log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
- else
- daemon->default_log_level = req->log_level; /* No endianess conversion necessary */
+ daemon->default_log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
+ else
+ daemon->default_log_level = req->log_level; /* No endianess conversion necessary */
/* Send Update to all contexts using the default log level */
dlt_daemon_user_send_default_update(daemon, verbose);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
-void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_all_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
@@ -1947,83 +2011,76 @@ void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemon
int32_t id = DLT_SERVICE_ID_SET_ALL_LOG_LEVEL;
int8_t loglevel = 0;
- if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
+ if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL)) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return;
}
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetDefaultLogLevel*) (msg->databuffer);
+ req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
/* No endianess conversion necessary */
- if ((req != NULL) && ((req->log_level <= DLT_LOG_VERBOSE) || (req->log_level == (uint8_t)DLT_LOG_DEFAULT)))
- {
+ if ((req != NULL) && ((req->log_level <= DLT_LOG_VERBOSE) || (req->log_level == (uint8_t)DLT_LOG_DEFAULT))) {
if (daemon_local->flags.enforceContextLLAndTS)
- {
loglevel = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
- }
else
- {
loglevel = req->log_level; /* No endianess conversion necessary */
- }
/* Send Update to all contexts using the new log level */
dlt_daemon_user_send_all_log_level_update(daemon, loglevel, verbose);
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
+ else {
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
-void dlt_daemon_control_set_default_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_default_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
/* Payload of request message */
DltServiceSetDefaultLogLevel *req;
- int32_t id=DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS;
+ int32_t id = DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetDefaultLogLevel*) (msg->databuffer);
+ req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
/* No endianess conversion necessary */
- if ((req->log_level==DLT_TRACE_STATUS_OFF) ||
- (req->log_level==DLT_TRACE_STATUS_ON))
- {
+ if ((req->log_level == DLT_TRACE_STATUS_OFF) ||
+ (req->log_level == DLT_TRACE_STATUS_ON)) {
if (daemon_local->flags.enforceContextLLAndTS)
- daemon->default_trace_status = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
- else
- daemon->default_trace_status = req->log_level; /* No endianess conversion necessary*/
+ daemon->default_trace_status = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
+ else
+ daemon->default_trace_status = req->log_level; /* No endianess conversion necessary*/
/* Send Update to all contexts using the default trace status */
dlt_daemon_user_send_default_update(daemon, verbose);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
-void dlt_daemon_control_set_all_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_all_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
@@ -2031,131 +2088,121 @@ void dlt_daemon_control_set_all_trace_status(int sock, DltDaemon *daemon, DltDae
int32_t id = DLT_SERVICE_ID_SET_ALL_TRACE_STATUS;
int8_t tracestatus = 0;
- if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
+ if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL)) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return;
}
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetDefaultLogLevel*) (msg->databuffer);
+ req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
/* No endianess conversion necessary */
- if ((req != NULL) && ((req->log_level <= DLT_TRACE_STATUS_ON) || (req->log_level == (uint8_t)DLT_TRACE_STATUS_DEFAULT)))
- {
+ if ((req != NULL) &&
+ ((req->log_level <= DLT_TRACE_STATUS_ON) || (req->log_level == (uint8_t)DLT_TRACE_STATUS_DEFAULT))) {
if (daemon_local->flags.enforceContextLLAndTS)
- {
tracestatus = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
- }
else
- {
tracestatus = req->log_level; /* No endianess conversion necessary */
- }
/* Send Update to all contexts using the new log level */
dlt_daemon_user_send_all_trace_status_update(daemon, tracestatus, verbose);
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
+ else {
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
-void dlt_daemon_control_set_timing_packets(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_timing_packets(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
DltServiceSetVerboseMode *req; /* request uses same struct as set verbose mode */
- int32_t id=DLT_SERVICE_ID_SET_TIMING_PACKETS;
+ int32_t id = DLT_SERVICE_ID_SET_TIMING_PACKETS;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetVerboseMode)) < 0)
- {
return;
- }
- req = (DltServiceSetVerboseMode*) (msg->databuffer);
- if ((req->new_status==0) || (req->new_status==1))
- {
+ req = (DltServiceSetVerboseMode *)(msg->databuffer);
+
+ if ((req->new_status == 0) || (req->new_status == 1)) {
daemon->timingpackets = req->new_status;
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
{
- int ret;
+ int ret;
DltMessage msg;
int32_t len;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
return;
- }
/* send message */
/* prepare storage header */
- msg.storageheader = (DltStorageHeader*)msg.headerbuffer;
- dlt_set_storageheader(msg.storageheader,daemon->ecuid);
+ msg.storageheader = (DltStorageHeader *)msg.headerbuffer;
+ dlt_set_storageheader(msg.storageheader, daemon->ecuid);
/* prepare standard header */
- msg.standardheader = (DltStandardHeader*)(msg.headerbuffer + sizeof(DltStorageHeader));
- msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1 ;
+ msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+ msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
-#if (BYTE_ORDER==BIG_ENDIAN)
- msg.standardheader->htyp = ( msg.standardheader->htyp | DLT_HTYP_MSBF);
+#if (BYTE_ORDER == BIG_ENDIAN)
+ msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_MSBF);
#endif
msg.standardheader->mcnt = 0;
/* Set header extra parameters */
- dlt_set_id(msg.headerextra.ecu,daemon->ecuid);
+ dlt_set_id(msg.headerextra.ecu, daemon->ecuid);
msg.headerextra.tmsp = dlt_uptime();
dlt_message_set_extraparameters(&msg, verbose);
/* prepare extended header */
- msg.extendedheader = (DltExtendedHeader*)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+ msg.extendedheader =
+ (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
msg.extendedheader->msin = DLT_MSIN_CONTROL_TIME;
msg.extendedheader->noar = 0; /* number of arguments */
- dlt_set_id(msg.extendedheader->apid,""); /* application id */
- dlt_set_id(msg.extendedheader->ctid,""); /* context id */
+ dlt_set_id(msg.extendedheader->apid, ""); /* application id */
+ dlt_set_id(msg.extendedheader->ctid, ""); /* context id */
/* prepare length information */
- msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
+ msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
- len=msg.headersize - sizeof(DltStorageHeader) + msg.datasize;
- if (len>UINT16_MAX)
- {
- dlt_log(LOG_WARNING,"Huge control message discarded!\n");
+ len = msg.headersize - sizeof(DltStorageHeader) + msg.datasize;
+
+ if (len > UINT16_MAX) {
+ dlt_log(LOG_WARNING, "Huge control message discarded!\n");
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return;
}
@@ -2163,14 +2210,14 @@ void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, DltDaemonLocal
msg.standardheader->len = DLT_HTOBE_16(((uint16_t)len));
/* Send message */
- if((ret = dlt_daemon_client_send(sock,daemon,daemon_local,msg.headerbuffer,sizeof(DltStorageHeader),msg.headerbuffer+sizeof(DltStorageHeader),msg.headersize-sizeof(DltStorageHeader),
- msg.databuffer,msg.datasize,verbose)))
- {
-
- }
+ if ((ret =
+ dlt_daemon_client_send(sock, daemon, daemon_local, msg.headerbuffer, sizeof(DltStorageHeader),
+ msg.headerbuffer + sizeof(DltStorageHeader),
+ msg.headersize - sizeof(DltStorageHeader),
+ msg.databuffer, msg.datasize, verbose))) {}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
}
int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
@@ -2184,8 +2231,7 @@ int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL))
- {
+ if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: invalid parameters",
@@ -2196,36 +2242,30 @@ int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
res = read(receiver->fd, &expir, sizeof(expir));
- if(res < 0)
- {
+ if (res < 0) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: Fail to read timer (%s)\n", __func__, strerror(errno));
dlt_log(LOG_WARNING, str);
/* Activity received on timer_wd, but unable to read the fd:
- let's go on sending notification */
+ * let's go on sending notification */
}
- if((daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
- (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL))
- {
+ if ((daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
+ (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL)) {
if (dlt_daemon_send_ringbuffer_to_client(daemon,
daemon_local,
daemon_local->flags.vflag))
- {
dlt_log(LOG_DEBUG,
"Can't send contents of ring buffer to clients\n");
- }
}
- if((daemon->timingpackets) &&
- (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT))
- {
+ if ((daemon->timingpackets) &&
+ (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT))
dlt_daemon_control_message_time(DLT_DAEMON_SEND_TO_ALL,
daemon,
daemon_local,
daemon_local->flags.vflag);
- }
dlt_log(LOG_DEBUG, "Timer timingpacket\n");
@@ -2243,8 +2283,7 @@ int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL))
- {
+ if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
snprintf(str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: invalid parameters",
@@ -2255,32 +2294,28 @@ int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon,
res = read(receiver->fd, &expir, sizeof(expir));
- if(res < 0)
- {
+ if (res < 0) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: Fail to read timer (%s)\n", __func__, strerror(errno));
dlt_log(LOG_WARNING, str);
/* Activity received on timer_wd, but unable to read the fd:
- let's go on sending notification */
+ * let's go on sending notification */
}
- if(daemon_local->flags.sendECUSoftwareVersion > 0)
- {
+ if (daemon_local->flags.sendECUSoftwareVersion > 0)
dlt_daemon_control_get_software_version(DLT_DAEMON_SEND_TO_ALL,
daemon,
daemon_local,
daemon_local->flags.vflag);
- }
- if(daemon_local->flags.sendTimezone > 0)
- {
- // send timezone information
+ if (daemon_local->flags.sendTimezone > 0) {
+ /* send timezone information */
time_t t = time(NULL);
struct tm lt;
/*Added memset to avoid compiler warning for near initialization */
- memset((void*)&lt, 0, sizeof(lt));
+ memset((void *)&lt, 0, sizeof(lt));
localtime_r(&t, &lt);
dlt_daemon_control_message_timezone(DLT_DAEMON_SEND_TO_ALL,
@@ -2306,8 +2341,7 @@ int dlt_daemon_process_systemd_timer(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL))
- {
+ if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: invalid parameters",
@@ -2318,21 +2352,18 @@ int dlt_daemon_process_systemd_timer(DltDaemon *daemon,
res = read(receiver->fd, &expir, sizeof(expir));
- if(res < 0)
- {
+ if (res < 0) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Failed to read timer_wd; %s\n",
strerror(errno));
dlt_log(LOG_WARNING, local_str);
/* Activity received on timer_wd, but unable to read the fd:
- let's go on sending notification */
+ * let's go on sending notification */
}
- if(sd_notify(0, "WATCHDOG=1") < 0)
- {
+ if (sd_notify(0, "WATCHDOG=1") < 0)
dlt_log(LOG_CRIT, "Could not reset systemd watchdog\n");
- }
dlt_log(LOG_DEBUG, "Timer watchdog\n");
@@ -2370,16 +2401,14 @@ void dlt_daemon_control_service_logstorage(int sock,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (msg == NULL) || (daemon_local == NULL))
- {
+ if ((daemon == NULL) || (msg == NULL) || (daemon_local == NULL)) {
dlt_vlog(LOG_ERR,
"%s: Invalid function parameters\n",
__func__);
- return ;
+ return;
}
- if ((daemon_local->flags.offlineLogstorageMaxDevices <= 0) || (msg->databuffer == NULL))
- {
+ if ((daemon_local->flags.offlineLogstorageMaxDevices <= 0) || (msg->databuffer == NULL)) {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
@@ -2393,19 +2422,16 @@ void dlt_daemon_control_service_logstorage(int sock,
}
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceOfflineLogstorage)) < 0)
- {
return;
- }
- req = (DltServiceOfflineLogstorage*) (msg->databuffer);
+ req = (DltServiceOfflineLogstorage *)(msg->databuffer);
- for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
+ for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
connection_type = daemon->storage_handle[i].connection_type;
+
/* Check if the requested device path is already used as log storage device */
if (strncmp(daemon->storage_handle[i].device_mount_point,
- req->mount_point, strlen(req->mount_point)) == 0)
- {
+ req->mount_point, strlen(req->mount_point)) == 0) {
device_index = i;
break;
}
@@ -2413,41 +2439,33 @@ void dlt_daemon_control_service_logstorage(int sock,
/* Get first available device index here */
if ((connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) &&
(device_index == -1))
- {
device_index = i;
- }
}
/* It might be possible to sync all caches of all devices */
if ((req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES) &&
- (strlen(req->mount_point) == 0))
- {
+ (strlen(req->mount_point) == 0)) {
/* It is expected to receive an empty mount point to sync all Logstorage
* devices in this case. */
}
- else
- {
- if (device_index == -1)
- {
- dlt_daemon_control_service_response(sock,
- daemon,
- daemon_local,
- DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
- DLT_SERVICE_RESPONSE_ERROR,
- verbose);
- dlt_log(LOG_WARNING, "MAX devices already in use \n");
- return;
- }
+ else if (device_index == -1) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
+ dlt_log(LOG_WARNING, "MAX devices already in use \n");
+ return;
}
/* Check for device connection request from log storage ctrl app */
device = &daemon->storage_handle[device_index];
- if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
- {
+
+ if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) {
ret = dlt_logstorage_device_connected(device, req->mount_point);
- if (ret == 1)
- {
+ if (ret == 1) {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
@@ -2482,15 +2500,15 @@ void dlt_daemon_control_service_logstorage(int sock,
}
/* Check for device disconnection request from log storage ctrl app */
- else if(req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED)
+ else if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED)
{
/* Check if log level of running application needs to be reset */
dlt_daemon_logstorage_reset_application_loglevel(
- daemon,
- daemon_local,
- device_index,
- daemon_local->flags.offlineLogstorageMaxDevices,
- verbose);
+ daemon,
+ daemon_local,
+ device_index,
+ daemon_local->flags.offlineLogstorageMaxDevices,
+ verbose);
dlt_logstorage_device_disconnected(&(daemon->storage_handle[device_index]),
DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT);
@@ -2504,54 +2522,45 @@ void dlt_daemon_control_service_logstorage(int sock,
}
/* Check for cache synchronization request from log storage ctrl app */
- else if(req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES)
+ else if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES)
{
int ret = 0;
- if (device_index == -1) /* sync all Logstorage devices */
- {
+
+ if (device_index == -1) { /* sync all Logstorage devices */
+
for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
if (daemon->storage_handle[i].connection_type ==
DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
- {
ret = dlt_daemon_logstorage_sync_cache(
- daemon,
- daemon_local,
- daemon->storage_handle[i].device_mount_point,
- verbose);
- }
- }
+ daemon,
+ daemon_local,
+ daemon->storage_handle[i].device_mount_point,
+ verbose);
}
- else
- {
+ else {
/* trigger logstorage to sync caches */
ret = dlt_daemon_logstorage_sync_cache(daemon,
- daemon_local,
- req->mount_point,
- verbose);
+ daemon_local,
+ req->mount_point,
+ verbose);
}
if (ret == 0)
- {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
DLT_SERVICE_RESPONSE_OK,
verbose);
- }
else
- {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
DLT_SERVICE_RESPONSE_ERROR,
verbose);
- }
}
- else
- {
+ else {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
@@ -2572,15 +2581,12 @@ void dlt_daemon_control_passive_node_connect(int sock,
DltServicePassiveNodeConnect *req;
uint32_t id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT;
- if (daemon == NULL || daemon_local == NULL || msg == NULL ||
- msg->databuffer == NULL)
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL) ||
+ (msg->databuffer == NULL))
return;
- }
/* return error, if gateway mode not enabled*/
- if (daemon_local->flags.gatewayMode == 0)
- {
+ if (daemon_local->flags.gatewayMode == 0) {
dlt_log(LOG_WARNING,
"Received passive node connection status request, "
"but GatewayMode is disabled\n");
@@ -2597,34 +2603,28 @@ void dlt_daemon_control_passive_node_connect(int sock,
}
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServicePassiveNodeConnect)) < 0)
- {
return;
- }
- req = (DltServicePassiveNodeConnect *) msg->databuffer;
+ req = (DltServicePassiveNodeConnect *)msg->databuffer;
if (dlt_gateway_process_on_demand_request(&daemon_local->pGateway,
daemon_local,
req->node_id,
req->connection_status,
verbose) < 0)
- {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
id,
DLT_SERVICE_RESPONSE_ERROR,
verbose);
- }
else
- {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
id,
DLT_SERVICE_RESPONSE_OK,
verbose);
- }
}
void dlt_daemon_control_passive_node_connect_status(int sock,
@@ -2639,19 +2639,14 @@ void dlt_daemon_control_passive_node_connect_status(int sock,
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || daemon_local == NULL)
- {
+ if ((daemon == NULL) || (daemon_local == NULL))
return;
- }
if (dlt_message_init(&msg, verbose) == -1)
- {
return;
- }
/* return error, if gateway mode not enabled*/
- if (daemon_local->flags.gatewayMode == 0)
- {
+ if (daemon_local->flags.gatewayMode == 0) {
dlt_log(LOG_WARNING,
"Received passive node connection status request, "
"but GatewayMode is disabled\n");
@@ -2669,39 +2664,37 @@ void dlt_daemon_control_passive_node_connect_status(int sock,
/* prepare payload of data */
msg.datasize = sizeof(DltServicePassiveNodeConnectionInfo);
+
if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
msg.databuffer = NULL;
- }
- if (msg.databuffer == NULL)
- {
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- if (msg.databuffer == NULL)
- {
+
+ if (msg.databuffer == NULL) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+
+ if (msg.databuffer == NULL) {
dlt_log(LOG_CRIT, "Cannot allocate memory for message response\n");
return;
}
+
msg.databuffersize = msg.datasize;
}
- resp = (DltServicePassiveNodeConnectionInfo *) msg.databuffer;
+ resp = (DltServicePassiveNodeConnectionInfo *)msg.databuffer;
memset(resp, 0, msg.datasize);
resp->service_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS;
resp->status = DLT_SERVICE_RESPONSE_OK;
resp->num_connections = daemon_local->pGateway.num_connections;
- for (i = 0; i < resp->num_connections; i++)
- {
- if ((i * DLT_ID_SIZE) > DLT_ENTRY_MAX)
- {
+ for (i = 0; i < resp->num_connections; i++) {
+ if ((i * DLT_ID_SIZE) > DLT_ENTRY_MAX) {
dlt_log(LOG_ERR,
"Maximal message size reached. Skip further information\n");
break;
}
con = &daemon_local->pGateway.connections[i];
- if (con == NULL)
- {
+
+ if (con == NULL) {
dlt_log(LOG_CRIT, "Passive node connection structure is NULL\n");
dlt_daemon_control_service_response(
sock,
diff --git a/src/daemon/dlt_daemon_client.h b/src/daemon/dlt_daemon_client.h
index b974b67..8406608 100644
--- a/src/daemon/dlt_daemon_client.h
+++ b/src/daemon/dlt_daemon_client.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_daemon_client.h
-*/
+ */
/*******************************************************************************
@@ -89,7 +89,16 @@ int dlt_daemon_client_send_all(DltDaemon *daemon, DltDaemonLocal *daemon_local,
* @param verbose if set to true verbose information is printed out.
* @return unequal 0 if there is an error or buffer is full
*/
-int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_local,void* storage_header,int storage_header_size,void* data1,int size1,void* data2,int size2,int verbose);
+int dlt_daemon_client_send(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ void *storage_header,
+ int storage_header_size,
+ void *data1,
+ int size1,
+ void *data2,
+ int size2,
+ int verbose);
/**
* Send out response message to dlt client
@@ -102,7 +111,13 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc
* @param verbose if set to true verbose information is printed out.
* @return -1 if there is an error or buffer is full
*/
-int dlt_daemon_client_send_control_message(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, char* appid, char* contid, int verbose);
+int dlt_daemon_client_send_control_message(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ char *appid,
+ char *contid,
+ int verbose);
/**
* Process and generate response to received get log info control message
* @param sock connection handle used for sending response
@@ -111,7 +126,11 @@ int dlt_daemon_client_send_control_message(int sock, DltDaemon *daemon, DltDaemo
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_get_log_info(int sock, DltDaemon *daemon,DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_get_log_info(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received get software version control message
* @param sock connection handle used for sending response
@@ -136,7 +155,12 @@ void dlt_daemon_control_get_default_log_level(int sock, DltDaemon *daemon, DltDa
* @param verbose if set to true verbose information is printed out.
* @return -1 if there is an error or buffer overflow, else 0
*/
-int dlt_daemon_control_message_buffer_overflow(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, unsigned int overflow_counter,char* apid, int verbose);
+int dlt_daemon_control_message_buffer_overflow(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ unsigned int overflow_counter,
+ char *apid,
+ int verbose);
/**
* Generate response to control message from dlt client
* @param sock connection handle used for sending response
@@ -146,7 +170,12 @@ int dlt_daemon_control_message_buffer_overflow(int sock, DltDaemon *daemon, DltD
* @param status status of response (e.g. ok, not supported, error)
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_service_response(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, uint32_t service_id, int8_t status, int verbose);
+void dlt_daemon_control_service_response(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ uint32_t service_id,
+ int8_t status,
+ int verbose);
/**
* Send control message unregister context (add on to AUTOSAR standard)
* @param sock connection handle used for sending response
@@ -157,7 +186,13 @@ void dlt_daemon_control_service_response(int sock, DltDaemon *daemon, DltDaemonL
* @param comid Communication id where apid is unregistered
* @param verbose if set to true verbose information is printed out.
*/
-int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, char* apid, char* ctid, char* comid, int verbose);
+int dlt_daemon_control_message_unregister_context(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ char *apid,
+ char *ctid,
+ char *comid,
+ int verbose);
/**
* Send control message connection info (add on to AUTOSAR standard)
* @param sock connection handle used for sending response
@@ -167,7 +202,12 @@ int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, D
* @param comid Communication id where connection state changed
* @param verbose if set to true verbose information is printed out.
*/
-int dlt_daemon_control_message_connection_info(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, uint8_t state, char* comid, int verbose);
+int dlt_daemon_control_message_connection_info(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ uint8_t state,
+ char *comid,
+ int verbose);
/**
* Send control message timezone (add on to AUTOSAR standard)
* @param sock connection handle used for sending response
@@ -192,7 +232,11 @@ int dlt_daemon_control_message_marker(int sock, DltDaemon *daemon, DltDaemonLoca
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+int dlt_daemon_client_process_control(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received sw injection control message
* @param sock connection handle used for sending response
@@ -201,7 +245,11 @@ int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLoca
* @param msg pointer to received sw injection control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_callsw_cinjection(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set log level control message
* @param sock connection handle used for sending response
@@ -210,7 +258,11 @@ void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltDaemon
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set trace status control message
* @param sock connection handle used for sending response
@@ -219,7 +271,11 @@ void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLoca
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set default log level control message
* @param sock connection handle used for sending response
@@ -228,7 +284,11 @@ void dlt_daemon_control_set_trace_status(int sock, DltDaemon *daemon, DltDaemonL
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_default_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_default_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set all log level control message
* @param sock connection handle used for sending response
@@ -237,7 +297,11 @@ void dlt_daemon_control_set_default_log_level(int sock, DltDaemon *daemon, DltDa
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_all_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set default trace status control message
@@ -247,7 +311,11 @@ void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemon
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_default_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_default_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set all trace status control message
* @param sock connection handle used for sending response
@@ -256,7 +324,11 @@ void dlt_daemon_control_set_default_trace_status(int sock, DltDaemon *daemon, Dl
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_all_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_all_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to set timing packets control message
* @param sock connection handle used for sending response
@@ -265,7 +337,11 @@ void dlt_daemon_control_set_all_trace_status(int sock, DltDaemon *daemon, DltDae
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_timing_packets(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_timing_packets(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Send time control message
* @param sock connection handle used for sending response
@@ -282,7 +358,11 @@ void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, DltDaemonLocal
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_service_logstorage(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_service_logstorage(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received passive node connect control
diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c
index ce2de71..8508dfe 100644
--- a/src/daemon/dlt_daemon_common.c
+++ b/src/daemon/dlt_daemon_common.c
@@ -63,8 +63,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <stdio.h>
@@ -94,37 +94,32 @@ sem_t dlt_daemon_mutex;
static int dlt_daemon_cmp_apid(const void *m1, const void *m2)
{
- if(m1 == NULL || m2 == NULL)
+ if ((m1 == NULL) || (m2 == NULL))
return -1;
- DltDaemonApplication *mi1 = (DltDaemonApplication *) m1;
- DltDaemonApplication *mi2 = (DltDaemonApplication *) m2;
+ DltDaemonApplication *mi1 = (DltDaemonApplication *)m1;
+ DltDaemonApplication *mi2 = (DltDaemonApplication *)m2;
return memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
}
static int dlt_daemon_cmp_apid_ctid(const void *m1, const void *m2)
{
- if(m1 == NULL || m2 == NULL)
+ if ((m1 == NULL) || (m2 == NULL))
return -1;
int ret, cmp;
- DltDaemonContext *mi1 = (DltDaemonContext *) m1;
- DltDaemonContext *mi2 = (DltDaemonContext *) m2;
+ DltDaemonContext *mi1 = (DltDaemonContext *)m1;
+ DltDaemonContext *mi2 = (DltDaemonContext *)m2;
- cmp=memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
- if (cmp<0)
- {
- ret=-1;
- }
- else if (cmp==0)
- {
- ret=memcmp(mi1->ctid, mi2->ctid, DLT_ID_SIZE);
- }
+ cmp = memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
+
+ if (cmp < 0)
+ ret = -1;
+ else if (cmp == 0)
+ ret = memcmp(mi1->ctid, mi2->ctid, DLT_ID_SIZE);
else
- {
- ret=1;
- }
+ ret = 1;
return ret;
}
@@ -137,90 +132,89 @@ DltDaemonRegisteredUsers *dlt_daemon_find_users_list(DltDaemon *daemon,
int i = 0;
- if (daemon == NULL || ecu == NULL)
- {
+ if ((daemon == NULL) || (ecu == NULL)) {
dlt_vlog(LOG_ERR, "%s: Wrong parameters", __func__);
- return (DltDaemonRegisteredUsers *) NULL;
+ return (DltDaemonRegisteredUsers *)NULL;
}
for (i = 0; i < daemon->num_user_lists; i++)
- {
if (strncmp(ecu, daemon->user_list[i].ecu, DLT_ID_SIZE) == 0)
- {
return &daemon->user_list[i];
- }
- }
dlt_vlog(LOG_ERR, "Cannot find user list for ECU: %4s\n", ecu);
- return (DltDaemonRegisteredUsers *) NULL;
+ return (DltDaemonRegisteredUsers *)NULL;
}
-int dlt_daemon_load_runtime_configuration(DltDaemon *daemon,const char *runtime_directory, int verbose)
+int dlt_daemon_load_runtime_configuration(DltDaemon *daemon, const char *runtime_directory, int verbose)
{
int append_length = 0;
- if (daemon == NULL || runtime_directory == NULL)
- {
+ if ((daemon == NULL) || (runtime_directory == NULL))
return DLT_RETURN_ERROR;
- }
/* prepare filenames for configuration */
append_length = PATH_MAX - sizeof(DLT_RUNTIME_APPLICATION_CFG);
- if(runtime_directory[0])
- {
- strncpy(daemon->runtime_application_cfg,runtime_directory,append_length);
- daemon->runtime_application_cfg[append_length]=0;
+
+ if (runtime_directory[0]) {
+ strncpy(daemon->runtime_application_cfg, runtime_directory, append_length);
+ daemon->runtime_application_cfg[append_length] = 0;
}
- else
- {
- strncpy(daemon->runtime_application_cfg,DLT_RUNTIME_DEFAULT_DIRECTORY,append_length);
- daemon->runtime_application_cfg[append_length]=0;
+ else {
+ strncpy(daemon->runtime_application_cfg, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+ daemon->runtime_application_cfg[append_length] = 0;
}
- strcat(daemon->runtime_application_cfg,DLT_RUNTIME_APPLICATION_CFG); /* strcat uncritical here, because max length already checked */
+
+ strcat(daemon->runtime_application_cfg, DLT_RUNTIME_APPLICATION_CFG); /* strcat uncritical here, because max length already checked */
append_length = PATH_MAX - sizeof(DLT_RUNTIME_CONTEXT_CFG);
- if(runtime_directory[0])
- {
- strncpy(daemon->runtime_context_cfg,runtime_directory,append_length);
- daemon->runtime_context_cfg[append_length]=0;
+
+ if (runtime_directory[0]) {
+ strncpy(daemon->runtime_context_cfg, runtime_directory, append_length);
+ daemon->runtime_context_cfg[append_length] = 0;
}
- else
- {
- strncpy(daemon->runtime_context_cfg,DLT_RUNTIME_DEFAULT_DIRECTORY,append_length);
- daemon->runtime_context_cfg[append_length]=0;
+ else {
+ strncpy(daemon->runtime_context_cfg, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+ daemon->runtime_context_cfg[append_length] = 0;
}
- strcat(daemon->runtime_context_cfg,DLT_RUNTIME_CONTEXT_CFG); /* strcat uncritical here, because max length already checked */
+
+ strcat(daemon->runtime_context_cfg, DLT_RUNTIME_CONTEXT_CFG); /* strcat uncritical here, because max length already checked */
append_length = PATH_MAX - sizeof(DLT_RUNTIME_CONFIGURATION);
- if(runtime_directory[0])
- {
- strncpy(daemon->runtime_configuration,runtime_directory,append_length);
- daemon->runtime_configuration[append_length]=0;
+
+ if (runtime_directory[0]) {
+ strncpy(daemon->runtime_configuration, runtime_directory, append_length);
+ daemon->runtime_configuration[append_length] = 0;
}
- else
- {
- strncpy(daemon->runtime_configuration,DLT_RUNTIME_DEFAULT_DIRECTORY,append_length);
- daemon->runtime_configuration[append_length]=0;
+ else {
+ strncpy(daemon->runtime_configuration, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+ daemon->runtime_configuration[append_length] = 0;
}
- strcat(daemon->runtime_configuration,DLT_RUNTIME_CONFIGURATION); /* strcat uncritical here, because max length already checked */
+
+ strcat(daemon->runtime_configuration, DLT_RUNTIME_CONFIGURATION); /* strcat uncritical here, because max length already checked */
/* Check for runtime cfg, if it is loadable, load it! */
- if ((dlt_daemon_applications_load(daemon,daemon->runtime_application_cfg, verbose)==0) &&
- (dlt_daemon_contexts_load(daemon,daemon->runtime_context_cfg, verbose)==0))
- {
+ if ((dlt_daemon_applications_load(daemon, daemon->runtime_application_cfg, verbose) == 0) &&
+ (dlt_daemon_contexts_load(daemon, daemon->runtime_context_cfg, verbose) == 0))
daemon->runtime_context_cfg_loaded = 1;
- }
/* load configuration if available */
- dlt_daemon_configuration_load(daemon,daemon->runtime_configuration, verbose);
+ dlt_daemon_configuration_load(daemon, daemon->runtime_configuration, verbose);
return DLT_RETURN_OK;
}
-int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned long RingbufferMaxSize,unsigned long RingbufferStepSize,const char *runtime_directory,int InitialContextLogLevel, int InitialContextTraceStatus, int ForceLLTS, int verbose)
+int dlt_daemon_init(DltDaemon *daemon,
+ unsigned long RingbufferMinSize,
+ unsigned long RingbufferMaxSize,
+ unsigned long RingbufferStepSize,
+ const char *runtime_directory,
+ int InitialContextLogLevel,
+ int InitialContextTraceStatus,
+ int ForceLLTS,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || runtime_directory == NULL)
+ if ((daemon == NULL) || (runtime_directory == NULL))
return -1;
daemon->user_list = NULL;
@@ -243,15 +237,20 @@ int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned l
daemon->sendserialheader = 0;
daemon->timingpackets = 0;
- dlt_set_id(daemon->ecuid,"");
+ dlt_set_id(daemon->ecuid, "");
/* initialize ring buffer for client connection */
- snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Ringbuffer configuration: %lu/%lu/%lu\n", RingbufferMinSize,RingbufferMaxSize,RingbufferStepSize );
+ snprintf(str,
+ DLT_DAEMON_COMMON_TEXTBUFSIZE,
+ "Ringbuffer configuration: %lu/%lu/%lu\n",
+ RingbufferMinSize,
+ RingbufferMaxSize,
+ RingbufferStepSize);
dlt_log(LOG_INFO, str);
- if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), RingbufferMinSize,RingbufferMaxSize,RingbufferStepSize) == DLT_RETURN_ERROR)
- {
+
+ if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), RingbufferMinSize, RingbufferMaxSize,
+ RingbufferStepSize) == DLT_RETURN_ERROR)
return -1;
- }
daemon->storage_handle = NULL;
return 0;
@@ -264,15 +263,14 @@ int dlt_daemon_free(DltDaemon *daemon, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || daemon->user_list == NULL)
+ if ((daemon == NULL) || (daemon->user_list == NULL))
return -1;
/* free all registered user information */
- for (i = 0; i < daemon->num_user_lists; i++)
- {
+ for (i = 0; i < daemon->num_user_lists; i++) {
user_list = &daemon->user_list[i];
- if (user_list != NULL)
- {
+
+ if (user_list != NULL) {
/* ignore return values */
dlt_daemon_contexts_clear(daemon, user_list->ecu, verbose);
dlt_daemon_applications_clear(daemon, user_list->ecu, verbose);
@@ -280,10 +278,10 @@ int dlt_daemon_free(DltDaemon *daemon, int verbose)
}
free(daemon->user_list);
+
if (app_recv_buffer)
- {
free(app_recv_buffer);
- }
+
/* free ringbuffer */
dlt_buffer_free_dynamic(&(daemon->client_ringbuffer));
@@ -301,16 +299,13 @@ int dlt_daemon_init_user_information(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || ((gateway_mode == 1) && (gateway == NULL)))
- {
return DLT_RETURN_ERROR;
- }
- if (gateway_mode == 0)
- {
+ if (gateway_mode == 0) {
/* initialize application list */
daemon->user_list = calloc(nodes, sizeof(DltDaemonRegisteredUsers));
- if (daemon->user_list == NULL)
- {
+
+ if (daemon->user_list == NULL) {
dlt_log(LOG_ERR, "Allocating memory for user information");
return DLT_RETURN_ERROR;
}
@@ -318,14 +313,13 @@ int dlt_daemon_init_user_information(DltDaemon *daemon,
dlt_set_id(daemon->user_list[0].ecu, daemon->ecuid);
daemon->num_user_lists = 1;
}
- else /* gateway is active */
- {
+ else { /* gateway is active */
nodes += gateway->num_connections;
/* initialize application list */
daemon->user_list = calloc(nodes, sizeof(DltDaemonRegisteredUsers));
- if (daemon->user_list == NULL)
- {
+
+ if (daemon->user_list == NULL) {
dlt_log(LOG_ERR, "Allocating memory for user information");
return DLT_RETURN_ERROR;
}
@@ -334,9 +328,7 @@ int dlt_daemon_init_user_information(DltDaemon *daemon,
daemon->num_user_lists = nodes;
for (i = 1; i < nodes; i++)
- {
- dlt_set_id(daemon->user_list[i].ecu, gateway->connections[i-1].ecuid);
- }
+ dlt_set_id(daemon->user_list[i].ecu, gateway->connections[i - 1].ecuid);
}
return DLT_RETURN_OK;
@@ -348,25 +340,19 @@ int dlt_daemon_applications_invalidate_fd(DltDaemon *daemon,
int verbose)
{
int i;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || ecu == NULL)
- {
+ if ((daemon == NULL) || (ecu == NULL))
return DLT_RETURN_ERROR;
- }
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
- if (user_list != NULL)
- {
- for (i=0; i<user_list->num_applications; i++)
- {
+
+ if (user_list != NULL) {
+ for (i = 0; i < user_list->num_applications; i++)
if (user_list->applications[i].user_handle == fd)
- {
user_list->applications[i].user_handle = DLT_FD_INIT;
- }
- }
return DLT_RETURN_OK;
}
@@ -382,29 +368,23 @@ int dlt_daemon_applications_clear(DltDaemon *daemon, char *ecu, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon->user_list == NULL) || (ecu == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (user_list == NULL)
- {
return DLT_RETURN_ERROR;
- }
- for (i=0; i < user_list->num_applications; i++)
- {
- if (user_list->applications[i].application_description != NULL)
- {
+ for (i = 0; i < user_list->num_applications; i++)
+ if (user_list->applications[i].application_description != NULL) {
free(user_list->applications[i].application_description);
user_list->applications[i].application_description = NULL;
}
- }
+
+
if (user_list->applications != NULL)
- {
free(user_list->applications);
- }
user_list->applications = NULL;
user_list->num_applications = 0;
@@ -412,7 +392,7 @@ int dlt_daemon_applications_clear(DltDaemon *daemon, char *ecu, int verbose)
return 0;
}
-DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
+DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
char *apid,
pid_t pid,
char *description,
@@ -426,56 +406,49 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
int dlt_user_handle;
DltDaemonRegisteredUsers *user_list = NULL;
#ifndef DLT_USE_UNIX_SOCKET_IPC
- (void) fd; /* To avoid compiler warning : unused variable */
+ (void)fd; /* To avoid compiler warning : unused variable */
char filename[DLT_DAEMON_COMMON_TEXTBUFSIZE];
#endif
- if ((daemon == NULL) || (apid == NULL) || (apid[0]=='\0') || (ecu == NULL))
- {
- return (DltDaemonApplication*) NULL;
- }
+ if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') || (ecu == NULL))
+ return (DltDaemonApplication *)NULL;
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (user_list == NULL)
- {
- return (DltDaemonApplication*) NULL;
- }
+ return (DltDaemonApplication *)NULL;
+
+ if (user_list->applications == NULL) {
+ user_list->applications = (DltDaemonApplication *)
+ malloc(sizeof(DltDaemonApplication) * DLT_DAEMON_APPL_ALLOC_SIZE);
- if (user_list->applications == NULL)
- {
- user_list->applications = (DltDaemonApplication*)
- malloc(sizeof(DltDaemonApplication) * DLT_DAEMON_APPL_ALLOC_SIZE);
if (user_list->applications == NULL)
- {
- return (DltDaemonApplication*) NULL;
- }
+ return (DltDaemonApplication *)NULL;
}
- new_application=0;
+ new_application = 0;
/* Check if application [apid] is already available */
application = dlt_daemon_application_find(daemon, apid, ecu, verbose);
- if (application == NULL)
- {
+
+ if (application == NULL) {
user_list->num_applications += 1;
- if (user_list->num_applications != 0)
- {
- if ((user_list->num_applications % DLT_DAEMON_APPL_ALLOC_SIZE) == 0)
- {
+ if (user_list->num_applications != 0) {
+ if ((user_list->num_applications % DLT_DAEMON_APPL_ALLOC_SIZE) == 0) {
/* allocate memory in steps of DLT_DAEMON_APPL_ALLOC_SIZE, e.g. 100 */
old = user_list->applications;
- user_list->applications = (DltDaemonApplication*)
- malloc(sizeof(DltDaemonApplication) *
- ((user_list->num_applications / DLT_DAEMON_APPL_ALLOC_SIZE) + 1) *
- DLT_DAEMON_APPL_ALLOC_SIZE);
+ user_list->applications = (DltDaemonApplication *)
+ malloc(sizeof(DltDaemonApplication) *
+ ((user_list->num_applications / DLT_DAEMON_APPL_ALLOC_SIZE) + 1) *
+ DLT_DAEMON_APPL_ALLOC_SIZE);
- if (user_list->applications == NULL)
- {
+ if (user_list->applications == NULL) {
user_list->applications = old;
user_list->num_applications -= 1;
- return (DltDaemonApplication*) NULL;
+ return (DltDaemonApplication *)NULL;
}
+
memcpy(user_list->applications,
old,
sizeof(DltDaemonApplication) * user_list->num_applications);
@@ -485,7 +458,7 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
application = &(user_list->applications[user_list->num_applications - 1]);
- dlt_set_id(application->apid,apid);
+ dlt_set_id(application->apid, apid);
application->pid = 0;
application->application_description = NULL;
application->num_contexts = 0;
@@ -493,7 +466,9 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
new_application = 1;
- } else if ((pid != application->pid) && (application->pid != 0)) {
+ }
+ else if ((pid != application->pid) && (application->pid != 0))
+ {
dlt_vlog(LOG_WARNING,
"Duplicate registration of ApplicationID: '%.4s'; registering from PID %d, existing from PID %d\n",
@@ -503,53 +478,47 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
}
/* Store application description and pid of application */
- if (application->application_description)
- {
+ if (application->application_description) {
free(application->application_description);
application->application_description = NULL;
}
- if (description != NULL)
- {
+ if (description != NULL) {
application->application_description = malloc(strlen(description) + 1);
- if (application->application_description)
- {
+
+ if (application->application_description) {
strncpy(application->application_description,
description,
strlen(description));
application->application_description[strlen(description)] = '\0';
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Cannot allocate memory to store application description\n");
free(application);
- return (DltDaemonApplication*) NULL;
+ return (DltDaemonApplication *)NULL;
}
}
- if (application->user_handle != DLT_FD_INIT)
- {
- if (application->pid != pid)
- {
+ if (application->user_handle != DLT_FD_INIT) {
+ if (application->pid != pid) {
#ifndef DLT_USE_UNIX_SOCKET_IPC
- if (close(application->user_handle) < 0)
- {
- dlt_vlog(LOG_WARNING,
- "close() failed to %s/dltpipes/dlt%d, errno=%d (%s)!\n",
- dltFifoBaseDir,
- pid,
- errno,
- strerror(errno)); /* errno 2: ENOENT - No such file or directory */
- }
+
+ if (close(application->user_handle) < 0)
+ dlt_vlog(LOG_WARNING,
+ "close() failed to %s/dltpipes/dlt%d, errno=%d (%s)!\n",
+ dltFifoBaseDir,
+ pid,
+ errno,
+ strerror(errno)); /* errno 2: ENOENT - No such file or directory */
+
#endif
- application->user_handle = DLT_FD_INIT;
- application->pid = 0;
+ application->user_handle = DLT_FD_INIT;
+ application->pid = 0;
}
}
/* open user pipe only if it is not yet opened */
- if ((application->user_handle == DLT_FD_INIT) && (pid != 0))
- {
+ if ((application->user_handle == DLT_FD_INIT) && (pid != 0)) {
#ifdef DLT_USE_UNIX_SOCKET_IPC
dlt_user_handle = fd;
#else
@@ -559,15 +528,16 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
dltFifoBaseDir,
pid);
- dlt_user_handle = open(filename, O_WRONLY|O_NONBLOCK);
- if (dlt_user_handle < 0)
- {
+ dlt_user_handle = open(filename, O_WRONLY | O_NONBLOCK);
+
+ if (dlt_user_handle < 0) {
int prio = (errno == ENOENT) ? LOG_INFO : LOG_WARNING;
dlt_vlog(prio, "open() failed to %s, errno=%d (%s)!\n", filename, errno, strerror(errno));
} /* if */
+
#endif
/* check if file descriptor was already used, and make it invalid if it
- * is reused. This prevents sending messages to wrong file descriptor */
+ * is reused. This prevents sending messages to wrong file descriptor */
dlt_daemon_applications_invalidate_fd(daemon, ecu, dlt_user_handle, verbose);
dlt_daemon_contexts_invalidate_fd(daemon, ecu, dlt_user_handle, verbose);
@@ -576,8 +546,7 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
}
/* Sort */
- if (new_application)
- {
+ if (new_application) {
qsort(user_list->applications,
user_list->num_applications,
sizeof(DltDaemonApplication),
@@ -601,21 +570,16 @@ int dlt_daemon_application_del(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (application == NULL) || (ecu == NULL))
- {
return -1;
- }
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (user_list == NULL)
- {
return -1;
- }
- if (user_list->num_applications > 0)
- {
+ if (user_list->num_applications > 0) {
/* Check if user handle is open; if yes, close it */
- if (application->user_handle >= DLT_FD_MINIMUM)
- {
+ if (application->user_handle >= DLT_FD_MINIMUM) {
#ifndef DLT_USE_UNIX_SOCKET_IPC
close(application->user_handle);
#endif
@@ -623,8 +587,7 @@ int dlt_daemon_application_del(DltDaemon *daemon,
}
/* Free description of application to be deleted */
- if (application->application_description)
- {
+ if (application->application_description) {
free(application->application_description);
application->application_description = NULL;
}
@@ -633,11 +596,11 @@ int dlt_daemon_application_del(DltDaemon *daemon,
/* move all applications above pos to pos */
memmove(&(user_list->applications[pos]),
- &(user_list->applications[pos+1]),
+ &(user_list->applications[pos + 1]),
sizeof(DltDaemonApplication) * ((user_list->num_applications - 1) - pos));
/* Clear last application */
- memset(&(user_list->applications[user_list->num_applications-1]),
+ memset(&(user_list->applications[user_list->num_applications - 1]),
0,
sizeof(DltDaemonApplication));
@@ -647,43 +610,38 @@ int dlt_daemon_application_del(DltDaemon *daemon,
return 0;
}
-DltDaemonApplication* dlt_daemon_application_find(DltDaemon *daemon,
+DltDaemonApplication *dlt_daemon_application_find(DltDaemon *daemon,
char *apid,
char *ecu,
int verbose)
{
DltDaemonApplication application;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon->user_list == NULL) || (apid == NULL) ||
- (apid[0]=='\0') || (ecu == NULL))
- {
- return (DltDaemonApplication*) NULL;
- }
+ (apid[0] == '\0') || (ecu == NULL))
+ return (DltDaemonApplication *)NULL;
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
- if (user_list == NULL || (user_list->num_applications == 0))
- {
- return (DltDaemonApplication*) NULL;
- }
+
+ if ((user_list == NULL) || (user_list->num_applications == 0))
+ return (DltDaemonApplication *)NULL;
/* Check, if apid is smaller than smallest apid or greater than greatest apid */
if ((memcmp(apid, user_list->applications[0].apid, DLT_ID_SIZE) < 0) ||
(memcmp(apid,
user_list->applications[user_list->num_applications - 1].apid,
DLT_ID_SIZE) > 0))
- {
- return (DltDaemonApplication*) NULL;
- }
+ return (DltDaemonApplication *)NULL;
dlt_set_id(application.apid, apid);
- return (DltDaemonApplication*)bsearch(&application,
- user_list->applications,
- user_list->num_applications,
- sizeof(DltDaemonApplication),
- dlt_daemon_cmp_apid);
+ return (DltDaemonApplication *)bsearch(&application,
+ user_list->applications,
+ user_list->num_applications,
+ sizeof(DltDaemonApplication),
+ dlt_daemon_cmp_apid);
}
int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int verbose)
@@ -696,13 +654,12 @@ int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int ve
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (filename == NULL) || (filename[0]=='\0'))
+ if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
return -1;
- fd=fopen(filename, "r");
+ fd = fopen(filename, "r");
- if (fd == NULL)
- {
+ if (fd == NULL) {
dlt_vlog(LOG_WARNING,
"%s: cannot open file %s: %s\n",
__func__,
@@ -712,19 +669,17 @@ int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int ve
return -1;
}
- while (!feof(fd))
- {
+ while (!feof(fd)) {
/* Clear buf */
memset(buf, 0, sizeof(buf));
/* Get line */
ret = fgets(buf, sizeof(buf), fd);
- if (NULL == ret)
- {
+
+ if (NULL == ret) {
/* fgets always null pointer if the last byte of the file is a new line
* We need to check here if there was an error or was it feof.*/
- if (ferror(fd))
- {
+ if (ferror(fd)) {
dlt_vlog(LOG_WARNING,
"%s: fgets(buf,sizeof(buf),fd) returned NULL. %s\n",
__func__,
@@ -732,31 +687,29 @@ int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int ve
fclose(fd);
return -1;
}
- else if(feof(fd))
+ else if (feof(fd))
{
fclose(fd);
return 0;
}
- else
- {
+ else {
dlt_vlog(LOG_WARNING,
- "%s: fgets(buf,sizeof(buf),fd) returned NULL. Unknown error.\n",
- __func__);
+ "%s: fgets(buf,sizeof(buf),fd) returned NULL. Unknown error.\n",
+ __func__);
fclose(fd);
return -1;
}
}
- if (strcmp(buf, "") != 0)
- {
+ if (strcmp(buf, "") != 0) {
/* Split line */
pb = strtok(buf, ":");
- if (pb != NULL)
- {
- dlt_set_id(apid,pb);
- pb = strtok(NULL,":");
- if (pb != NULL)
- {
+
+ if (pb != NULL) {
+ dlt_set_id(apid, pb);
+ pb = strtok(NULL, ":");
+
+ if (pb != NULL) {
/* pb contains now the description */
/* pid is unknown at loading time */
if (dlt_daemon_application_add(daemon,
@@ -765,8 +718,7 @@ int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int ve
pb,
-1,
daemon->ecuid,
- verbose) == 0)
- {
+ verbose) == 0) {
dlt_vlog(LOG_WARNING,
"%s: dlt_daemon_application_add failed for %4s\n",
__func__,
@@ -778,6 +730,7 @@ int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int ve
}
}
}
+
fclose(fd);
return 0;
@@ -788,50 +741,41 @@ int dlt_daemon_applications_save(DltDaemon *daemon, const char *filename, int ve
FILE *fd;
int i;
- char apid[DLT_ID_SIZE+1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
- DltDaemonRegisteredUsers* user_list = NULL;
+ char apid[DLT_ID_SIZE + 1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (filename == NULL) || (filename[0]=='\0'))
- {
+ if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
return -1;
- }
memset(apid, 0, sizeof(apid));
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return -1;
- }
- if ((user_list->applications != NULL) && (user_list->num_applications > 0))
- {
+ if ((user_list->applications != NULL) && (user_list->num_applications > 0)) {
fd = fopen(filename, "w");
- if (fd != NULL)
- {
- for (i = 0; i < user_list->num_applications; i++)
- {
+
+ if (fd != NULL) {
+ for (i = 0; i < user_list->num_applications; i++) {
dlt_set_id(apid, user_list->applications[i].apid);
if ((user_list->applications[i].application_description) &&
(user_list->applications[i].application_description[0] != '\0'))
- {
fprintf(fd,
"%s:%s:\n",
apid,
user_list->applications[i].application_description);
- }
else
- {
fprintf(fd, "%s::\n", apid);
- }
}
+
fclose(fd);
}
- else
- {
+ else {
dlt_vlog(LOG_ERR, "%s: open %s failed! No application information stored.\n",
__func__,
filename);
@@ -841,7 +785,7 @@ int dlt_daemon_applications_save(DltDaemon *daemon, const char *filename, int ve
return 0;
}
-DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
+DltDaemonContext *dlt_daemon_context_add(DltDaemon *daemon,
char *apid,
char *ctid,
int8_t log_level,
@@ -855,70 +799,60 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
DltDaemonApplication *application;
DltDaemonContext *context;
DltDaemonContext *old;
- int new_context=0;
- DltDaemonRegisteredUsers* user_list = NULL;
+ int new_context = 0;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (apid == NULL) || (apid[0]=='\0') ||
- (ctid == NULL) || (ctid[0]=='\0') || (ecu == NULL))
- {
- return (DltDaemonContext*) NULL;
- }
+ if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') ||
+ (ctid == NULL) || (ctid[0] == '\0') || (ecu == NULL))
+ return (DltDaemonContext *)NULL;
- if ((log_level<DLT_LOG_DEFAULT) || (log_level>DLT_LOG_VERBOSE))
- {
- return (DltDaemonContext*) NULL;
- }
+ if ((log_level < DLT_LOG_DEFAULT) || (log_level > DLT_LOG_VERBOSE))
+ return (DltDaemonContext *)NULL;
- if ((trace_status<DLT_TRACE_STATUS_DEFAULT) || (trace_status>DLT_TRACE_STATUS_ON))
- {
- return (DltDaemonContext*) NULL;
- }
+ if ((trace_status < DLT_TRACE_STATUS_DEFAULT) || (trace_status > DLT_TRACE_STATUS_ON))
+ return (DltDaemonContext *)NULL;
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (user_list == NULL)
- {
- return (DltDaemonContext*) NULL;
- }
+ return (DltDaemonContext *)NULL;
+
+ if (user_list->contexts == NULL) {
+ user_list->contexts = (DltDaemonContext *)malloc(sizeof(DltDaemonContext) * DLT_DAEMON_CONTEXT_ALLOC_SIZE);
- if (user_list->contexts == NULL)
- {
- user_list->contexts = (DltDaemonContext*) malloc(sizeof(DltDaemonContext)*DLT_DAEMON_CONTEXT_ALLOC_SIZE);
if (user_list->contexts == NULL)
- {
- return (DltDaemonContext*) NULL;
- }
+ return (DltDaemonContext *)NULL;
}
/* Check if application [apid] is available */
application = dlt_daemon_application_find(daemon, apid, ecu, verbose);
+
if (application == NULL)
- {
- return (DltDaemonContext*) NULL;
- }
+ return (DltDaemonContext *)NULL;
/* Check if context [apid, ctid] is already available */
context = dlt_daemon_context_find(daemon, apid, ctid, ecu, verbose);
- if (context == NULL)
- {
+
+ if (context == NULL) {
user_list->num_contexts += 1;
- if (user_list->num_contexts != 0)
- {
- if ((user_list->num_contexts % DLT_DAEMON_CONTEXT_ALLOC_SIZE) == 0)
- {
+ if (user_list->num_contexts != 0) {
+ if ((user_list->num_contexts % DLT_DAEMON_CONTEXT_ALLOC_SIZE) == 0) {
/* allocate memory for context in steps of DLT_DAEMON_CONTEXT_ALLOC_SIZE, e.g 100 */
old = user_list->contexts;
- user_list->contexts = (DltDaemonContext*) malloc(sizeof(DltDaemonContext) *
- ((user_list->num_contexts / DLT_DAEMON_CONTEXT_ALLOC_SIZE) + 1) * DLT_DAEMON_CONTEXT_ALLOC_SIZE);
+ user_list->contexts = (DltDaemonContext *)malloc(sizeof(DltDaemonContext) *
+ ((user_list->num_contexts /
+ DLT_DAEMON_CONTEXT_ALLOC_SIZE) + 1) *
+ DLT_DAEMON_CONTEXT_ALLOC_SIZE);
- if (user_list->contexts == NULL)
- {
+ if (user_list->contexts == NULL) {
user_list->contexts = old;
user_list->num_contexts -= 1;
- return (DltDaemonContext*) NULL;
+ return (DltDaemonContext *)NULL;
}
+
memcpy(user_list->contexts,
old,
sizeof(DltDaemonContext) * user_list->num_contexts);
@@ -928,42 +862,35 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
context = &(user_list->contexts[user_list->num_contexts - 1]);
- dlt_set_id(context->apid,apid);
- dlt_set_id(context->ctid,ctid);
+ dlt_set_id(context->apid, apid);
+ dlt_set_id(context->ctid, ctid);
context->context_description = NULL;
application->num_contexts++;
- new_context =1;
+ new_context = 1;
}
/* Set context description */
- if (context->context_description)
- {
+ if (context->context_description) {
free(context->context_description);
context->context_description = NULL;
}
- if (description != NULL)
- {
- context->context_description = malloc(strlen(description)+1);
+ if (description != NULL) {
+ context->context_description = malloc(strlen(description) + 1);
- if (context->context_description)
- {
- strncpy(context->context_description,description,strlen(description));
- context->context_description[strlen(description)]='\0';
+ if (context->context_description) {
+ strncpy(context->context_description, description, strlen(description));
+ context->context_description[strlen(description)] = '\0';
}
}
- if ((strncmp(daemon->ecuid, ecu, DLT_ID_SIZE) == 0) && (daemon->force_ll_ts))
- {
+ if ((strncmp(daemon->ecuid, ecu, DLT_ID_SIZE) == 0) && (daemon->force_ll_ts)) {
if (log_level > daemon->default_log_level)
- {
log_level = daemon->default_log_level;
- }
+
if (trace_status > daemon->default_trace_status)
- {
trace_status = daemon->default_trace_status;
- }
dlt_vlog(LOG_NOTICE,
"Adapting ll_ts for context: %.4s:%.4s with %i %i\n",
@@ -974,11 +901,10 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
}
/* Store log level and trace status,
- if this is a new context, or
- if this is an old context and the runtime cfg was not loaded */
+ * if this is a new context, or
+ * if this is an old context and the runtime cfg was not loaded */
if ((new_context == 1) ||
- ((new_context == 0) && (daemon->runtime_context_cfg_loaded == 0)))
- {
+ ((new_context == 0) && (daemon->runtime_context_cfg_loaded == 0))) {
context->log_level = log_level;
context->trace_status = trace_status;
}
@@ -987,8 +913,7 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
context->user_handle = user_handle;
/* Sort */
- if (new_context)
- {
+ if (new_context) {
qsort(user_list->contexts,
user_list->num_contexts,
sizeof(DltDaemonContext),
@@ -1002,7 +927,7 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
}
int dlt_daemon_context_del(DltDaemon *daemon,
- DltDaemonContext* context,
+ DltDaemonContext *context,
char *ecu,
int verbose)
{
@@ -1013,28 +938,23 @@ int dlt_daemon_context_del(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (context == NULL) || (ecu == NULL))
- {
return -1;
- }
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (user_list == NULL)
- {
return -1;
- }
- if (user_list->num_contexts > 0)
- {
+ if (user_list->num_contexts > 0) {
application = dlt_daemon_application_find(daemon, context->apid, ecu, verbose);
/* Free description of context to be deleted */
- if (context->context_description)
- {
+ if (context->context_description) {
free(context->context_description);
context->context_description = NULL;
}
- pos = context-(user_list->contexts);
+ pos = context - (user_list->contexts);
/* move all contexts above pos to pos */
memmove(&(user_list->contexts[pos]),
@@ -1042,7 +962,7 @@ int dlt_daemon_context_del(DltDaemon *daemon,
sizeof(DltDaemonContext) * ((user_list->num_contexts - 1) - pos));
/* Clear last context */
- memset(&(user_list->contexts[user_list->num_contexts-1]),
+ memset(&(user_list->contexts[user_list->num_contexts - 1]),
0,
sizeof(DltDaemonContext));
@@ -1050,54 +970,47 @@ int dlt_daemon_context_del(DltDaemon *daemon,
/* Check if application [apid] is available */
if (application != NULL)
- {
application->num_contexts--;
- }
}
return 0;
}
-DltDaemonContext* dlt_daemon_context_find(DltDaemon *daemon,
+DltDaemonContext *dlt_daemon_context_find(DltDaemon *daemon,
char *apid,
char *ctid,
char *ecu,
int verbose)
{
DltDaemonContext context;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (apid == NULL) || (apid[0]=='\0') ||
- (ctid == NULL) || (ctid[0]=='\0') || (ecu == NULL))
- {
- return (DltDaemonContext*) NULL;
- }
+ if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') ||
+ (ctid == NULL) || (ctid[0] == '\0') || (ecu == NULL))
+ return (DltDaemonContext *)NULL;
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if ((user_list == NULL) || (user_list->num_contexts == 0))
- {
- return (DltDaemonContext*) NULL;
- }
+ return (DltDaemonContext *)NULL;
/* Check, if apid is smaller than smallest apid or greater than greatest apid */
if ((memcmp(apid, user_list->contexts[0].apid, DLT_ID_SIZE) < 0) ||
(memcmp(apid,
- user_list->contexts[user_list->num_contexts-1].apid,
+ user_list->contexts[user_list->num_contexts - 1].apid,
DLT_ID_SIZE) > 0))
- {
- return (DltDaemonContext*) NULL;
- }
+ return (DltDaemonContext *)NULL;
- dlt_set_id(context.apid,apid);
- dlt_set_id(context.ctid,ctid);
+ dlt_set_id(context.apid, apid);
+ dlt_set_id(context.ctid, ctid);
- return (DltDaemonContext*)bsearch(&context,
- user_list->contexts,
- user_list->num_contexts,
- sizeof(DltDaemonContext),
- dlt_daemon_cmp_apid_ctid);
+ return (DltDaemonContext *)bsearch(&context,
+ user_list->contexts,
+ user_list->num_contexts,
+ sizeof(DltDaemonContext),
+ dlt_daemon_cmp_apid_ctid);
}
int dlt_daemon_contexts_invalidate_fd(DltDaemon *daemon,
@@ -1106,25 +1019,19 @@ int dlt_daemon_contexts_invalidate_fd(DltDaemon *daemon,
int verbose)
{
int i;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (ecu == NULL))
- {
return -1;
- }
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
- if (user_list != NULL)
- {
- for (i=0; i<user_list->num_contexts; i++)
- {
+
+ if (user_list != NULL) {
+ for (i = 0; i < user_list->num_contexts; i++)
if (user_list->contexts[i].user_handle == fd)
- {
user_list->contexts[i].user_handle = DLT_FD_INIT;
- }
- }
return 0;
}
@@ -1139,36 +1046,29 @@ int dlt_daemon_contexts_clear(DltDaemon *daemon, char *ecu, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || ecu == NULL)
- {
+ if ((daemon == NULL) || (ecu == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- }
users = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (users == NULL)
- {
return DLT_RETURN_ERROR;
- }
for (i = 0; i < users->num_contexts; i++)
- {
- if (users->contexts[i].context_description != NULL)
- {
+ if (users->contexts[i].context_description != NULL) {
free(users->contexts[i].context_description);
users->contexts[i].context_description = NULL;
}
- }
- if (users->contexts)
- {
+
+
+ if (users->contexts) {
free(users->contexts);
users->contexts = NULL;
}
for (i = 0; i < users->num_applications; i++)
- {
users->applications[i].num_contexts = 0;
- }
users->num_contexts = 0;
@@ -1186,15 +1086,12 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (filename == NULL) ||( filename[0]=='\0'))
- {
+ if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
return -1;
- }
fd = fopen(filename, "r");
- if (fd == NULL)
- {
+ if (fd == NULL) {
dlt_vlog(LOG_WARNING,
"DLT runtime-context load, cannot open file %s: %s\n",
filename,
@@ -1203,19 +1100,17 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
return -1;
}
- while (!feof(fd))
- {
+ while (!feof(fd)) {
/* Clear buf */
memset(buf, 0, sizeof(buf));
/* Get line */
- ret = fgets(buf,sizeof(buf),fd);
- if (NULL == ret)
- {
+ ret = fgets(buf, sizeof(buf), fd);
+
+ if (NULL == ret) {
/* fgets always returns null pointer if the last byte of the file is a new line.
* We need to check here if there was an error or was it feof.*/
- if (ferror(fd))
- {
+ if (ferror(fd)) {
dlt_vlog(LOG_WARNING,
"%s fgets(buf,sizeof(buf),fd[%d]) returned NULL. %s\n",
__func__,
@@ -1224,13 +1119,12 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
fclose(fd);
return -1;
}
- else if(feof(fd))
+ else if (feof(fd))
{
fclose(fd);
return 0;
}
- else
- {
+ else {
dlt_vlog(LOG_WARNING,
"%s fgets(buf,sizeof(buf),fd[%d]) returned NULL. Unknown error.\n",
__func__,
@@ -1240,28 +1134,27 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
}
}
- if (strcmp(buf ,"") != 0)
- {
+ if (strcmp(buf, "") != 0) {
/* Split line */
pb = strtok(buf, ":");
- if (pb != NULL)
- {
+
+ if (pb != NULL) {
dlt_set_id(apid, pb);
pb = strtok(NULL, ":");
- if (pb != NULL)
- {
+
+ if (pb != NULL) {
dlt_set_id(ctid, pb);
pb = strtok(NULL, ":");
- if (pb != NULL)
- {
+
+ if (pb != NULL) {
sscanf(pb, "%d", &ll);
pb = strtok(NULL, ":");
- if (pb != NULL)
- {
+
+ if (pb != NULL) {
sscanf(pb, "%d", &ts);
- pb = strtok(NULL,":");
- if (pb != NULL)
- {
+ pb = strtok(NULL, ":");
+
+ if (pb != NULL) {
/* pb contains now the description */
/* log_level_pos, and user_handle are unknown at loading time */
@@ -1274,8 +1167,7 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
0,
pb,
daemon->ecuid,
- verbose) == NULL)
- {
+ verbose) == NULL) {
dlt_vlog(LOG_WARNING,
"%s dlt_daemon_context_add failed\n",
__func__);
@@ -1289,64 +1181,56 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
}
}
}
+
fclose(fd);
return 0;
}
-int dlt_daemon_contexts_save(DltDaemon *daemon,const char *filename, int verbose)
+int dlt_daemon_contexts_save(DltDaemon *daemon, const char *filename, int verbose)
{
FILE *fd;
int i;
- char apid[DLT_ID_SIZE+1], ctid[DLT_ID_SIZE+1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
- DltDaemonRegisteredUsers* user_list = NULL;
+ char apid[DLT_ID_SIZE + 1], ctid[DLT_ID_SIZE + 1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (filename == NULL) || (filename[0]=='\0'))
- {
+ if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
return -1;
- }
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return -1;
- }
memset(apid, 0, sizeof(apid));
memset(ctid, 0, sizeof(ctid));
- if ((user_list->contexts) && (user_list->num_contexts > 0))
- {
+ if ((user_list->contexts) && (user_list->num_contexts > 0)) {
fd = fopen(filename, "w");
- if (fd != NULL)
- {
- for (i = 0; i < user_list->num_contexts; i++)
- {
+
+ if (fd != NULL) {
+ for (i = 0; i < user_list->num_contexts; i++) {
dlt_set_id(apid, user_list->contexts[i].apid);
dlt_set_id(ctid, user_list->contexts[i].ctid);
if ((user_list->contexts[i].context_description) &&
(user_list->contexts[i].context_description[0] != '\0'))
- {
- fprintf(fd,"%s:%s:%d:%d:%s:\n",apid,ctid,
+ fprintf(fd, "%s:%s:%d:%d:%s:\n", apid, ctid,
(int)(user_list->contexts[i].log_level),
(int)(user_list->contexts[i].trace_status),
user_list->contexts[i].context_description);
- }
else
- {
- fprintf(fd,"%s:%s:%d:%d::\n",apid,ctid,
+ fprintf(fd, "%s:%s:%d:%d::\n", apid, ctid,
(int)(user_list->contexts[i].log_level),
(int)(user_list->contexts[i].trace_status));
- }
}
+
fclose(fd);
}
- else
- {
+ else {
dlt_vlog(LOG_ERR,
"%s: Cannot open %s. No context information stored\n",
__func__,
@@ -1366,11 +1250,11 @@ int dlt_daemon_configuration_save(DltDaemon *daemon, const char *filename, int v
if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
return -1;
- fd=fopen(filename, "w");
- if (fd != NULL)
- {
- fprintf(fd,"# 0 = off, 1 = external, 2 = internal, 3 = both\n");
- fprintf(fd,"LoggingMode = %d\n",daemon->mode);
+ fd = fopen(filename, "w");
+
+ if (fd != NULL) {
+ fprintf(fd, "# 0 = off, 1 = external, 2 = internal, 3 = both\n");
+ fprintf(fd, "LoggingMode = %d\n", daemon->mode);
fclose(fd);
}
@@ -1380,10 +1264,10 @@ int dlt_daemon_configuration_save(DltDaemon *daemon, const char *filename, int v
int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int verbose)
{
- if(daemon == NULL || filename == NULL)
+ if ((daemon == NULL) || (filename == NULL))
return -1;
- FILE * pFile;
+ FILE *pFile;
char line[1024];
char token[1024];
char value[1024];
@@ -1391,65 +1275,55 @@ int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int v
PRINT_FUNCTION_VERBOSE(verbose);
- pFile = fopen (filename,"r");
+ pFile = fopen (filename, "r");
- if (pFile != NULL)
- {
- while(1)
- {
+ if (pFile != NULL) {
+ while (1) {
/* fetch line from configuration file */
- if ( fgets (line , 1024 , pFile) != NULL )
- {
- pch = strtok (line," =\r\n");
- token[0]=0;
- value[0]=0;
+ if (fgets (line, 1024, pFile) != NULL) {
+ pch = strtok (line, " =\r\n");
+ token[0] = 0;
+ value[0] = 0;
- while (pch != NULL)
- {
- if(strcmp(pch,"#")==0)
+ while (pch != NULL) {
+ if (strcmp(pch, "#") == 0)
break;
- if(token[0]==0)
- {
- strncpy(token,pch,sizeof(token)-1);
- token[sizeof(token)-1]=0;
+ if (token[0] == 0) {
+ strncpy(token, pch, sizeof(token) - 1);
+ token[sizeof(token) - 1] = 0;
}
- else
- {
- strncpy(value,pch,sizeof(value)-1);
- value[sizeof(value)-1]=0;
+ else {
+ strncpy(value, pch, sizeof(value) - 1);
+ value[sizeof(value) - 1] = 0;
break;
}
pch = strtok (NULL, " =\r\n");
- }
-
- if(token[0] && value[0])
- {
- /* parse arguments here */
- if(strcmp(token, "LoggingMode") == 0)
- {
- daemon->mode = atoi(value);
- snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Runtime Option: %s=%d\n",token,daemon->mode);
- dlt_log(LOG_INFO, str);
- }
- else
- {
- snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Unknown option: %s=%s\n",token,value);
- dlt_log(LOG_WARNING, str);
- }
+ }
+
+ if (token[0] && value[0]) {
+ /* parse arguments here */
+ if (strcmp(token, "LoggingMode") == 0) {
+ daemon->mode = atoi(value);
+ snprintf(str, DLT_DAEMON_COMMON_TEXTBUFSIZE, "Runtime Option: %s=%d\n", token, daemon->mode);
+ dlt_log(LOG_INFO, str);
+ }
+ else {
+ snprintf(str, DLT_DAEMON_COMMON_TEXTBUFSIZE, "Unknown option: %s=%s\n", token, value);
+ dlt_log(LOG_WARNING, str);
}
+ }
}
- else
- {
+ else {
break;
}
}
+
fclose (pFile);
}
- else
- {
- dlt_vlog(LOG_INFO, "Cannot open configuration file: %s\n",filename);
+ else {
+ dlt_vlog(LOG_INFO, "Cannot open configuration file: %s\n", filename);
}
return 0;
@@ -1463,28 +1337,25 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (context == NULL))
- {
+ if ((daemon == NULL) || (context == NULL)) {
dlt_vlog(LOG_ERR, "NULL parameter in %s", __func__);
return -1;
}
- if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_LEVEL) < DLT_RETURN_OK)
- {
+ if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_LEVEL) < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "Failed to set userheader in %s", __func__);
return -1;
}
- if(context->storage_log_level != DLT_LOG_DEFAULT)
- {
- usercontext.log_level = context->log_level > context->storage_log_level ? context->log_level:context->storage_log_level;
- }
+ if (context->storage_log_level != DLT_LOG_DEFAULT)
+ usercontext.log_level = context->log_level >
+ context->storage_log_level ? context->log_level : context->storage_log_level;
else /* Storage log level is not updated (is DEFAULT) then no device is yet connected so ignore */
- {
- usercontext.log_level = ((context->log_level == DLT_LOG_DEFAULT)?daemon->default_log_level:context->log_level);
- }
+ usercontext.log_level =
+ ((context->log_level == DLT_LOG_DEFAULT) ? daemon->default_log_level : context->log_level);
- usercontext.trace_status = ((context->trace_status == DLT_TRACE_STATUS_DEFAULT)?daemon->default_trace_status:context->trace_status);
+ usercontext.trace_status =
+ ((context->trace_status == DLT_TRACE_STATUS_DEFAULT) ? daemon->default_trace_status : context->trace_status);
usercontext.log_level_pos = context->log_level_pos;
@@ -1499,17 +1370,15 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,
/* log to FIFO */
errno = 0;
ret = dlt_user_log_out2(context->user_handle,
- &(userheader), sizeof(DltUserHeader),
- &(usercontext), sizeof(DltUserControlMsgLogLevel));
+ &(userheader), sizeof(DltUserHeader),
+ &(usercontext), sizeof(DltUserControlMsgLogLevel));
- if (ret < DLT_RETURN_OK)
- {
+ if (ret < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "Failed to send data to application in %s: %s",
__func__,
errno != 0 ? strerror(errno) : "Unknown error");
- if (errno == EPIPE)
- {
+ if (errno == EPIPE) {
#ifndef DLT_USE_UNIX_SOCKET_IPC
/* Close connection */
close(context->user_handle);
@@ -1518,7 +1387,7 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,
}
}
- return ((ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR);
+ return (ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR;
}
int dlt_daemon_user_send_log_state(DltDaemon *daemon, DltDaemonApplication *app, int verbose)
@@ -1539,56 +1408,56 @@ int dlt_daemon_user_send_log_state(DltDaemon *daemon, DltDaemonApplication *app,
/* log to FIFO */
ret = dlt_user_log_out2(app->user_handle,
- &(userheader), sizeof(DltUserHeader),
- &(logstate), sizeof(DltUserControlMsgLogState));
+ &(userheader), sizeof(DltUserHeader),
+ &(logstate), sizeof(DltUserControlMsgLogState));
- if (ret < DLT_RETURN_OK)
- {
- if (errno==EPIPE)
- {
+ if (ret < DLT_RETURN_OK) {
+ if (errno == EPIPE) {
#ifndef DLT_USE_UNIX_SOCKET_IPC
/* Close connection */
close(app->user_handle);
#endif
- app->user_handle=DLT_FD_INIT;
+ app->user_handle = DLT_FD_INIT;
}
}
- return ((ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR);
+ return (ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR;
}
-void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *filename, const char *filename1, int InitialContextLogLevel, int InitialContextTraceStatus, int InitialEnforceLlTsStatus, int verbose)
+void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,
+ const char *filename,
+ const char *filename1,
+ int InitialContextLogLevel,
+ int InitialContextTraceStatus,
+ int InitialEnforceLlTsStatus,
+ int verbose)
{
FILE *fd;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (filename == NULL) || (filename1 == NULL))
- {
+ if ((daemon == NULL) || (filename == NULL) || (filename1 == NULL)) {
dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
return;
}
- if ((filename[0] == '\0') || (filename1[0] == '\0'))
- {
+ if ((filename[0] == '\0') || (filename1[0] == '\0')) {
dlt_log(LOG_WARNING, "Wrong parameter: Empty string\n");
return;
}
/* Check for runtime cfg file and delete it, if available */
- fd=fopen(filename, "r");
+ fd = fopen(filename, "r");
- if (fd != NULL)
- {
+ if (fd != NULL) {
/* Close and delete file */
fclose(fd);
unlink(filename);
}
- fd=fopen(filename1, "r");
+ fd = fopen(filename1, "r");
- if (fd != NULL)
- {
+ if (fd != NULL) {
/* Close and delete file */
fclose(fd);
unlink(filename1);
@@ -1599,7 +1468,7 @@ void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *f
daemon->force_ll_ts = InitialEnforceLlTsStatus;
/* Reset all other things (log level, trace status, etc.
- to default values */
+ * to default values */
/* Inform user libraries about changed default log level/trace status */
dlt_daemon_user_send_default_update(daemon, verbose);
@@ -1613,35 +1482,27 @@ void dlt_daemon_user_send_default_update(DltDaemon *daemon, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL)
- {
+ if (daemon == NULL) {
dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
return;
}
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
- for (count = 0; count < user_list->num_contexts; count ++)
- {
+ for (count = 0; count < user_list->num_contexts; count++) {
context = &(user_list->contexts[count]);
- if (context != NULL)
- {
+ if (context != NULL) {
if ((context->log_level == DLT_LOG_DEFAULT) ||
- (context->trace_status == DLT_TRACE_STATUS_DEFAULT))
- {
- if (context->user_handle >= DLT_FD_MINIMUM)
- {
+ (context->trace_status == DLT_TRACE_STATUS_DEFAULT)) {
+ if (context->user_handle >= DLT_FD_MINIMUM) {
if (dlt_daemon_user_send_log_level(daemon,
context,
verbose) == -1)
- {
dlt_vlog(LOG_WARNING, "Cannot update default of %.4s:%.4s\n", context->apid, context->ctid);
- }
}
}
}
@@ -1657,30 +1518,28 @@ void dlt_daemon_user_send_all_log_level_update(DltDaemon *daemon, int8_t log_lev
PRINT_FUNCTION_VERBOSE(verbose);
if (daemon == NULL)
- {
return;
- }
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
- for (count = 0; count < user_list->num_contexts; count++)
- {
+ for (count = 0; count < user_list->num_contexts; count++) {
context = &(user_list->contexts[count]);
- if (context)
- {
- if (context->user_handle >= DLT_FD_MINIMUM)
- {
+
+ if (context) {
+ if (context->user_handle >= DLT_FD_MINIMUM) {
context->log_level = log_level;
+
if (dlt_daemon_user_send_log_level(daemon,
context,
verbose) == -1)
- {
- dlt_vlog(LOG_WARNING, "Cannot send log level %.4s:%.4s -> %i\n", context->apid, context->ctid, context->log_level);
- }
+ dlt_vlog(LOG_WARNING,
+ "Cannot send log level %.4s:%.4s -> %i\n",
+ context->apid,
+ context->ctid,
+ context->log_level);
}
}
}
@@ -1695,29 +1554,28 @@ void dlt_daemon_user_send_all_trace_status_update(DltDaemon *daemon, int8_t trac
PRINT_FUNCTION_VERBOSE(verbose);
if (daemon == NULL)
- {
return;
- }
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
+
dlt_vlog(LOG_NOTICE, "All trace status is updated -> %i\n", trace_status);
- for (count = 0; count < user_list->num_contexts; count++)
- {
+ for (count = 0; count < user_list->num_contexts; count++) {
context = &(user_list->contexts[count]);
- if (context)
- {
- if (context->user_handle >= DLT_FD_MINIMUM)
- {
+
+ if (context) {
+ if (context->user_handle >= DLT_FD_MINIMUM) {
context->trace_status = trace_status;
+
if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1)
- {
- dlt_vlog(LOG_WARNING, "Cannot send trace status %.4s:%.4s -> %i\n", context->apid, context->ctid, context->trace_status);
- }
+ dlt_vlog(LOG_WARNING,
+ "Cannot send trace status %.4s:%.4s -> %i\n",
+ context->apid,
+ context->ctid,
+ context->trace_status);
}
}
}
@@ -1731,30 +1589,23 @@ void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL)
- {
+ if (daemon == NULL) {
dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
return;
}
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
- for (count = 0; count < user_list->num_applications; count ++)
- {
+ for (count = 0; count < user_list->num_applications; count++) {
app = &(user_list->applications[count]);
- if (app != NULL)
- {
- if (app->user_handle >= DLT_FD_MINIMUM)
- {
+ if (app != NULL) {
+ if (app->user_handle >= DLT_FD_MINIMUM) {
if (dlt_daemon_user_send_log_state(daemon, app, verbose) == -1)
- {
- dlt_vlog(LOG_WARNING, "Cannot send log state to Apid: %.4s, PID: %d\n",app->apid, app->pid);
- }
+ dlt_vlog(LOG_WARNING, "Cannot send log state to Apid: %.4s, PID: %d\n", app->apid, app->pid);
}
}
}
@@ -1762,28 +1613,26 @@ void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose)
void dlt_daemon_change_state(DltDaemon *daemon, DltDaemonState newState)
{
- switch(newState)
- {
- case DLT_DAEMON_STATE_INIT:
- dlt_log(LOG_INFO,"Switched to init state.\n");
- daemon->state = DLT_DAEMON_STATE_INIT;
- break;
- case DLT_DAEMON_STATE_BUFFER:
- dlt_log(LOG_INFO,"Switched to buffer state for socket connections.\n");
- daemon->state = DLT_DAEMON_STATE_BUFFER;
- break;
- case DLT_DAEMON_STATE_BUFFER_FULL:
- dlt_log(LOG_INFO,"Switched to buffer full state.\n");
- daemon->state = DLT_DAEMON_STATE_BUFFER_FULL;
- break;
- case DLT_DAEMON_STATE_SEND_BUFFER:
- dlt_log(LOG_INFO,"Switched to send buffer state for socket connections.\n");
- daemon->state = DLT_DAEMON_STATE_SEND_BUFFER;
- break;
- case DLT_DAEMON_STATE_SEND_DIRECT:
- dlt_log(LOG_INFO,"Switched to send direct state.\n");
- daemon->state = DLT_DAEMON_STATE_SEND_DIRECT;
- break;
+ switch (newState) {
+ case DLT_DAEMON_STATE_INIT:
+ dlt_log(LOG_INFO, "Switched to init state.\n");
+ daemon->state = DLT_DAEMON_STATE_INIT;
+ break;
+ case DLT_DAEMON_STATE_BUFFER:
+ dlt_log(LOG_INFO, "Switched to buffer state for socket connections.\n");
+ daemon->state = DLT_DAEMON_STATE_BUFFER;
+ break;
+ case DLT_DAEMON_STATE_BUFFER_FULL:
+ dlt_log(LOG_INFO, "Switched to buffer full state.\n");
+ daemon->state = DLT_DAEMON_STATE_BUFFER_FULL;
+ break;
+ case DLT_DAEMON_STATE_SEND_BUFFER:
+ dlt_log(LOG_INFO, "Switched to send buffer state for socket connections.\n");
+ daemon->state = DLT_DAEMON_STATE_SEND_BUFFER;
+ break;
+ case DLT_DAEMON_STATE_SEND_DIRECT:
+ dlt_log(LOG_INFO, "Switched to send direct state.\n");
+ daemon->state = DLT_DAEMON_STATE_SEND_DIRECT;
+ break;
}
-
}
diff --git a/src/daemon/dlt_daemon_common.h b/src/daemon/dlt_daemon_common.h
index 4110a72..112cb92 100644
--- a/src/daemon/dlt_daemon_common.h
+++ b/src/daemon/dlt_daemon_common.h
@@ -64,41 +64,41 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 15.02.2010 initial
+ * Initials Date Comment
+ * aw 15.02.2010 initial
*/
#ifndef DLT_DAEMON_COMMON_H
-#define DLT_DAEMON_COMMON_H
+# define DLT_DAEMON_COMMON_H
/**
- \defgroup daemonapi DLT Daemon API
- \addtogroup daemonapi
- \{
-*/
+ * \defgroup daemonapi DLT Daemon API
+ * \addtogroup daemonapi
+ \{
+ */
-#include <limits.h>
-#include <semaphore.h>
-#include "dlt_common.h"
-#include "dlt_user.h"
-#include "dlt_offline_logstorage.h"
-#include "dlt_gateway_types.h"
+# include <limits.h>
+# include <semaphore.h>
+# include "dlt_common.h"
+# include "dlt_user.h"
+# include "dlt_offline_logstorage.h"
+# include "dlt_gateway_types.h"
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
-#define DLT_DAEMON_RINGBUFFER_MIN_SIZE 500000 /**< Ring buffer size for storing log messages while no client is connected */
-#define DLT_DAEMON_RINGBUFFER_MAX_SIZE 10000000 /**< Ring buffer size for storing log messages while no client is connected */
-#define DLT_DAEMON_RINGBUFFER_STEP_SIZE 500000 /**< Ring buffer size for storing log messages while no client is connected */
+# define DLT_DAEMON_RINGBUFFER_MIN_SIZE 500000/**< Ring buffer size for storing log messages while no client is connected */
+# define DLT_DAEMON_RINGBUFFER_MAX_SIZE 10000000/**< Ring buffer size for storing log messages while no client is connected */
+# define DLT_DAEMON_RINGBUFFER_STEP_SIZE 500000/**< Ring buffer size for storing log messages while no client is connected */
-#define DLT_DAEMON_SEND_TO_ALL -3 /**< Constant value to identify the command "send to all" */
-#define DLT_DAEMON_SEND_FORCE -4 /**< Constant value to identify the command "send force to all" */
+# define DLT_DAEMON_SEND_TO_ALL -3/**< Constant value to identify the command "send to all" */
+# define DLT_DAEMON_SEND_FORCE -4/**< Constant value to identify the command "send force to all" */
/* Use a semaphore or mutex from your OS to prevent concurrent access to the DLT buffer. */
-#define DLT_DAEMON_SEM_LOCK() { sem_wait(&dlt_daemon_mutex); }
-#define DLT_DAEMON_SEM_FREE() { sem_post(&dlt_daemon_mutex); }
+# define DLT_DAEMON_SEM_LOCK() { sem_wait(&dlt_daemon_mutex); }
+# define DLT_DAEMON_SEM_FREE() { sem_post(&dlt_daemon_mutex); }
extern sem_t dlt_daemon_mutex;
/**
@@ -106,11 +106,11 @@ extern sem_t dlt_daemon_mutex;
*/
typedef enum
{
- DLT_DAEMON_STATE_INIT = 0, /**< Initial state */
- DLT_DAEMON_STATE_BUFFER = 1, /**< logging is buffered until external logger is connected or internal logging is activated */
- DLT_DAEMON_STATE_BUFFER_FULL = 2, /**< then internal buffer is full, wait for connect from client */
- DLT_DAEMON_STATE_SEND_BUFFER = 3, /**< external logger is connected, but buffer is still not empty or external logger queue is full */
- DLT_DAEMON_STATE_SEND_DIRECT = 4 /**< External logger is connected or internal logging is active, and buffer is empty */
+ DLT_DAEMON_STATE_INIT = 0, /**< Initial state */
+ DLT_DAEMON_STATE_BUFFER = 1, /**< logging is buffered until external logger is connected or internal logging is activated */
+ DLT_DAEMON_STATE_BUFFER_FULL = 2, /**< then internal buffer is full, wait for connect from client */
+ DLT_DAEMON_STATE_SEND_BUFFER = 3, /**< external logger is connected, but buffer is still not empty or external logger queue is full */
+ DLT_DAEMON_STATE_SEND_DIRECT = 4 /**< External logger is connected or internal logging is active, and buffer is empty */
} DltDaemonState;
/**
@@ -118,7 +118,7 @@ typedef enum
*/
typedef struct
{
- char apid[DLT_ID_SIZE]; /**< application id */
+ char apid[DLT_ID_SIZE]; /**< application id */
pid_t pid; /**< process id of user application */
int user_handle; /**< connection handle for connection to user application */
char *application_description; /**< context description */
@@ -192,14 +192,22 @@ typedef struct
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned long RingbufferMaxSize,unsigned long RingbufferStepSize,const char *runtime_directory,int InitialContextLogLevel, int InitialContextTraceStatus, int ForceLLTS, int verbose);
+int dlt_daemon_init(DltDaemon *daemon,
+ unsigned long RingbufferMinSize,
+ unsigned long RingbufferMaxSize,
+ unsigned long RingbufferStepSize,
+ const char *runtime_directory,
+ int InitialContextLogLevel,
+ int InitialContextTraceStatus,
+ int ForceLLTS,
+ int verbose);
/**
* De-Initialise the dlt daemon structure
* @param daemon pointer to dlt daemon structure
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_free(DltDaemon *daemon,int verbose);
+int dlt_daemon_free(DltDaemon *daemon, int verbose);
/**
* Initialize data structures to store information about applications running on same
* or passive node.
@@ -245,7 +253,7 @@ int dlt_daemon_load_runtime_configuration(DltDaemon *daemon,
* @param verbose if set to true verbose information is printed out.
* @return Pointer to added context, null pointer on error
*/
-DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
+DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
char *apid,
pid_t pid,
char *description,
@@ -272,7 +280,7 @@ int dlt_daemon_application_del(DltDaemon *daemon,
* @param verbose if set to true verbose information is printed out.
* @return Pointer to application, null pointer on error or not found
*/
-DltDaemonApplication* dlt_daemon_application_find(DltDaemon *daemon,
+DltDaemonApplication *dlt_daemon_application_find(DltDaemon *daemon,
char *apid,
char *ecu,
int verbose);
@@ -283,7 +291,7 @@ DltDaemonApplication* dlt_daemon_application_find(DltDaemon *daemon,
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_applications_load(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int verbose);
/**
* Save applications from internal context management to file
* @param daemon pointer to dlt daemon structure
@@ -291,7 +299,7 @@ int dlt_daemon_applications_load(DltDaemon *daemon,const char *filename, int ver
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_applications_save(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_applications_save(DltDaemon *daemon, const char *filename, int verbose);
/**
* Invalidate all applications fd, if fd is reused
* @param daemon pointer to dlt daemon structure
@@ -311,7 +319,7 @@ int dlt_daemon_applications_invalidate_fd(DltDaemon *daemon,
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_applications_clear(DltDaemon *daemon,char *ecu, int verbose);
+int dlt_daemon_applications_clear(DltDaemon *daemon, char *ecu, int verbose);
/**
* Add (new) context to internal context management
@@ -327,7 +335,7 @@ int dlt_daemon_applications_clear(DltDaemon *daemon,char *ecu, int verbose);
* @param verbose if set to true verbose information is printed out.
* @return Pointer to added context, null pointer on error
*/
-DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
+DltDaemonContext *dlt_daemon_context_add(DltDaemon *daemon,
char *apid,
char *ctid,
int8_t log_level,
@@ -346,7 +354,7 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
* @return negative value if there was an error
*/
int dlt_daemon_context_del(DltDaemon *daemon,
- DltDaemonContext* context,
+ DltDaemonContext *context,
char *ecu,
int verbose);
/**
@@ -358,7 +366,7 @@ int dlt_daemon_context_del(DltDaemon *daemon,
* @param verbose if set to true verbose information is printed out.
* @return Pointer to context, null pointer on error or not found
*/
-DltDaemonContext* dlt_daemon_context_find(DltDaemon *daemon,
+DltDaemonContext *dlt_daemon_context_find(DltDaemon *daemon,
char *apid,
char *ctid,
char *ecu,
@@ -390,7 +398,7 @@ int dlt_daemon_contexts_clear(DltDaemon *daemon, char *ecu, int verbose);
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_contexts_load(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbose);
/**
* Save contexts from internal context management to file
* @param daemon pointer to dlt daemon structure
@@ -398,7 +406,7 @@ int dlt_daemon_contexts_load(DltDaemon *daemon,const char *filename, int verbose
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_contexts_save(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_contexts_save(DltDaemon *daemon, const char *filename, int verbose);
/**
* Load persistant configuration
* @param daemon pointer to dlt daemon structure
@@ -406,7 +414,7 @@ int dlt_daemon_contexts_save(DltDaemon *daemon,const char *filename, int verbose
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_configuration_load(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int verbose);
/**
* Save configuration persistantly
* @param daemon pointer to dlt daemon structure
@@ -414,7 +422,7 @@ int dlt_daemon_configuration_load(DltDaemon *daemon,const char *filename, int ve
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_configuration_save(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_configuration_save(DltDaemon *daemon, const char *filename, int verbose);
/**
@@ -424,7 +432,7 @@ int dlt_daemon_configuration_save(DltDaemon *daemon,const char *filename, int ve
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_user_send_log_level(DltDaemon *daemon,DltDaemonContext *context, int verbose);
+int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context, int verbose);
/**
* Send user message DLT_USER_MESSAGE_LOG_STATE to user application
@@ -433,7 +441,7 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon,DltDaemonContext *context,
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_user_send_log_state(DltDaemon *daemon,DltDaemonApplication *app,int verbose);
+int dlt_daemon_user_send_log_state(DltDaemon *daemon, DltDaemonApplication *app, int verbose);
/**
* Send user messages to all user applications using default context, or trace status
@@ -477,7 +485,13 @@ void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose);
* @param ForceLLTS force default log-level
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *filename, const char *filename1, int InitialContextLogLevel, int InitialContextTraceStatus, int InitialEnforceLlTsStatus, int verbose);
+void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,
+ const char *filename,
+ const char *filename1,
+ int InitialContextLogLevel,
+ int InitialContextTraceStatus,
+ int InitialEnforceLlTsStatus,
+ int verbose);
/**
* Change the logging state of dlt daemon
@@ -486,12 +500,12 @@ void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *f
*/
void dlt_daemon_change_state(DltDaemon *daemon, DltDaemonState newState);
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
/**
- \}
-*/
+ \}
+ */
#endif /* DLT_DAEMON_COMMON_H */
diff --git a/src/daemon/dlt_daemon_common_cfg.h b/src/daemon/dlt_daemon_common_cfg.h
index 468ed41..31d2f8b 100644
--- a/src/daemon/dlt_daemon_common_cfg.h
+++ b/src/daemon/dlt_daemon_common_cfg.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_daemon_common_cfg.h
-*/
+ */
@@ -86,30 +86,30 @@
/* Default Path for control socket */
#define DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \
- "/dlt-ctrl.sock"
+ "/dlt-ctrl.sock"
#ifdef DLT_USE_UNIX_SOCKET_IPC
-#define DLT_DAEMON_DEFAULT_APP_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \
- "/dlt-app.sock"
+# define DLT_DAEMON_DEFAULT_APP_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \
+ "/dlt-app.sock"
#endif
/* Size of text buffer */
#define DLT_DAEMON_COMMON_TEXTBUFSIZE 255
/* Application ID used when the dlt daemon creates a control message */
-#define DLT_DAEMON_CTRL_APID "DA1"
+#define DLT_DAEMON_CTRL_APID "DA1"
/* Context ID used when the dlt daemon creates a control message */
-#define DLT_DAEMON_CTRL_CTID "DC1"
+#define DLT_DAEMON_CTRL_CTID "DC1"
/* Number of entries to be allocated at one in application table,
- when no more entries are available */
+ * when no more entries are available */
#define DLT_DAEMON_APPL_ALLOC_SIZE 500
/* Number of entries to be allocated at one in context table,
- when no more entries are available */
+ * when no more entries are available */
#define DLT_DAEMON_CONTEXT_ALLOC_SIZE 1000
/* Debug get log info function,
- set to 1 to enable, 0 to disable debugging */
+ * set to 1 to enable, 0 to disable debugging */
#define DLT_DEBUG_GETLOGINFO 0
/************************/
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c
index c9e7be7..669a7b1 100644
--- a/src/daemon/dlt_daemon_connection.c
+++ b/src/daemon/dlt_daemon_connection.c
@@ -67,36 +67,33 @@ extern char *app_recv_buffer;
* errno is appropriately set.
*/
DLT_STATIC int dlt_connection_send(DltConnection *conn,
- void *msg,
- size_t msg_size)
+ void *msg,
+ size_t msg_size)
{
DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
int bytes_sent = 0;
int ret = 0;
if ((conn != NULL) && (conn->receiver != NULL))
- {
type = conn->type;
- }
- switch (type)
- {
- case DLT_CONNECTION_CLIENT_MSG_SERIAL:
- if (write(conn->receiver->fd, msg, msg_size) > 0)
- {
- return DLT_DAEMON_ERROR_OK;
- }
- return DLT_DAEMON_ERROR_UNKNOWN;
-
- case DLT_CONNECTION_CLIENT_MSG_TCP:
- ret = dlt_daemon_socket_sendreliable(conn->receiver->fd,
- msg,
- msg_size,
- &bytes_sent);
- conn->receiver->bytes_sent += bytes_sent;
- return ret;
- default:
- return DLT_DAEMON_ERROR_UNKNOWN;
+ switch (type) {
+ case DLT_CONNECTION_CLIENT_MSG_SERIAL:
+
+ if (write(conn->receiver->fd, msg, msg_size) > 0)
+ return DLT_DAEMON_ERROR_OK;
+
+ return DLT_DAEMON_ERROR_UNKNOWN;
+
+ case DLT_CONNECTION_CLIENT_MSG_TCP:
+ ret = dlt_daemon_socket_sendreliable(conn->receiver->fd,
+ msg,
+ msg_size,
+ &bytes_sent);
+ conn->receiver->bytes_sent += bytes_sent;
+ return ret;
+ default:
+ return DLT_DAEMON_ERROR_UNKNOWN;
}
}
@@ -115,35 +112,27 @@ DLT_STATIC int dlt_connection_send(DltConnection *conn,
* @return DLT_DAEMON_ERROR_OK on success, -1 otherwise. errno is properly set.
*/
int dlt_connection_send_multiple(DltConnection *con,
- void *data1,
- int size1,
- void *data2,
- int size2,
- int sendserialheader)
+ void *data1,
+ int size1,
+ void *data2,
+ int size2,
+ int sendserialheader)
{
int ret = 0;
if (con == NULL)
- {
return DLT_DAEMON_ERROR_UNKNOWN;
- }
if (sendserialheader)
- {
ret = dlt_connection_send(con,
- (void *)dltSerialHeader,
- sizeof(dltSerialHeader));
- }
+ (void *)dltSerialHeader,
+ sizeof(dltSerialHeader));
if ((data1 != NULL) && (ret == DLT_RETURN_OK))
- {
ret = dlt_connection_send(con, data1, size1);
- }
if ((data2 != NULL) && (ret == DLT_RETURN_OK))
- {
ret = dlt_connection_send(con, data2, size2);
- }
return ret;
}
@@ -163,9 +152,7 @@ int dlt_connection_send_multiple(DltConnection *con,
DltConnection *dlt_connection_get_next(DltConnection *current, int type_mask)
{
while (current && !((1 << current->type) & type_mask))
- {
current = current->next;
- }
return current;
}
@@ -175,8 +162,7 @@ DLT_STATIC void dlt_connection_destroy_receiver(DltConnection *con)
if (!con)
return;
- switch (con->type)
- {
+ switch (con->type) {
case DLT_CONNECTION_GATEWAY:
/* We rely on the gateway for clean-up */
break;
@@ -186,7 +172,7 @@ DLT_STATIC void dlt_connection_destroy_receiver(DltConnection *con)
con->receiver = NULL;
break;
default:
- (void) dlt_receiver_free(con->receiver);
+ (void)dlt_receiver_free(con->receiver);
free(con->receiver);
con->receiver = NULL;
break;
@@ -208,13 +194,12 @@ DLT_STATIC void dlt_connection_destroy_receiver(DltConnection *con)
* @return DltReceiver structure or NULL if none corresponds to the type.
*/
DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local,
- DltConnectionType type,
- int fd)
+ DltConnectionType type,
+ int fd)
{
DltReceiver *ret = NULL;
- switch (type)
- {
+ switch (type) {
case DLT_CONNECTION_CONTROL_CONNECT:
/* FALL THROUGH */
case DLT_CONNECTION_CONTROL_MSG:
@@ -223,26 +208,29 @@ DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local
/* FALL THROUGH */
case DLT_CONNECTION_CLIENT_MSG_TCP:
ret = calloc(1, sizeof(DltReceiver));
- if (ret) {
+
+ if (ret)
dlt_receiver_init(ret, fd, DLT_DAEMON_RCVBUFSIZESOCK);
- }
+
break;
case DLT_CONNECTION_CLIENT_MSG_SERIAL:
ret = calloc(1, sizeof(DltReceiver));
- if (ret) {
+
+ if (ret)
dlt_receiver_init(ret, fd, DLT_DAEMON_RCVBUFSIZESERIAL);
- }
+
break;
case DLT_CONNECTION_APP_MSG:
ret = calloc(1, sizeof(DltReceiver));
- if (ret)
- {
+
+ if (ret) {
#ifdef DLT_USE_UNIX_SOCKET_IPC
dlt_receiver_init_unix_socket(ret, fd, &app_recv_buffer);
#else
dlt_receiver_init(ret, fd, DLT_RECEIVE_BUFSIZE);
#endif
}
+
break;
case DLT_CONNECTION_APP_CONNECT:
/* FALL THROUGH */
@@ -256,9 +244,10 @@ DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local
/* FALL THROUGH */
case DLT_CONNECTION_GATEWAY_TIMER:
ret = calloc(1, sizeof(DltReceiver));
- if (ret) {
+
+ if (ret)
dlt_receiver_init(ret, fd, DLT_DAEMON_RCVBUFSIZE);
- }
+
break;
case DLT_CONNECTION_GATEWAY:
/* We rely on the gateway for init */
@@ -288,12 +277,9 @@ void *dlt_connection_get_callback(DltConnection *con)
DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
if (con)
- {
type = con->type;
- }
- switch (type)
- {
+ switch (type) {
case DLT_CONNECTION_CLIENT_CONNECT:
ret = dlt_daemon_process_client_connect;
break;
@@ -377,32 +363,28 @@ void dlt_connection_destroy(DltConnection *to_destroy)
* @return 0 On success, -1 otherwise.
*/
int dlt_connection_create(DltDaemonLocal *daemon_local,
- DltEventHandler *evh,
- int fd,
- int mask,
- DltConnectionType type)
+ DltEventHandler *evh,
+ int fd,
+ int mask,
+ DltConnectionType type)
{
DltConnection *temp = NULL;
- if (fd < 0) {
+ if (fd < 0)
/* Nothing to do */
return 0;
- }
if (dlt_event_handler_find_connection(evh, fd) != NULL)
- {
/* No need for the same client to be registered twice
* for the same event.
* TODO: If another mask can be expected,
* we need it to update the poll event here.
*/
return 0;
- }
temp = (DltConnection *)malloc(sizeof(DltConnection));
- if (temp == NULL)
- {
+ if (temp == NULL) {
dlt_log(LOG_CRIT, "Allocation of client handle failed\n");
return -1;
}
@@ -410,6 +392,7 @@ int dlt_connection_create(DltDaemonLocal *daemon_local,
memset(temp, 0, sizeof(DltConnection));
temp->receiver = dlt_connection_get_receiver(daemon_local, type, fd);
+
if (!temp->receiver) {
char local_str[DLT_DAEMON_TEXTBUFSIZE];
snprintf(local_str,
@@ -424,11 +407,10 @@ int dlt_connection_create(DltDaemonLocal *daemon_local,
/* We are single threaded no need for protection. */
temp->id = connectionId++;
+
if (!temp->id)
- {
/* Skipping 0 */
temp->id = connectionId++;
- }
temp->type = type;
temp->status = ACTIVE;
diff --git a/src/daemon/dlt_daemon_connection.h b/src/daemon/dlt_daemon_connection.h
index 00759c6..e46c05c 100644
--- a/src/daemon/dlt_daemon_connection.h
+++ b/src/daemon/dlt_daemon_connection.h
@@ -40,24 +40,24 @@ DltConnection *dlt_connection_get_next(DltConnection *, int);
int dlt_connection_create_remaining(DltDaemonLocal *);
int dlt_connection_create(DltDaemonLocal *,
- DltEventHandler *,
- int,
- int,
- DltConnectionType);
+ DltEventHandler *,
+ int,
+ int,
+ DltConnectionType);
void dlt_connection_destroy(DltConnection *);
void *dlt_connection_get_callback(DltConnection *);
#ifdef DLT_UNIT_TESTS
int dlt_connection_send(DltConnection *conn,
- void *msg,
- size_t msg_size);
+ void *msg,
+ size_t msg_size);
void dlt_connection_destroy_receiver(DltConnection *con);
DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local,
- DltConnectionType type,
- int fd);
+ DltConnectionType type,
+ int fd);
#endif
#endif /* DLT_DAEMON_CONNECTION_H */
diff --git a/src/daemon/dlt_daemon_event_handler.c b/src/daemon/dlt_daemon_event_handler.c
index 029e938..895a896 100644
--- a/src/daemon/dlt_daemon_event_handler.c
+++ b/src/daemon/dlt_daemon_event_handler.c
@@ -81,22 +81,17 @@ int dlt_daemon_prepare_event_handling(DltEventHandler *ev)
int i = 0;
if (ev == NULL)
- {
return DLT_RETURN_ERROR;
- }
ev->pfd = calloc(DLT_EV_BASE_FD, sizeof(struct pollfd));
- if (ev->pfd == NULL)
- {
+ if (ev->pfd == NULL) {
dlt_log(LOG_CRIT, "Creation of poll instance failed!\n");
return -1;
}
for (i = 0; i < DLT_EV_BASE_FD; i++)
- {
init_poll_fd(&ev->pfd[i]);
- }
ev->nfds = 0;
ev->max_nfds = DLT_EV_BASE_FD;
@@ -115,14 +110,12 @@ int dlt_daemon_prepare_event_handling(DltEventHandler *ev)
*/
static void dlt_event_handler_enable_fd(DltEventHandler *ev, int fd, int mask)
{
- if (ev->max_nfds <= ev->nfds)
- {
+ if (ev->max_nfds <= ev->nfds) {
int i = ev->nfds;
int max = 2 * ev->max_nfds;
struct pollfd *tmp = realloc(ev->pfd, max * sizeof(*ev->pfd));
- if (!tmp)
- {
+ if (!tmp) {
dlt_log(LOG_CRIT,
"Unable to register new fd for the event handler.\n");
return;
@@ -132,9 +125,7 @@ static void dlt_event_handler_enable_fd(DltEventHandler *ev, int fd, int mask)
ev->max_nfds = max;
for (; i < max; i++)
- {
init_poll_fd(&ev->pfd[i]);
- }
}
ev->pfd[ev->nfds].fd = fd;
@@ -156,29 +147,23 @@ static void dlt_event_handler_disable_fd(DltEventHandler *ev, int fd)
unsigned int j = 0;
unsigned int nfds = ev->nfds;
- for (; i < nfds; i++, j++)
- {
- if (ev->pfd[i].fd == fd)
- {
+ for (; i < nfds; i++, j++) {
+ if (ev->pfd[i].fd == fd) {
init_poll_fd(&ev->pfd[i]);
j++;
ev->nfds--;
}
if (i == j)
- {
continue;
- }
/* Compressing the table */
- if (i < ev->nfds)
- {
+ if (i < ev->nfds) {
ev->pfd[i].fd = ev->pfd[j].fd;
ev->pfd[i].events = ev->pfd[j].events;
ev->pfd[i].revents = ev->pfd[j].revents;
}
- else
- {
+ else {
init_poll_fd(&ev->pfd[i]);
}
}
@@ -205,82 +190,65 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
char str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
int (*callback)(DltDaemon *, DltDaemonLocal *, DltReceiver *, int) = NULL;
- if ((pEvent == NULL) || (daemon == NULL) || (daemon_local == NULL))
- {
+ if ((pEvent == NULL) || (daemon == NULL) || (daemon_local == NULL))
return DLT_RETURN_ERROR;
- }
ret = poll(pEvent->pfd, pEvent->nfds, DLT_EV_TIMEOUT_MSEC);
- if (ret <= 0)
- {
+ if (ret <= 0) {
/* We are not interested in EINTR has it comes
* either from timeout or signal.
*/
if (errno == EINTR)
- {
ret = 0;
- }
if (ret < 0)
- {
dlt_vlog(LOG_CRIT, "poll() failed: %s\n", strerror(errno));
- }
return ret;
}
- for (i = 0 ; i < pEvent->nfds ; i++)
- {
+ for (i = 0; i < pEvent->nfds; i++) {
int fd = 0;
DltConnection *con = NULL;
DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
if (pEvent->pfd[i].revents == 0)
- {
continue;
- }
con = dlt_event_handler_find_connection(pEvent, pEvent->pfd[i].fd);
- if (con && con->receiver)
- {
+ if (con && con->receiver) {
type = con->type;
fd = con->receiver->fd;
}
- else /* connection might have been destroyed in the meanwhile */
- {
+ else { /* connection might have been destroyed in the meanwhile */
dlt_event_handler_disable_fd(pEvent, pEvent->pfd[i].fd);
continue;
}
/* First of all handle error events */
- if (pEvent->pfd[i].revents & DLT_EV_MASK_REJECTED)
- {
+ if (pEvent->pfd[i].revents & DLT_EV_MASK_REJECTED) {
/* An error occurred, we need to clean-up the concerned event
*/
if (type == DLT_CONNECTION_CLIENT_MSG_TCP)
- {
/* To transition to BUFFER state if this is final TCP client connection,
* call dedicated function. this function also calls
* dlt_event_handler_unregister_connection() inside the function.
*/
dlt_daemon_close_socket(fd, daemon, daemon_local, 0);
- }
else
- {
dlt_event_handler_unregister_connection(pEvent,
daemon_local,
fd);
- }
+
continue;
}
/* Get the function to be used to handle the event */
callback = dlt_connection_get_callback(con);
- if (!callback)
- {
+ if (!callback) {
snprintf(str,
DLT_DAEMON_TEXTBUFSIZE,
"Unable to find function for %d handle type.\n",
@@ -293,16 +261,16 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
if (callback(daemon,
daemon_local,
con->receiver,
- daemon_local->flags.vflag) == -1)
- {
+ daemon_local->flags.vflag) == -1) {
snprintf(str,
DLT_DAEMON_TEXTBUFSIZE,
"Processing from %d handle type failed!\n",
- type );
+ type);
dlt_log(LOG_CRIT, str);
return -1;
}
}
+
return 0;
}
@@ -318,15 +286,13 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
* @return The found connection pointer, NULL otherwise.
*/
DltConnection *dlt_event_handler_find_connection(DltEventHandler *ev,
- int fd)
+ int fd)
{
DltConnection *temp = ev->connections;
while ((temp != NULL) && (temp->receiver->fd != fd))
- {
temp = temp->next;
- }
return temp;
}
@@ -342,25 +308,21 @@ DltConnection *dlt_event_handler_find_connection(DltEventHandler *ev,
* @return 0 on success, -1 if the connection is not found.
*/
DLT_STATIC int dlt_daemon_remove_connection(DltEventHandler *ev,
- DltConnection *to_remove)
+ DltConnection *to_remove)
{
- if (ev == NULL || to_remove == NULL)
- {
+ if ((ev == NULL) || (to_remove == NULL))
return DLT_RETURN_ERROR;
- }
DltConnection *curr = ev->connections;
DltConnection *prev = curr;
/* Find the address where to_remove value is registered */
- while (curr && (curr != to_remove))
- {
+ while (curr && (curr != to_remove)) {
prev = curr;
curr = curr->next;
}
- if (!curr)
- {
+ if (!curr) {
/* Must not be possible as we check for existence before */
dlt_log(LOG_CRIT, "Connection not found for removal.\n");
return -1;
@@ -369,8 +331,7 @@ DLT_STATIC int dlt_daemon_remove_connection(DltEventHandler *ev,
{
ev->connections = curr->next;
}
- else
- {
+ else {
prev->next = curr->next;
}
@@ -391,21 +352,15 @@ void dlt_event_handler_cleanup_connections(DltEventHandler *ev)
unsigned int i = 0;
if (ev == NULL)
- {
/* Nothing to do. */
return;
- }
while (ev->connections != NULL)
- {
/* We don really care on failure */
(void)dlt_daemon_remove_connection(ev, ev->connections);
- }
for (i = 0; i < ev->nfds; i++)
- {
init_poll_fd(&ev->pfd[i]);
- }
free(ev->pfd);
}
@@ -418,15 +373,14 @@ void dlt_event_handler_cleanup_connections(DltEventHandler *ev)
* @param connection The connection to be added.
*/
DLT_STATIC void dlt_daemon_add_connection(DltEventHandler *ev,
- DltConnection *connection)
+ DltConnection *connection)
{
DltConnection **temp = &ev->connections;
while (*temp != NULL)
- {
temp = &(*temp)->next;
- }
+
*temp = connection;
}
@@ -449,23 +403,21 @@ int dlt_connection_check_activate(DltEventHandler *evhdl,
{
char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
- if (!evhdl || !con || !con->receiver)
- {
+ if (!evhdl || !con || !con->receiver) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: wrong parameters (%p %p).\n",
__func__,
evhdl,
con);
- dlt_log(LOG_ERR, local_str);
- return -1;
+ dlt_log(LOG_ERR, local_str);
+ return -1;
}
- switch (con->status)
- {
+ switch (con->status) {
case ACTIVE:
- if (activation_type == DEACTIVATE)
- {
+
+ if (activation_type == DEACTIVATE) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Deactivate connection type: %d\n",
@@ -473,17 +425,17 @@ int dlt_connection_check_activate(DltEventHandler *evhdl,
dlt_log(LOG_INFO, local_str);
dlt_event_handler_disable_fd(evhdl, con->receiver->fd);
-
+
if (con->type == DLT_CONNECTION_CLIENT_CONNECT)
- {
con->receiver->fd = -1;
- }
+
con->status = INACTIVE;
}
+
break;
case INACTIVE:
- if (activation_type == ACTIVATE)
- {
+
+ if (activation_type == ACTIVATE) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Activate connection type: %d\n",
@@ -496,14 +448,15 @@ int dlt_connection_check_activate(DltEventHandler *evhdl,
con->status = ACTIVE;
}
+
break;
default:
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Unknown connection status: %d\n",
- con->status);
- dlt_log(LOG_ERR, local_str);
- return -1;
+ snprintf(local_str,
+ DLT_DAEMON_TEXTBUFSIZE,
+ "Unknown connection status: %d\n",
+ con->status);
+ dlt_log(LOG_ERR, local_str);
+ return -1;
}
return 0;
@@ -530,8 +483,7 @@ int dlt_event_handler_register_connection(DltEventHandler *evhdl,
DltConnection *connection,
int mask)
{
- if (!evhdl || !connection || !connection->receiver)
- {
+ if (!evhdl || !connection || !connection->receiver) {
dlt_log(LOG_ERR, "Wrong parameters when registering connection.\n");
return -1;
}
@@ -540,9 +492,7 @@ int dlt_event_handler_register_connection(DltEventHandler *evhdl,
if ((connection->type == DLT_CONNECTION_CLIENT_MSG_TCP) ||
(connection->type == DLT_CONNECTION_CLIENT_MSG_SERIAL))
- {
daemon_local->client_connections++;
- }
/* On creation the connection is not active by default */
connection->status = INACTIVE;
@@ -573,29 +523,24 @@ int dlt_event_handler_unregister_connection(DltEventHandler *evhdl,
DltDaemonLocal *daemon_local,
int fd)
{
- if (evhdl == NULL || daemon_local == NULL)
- {
+ if ((evhdl == NULL) || (daemon_local == NULL))
return DLT_RETURN_ERROR;
- }
/* Look for the pointer in the client list.
* There shall be only one event handler with the same fd.
*/
DltConnection *temp = dlt_event_handler_find_connection(evhdl, fd);
- if (!temp)
- {
+ if (!temp) {
dlt_log(LOG_ERR, "Connection not found for unregistration.\n");
return -1;
}
if ((temp->type == DLT_CONNECTION_CLIENT_MSG_TCP) ||
- (temp->type == DLT_CONNECTION_CLIENT_MSG_SERIAL))
- {
+ (temp->type == DLT_CONNECTION_CLIENT_MSG_SERIAL)) {
daemon_local->client_connections--;
- if (daemon_local->client_connections < 0)
- {
+ if (daemon_local->client_connections < 0) {
daemon_local->client_connections = 0;
dlt_log(LOG_CRIT, "Unregistering more client than registered!\n");
}
@@ -604,9 +549,7 @@ int dlt_event_handler_unregister_connection(DltEventHandler *evhdl,
if (dlt_connection_check_activate(evhdl,
temp,
DEACTIVATE) < 0)
- {
dlt_log(LOG_ERR, "Unable to unregister event.\n");
- }
/* Cannot fail as far as dlt_daemon_find_connection succeed */
return dlt_daemon_remove_connection(evhdl, temp);
diff --git a/src/daemon/dlt_daemon_event_handler.h b/src/daemon/dlt_daemon_event_handler.h
index 280bfd7..53639c4 100644
--- a/src/daemon/dlt_daemon_event_handler.h
+++ b/src/daemon/dlt_daemon_event_handler.h
@@ -42,27 +42,27 @@ int dlt_daemon_handle_event(DltEventHandler *, DltDaemon *, DltDaemonLocal *);
DltConnection *dlt_event_handler_find_connection_by_id(DltEventHandler *,
DltConnectionId);
DltConnection *dlt_event_handler_find_connection(DltEventHandler *,
- int);
+ int);
void dlt_event_handler_cleanup_connections(DltEventHandler *);
int dlt_event_handler_register_connection(DltEventHandler *,
- DltDaemonLocal *,
- DltConnection *,
- int);
+ DltDaemonLocal *,
+ DltConnection *,
+ int);
int dlt_event_handler_unregister_connection(DltEventHandler *,
- DltDaemonLocal *,
- int);
+ DltDaemonLocal *,
+ int);
int dlt_connection_check_activate(DltEventHandler *,
DltConnection *,
int);
-#ifdef DLT_UNIT_TESTS
+# ifdef DLT_UNIT_TESTS
int dlt_daemon_remove_connection(DltEventHandler *ev,
- DltConnection *to_remove);
+ DltConnection *to_remove);
void dlt_daemon_add_connection(DltEventHandler *ev,
- DltConnection *connection);
-#endif
+ DltConnection *connection);
+# endif
#endif /* DLT_DAEMON_EVENT_HANDLER_H */
diff --git a/src/daemon/dlt_daemon_event_handler_types.h b/src/daemon/dlt_daemon_event_handler_types.h
index 99a1217..16e0a98 100644
--- a/src/daemon/dlt_daemon_event_handler_types.h
+++ b/src/daemon/dlt_daemon_event_handler_types.h
@@ -32,7 +32,7 @@
#include "dlt_daemon_connection_types.h"
#ifndef DLT_DAEMON_EVENT_HANDLER_TYPES_H
-#define DLT_DAEMON_EVENT_HANDLER_TYPES_H
+# define DLT_DAEMON_EVENT_HANDLER_TYPES_H
/* FIXME: Remove the need for DltDaemonLocal everywhere in the code
* These typedefs are needed by DltDaemonLocal which is
@@ -43,9 +43,9 @@
typedef enum {
DLT_TIMER_PACKET = 0,
DLT_TIMER_ECU,
-#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+# ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
DLT_TIMER_SYSTEMD,
-#endif
+# endif
DLT_TIMER_GATEWAY,
DLT_TIMER_UNKNOWN
} DltTimers;
diff --git a/src/daemon/dlt_daemon_offline_logstorage.c b/src/daemon/dlt_daemon_offline_logstorage.c
index 86d4b5e..8ec7016 100644
--- a/src/daemon/dlt_daemon_offline_logstorage.c
+++ b/src/daemon/dlt_daemon_offline_logstorage.c
@@ -43,15 +43,13 @@
* @return 0 on success -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid(char *key,
- int len,
- char *ecuid,
- char *appid,
- char *ctxid)
+ int len,
+ char *ecuid,
+ char *appid,
+ char *ctxid)
{
if ((len > (DLT_ID_SIZE + 2)) || (len < 2))
- {
return DLT_RETURN_ERROR;
- }
strncpy(ecuid, key, (len - 2));
strncpy(appid, ".*", 2);
@@ -72,14 +70,12 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid(char *key,
* @return 0 on success -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_ctid(char *key,
- int len,
- char *appid,
- char *ctxid)
+ int len,
+ char *appid,
+ char *ctxid)
{
- if ((len > (DLT_ID_SIZE + 2)) || (len < 1) )
- {
+ if ((len > (DLT_ID_SIZE + 2)) || (len < 1))
return DLT_RETURN_ERROR;
- }
strncpy(ctxid, (key + 2), (len - 1));
strncpy(appid, ".*", 2);
@@ -99,14 +95,12 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_ctid(char *key,
* @return 0 on success -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_apid(char *key,
- int len,
- char *appid,
- char *ctxid)
+ int len,
+ char *appid,
+ char *ctxid)
{
if ((len > (DLT_ID_SIZE + 2)) || (len < 2))
- {
return DLT_RETURN_ERROR;
- }
strncpy(appid, key + 1, (len - 2));
strncpy(ctxid, ".*", 2);
@@ -126,37 +120,29 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_apid(char *key,
* @return 0 on success -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_apid_ctid(char *key,
- int len,
- char *appid,
- char *ctxid)
+ int len,
+ char *appid,
+ char *ctxid)
{
char *tok = NULL;
if (len > DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)
- {
return DLT_RETURN_ERROR;
- }
/* copy appid and ctxid */
tok = strtok(key, ":");
+
if (tok != NULL)
- {
strncpy(appid, tok, DLT_ID_SIZE);
- }
else
- {
return DLT_RETURN_ERROR;
- }
tok = strtok(NULL, ":");
+
if (tok != NULL)
- {
strncpy(ctxid, tok, DLT_ID_SIZE);
- }
else
- {
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
}
@@ -174,39 +160,31 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_apid_ctid(char *key,
* @return 0 on success -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid_apid(char *key,
- int len,
- char *ecuid,
- char *appid,
- char *ctxid)
+ int len,
+ char *ecuid,
+ char *appid,
+ char *ctxid)
{
char *tok = NULL;
if (len > DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)
- {
return DLT_RETURN_ERROR;
- }
/* copy appid and ctxid */
tok = strtok(key, ":");
+
if (tok != NULL)
- {
strncpy(ecuid, tok, DLT_ID_SIZE);
- }
else
- {
return DLT_RETURN_ERROR;
- }
tok = strtok(NULL, ":");
if (tok != NULL)
- {
strncpy(appid, tok, DLT_ID_SIZE);
- }
else
- {
return DLT_RETURN_ERROR;
- }
+
strncpy(ctxid, ".*", 2);
return DLT_RETURN_OK;
@@ -224,38 +202,34 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid_apid(char *key,
* @return None
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_multi(char *key,
- int len,
- char *ecuid,
- char *appid,
- char *ctxid)
+ int len,
+ char *ecuid,
+ char *appid,
+ char *ctxid)
{
char *tok = NULL;
if (len > DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)
- {
return DLT_RETURN_ERROR;
- }
tok = strtok(key, ":");
+
if (tok == NULL)
- {
return DLT_RETURN_ERROR;
- }
len = strlen(tok);
- if (key[len + 1] == ':')
- {
+
+ if (key[len + 1] == ':') {
strncpy(ecuid, tok, DLT_ID_SIZE);
tok = strtok(NULL, ":");
+
if (tok != NULL)
- {
strncpy(ctxid, tok, DLT_ID_SIZE);
- }
+
strncpy(appid, ".*", 2);
}
- else
- {
+ else {
strncpy(ecuid, tok, DLT_ID_SIZE);
tok = strtok(NULL, ":");
strncpy(appid, tok, DLT_ID_SIZE);
@@ -285,49 +259,33 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_key(char *key, char *appid, char
char *sep = NULL;
if ((key == NULL) || (appid == NULL) || (ctxid == NULL) || (ecuid == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
len = strlen(key);
sep = strchr (key, ':');
if (sep == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* key is ecuid only ecuid::*/
if ((key[len - 1] == ':') && (key[len - 2] == ':'))
- {
return dlt_logstorage_split_ecuid(key, len, ecuid, appid, ctxid);
- }
/* key is context id only ::apid*/
else if ((key[0] == ':') && (key[1] == ':'))
- {
return dlt_logstorage_split_ctid(key, len, appid, ctxid);
- }
/* key is application id only :apid: */
- else if ((key[0] == ':') && key[len - 1] == ':')
- {
+ else if ((key[0] == ':') && (key[len - 1] == ':'))
return dlt_logstorage_split_apid(key, len, appid, ctxid);
- }
/* key is :apid:ctid */
- else if ((key[0] == ':') && key[len - 1] != ':')
- {
+ else if ((key[0] == ':') && (key[len - 1] != ':'))
return dlt_logstorage_split_apid_ctid(key, len, appid, ctxid);
- }
/* key is ecuid:apid: */
- else if ((key[0] != ':') && key[len - 1] == ':')
- {
- return dlt_logstorage_split_ecuid_apid(key, len, ecuid, appid, ctxid);
- }
+ else if ((key[0] != ':') && (key[len - 1] == ':'))
+ return dlt_logstorage_split_ecuid_apid(key, len, ecuid, appid, ctxid);
/* key is either ecuid::ctid or ecuid:apid:ctid */
else
- {
return dlt_logstorage_split_multi(key, len, ecuid, appid, ctxid);
- }
}
/**
@@ -341,30 +299,28 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_key(char *key, char *appid, char
* @param verbose verbosity flag
*/
DLT_STATIC DltReturnValue dlt_daemon_logstorage_update_passive_node_context(
- DltDaemonLocal *daemon_local,
- char *apid,
- char *ctid,
- char *ecuid,
- int loglevel,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *apid,
+ char *ctid,
+ char *ecuid,
+ int loglevel,
+ int verbose)
{
- DltServiceSetLogLevel req = {0};
- DltPassiveControlMessage ctrl = {0};
+ DltServiceSetLogLevel req = { 0 };
+ DltPassiveControlMessage ctrl = { 0 };
DltGatewayConnection *con = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon_local == NULL) || (apid == NULL) || (ctid == NULL) || (ecuid == NULL) ||
- (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT))
- {
+ (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
con = dlt_gateway_get_connection(&daemon_local->pGateway, ecuid, verbose);
- if (con == NULL)
- {
+ if (con == NULL) {
dlt_vlog(LOG_ERR,
"Failed to fond connection to passive node %s\n",
ecuid);
@@ -379,8 +335,7 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_update_passive_node_context(
req.log_level = loglevel;
- if (dlt_gateway_send_control_message(con, &ctrl, (void *) &req, verbose) != 0)
- {
+ if (dlt_gateway_send_control_message(con, &ctrl, (void *)&req, verbose) != 0) {
dlt_vlog(LOG_ERR,
"Failed to forward SET_LOG_LEVEL message to passive node %s\n",
ecuid);
@@ -406,58 +361,49 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_update_passive_node_context(
* @return 0 on success, -1 on error
*/
DLT_STATIC DltReturnValue dlt_daemon_logstorage_send_log_level(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltDaemonContext *context,
- char *ecuid,
- int loglevel,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ DltDaemonContext *context,
+ char *ecuid,
+ int loglevel,
+ int verbose)
{
int old_log_level = -1;
int ll = DLT_LOG_DEFAULT;
if ((daemon == NULL) || (daemon_local == NULL) || (ecuid == NULL) ||
- (context == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT))
- {
+ (context == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
-
- if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0)
- {
+ if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0) {
old_log_level = context->storage_log_level;
context->storage_log_level = DLT_OFFLINE_LOGSTORAGE_MAX(loglevel,
- context->storage_log_level);
+ context->storage_log_level);
- if (context->storage_log_level > old_log_level)
- {
- if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1)
- {
+ if (context->storage_log_level > old_log_level) {
+ if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1) {
dlt_log(LOG_ERR, "Unable to update log level\n");
return DLT_RETURN_ERROR;
}
}
-
}
- else
- {
+ else {
old_log_level = context->log_level;
ll = DLT_OFFLINE_LOGSTORAGE_MAX(loglevel, context->log_level);
if (ll > old_log_level)
- {
return dlt_daemon_logstorage_update_passive_node_context(daemon_local,
context->apid,
context->ctid,
ecuid,
ll,
verbose);
- }
-
}
+
return DLT_RETURN_OK;
}
@@ -476,45 +422,40 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_send_log_level(DltDaemon *daemon
* @return 0 on success, -1 on error
*/
DLT_STATIC DltReturnValue dlt_daemon_logstorage_reset_log_level(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltDaemonContext *context,
- char *ecuid,
- int loglevel,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ DltDaemonContext *context,
+ char *ecuid,
+ int loglevel,
+ int verbose)
{
if ((daemon == NULL) || (daemon_local == NULL) || (ecuid == NULL) ||
- (context == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT))
- {
+ (context == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
-
/* Set storage level to -1, to clear log levels */
context->storage_log_level = DLT_LOG_DEFAULT;
- if (loglevel == DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL)
- {
- if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0)
- {
+ if (loglevel == DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL) {
+ if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0) {
if (dlt_daemon_user_send_log_level(daemon,
context,
- verbose) == DLT_RETURN_ERROR)
- {
+ verbose) == DLT_RETURN_ERROR) {
dlt_log(LOG_ERR, "Unable to update log level\n");
return DLT_RETURN_ERROR;
}
}
- else /* forward set log level to passive node */
- {
+ else { /* forward set log level to passive node */
return dlt_daemon_logstorage_update_passive_node_context(daemon_local,
- context->apid,
- context->ctid,
- ecuid,
- DLT_LOG_DEFAULT,
- verbose);
+ context->apid,
+ context->ctid,
+ ecuid,
+ DLT_LOG_DEFAULT,
+ verbose);
}
}
+
return DLT_RETURN_OK;
}
@@ -531,12 +472,12 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_reset_log_level(DltDaemon *daemo
* @return 0 on success, -1 on error
*/
DLT_STATIC DltReturnValue dlt_daemon_logstorage_force_reset_level(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *apid,
- char *ctxid,
- char *ecuid,
- int loglevel,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *apid,
+ char *ctxid,
+ char *ecuid,
+ int loglevel,
+ int verbose)
{
int ll = DLT_LOG_DEFAULT;
int num = 0;
@@ -544,37 +485,29 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_force_reset_level(DltDaemon *dae
DltLogStorageFilterConfig *config[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS] = { 0 };
if ((daemon == NULL) || (daemon_local == NULL) || (ecuid == NULL) ||
- (apid == NULL) || (ctxid == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT))
- {
+ (apid == NULL) || (ctxid == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
+ for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
num = dlt_logstorage_get_config(&(daemon->storage_handle[i]), config, apid, ctxid, ecuid);
+
if (num > 0)
- {
break; /* found config */
- }
}
- if ((num == 0) || (config[0] == NULL ))
- {
+ if ((num == 0) || (config[0] == NULL)) {
dlt_vlog(LOG_ERR,
- "%s: No information about APID: %s, CTID: %s, ECU: %s in Logstorage configuration\n",
- __func__, apid, ctxid, ecuid);
+ "%s: No information about APID: %s, CTID: %s, ECU: %s in Logstorage configuration\n",
+ __func__, apid, ctxid, ecuid);
return DLT_RETURN_ERROR;
}
if (loglevel == DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL)
- {
ll = config[0]->reset_log_level;
- }
else
- {
ll = config[0]->log_level;
- }
return dlt_daemon_logstorage_update_passive_node_context(daemon_local, apid,
ctxid, ecuid, ll, verbose);
@@ -601,64 +534,53 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_force_reset_level(DltDaemon *dae
* @return 0 on success, -1 on error
*/
DltReturnValue dlt_logstorage_update_all_contexts(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *id,
- int curr_log_level,
- int cmp_flag,
- char *ecuid,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *id,
+ int curr_log_level,
+ int cmp_flag,
+ char *ecuid,
+ int verbose)
{
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
int i = 0;
- char tmp_id[DLT_ID_SIZE + 1] = {'\0'};
+ char tmp_id[DLT_ID_SIZE + 1] = { '\0' };
- if ((daemon == NULL) || (daemon_local == NULL) ||(id == NULL) ||
+ if ((daemon == NULL) || (daemon_local == NULL) || (id == NULL) ||
(ecuid == NULL) || (cmp_flag < DLT_DAEMON_LOGSTORAGE_CMP_APID) ||
- (cmp_flag > DLT_DAEMON_LOGSTORAGE_CMP_CTID))
- {
+ (cmp_flag > DLT_DAEMON_LOGSTORAGE_CMP_CTID)) {
dlt_vlog(LOG_ERR, "Wrong parameter in function %s\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
user_list = dlt_daemon_find_users_list(daemon, ecuid, verbose);
+
if (user_list == NULL)
- {
return DLT_RETURN_ERROR;
- }
- for (i = 0; i < user_list->num_contexts; i++)
- {
+ for (i = 0; i < user_list->num_contexts; i++) {
if (cmp_flag == 1)
- {
dlt_set_id(tmp_id, user_list->contexts[i].apid);
- }
else
- {
dlt_set_id(tmp_id, user_list->contexts[i].ctid);
- }
- if (strncmp(id, tmp_id, DLT_ID_SIZE) == 0)
- {
+ if (strncmp(id, tmp_id, DLT_ID_SIZE) == 0) {
if (curr_log_level > 0)
- {
dlt_daemon_logstorage_send_log_level(daemon,
daemon_local,
&user_list->contexts[i],
ecuid,
curr_log_level,
verbose);
- }
else /* The request is to reset log levels */
- {
dlt_daemon_logstorage_reset_log_level(daemon,
daemon_local,
&user_list->contexts[i],
ecuid,
curr_log_level,
verbose);
- }
}
}
+
return DLT_RETURN_OK;
}
@@ -680,50 +602,43 @@ DltReturnValue dlt_logstorage_update_all_contexts(DltDaemon *daemon,
* @return 0 on success, -1 on error
*/
DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *apid,
- char *ctxid,
- char *ecuid,
- int curr_log_level,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *apid,
+ char *ctxid,
+ char *ecuid,
+ int curr_log_level,
+ int verbose)
{
DltDaemonContext *context = NULL;
- if ((daemon == NULL) || (daemon_local == NULL) ||(apid == NULL)
- || (ctxid == NULL) || (ecuid == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (apid == NULL)
+ || (ctxid == NULL) || (ecuid == NULL)) {
dlt_vlog(LOG_ERR, "Wrong parameter in function %s\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
context = dlt_daemon_context_find(daemon, apid, ctxid, ecuid, verbose);
- if (context != NULL)
- {
+
+ if (context != NULL) {
if (curr_log_level > 0)
- {
return dlt_daemon_logstorage_send_log_level(daemon,
daemon_local,
context,
ecuid,
curr_log_level,
verbose);
- }
else /* The request is to reset log levels */
- {
return dlt_daemon_logstorage_reset_log_level(daemon,
daemon_local,
context,
ecuid,
curr_log_level,
verbose);
- }
}
- else
- {
- if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) != 0)
- {
- // we intentionally have no data provided by passive node.
- // We blindly send the log level or reset log level
+ else {
+ if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) != 0) {
+ /* we intentionally have no data provided by passive node. */
+ /* We blindly send the log level or reset log level */
return dlt_daemon_logstorage_force_reset_level(daemon,
daemon_local,
apid,
@@ -732,14 +647,13 @@ DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon,
curr_log_level,
verbose);
}
- else
- {
+ else {
dlt_vlog(LOG_WARNING,
- "%s: No information about APID: %s, CTID: %s, ECU: %s\n",
- __func__,
- apid,
- ctxid,
- ecuid);
+ "%s: No information about APID: %s, CTID: %s, ECU: %s\n",
+ __func__,
+ apid,
+ ctxid,
+ ecuid);
return DLT_RETURN_ERROR;
}
@@ -760,38 +674,32 @@ DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon,
* @return 0 on success, -1 on error
*/
DltReturnValue dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *key,
- int curr_log_level,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *key,
+ int curr_log_level,
+ int verbose)
{
int cmp_flag = 0;
- char appid[DLT_ID_SIZE + 1] = {'\0'};
- char ctxid[DLT_ID_SIZE + 1] = {'\0'};
- char ecuid[DLT_ID_SIZE + 1] = {'\0'};
+ char appid[DLT_ID_SIZE + 1] = { '\0' };
+ char ctxid[DLT_ID_SIZE + 1] = { '\0' };
+ char ecuid[DLT_ID_SIZE + 1] = { '\0' };
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (key == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (dlt_logstorage_split_key(key, appid, ctxid, ecuid) != 0)
- {
+ if (dlt_logstorage_split_key(key, appid, ctxid, ecuid) != 0) {
dlt_log(LOG_ERR,
"Error while updating application log levels (split key)\n");
return DLT_RETURN_ERROR;
}
if (ecuid[0] == '\0') /* ECU id was not specified in filter configuration */
- {
dlt_set_id(ecuid, daemon->ecuid);
- }
/* wildcard for context id, find all contexts of given application id */
- if (strcmp(ctxid, ".*") == 0)
- {
+ if (strcmp(ctxid, ".*") == 0) {
cmp_flag = DLT_DAEMON_LOGSTORAGE_CMP_APID;
if (dlt_logstorage_update_all_contexts(daemon,
@@ -801,9 +709,7 @@ DltReturnValue dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
cmp_flag,
ecuid,
verbose) != 0)
- {
return DLT_RETURN_ERROR;
- }
}
/* wildcard for application id, find all contexts with context id */
else if (strcmp(appid, ".*") == 0)
@@ -817,9 +723,7 @@ DltReturnValue dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
cmp_flag,
ecuid,
verbose) != 0)
- {
return DLT_RETURN_ERROR;
- }
}
/* In case of given application id, context id pair, call available context
* find function */
@@ -861,15 +765,14 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
DltLogStorage *handle = NULL;
DltLogStorageFilterList **tmp = NULL;
int i = 0;
- char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = {'\0'};
+ char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { '\0' };
int num_device_configured = 0;
unsigned int status;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) ||
- (daemon->storage_handle == NULL) || (dev_num < 0))
- {
+ (daemon->storage_handle == NULL) || (dev_num < 0)) {
dlt_vlog(LOG_ERR,
"Invalid function parameters used for %s\n",
__func__);
@@ -880,26 +783,21 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
if ((handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
(handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
- {
return;
- }
/* First, check number of devices configured */
- for (i = 0; i < max_device; i++)
- {
+ for (i = 0; i < max_device; i++) {
status = daemon->storage_handle[i].config_status;
if (status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- {
num_device_configured++;
- }
}
/* for all filters (keys) check if application context are already running
* and log level need to be reset*/
tmp = &(handle->config_list);
- while (*(tmp) != NULL)
- {
+
+ while (*(tmp) != NULL) {
memset(key, 0, sizeof(key));
strncpy(key,
@@ -907,7 +805,6 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN);
if (num_device_configured == 1)
- {
/* Reset context log level and send to application */
dlt_logstorage_update_context_loglevel(
daemon,
@@ -915,36 +812,30 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
key,
DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL,
verbose);
- }
else /* Reset context log level do not send to application as other
- devices can have same configuration */
- {
+ * devices can have same configuration */
dlt_logstorage_update_context_loglevel(
daemon,
daemon_local,
key,
DLT_DAEMON_LOGSTORAGE_RESET_LOGLEVEL,
verbose);
- }
+
tmp = &(*tmp)->next;
}
/* Re-run update log level for all other configured devices */
- for (i = 0; i < max_device; i++)
- {
+ for (i = 0; i < max_device; i++) {
status = daemon->storage_handle[i].config_status;
+
if (i == dev_num)
- {
continue;
- }
if (status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- {
dlt_daemon_logstorage_update_application_loglevel(daemon,
daemon_local,
i,
verbose);
- }
}
return;
@@ -970,12 +861,11 @@ void dlt_daemon_logstorage_update_application_loglevel(DltDaemon *daemon,
{
DltLogStorage *handle = NULL;
DltLogStorageFilterList **tmp = NULL;
- char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = {'\0'};
+ char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { '\0' };
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (dev_num < 0))
- {
+ if ((daemon == NULL) || (dev_num < 0)) {
dlt_vlog(LOG_ERR,
"Invalid function parameters used for %s\n",
__func__);
@@ -986,15 +876,13 @@ void dlt_daemon_logstorage_update_application_loglevel(DltDaemon *daemon,
if ((handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
(handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
- {
return;
- }
/* for all filters (keys) check if application or context already running
* and log level need to be updated*/
tmp = &(handle->config_list);
- while (*(tmp) != NULL)
- {
+
+ while (*(tmp) != NULL) {
int log_level = -1;
memset(key, 0, sizeof(key));
@@ -1006,8 +894,7 @@ void dlt_daemon_logstorage_update_application_loglevel(DltDaemon *daemon,
/* Obtain storage configuration data */
log_level = dlt_logstorage_get_loglevel_by_key(handle, key);
- if (log_level < 0)
- {
+ if (log_level < 0) {
dlt_log(LOG_ERR, "Failed to get log level by key \n");
return;
}
@@ -1041,7 +928,7 @@ int dlt_daemon_logstorage_get_loglevel(DltDaemon *daemon,
char *apid,
char *ctid)
{
- DltLogStorageFilterConfig *config[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS] = {0};
+ DltLogStorageFilterConfig *config[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS] = { 0 };
int i = 0;
int j = 0;
int8_t storage_loglevel = -1;
@@ -1049,48 +936,39 @@ int dlt_daemon_logstorage_get_loglevel(DltDaemon *daemon,
int num_config = 0;
if ((daemon == NULL) || (max_device == 0) || (apid == NULL) || (ctid == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
for (i = 0; i < max_device; i++)
- {
if (daemon->storage_handle[i].config_status ==
- DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- {
+ DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) {
num_config = dlt_logstorage_get_config(&(daemon->storage_handle[i]),
- config,
- apid,
- ctid,
- daemon->ecuid);
+ config,
+ apid,
+ ctid,
+ daemon->ecuid);
- if (num_config == 0)
- {
+ if (num_config == 0) {
dlt_log(LOG_DEBUG, "No valid filter configuration found\n");
continue;
}
- for (j = 0; j < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS; j++)
- {
+ for (j = 0; j < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS; j++) {
if (config[j] == NULL)
- {
continue;
- }
/* If logstorage configuration do not contain file name,
* then it is non verbose control filter, so return level as in this filter */
- if (config[j]->file_name == NULL)
- {
+ if (config[j]->file_name == NULL) {
storage_loglevel = config[j]->log_level;
break;
}
+
configured_loglevel = config[j]->log_level;
storage_loglevel = DLT_OFFLINE_LOGSTORAGE_MAX(
- configured_loglevel,
- storage_loglevel);
+ configured_loglevel,
+ storage_loglevel);
}
}
- }
return storage_loglevel;
}
@@ -1125,10 +1003,9 @@ void dlt_daemon_logstorage_write(DltDaemon *daemon,
if ((daemon == NULL) || (user_config == NULL) ||
(user_config->offlineLogstorageMaxDevices <= 0) || (data1 == NULL) ||
- (data2 == NULL) || (data3 == NULL))
- {
+ (data2 == NULL) || (data3 == NULL)) {
dlt_vlog(LOG_DEBUG,
- "%s: message type is not LOG. Skip storing.\n",
+ "%s: message type is not LOG. Skip storing.\n",
__func__);
return;
/* Log Level changed callback */
@@ -1142,10 +1019,8 @@ void dlt_daemon_logstorage_write(DltDaemon *daemon,
user_config->offlineLogstorageMaxCounterIdx;
for (i = 0; i < user_config->offlineLogstorageMaxDevices; i++)
- {
if (daemon->storage_handle[i].config_status ==
- DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- {
+ DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) {
if (dlt_logstorage_write(&(daemon->storage_handle[i]),
&file_config,
data1,
@@ -1153,8 +1028,7 @@ void dlt_daemon_logstorage_write(DltDaemon *daemon,
data2,
size2,
data3,
- size3) != 0)
- {
+ size3) != 0) {
dlt_log(LOG_ERR,
"dlt_daemon_logstorage_write: failed. "
"Disable storage device\n");
@@ -1165,7 +1039,6 @@ void dlt_daemon_logstorage_write(DltDaemon *daemon,
DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT);
}
}
- }
}
/**
@@ -1189,16 +1062,13 @@ int dlt_daemon_logstorage_setup_internal_storage(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((path == NULL) || (daemon == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* connect internal storage device */
/* Device index always used as 0 as it is setup on DLT daemon startup */
ret = dlt_logstorage_device_connected(&(daemon->storage_handle[0]), path);
- if (ret != 0)
- {
+ if (ret != 0) {
dlt_vlog(LOG_ERR, "%s: Device connect failed\n", __func__);
return DLT_RETURN_ERROR;
}
@@ -1227,21 +1097,15 @@ int dlt_daemon_logstorage_cleanup(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
/* call disconnect on all currently connected devices */
if (daemon->storage_handle[i].connection_type ==
DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
- {
dlt_logstorage_device_disconnected(
&daemon->storage_handle[i],
DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT);
- }
- }
return 0;
}
@@ -1257,57 +1121,48 @@ int dlt_daemon_logstorage_sync_cache(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (mnt_point == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (strlen(mnt_point) > 0) /* mount point is given */
- {
+ if (strlen(mnt_point) > 0) { /* mount point is given */
handle = dlt_daemon_logstorage_get_device(daemon,
daemon_local,
mnt_point,
verbose);
- if (handle == NULL)
- {
+
+ if (handle == NULL) {
return DLT_RETURN_ERROR;
}
- else
- {
+ else {
handle->uconfig.logfile_counteridxlen =
- daemon_local->flags.offlineLogstorageMaxCounterIdx;
+ daemon_local->flags.offlineLogstorageMaxCounterIdx;
handle->uconfig.logfile_delimiter =
- daemon_local->flags.offlineLogstorageDelimiter;
+ daemon_local->flags.offlineLogstorageDelimiter;
handle->uconfig.logfile_maxcounter =
- daemon_local->flags.offlineLogstorageMaxCounter;
+ daemon_local->flags.offlineLogstorageMaxCounter;
handle->uconfig.logfile_timestamp =
- daemon_local->flags.offlineLogstorageTimestamp;
+ daemon_local->flags.offlineLogstorageTimestamp;
+
if (dlt_logstorage_sync_caches(handle) != 0)
- {
return DLT_RETURN_ERROR;
- }
}
}
- else /* sync caches for all connected logstorage devices */
- {
+ else { /* sync caches for all connected logstorage devices */
+
for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
if (daemon->storage_handle[i].connection_type ==
- DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
- {
+ DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) {
daemon->storage_handle[i].uconfig.logfile_counteridxlen =
- daemon_local->flags.offlineLogstorageMaxCounterIdx;
+ daemon_local->flags.offlineLogstorageMaxCounterIdx;
daemon->storage_handle[i].uconfig.logfile_delimiter =
- daemon_local->flags.offlineLogstorageDelimiter;
+ daemon_local->flags.offlineLogstorageDelimiter;
daemon->storage_handle[i].uconfig.logfile_maxcounter =
- daemon_local->flags.offlineLogstorageMaxCounter;
+ daemon_local->flags.offlineLogstorageMaxCounter;
daemon->storage_handle[i].uconfig.logfile_timestamp =
- daemon_local->flags.offlineLogstorageTimestamp;
+ daemon_local->flags.offlineLogstorageTimestamp;
+
if (dlt_logstorage_sync_caches(&daemon->storage_handle[i]) != 0)
- {
return DLT_RETURN_ERROR;
- }
}
- }
}
return 0;
@@ -1326,24 +1181,20 @@ DltLogStorage *dlt_daemon_logstorage_get_device(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (mnt_point == NULL))
- {
return NULL;
- }
len1 = strlen(mnt_point);
- for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
+ for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
len2 = strlen(daemon->storage_handle[i].device_mount_point);
/* Check if the requested device path is already used as log storage
* device. Check for strlen first, to avoid comparison errors when
* final '/' is given or not */
len = len1 > len2 ? len2 : len1;
+
if (strncmp(daemon->storage_handle[i].device_mount_point, mnt_point, len) == 0)
- {
return &daemon->storage_handle[i];
- }
}
return NULL;
diff --git a/src/daemon/dlt_daemon_offline_logstorage_internal.h b/src/daemon/dlt_daemon_offline_logstorage_internal.h
index cf5c593..4ad22c3 100644
--- a/src/daemon/dlt_daemon_offline_logstorage_internal.h
+++ b/src/daemon/dlt_daemon_offline_logstorage_internal.h
@@ -72,9 +72,9 @@ DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon,
int verbose);
DltReturnValue dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *key,
- int curr_log_level,
- int verbose);
+ DltDaemonLocal *daemon_local,
+ char *key,
+ int curr_log_level,
+ int verbose);
#endif
diff --git a/src/daemon/dlt_daemon_serial.c b/src/daemon/dlt_daemon_serial.c
index cafcf80..58c2a67 100644
--- a/src/daemon/dlt_daemon_serial.c
+++ b/src/daemon/dlt_daemon_serial.c
@@ -70,28 +70,24 @@
#include "dlt_daemon_serial.h"
-int dlt_daemon_serial_send(int sock,void* data1,int size1,void* data2,int size2,char serialheader)
+int dlt_daemon_serial_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader)
{
/* Optional: Send serial header, if requested */
if (serialheader)
- {
- if ( 0 > write(sock, dltSerialHeader,sizeof(dltSerialHeader)) )
+ if (0 > write(sock, dltSerialHeader, sizeof(dltSerialHeader)))
return DLT_DAEMON_ERROR_SEND_FAILED;
- }
-
/* Send data */
- if(data1 && size1>0)
- {
- if (0 > write(sock, data1,size1))
+
+ if (data1 && (size1 > 0))
+ if (0 > write(sock, data1, size1))
return DLT_DAEMON_ERROR_SEND_FAILED;
- }
- if(data2 && size2>0)
- {
- if (0 > write(sock, data2,size2))
- return DLT_DAEMON_ERROR_SEND_FAILED;
- }
+
+
+ if (data2 && (size2 > 0))
+ if (0 > write(sock, data2, size2))
+ return DLT_DAEMON_ERROR_SEND_FAILED;
return DLT_DAEMON_ERROR_OK;
}
diff --git a/src/daemon/dlt_daemon_serial.h b/src/daemon/dlt_daemon_serial.h
index d5ffb0a..fb540bf 100644
--- a/src/daemon/dlt_daemon_serial.h
+++ b/src/daemon/dlt_daemon_serial.h
@@ -62,6 +62,6 @@
#include "dlt_common.h"
#include "dlt_user.h"
-int dlt_daemon_serial_send(int sock,void* data1,int size1,void* data2,int size2,char serialheader);
+int dlt_daemon_serial_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader);
#endif /* DLT_DAEMON_SERIAL_H */
diff --git a/src/daemon/dlt_daemon_socket.c b/src/daemon/dlt_daemon_socket.c
index f51d803..5a45195 100644
--- a/src/daemon/dlt_daemon_socket.c
+++ b/src/daemon/dlt_daemon_socket.c
@@ -45,12 +45,12 @@
#include <net/if.h>
#ifdef linux
-#include <sys/timerfd.h>
+# include <sys/timerfd.h>
#endif
#include <sys/stat.h>
#include <sys/time.h>
#if defined(linux) && defined(__NR_statx)
-#include <linux/stat.h>
+# include <linux/stat.h>
#endif
#include "dlt_types.h"
@@ -72,20 +72,21 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort)
memset(&hints, 0, sizeof hints);
#ifdef DLT_USE_IPv6
- hints.ai_family = AF_INET6; // force IPv6 - will still work with IPv4
+ hints.ai_family = AF_INET6; /* force IPv6 - will still work with IPv4 */
#else
hints.ai_family = AF_INET;
#endif
hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_PASSIVE; // use my IP address
+ hints.ai_flags = AI_PASSIVE; /* use my IP address */
snprintf(portnumbuffer, 32, "%d", servPort);
+
if ((rv = getaddrinfo(NULL, portnumbuffer, &hints, &servinfo)) != 0) {
dlt_vlog(LOG_WARNING, "getaddrinfo error %d: %s\n", rv, gai_strerror(rv));
return -1;
}
- for(p = servinfo; p != NULL; p = p->ai_next) {
+ for (p = servinfo; p != NULL; p = p->ai_next) {
if ((*sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
const int lastErrno = errno;
dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno, strerror(lastErrno));
@@ -96,15 +97,17 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort)
__FUNCTION__, p->ai_family, p->ai_socktype, p->ai_protocol);
dlt_log(LOG_INFO, str);
- if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1)
- {
+ if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
const int lastErrno = errno;
- dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: Setsockopt error %d in dlt_daemon_local_connection_init: %s\n", lastErrno, strerror(lastErrno));
+ dlt_vlog(LOG_WARNING,
+ "dlt_daemon_socket_open: Setsockopt error %d in dlt_daemon_local_connection_init: %s\n",
+ lastErrno,
+ strerror(lastErrno));
continue;
}
if (bind(*sock, p->ai_addr, p->ai_addrlen) == -1) {
- const int lastErrno = errno; //close() may set errno too
+ const int lastErrno = errno; /*close() may set errno too */
close(*sock);
dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: bind() error %d: %s\n", lastErrno, strerror(lastErrno));
continue;
@@ -123,18 +126,21 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort)
snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "%s: Listening on port: %u\n", __FUNCTION__, servPort);
dlt_log(LOG_INFO, str);
- // get socket buffer size
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "dlt_daemon_socket_open: Socket send queue size: %d\n", dlt_daemon_socket_get_send_qeue_max_size(*sock));
+ /* get socket buffer size */
+ snprintf(str,
+ DLT_DAEMON_TEXTBUFSIZE,
+ "dlt_daemon_socket_open: Socket send queue size: %d\n",
+ dlt_daemon_socket_get_send_qeue_max_size(*sock));
dlt_log(LOG_INFO, str);
- if (listen(*sock, 3) < 0)
- {
+ if (listen(*sock, 3) < 0) {
const int lastErrno = errno;
- dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: listen() failed with error %d: %s\n", lastErrno, strerror(lastErrno));
+ dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: listen() failed with error %d: %s\n", lastErrno,
+ strerror(lastErrno));
return -1;
}
- return 0; // OK
+ return 0; /* OK */
}
int dlt_daemon_socket_close(int sock)
@@ -144,36 +150,32 @@ int dlt_daemon_socket_close(int sock)
return 0;
}
-int dlt_daemon_socket_send(int sock,void* data1,int size1,void* data2,int size2,char serialheader)
+int dlt_daemon_socket_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader)
{
int ret = DLT_RETURN_OK;
int bytes_sent = 0;
-
+
/* Optional: Send serial header, if requested */
- if (serialheader)
- {
+ if (serialheader) {
ret = dlt_daemon_socket_sendreliable(sock,
- (void *) dltSerialHeader,
+ (void *)dltSerialHeader,
sizeof(dltSerialHeader),
&bytes_sent);
+
if (ret != DLT_RETURN_OK)
return ret;
}
/* Send data */
- if ((data1 != NULL) && (size1 > 0))
- {
+ if ((data1 != NULL) && (size1 > 0)) {
ret = dlt_daemon_socket_sendreliable(sock, data1, size1, &bytes_sent);
+
if (ret != DLT_RETURN_OK)
- {
return ret;
- }
}
if ((data2 != NULL) && (size2 > 0))
- {
ret = dlt_daemon_socket_sendreliable(sock, data2, size2, &bytes_sent);
- }
return ret;
}
@@ -187,23 +189,21 @@ int dlt_daemon_socket_get_send_qeue_max_size(int sock)
return n;
}
-int dlt_daemon_socket_sendreliable(int sock, void* data_buffer, int message_size, int* bytes_sent)
+int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size, int *bytes_sent)
{
int data_sent = 0;
- while (data_sent < message_size)
- {
+ while (data_sent < message_size) {
ssize_t ret = send(sock, data_buffer + data_sent, message_size - data_sent, 0);
- if (ret < 0)
- {
+
+ if (ret < 0) {
dlt_vlog(LOG_WARNING,
"dlt_daemon_socket_sendreliable: socket send failed [errno: %d]!\n",
errno);
*bytes_sent = data_sent;
return DLT_DAEMON_ERROR_SEND_FAILED;
}
- else
- {
+ else {
data_sent += ret;
}
}
diff --git a/src/daemon/dlt_daemon_socket.h b/src/daemon/dlt_daemon_socket.h
index 3765c70..7276b2d 100644
--- a/src/daemon/dlt_daemon_socket.h
+++ b/src/daemon/dlt_daemon_socket.h
@@ -67,7 +67,7 @@ int dlt_daemon_socket_close(int sock);
int dlt_daemon_socket_get_send_qeue_max_size(int sock);
-int dlt_daemon_socket_send(int sock, void* data1, int size1, void* data2, int size2, char serialheader);
+int dlt_daemon_socket_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader);
/**
* @brief dlt_daemon_socket_sendreliable - sends data to socket with additional checks and resending functionality - trying to be reliable
@@ -76,6 +76,6 @@ int dlt_daemon_socket_send(int sock, void* data1, int size1, void* data2, int si
* @param message_size
* @return on sucess: DLT_DAEMON_ERROR_OK, on error: DLT_DAEMON_ERROR_SEND_FAILED
*/
-int dlt_daemon_socket_sendreliable(int sock, void* data_buffer, int message_size, int* bytes_sent);
+int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size, int *bytes_sent);
#endif /* DLT_DAEMON_SOCKET_H */
diff --git a/src/daemon/dlt_daemon_unix_socket.c b/src/daemon/dlt_daemon_unix_socket.c
index 0ed92ad..743035a 100644
--- a/src/daemon/dlt_daemon_unix_socket.c
+++ b/src/daemon/dlt_daemon_unix_socket.c
@@ -47,14 +47,12 @@ int dlt_daemon_unix_socket_open(int *sock, char *sock_path, int type, int mask)
struct sockaddr_un addr;
int old_mask;
- if (sock == NULL || sock_path == NULL)
- {
+ if ((sock == NULL) || (sock_path == NULL)) {
dlt_log(LOG_ERR, "dlt_daemon_unix_socket_open: arguments invalid");
return -1;
}
- if ((*sock = socket(AF_UNIX, type, 0)) == -1)
- {
+ if ((*sock = socket(AF_UNIX, type, 0)) == -1) {
dlt_log(LOG_WARNING, "unix socket: socket() error");
return -1;
}
@@ -68,14 +66,12 @@ int dlt_daemon_unix_socket_open(int *sock, char *sock_path, int type, int mask)
/* set appropriate access permissions */
old_mask = umask(mask);
- if (bind(*sock, (struct sockaddr *) &addr, sizeof(addr)) == -1)
- {
+ if (bind(*sock, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
dlt_log(LOG_WARNING, "unix socket: bind() error");
return -1;
}
- if (listen(*sock, 1) == -1)
- {
+ if (listen(*sock, 1) == -1) {
dlt_log(LOG_WARNING, "unix socket: listen error");
return -1;
}
@@ -90,8 +86,7 @@ int dlt_daemon_unix_socket_close(int sock)
{
int ret = close(sock);
- if (ret != 0)
- {
+ if (ret != 0) {
sprintf(err_string, "unix socket close failed: %s", strerror(errno));
dlt_log(LOG_WARNING, err_string);
}
diff --git a/src/dbus/dlt-dbus-options.c b/src/dbus/dlt-dbus-options.c
index 27bf4f4..fc5b584 100644
--- a/src/dbus/dlt-dbus-options.c
+++ b/src/dbus/dlt-dbus-options.c
@@ -37,7 +37,7 @@
void usage(char *prog_name)
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: %s [options]\n", prog_name);
printf("Application to forward dbus messages to DLT.\n");
@@ -57,10 +57,10 @@ void usage(char *prog_name)
*/
void init_cli_options(DltDBusCliOptions *options)
{
- options->ConfigurationFileName = DEFAULT_CONF_FILE;
- options->ApplicationId = 0;
- options->BusType = 0;
- options->Daemonize = 0;
+ options->ConfigurationFileName = DEFAULT_CONF_FILE;
+ options->ApplicationId = 0;
+ options->BusType = 0;
+ options->Daemonize = 0;
}
/**
@@ -71,49 +71,48 @@ int read_command_line(DltDBusCliOptions *options, int argc, char *argv[])
init_cli_options(options);
int opt;
- while((opt = getopt(argc, argv, "c:b:a:hd")) != -1)
- {
- switch(opt) {
- case 'd':
- {
- options->Daemonize = 1;
- break;
- }
- case 'b':
- {
- options->BusType = malloc(strlen(optarg)+1);
- MALLOC_ASSERT(options->BusType);
- strcpy(options->BusType, optarg); /* strcpy unritical here, because size matches exactly the size to be copied */
- break;
- }
- case 'a':
- {
- options->ApplicationId = malloc(strlen(optarg)+1);
- MALLOC_ASSERT(options->ApplicationId);
- strcpy(options->ApplicationId, optarg); /* strcpy unritical here, because size matches exactly the size to be copied */
- break;
- }
- case 'c':
- {
- options->ConfigurationFileName = malloc(strlen(optarg)+1);
- MALLOC_ASSERT(options->ConfigurationFileName);
- strcpy(options->ConfigurationFileName, optarg); /* strcpy unritical here, because size matches exactly the size to be copied */
- break;
- }
- case 'h':
- {
- usage(argv[0]);
- exit(0);
- return -1;//for parasoft
- }
- default:
- {
- fprintf(stderr, "Unknown option '%c'\n", optopt);
- usage(argv[0]);
- return -1;
- }
+ while ((opt = getopt(argc, argv, "c:b:a:hd")) != -1)
+ switch (opt) {
+ case 'd':
+ {
+ options->Daemonize = 1;
+ break;
}
- }
+ case 'b':
+ {
+ options->BusType = malloc(strlen(optarg) + 1);
+ MALLOC_ASSERT(options->BusType);
+ strcpy(options->BusType, optarg); /* strcpy unritical here, because size matches exactly the size to be copied */
+ break;
+ }
+ case 'a':
+ {
+ options->ApplicationId = malloc(strlen(optarg) + 1);
+ MALLOC_ASSERT(options->ApplicationId);
+ strcpy(options->ApplicationId, optarg); /* strcpy unritical here, because size matches exactly the size to be copied */
+ break;
+ }
+ case 'c':
+ {
+ options->ConfigurationFileName = malloc(strlen(optarg) + 1);
+ MALLOC_ASSERT(options->ConfigurationFileName);
+ strcpy(options->ConfigurationFileName, optarg); /* strcpy unritical here, because size matches exactly the size to be copied */
+ break;
+ }
+ case 'h':
+ {
+ usage(argv[0]);
+ exit(0);
+ return -1; /*for parasoft */
+ }
+ default:
+ {
+ fprintf(stderr, "Unknown option '%c'\n", optopt);
+ usage(argv[0]);
+ return -1;
+ }
+ }
+
return 0;
}
@@ -122,13 +121,13 @@ int read_command_line(DltDBusCliOptions *options, int argc, char *argv[])
*/
void init_configuration(DltDBusConfiguration *config)
{
- // Common
- config->ApplicationId = "IPC0";
+ /* Common */
+ config->ApplicationId = "IPC0";
- // DBus
- config->DBus.ContextId = "ALL";
- config->DBus.BusType = 0;
- config->DBus.FilterCount = 0;
+ /* DBus */
+ config->DBus.ContextId = "ALL";
+ config->DBus.BusType = 0;
+ config->DBus.FilterCount = 0;
}
@@ -140,14 +139,13 @@ int read_configuration_file(DltDBusConfiguration *config, char *file_name)
FILE *file;
char *line, *token, *value, *filter, *pch;
int ret = 0;
- char *filterBegin,*filterEnd;
+ char *filterBegin, *filterEnd;
init_configuration(config);
file = fopen(file_name, "r");
- if(file == NULL)
- {
+ if (file == NULL) {
fprintf(stderr, "dlt-dbus-options, could not open configuration file.\n");
return -1;
}
@@ -162,78 +160,69 @@ int read_configuration_file(DltDBusConfiguration *config, char *file_name)
MALLOC_ASSERT(value);
MALLOC_ASSERT(filter);
- while(fgets(line, MAX_LINE, file) != NULL)
- {
+ while (fgets(line, MAX_LINE, file) != NULL) {
token[0] = 0;
value[0] = 0;
filter[0] = 0;
- filterBegin = strchr(line,'=');
- filterEnd = strpbrk (line,"\r\n");
+ filterBegin = strchr(line, '=');
+ filterEnd = strpbrk (line, "\r\n");
- if(filterBegin)
- {
- if(filterEnd && (filterEnd>filterBegin))
- {
- strncpy(filter,filterBegin+1,filterEnd-filterBegin-1);
- filter[filterEnd-filterBegin-1]=0;
+ if (filterBegin) {
+ if (filterEnd && (filterEnd > filterBegin)) {
+ strncpy(filter, filterBegin + 1, filterEnd - filterBegin - 1);
+ filter[filterEnd - filterBegin - 1] = 0;
}
- else
- {
- strcpy(filter,filterBegin+1);
+ else {
+ strcpy(filter, filterBegin + 1);
}
}
pch = strtok (line, " =\r\n");
- while(pch != NULL)
- {
- if(pch[0] == '#')
+
+ while (pch != NULL) {
+ if (pch[0] == '#')
break;
- if(token[0] == 0)
- {
- strncpy(token, pch, MAX_LINE-1);
- token[MAX_LINE-1]=0;
+ if (token[0] == 0) {
+ strncpy(token, pch, MAX_LINE - 1);
+ token[MAX_LINE - 1] = 0;
}
- else
- {
+ else {
strncpy(value, pch, MAX_LINE);
- value[MAX_LINE-1]=0;
+ value[MAX_LINE - 1] = 0;
break;
}
pch = strtok (NULL, " =\r\n");
}
- if(token[0] && value[0])
- {
- // Common
- if(strcmp(token, "ApplicationId") == 0)
- {
- config->ApplicationId = malloc(strlen(value)+1);
+ if (token[0] && value[0]) {
+ /* Common */
+ if (strcmp(token, "ApplicationId") == 0) {
+ config->ApplicationId = malloc(strlen(value) + 1);
MALLOC_ASSERT(config->ApplicationId);
strcpy(config->ApplicationId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
}
- // ContextId
- else if(strcmp(token, "ContextId") == 0)
+ /* ContextId */
+ else if (strcmp(token, "ContextId") == 0)
{
- config->DBus.ContextId = malloc(strlen(value)+1);
+ config->DBus.ContextId = malloc(strlen(value) + 1);
MALLOC_ASSERT(config->DBus.ContextId);
strcpy(config->DBus.ContextId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
}
- // BusType
- else if(strcmp(token, "BusType") == 0)
+ /* BusType */
+ else if (strcmp(token, "BusType") == 0)
{
- config->DBus.BusType = malloc(strlen(value)+1);
+ config->DBus.BusType = malloc(strlen(value) + 1);
MALLOC_ASSERT(config->DBus.BusType);
strcpy(config->DBus.BusType, value); /* strcpy unritical here, because size matches exactly the size to be copied */
}
- // BusType
- else if(strcmp(token, "FilterMatch") == 0)
+ /* BusType */
+ else if (strcmp(token, "FilterMatch") == 0)
{
- if(config->DBus.FilterCount<DLT_DBUS_FILTER_MAX)
- {
- config->DBus.FilterMatch[config->DBus.FilterCount]= malloc(strlen(filter)+1);
+ if (config->DBus.FilterCount < DLT_DBUS_FILTER_MAX) {
+ config->DBus.FilterMatch[config->DBus.FilterCount] = malloc(strlen(filter) + 1);
MALLOC_ASSERT(config->DBus.FilterMatch[config->DBus.FilterCount]);
strcpy(config->DBus.FilterMatch[config->DBus.FilterCount], filter);
config->DBus.FilterCount++;
@@ -241,6 +230,7 @@ int read_configuration_file(DltDBusConfiguration *config, char *file_name)
}
}
}
+
fclose(file);
free(value);
free(token);
diff --git a/src/dbus/dlt-dbus.c b/src/dbus/dlt-dbus.c
index a42d02c..54dce33 100644
--- a/src/dbus/dlt-dbus.c
+++ b/src/dbus/dlt-dbus.c
@@ -45,40 +45,38 @@ filter_func (DBusConnection *con,
DBusMessage *message,
void *data)
{
- char **buf;
- int len_p;
- UNUSED(con);
- UNUSED(data);
-
- buf = (char**)&dbus_message_buffer;
- if (!dbus_message_marshal(message,
- buf,
- &len_p))
- {
- fprintf (stderr, "Failed to serialize DBus message!\n");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- DLT_TRACE_NETWORK_SEGMENTED(dbusContext,DLT_NW_TRACE_IPC,0,0,len_p,(void *)*buf);
+ char **buf;
+ int len_p;
+ UNUSED(con);
+ UNUSED(data);
+
+ buf = (char **)&dbus_message_buffer;
+
+ if (!dbus_message_marshal(message,
+ buf,
+ &len_p)) {
+ fprintf (stderr, "Failed to serialize DBus message!\n");
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
- free(*buf);
- *buf = NULL;
+ DLT_TRACE_NETWORK_SEGMENTED(dbusContext, DLT_NW_TRACE_IPC, 0, 0, len_p, (void *)*buf);
- if (dbus_message_is_signal (message,
- DBUS_INTERFACE_LOCAL,
- "Disconnected"))
- {
- DLT_UNREGISTER_CONTEXT (dbusContext);
- DLT_UNREGISTER_APP ();
- exit (0);
- }
+ free(*buf);
+ *buf = NULL;
+ if (dbus_message_is_signal (message,
+ DBUS_INTERFACE_LOCAL,
+ "Disconnected")) {
+ DLT_UNREGISTER_CONTEXT (dbusContext);
+ DLT_UNREGISTER_APP ();
+ exit (0);
+ }
- /* Conceptually we want this to be
- * DBUS_HANDLER_RESULT_NOT_YET_HANDLED, but this raises
- * some problems. See bug 1719.
- */
- return DBUS_HANDLER_RESULT_HANDLED;
+ /* Conceptually we want this to be
+ * DBUS_HANDLER_RESULT_NOT_YET_HANDLED, but this raises
+ * some problems. See bug 1719.
+ */
+ return DBUS_HANDLER_RESULT_HANDLED;
}
int main (int argc, char *argv[])
@@ -92,74 +90,76 @@ int main (int argc, char *argv[])
int num;
- if(read_command_line(&options, argc, argv) < 0)
- {
+ if (read_command_line(&options, argc, argv) < 0) {
fprintf(stderr, "Failed to read command line!\n");
return -1;
}
- if(read_configuration_file(&config, options.ConfigurationFileName) < 0)
- {
+ if (read_configuration_file(&config, options.ConfigurationFileName) < 0) {
fprintf(stderr, "Failed to read configuration file!\n");
return -1;
}
- // register application
- if(options.ApplicationId)
+ /* register application */
+ if (options.ApplicationId)
DLT_REGISTER_APP (options.ApplicationId, "DBus Logging");
else
DLT_REGISTER_APP (config.ApplicationId, "DBus Logging");
- // register context
- DLT_REGISTER_CONTEXT_LL_TS(dbusContext, config.DBus.ContextId, "DBus Context for Logging",DLT_LOG_INFO,DLT_TRACE_STATUS_ON);
+ /* register context */
+ DLT_REGISTER_CONTEXT_LL_TS(dbusContext,
+ config.DBus.ContextId,
+ "DBus Context for Logging",
+ DLT_LOG_INFO,
+ DLT_TRACE_STATUS_ON);
DLT_REGISTER_CONTEXT(dbusLog, "Log", "DBus Context for Logging Generic information");
- // initialise error handler
+ /* initialise error handler */
dbus_error_init (&error);
- // set DBus bus type
- if(options.BusType)
- type = (DBusBusType) atoi(options.BusType);
+ /* set DBus bus type */
+ if (options.BusType)
+ type = (DBusBusType)atoi(options.BusType);
else
- type = (DBusBusType) atoi(config.DBus.BusType);
+ type = (DBusBusType)atoi(config.DBus.BusType);
- // get connection
+ /* get connection */
connection = dbus_bus_get (type, &error);
- if(type==0)
- DLT_LOG(dbusLog,DLT_LOG_INFO,DLT_STRING("BusType"),DLT_STRING("Session Bus"));
- else if(type==1)
- DLT_LOG(dbusLog,DLT_LOG_INFO,DLT_STRING("BusType"),DLT_STRING("System Bus"));
+ if (type == 0)
+ DLT_LOG(dbusLog, DLT_LOG_INFO, DLT_STRING("BusType"), DLT_STRING("Session Bus"));
+ else if (type == 1)
+ DLT_LOG(dbusLog, DLT_LOG_INFO, DLT_STRING("BusType"), DLT_STRING("System Bus"));
else
- DLT_LOG(dbusLog,DLT_LOG_INFO,DLT_STRING("BusType"),DLT_INT(type));
-
- if (NULL == connection)
- {
- fprintf (stderr, "Failed to open connection to %d: %s\n",
- DBUS_BUS_SYSTEM,
- error.message);
- dbus_error_free (&error);
- exit (1);
+ DLT_LOG(dbusLog, DLT_LOG_INFO, DLT_STRING("BusType"), DLT_INT(type));
+
+ if (NULL == connection) {
+ fprintf (stderr, "Failed to open connection to %d: %s\n",
+ DBUS_BUS_SYSTEM,
+ error.message);
+ dbus_error_free (&error);
+ exit (1);
}
- for(num=0;num<config.DBus.FilterCount;num++)
- {
+ for (num = 0; num < config.DBus.FilterCount; num++) {
dbus_bus_add_match (connection,
- config.DBus.FilterMatch[num],
- &error);
- printf("Added FilterMatch: %s\n",config.DBus.FilterMatch[num]);
- DLT_LOG(dbusLog,DLT_LOG_INFO,DLT_STRING("FilterMatch"),DLT_UINT(num+1),DLT_STRING(config.DBus.FilterMatch[num]));
+ config.DBus.FilterMatch[num],
+ &error);
+ printf("Added FilterMatch: %s\n", config.DBus.FilterMatch[num]);
+ DLT_LOG(dbusLog, DLT_LOG_INFO, DLT_STRING("FilterMatch"), DLT_UINT(num + 1),
+ DLT_STRING(config.DBus.FilterMatch[num]));
+
if (dbus_error_is_set (&error))
- goto fail;
+ goto fail;
}
if (!dbus_connection_add_filter (connection, filter_func, NULL, NULL)) {
- fprintf (stderr, "Couldn't add filter!\n");
- exit (1);
+ fprintf (stderr, "Couldn't add filter!\n");
+ exit (1);
}
while (dbus_connection_read_write_dispatch(connection, -1))
- ;
+ ;
DLT_UNREGISTER_CONTEXT (dbusContext);
DLT_UNREGISTER_CONTEXT (dbusLog);
diff --git a/src/dbus/dlt-dbus.h b/src/dbus/dlt-dbus.h
index 50a26e8..6f553d9 100644
--- a/src/dbus/dlt-dbus.h
+++ b/src/dbus/dlt-dbus.h
@@ -27,7 +27,7 @@
#ifndef DLT_DBUS_H_
#define DLT_DBUS_H_
-// DLT related includes.
+/* DLT related includes. */
#include "dlt.h"
#include "dlt_common.h"
@@ -35,33 +35,33 @@
#define DLT_DBUS_FILTER_MAX 32
-// Macros
+/* Macros */
#define UNUSED(x) (void)(x)
-#define MALLOC_ASSERT(x) if(x == NULL) {\
- fprintf(stderr, "Out of memory\n");\
- abort();}
+#define MALLOC_ASSERT(x) if (x == NULL) { \
+ fprintf(stderr, "Out of memory\n"); \
+ abort(); }
#define MAX_LINE 1024
-// Command line options
+/* Command line options */
typedef struct {
- char *ConfigurationFileName;
- char *ApplicationId;
- char *BusType;
- int Daemonize;
+ char *ConfigurationFileName;
+ char *ApplicationId;
+ char *BusType;
+ int Daemonize;
} DltDBusCliOptions;
-// Configuration dbus options
+/* Configuration dbus options */
typedef struct {
- char *ContextId;
- char *BusType;
- int FilterCount;
+ char *ContextId;
+ char *BusType;
+ int FilterCount;
char *FilterMatch[DLT_DBUS_FILTER_MAX];
} DBusOptions;
typedef struct {
char *ApplicationId;
- DBusOptions DBus;
+ DBusOptions DBus;
} DltDBusConfiguration;
diff --git a/src/examples/dlt-example-filetransfer.c b/src/examples/dlt-example-filetransfer.c
index 0f4f038..f7028df 100644
--- a/src/examples/dlt-example-filetransfer.c
+++ b/src/examples/dlt-example-filetransfer.c
@@ -72,7 +72,7 @@
#define TIMEOUT 1
-//!Declare some context for the file transfer. It's not a must have to do this, but later you can set a filter on this context in the dlt viewer.
+/*!Declare some context for the file transfer. It's not a must have to do this, but later you can set a filter on this context in the dlt viewer. */
DLT_DECLARE_CONTEXT(fileContext)
@@ -83,7 +83,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-example-filetransfer [options] absolute-path-to-file\n");
printf("Simple filetransfer example");
@@ -99,16 +99,16 @@ void usage()
}
-//!Main program dlt-test-filestransfer starts here
-int main(int argc, char* argv[])
+/*!Main program dlt-test-filestransfer starts here */
+int main(int argc, char *argv[])
{
- //char str[MAXSTRLEN];
+ /*char str[MAXSTRLEN]; */
int opt, timeout;
char apid[DLT_ID_SIZE];
char ctid[DLT_ID_SIZE];
- //char version[255];
+ /*char version[255]; */
int index;
int dflag = 0;
int iflag = 0;
@@ -119,9 +119,7 @@ int main(int argc, char* argv[])
dlt_set_id(ctid, FLTR_CONTEXT);
while ((opt = getopt(argc, argv, "idf:t:a:c:h")) != -1)
- {
- switch (opt)
- {
+ switch (opt) {
case 'd':
{
dflag = 1;
@@ -139,12 +137,12 @@ int main(int argc, char* argv[])
}
case 'a':
{
- dlt_set_id(apid,optarg);
+ dlt_set_id(apid, optarg);
break;
}
case 'c':
{
- dlt_set_id(ctid,optarg);
+ dlt_set_id(ctid, optarg);
break;
}
case 'h':
@@ -154,68 +152,52 @@ int main(int argc, char* argv[])
}
case '?':
{
- if (optopt == 'a' || optopt == 'c' || optopt == 't')
- {
+ if ((optopt == 'a') || (optopt == 'c') || (optopt == 't'))
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
/* unknown or wrong option used, show usage information and terminate */
usage();
return -1;
}
}
- }
+
+
for (index = optind; index < argc; index++)
- {
file = argv[index];
- }
- if (file == 0)
- {
+ if (file == 0) {
/* no message, show usage and terminate */
- fprintf(stderr,"ERROR: No absolute path to file specified\n");
+ fprintf(stderr, "ERROR: No absolute path to file specified\n");
usage();
return -1;
}
-
if (tvalue)
- {
timeout = atoi(tvalue);
- }
else
- {
timeout = TIMEOUT;
- }
- //Register the application at the dlt-daemon
- DLT_REGISTER_APP(apid,FLTR_APP_DESC);
+ /*Register the application at the dlt-daemon */
+ DLT_REGISTER_APP(apid, FLTR_APP_DESC);
- //Register the context of the main program at the dlt-daemon
- DLT_REGISTER_CONTEXT(fileContext,ctid,FLTR_CONTEXT_DESC);
+ /*Register the context of the main program at the dlt-daemon */
+ DLT_REGISTER_CONTEXT(fileContext, ctid, FLTR_CONTEXT_DESC);
- //More details in corresponding methods
- if( iflag )
- {
- dlt_user_log_file_infoAbout(&fileContext,file);
- }
+ /*More details in corresponding methods */
+ if (iflag)
+ dlt_user_log_file_infoAbout(&fileContext, file);
- if( dlt_user_log_file_complete(&fileContext,file,dflag,timeout) < 0 )
- {
+ if (dlt_user_log_file_complete(&fileContext, file, dflag, timeout) < 0)
printf("File couldn't be transferred. Please check the dlt log messages.\n");
- }
- //Unregister the context in which the file transfer happened from the dlt-daemon
+ /*Unregister the context in which the file transfer happened from the dlt-daemon */
DLT_UNREGISTER_CONTEXT(fileContext);
- //Unregister the context of the main program from the dlt-daemon
+ /*Unregister the context of the main program from the dlt-daemon */
DLT_UNREGISTER_APP();
return 0;
diff --git a/src/examples/dlt-example-user-common-api.c b/src/examples/dlt-example-user-common-api.c
index 171ca89..880ea97 100644
--- a/src/examples/dlt-example-user-common-api.c
+++ b/src/examples/dlt-example-user-common-api.c
@@ -72,7 +72,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-example-common-api [options] message\n");
printf("Generate DLT messages and store them to file or send them to daemon.\n");
@@ -94,7 +94,7 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
#ifdef DLT_TEST_ENABLE
int cflag = 0;
@@ -110,20 +110,21 @@ int main(int argc, char* argv[])
int c;
char *text;
- int num,maxnum;
+ int num, maxnum;
int delay;
- int state=-1,newstate;
+ int state = -1, newstate;
opterr = 0;
#ifdef DLT_TEST_ENABLE
+
while ((c = getopt (argc, argv, "vgcd:n:z:s:")) != -1)
#else
+
while ((c = getopt (argc, argv, "vgd:n:")) != -1)
#endif /* DLT_TEST_ENABLE */
{
- switch (c)
- {
+ switch (c) {
#ifdef DLT_TEST_ENABLE
case 'c':
{
@@ -158,18 +159,12 @@ int main(int argc, char* argv[])
}
case '?':
{
- if (optopt == 'd' || optopt == 'f' || optopt == 'n')
- {
+ if ((optopt == 'd') || (optopt == 'f') || (optopt == 'n'))
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
/* unknown or wrong option used, show usage information and terminate */
usage();
@@ -178,114 +173,93 @@ int main(int argc, char* argv[])
default:
{
abort ();
- break;//for parasoft
+ break;/*for parasoft */
}
}
}
for (index = optind; index < argc; index++)
- {
message = argv[index];
- }
- if (message == 0)
- {
+ if (message == 0) {
/* no message, show usage and terminate */
- fprintf(stderr,"ERROR: No message selected\n");
+ fprintf(stderr, "ERROR: No message selected\n");
usage();
return -1;
}
- DLT_REGISTER_APP("LOG","Test Application for Logging");
- DLT_REGISTER_CONTEXT_APP(mycontext,"TEST","LOG","Test Context for Logging");
+ DLT_REGISTER_APP("LOG", "Test Application for Logging");
+ DLT_REGISTER_CONTEXT_APP(mycontext, "TEST", "LOG", "Test Context for Logging");
text = message;
if (nvalue)
- {
maxnum = atoi(nvalue);
- }
else
- {
maxnum = 10;
- }
if (dvalue)
- {
delay = atoi(dvalue) * 1000;
- }
else
- {
delay = 500 * 1000;
- }
- if (gflag)
- {
+ if (gflag) {
/* DLT messages to test Fibex non-verbose description: dlt-example-non-verbose.xml */
- DLT_LOG_ID0(mycontext,DLT_LOG_INFO,10);
- DLT_LOG_ID1(mycontext,DLT_LOG_INFO,11,DLT_UINT16(1011));
- DLT_LOG_ID2(mycontext,DLT_LOG_INFO,12,DLT_UINT32(1012),DLT_UINT32(1013));
- DLT_LOG_ID2(mycontext,DLT_LOG_INFO,13,DLT_UINT8(123),DLT_FLOAT32(1.12));
- DLT_LOG_ID1(mycontext,DLT_LOG_INFO,14,DLT_STRING("DEAD BEEF"));
+ DLT_LOG_ID0(mycontext, DLT_LOG_INFO, 10);
+ DLT_LOG_ID1(mycontext, DLT_LOG_INFO, 11, DLT_UINT16(1011));
+ DLT_LOG_ID2(mycontext, DLT_LOG_INFO, 12, DLT_UINT32(1012), DLT_UINT32(1013));
+ DLT_LOG_ID2(mycontext, DLT_LOG_INFO, 13, DLT_UINT8(123), DLT_FLOAT32(1.12));
+ DLT_LOG_ID1(mycontext, DLT_LOG_INFO, 14, DLT_STRING("DEAD BEEF"));
}
#ifdef DLT_TEST_ENABLE
+
if (cflag)
- {
dlt_user_test_corrupt_user_header(1);
- }
+
if (svalue)
- {
- dlt_user_test_corrupt_message_size(1,atoi(svalue));
- }
- if (zvalue)
- {
- char* buffer = malloc(atoi(zvalue));
- if(buffer==0)
- {
+ dlt_user_test_corrupt_message_size(1, atoi(svalue));
+
+ if (zvalue) {
+ char *buffer = malloc(atoi(zvalue));
+
+ if (buffer == 0) {
/* no message, show usage and terminate */
- fprintf(stderr,"Cannot allocate buffer memory!\n");
+ fprintf(stderr, "Cannot allocate buffer memory!\n");
return -1;
}
- DLT_LOG2(mycontext,DLT_LOG_WARN,DLT_STRING(text),DLT_RAW(buffer,atoi(zvalue)));
+
+ DLT_LOG2(mycontext, DLT_LOG_WARN, DLT_STRING(text), DLT_RAW(buffer, atoi(zvalue)));
free(buffer);
}
+
#endif /* DLT_TEST_ENABLE */
- for (num=0;num<maxnum;num++)
- {
- printf("Send %d %s\n",num,text);
+ for (num = 0; num < maxnum; num++) {
+ printf("Send %d %s\n", num, text);
newstate = dlt_get_log_state();
- if(state!=newstate)
- {
+
+ if (state != newstate) {
state = newstate;
- if(state == -1) {
+
+ if (state == -1)
printf("Client unknown state!\n");
- }
- else if(state == 0) {
+ else if (state == 0)
printf("Client disconnected!\n");
- }
- else if(state == 1) {
+ else if (state == 1)
printf("Client connected!\n");
- }
}
if (gflag)
- {
/* Non-verbose mode */
- DLT_LOG_ID2(mycontext,DLT_LOG_WARN,num,DLT_INT(num),DLT_STRING(text));
- }
+ DLT_LOG_ID2(mycontext, DLT_LOG_WARN, num, DLT_INT(num), DLT_STRING(text));
else
- {
/* Verbose mode */
- DLT_LOG2(mycontext,DLT_LOG_WARN,DLT_INT(num),DLT_STRING(text));
- }
+ DLT_LOG2(mycontext, DLT_LOG_WARN, DLT_INT(num), DLT_STRING(text));
- if (delay>0)
- {
+ if (delay > 0)
usleep(delay);
- }
}
sleep(1);
diff --git a/src/examples/dlt-example-user-func.c b/src/examples/dlt-example-user-func.c
index 68b3397..b29ff9f 100644
--- a/src/examples/dlt-example-user-func.c
+++ b/src/examples/dlt-example-user-func.c
@@ -63,8 +63,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <netdb.h>
#include <ctype.h>
@@ -88,7 +88,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-example-user-func [options] message\n");
printf("Generate DLT messages and store them to file or send them to daemon.\n");
@@ -104,7 +104,7 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
int gflag = 0;
int aflag = 0;
@@ -116,15 +116,13 @@ int main(int argc, char* argv[])
int index;
int c;
char *text;
- int num,maxnum;
+ int num, maxnum;
int delay;
opterr = 0;
while ((c = getopt (argc, argv, "vgad:f:n:")) != -1)
- {
- switch (c)
- {
+ switch (c) {
case 'g':
{
gflag = 1;
@@ -152,18 +150,12 @@ int main(int argc, char* argv[])
}
case '?':
{
- if (optopt == 'd' || optopt == 'f' || optopt == 'n')
- {
+ if ((optopt == 'd') || (optopt == 'f') || (optopt == 'n'))
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
/* unknown or wrong option used, show usage information and terminate */
usage();
@@ -172,129 +164,101 @@ int main(int argc, char* argv[])
default:
{
abort ();
- return -1;//for parasoft
+ return -1;/*for parasoft */
}
}
- }
+
+
for (index = optind; index < argc; index++)
- {
message = argv[index];
- }
- if (message == 0)
- {
+ if (message == 0) {
/* no message, show usage and terminate */
- fprintf(stderr,"ERROR: No message selected\n");
+ fprintf(stderr, "ERROR: No message selected\n");
usage();
return -1;
}
- if (fvalue)
- {
+ if (fvalue) {
/* DLT is intialised automatically, except another output target will be used */
- if (dlt_init_file(fvalue)<0) /* log to file */
- {
+ if (dlt_init_file(fvalue) < 0) /* log to file */
return -1;
- }
}
- dlt_register_app("LOG","Test Application for Logging");
+ dlt_register_app("LOG", "Test Application for Logging");
- dlt_register_context(&mycontext,"TEST","Test Context for Logging");
+ dlt_register_context(&mycontext, "TEST", "Test Context for Logging");
dlt_register_injection_callback(&mycontext, 0xFFF, dlt_user_injection_callback);
text = message;
if (gflag)
- {
dlt_nonverbose_mode();
- }
if (aflag)
- {
dlt_enable_local_print();
- }
if (nvalue)
- {
maxnum = atoi(nvalue);
- }
else
- {
maxnum = 10;
- }
if (dvalue)
- {
delay = atoi(dvalue) * 1000;
- }
else
- {
delay = 500 * 1000;
- }
- if (gflag)
- {
+ if (gflag) {
/* DLT messages to test Fibex non-verbose description: dlt-example-non-verbose.xml */
- if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,10)>0)
- {
+ if (dlt_user_log_write_start_id(&mycontext, &mycontextdata, DLT_LOG_INFO, 10) > 0)
dlt_user_log_write_finish(&mycontextdata);
- }
- if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,11)>0)
- {
- dlt_user_log_write_uint16(&mycontextdata,1011);
+
+ if (dlt_user_log_write_start_id(&mycontext, &mycontextdata, DLT_LOG_INFO, 11) > 0) {
+ dlt_user_log_write_uint16(&mycontextdata, 1011);
dlt_user_log_write_finish(&mycontextdata);
}
- if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,12)>0)
- {
- dlt_user_log_write_uint32(&mycontextdata,1012);
- dlt_user_log_write_uint32(&mycontextdata,1013);
+
+ if (dlt_user_log_write_start_id(&mycontext, &mycontextdata, DLT_LOG_INFO, 12) > 0) {
+ dlt_user_log_write_uint32(&mycontextdata, 1012);
+ dlt_user_log_write_uint32(&mycontextdata, 1013);
dlt_user_log_write_finish(&mycontextdata);
}
- if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,13)>0)
- {
- dlt_user_log_write_uint8(&mycontextdata,123);
- dlt_user_log_write_float32(&mycontextdata,1.12);
+
+ if (dlt_user_log_write_start_id(&mycontext, &mycontextdata, DLT_LOG_INFO, 13) > 0) {
+ dlt_user_log_write_uint8(&mycontextdata, 123);
+ dlt_user_log_write_float32(&mycontextdata, 1.12);
dlt_user_log_write_finish(&mycontextdata);
}
- if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,14)>0)
- {
- dlt_user_log_write_string(&mycontextdata,"DEAD BEEF");
+
+ if (dlt_user_log_write_start_id(&mycontext, &mycontextdata, DLT_LOG_INFO, 14) > 0) {
+ dlt_user_log_write_string(&mycontextdata, "DEAD BEEF");
dlt_user_log_write_finish(&mycontextdata);
}
}
- for (num=0;num<maxnum;num++)
- {
- printf("Send %d %s\n",num,text);
+ for (num = 0; num < maxnum; num++) {
+ printf("Send %d %s\n", num, text);
- if (gflag)
- {
+ if (gflag) {
/* Non-verbose mode */
- if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_WARN,num)>0)
- {
- dlt_user_log_write_int(&mycontextdata,num);
- dlt_user_log_write_string(&mycontextdata,text);
+ if (dlt_user_log_write_start_id(&mycontext, &mycontextdata, DLT_LOG_WARN, num) > 0) {
+ dlt_user_log_write_int(&mycontextdata, num);
+ dlt_user_log_write_string(&mycontextdata, text);
dlt_user_log_write_finish(&mycontextdata);
}
}
else
- {
- /* Verbose mode */
- if (dlt_user_log_write_start(&mycontext,&mycontextdata,DLT_LOG_WARN)>0)
- {
- dlt_user_log_write_int(&mycontextdata,num);
- dlt_user_log_write_string(&mycontextdata,text);
- dlt_user_log_write_finish(&mycontextdata);
- }
+ /* Verbose mode */
+ if (dlt_user_log_write_start(&mycontext, &mycontextdata, DLT_LOG_WARN) > 0) {
+ dlt_user_log_write_int(&mycontextdata, num);
+ dlt_user_log_write_string(&mycontextdata, text);
+ dlt_user_log_write_finish(&mycontextdata);
}
- if (delay>0)
- {
+ if (delay > 0)
usleep(delay);
- }
}
dlt_unregister_context(&mycontext);
@@ -308,10 +272,10 @@ int dlt_user_injection_callback(uint32_t service_id, void *data, uint32_t length
{
char text[1024];
- printf("Injection %d, Length=%d \n",service_id,length);
- if (length>0)
- {
- dlt_print_mixed_string(text,1024,data,length,0);
+ printf("Injection %d, Length=%d \n", service_id, length);
+
+ if (length > 0) {
+ dlt_print_mixed_string(text, 1024, data, length, 0);
printf("%s \n", text);
}
diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c
index df5a163..19cf73f 100644
--- a/src/examples/dlt-example-user.c
+++ b/src/examples/dlt-example-user.c
@@ -63,8 +63,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <netdb.h>
#include <ctype.h>
@@ -79,7 +79,7 @@
int dlt_user_injection_callback(uint32_t service_id, void *data, uint32_t length);
int dlt_user_injection_callback_with_specific_data(uint32_t service_id, void *data, uint32_t length, void *priv_data);
-void dlt_user_log_level_changed_callback(char context_id[DLT_ID_SIZE],uint8_t log_level,uint8_t trace_status);
+void dlt_user_log_level_changed_callback(char context_id[DLT_ID_SIZE], uint8_t log_level, uint8_t trace_status);
DLT_DECLARE_CONTEXT(mycontext1)
DLT_DECLARE_CONTEXT(mycontext2)
@@ -92,7 +92,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-example-user [options] message\n");
printf("Generate DLT messages and store them to file or send them to daemon.\n");
@@ -118,7 +118,7 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
int gflag = 0;
int aflag = 0;
@@ -140,20 +140,21 @@ int main(int argc, char* argv[])
int c;
char *text;
- int num,maxnum;
+ int num, maxnum;
int delay;
- int state=-1,newstate;
+ int state = -1, newstate;
opterr = 0;
#ifdef DLT_TEST_ENABLE
+
while ((c = getopt (argc, argv, "vgakcd:f:n:m:z:r:s:l:t:")) != -1)
#else
+
while ((c = getopt (argc, argv, "vgakd:f:n:m:l:r:t:")) != -1)
#endif /* DLT_TEST_ENABLE */
{
- switch (c)
- {
+ switch (c) {
case 'g':
{
gflag = 1;
@@ -223,18 +224,12 @@ 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'))
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
/* unknown or wrong option used, show usage information and terminate */
usage();
@@ -243,39 +238,31 @@ int main(int argc, char* argv[])
default:
{
abort ();
- break;//for parasoft
+ break;/*for parasoft */
}
}
}
- if (rvalue == -1)
- {
+ if (rvalue == -1) {
for (index = optind; index < argc; index++)
- {
message = argv[index];
- }
}
- else /* allocate raw buffer */
- {
+ else { /* allocate raw buffer */
message = calloc(sizeof(char), rvalue);
- memset(message, 'X', rvalue-1);
+ memset(message, 'X', rvalue - 1);
}
- if (message == 0)
- {
+ if (message == 0) {
/* no message, show usage and terminate */
- fprintf(stderr,"ERROR: No message selected\n");
+ fprintf(stderr, "ERROR: No message selected\n");
usage();
return -1;
}
- if (fvalue)
- {
+ if (fvalue) {
/* DLT is initialized automatically, except another output target will be used */
- if (dlt_init_file(fvalue)<0) /* log to file */
- {
+ if (dlt_init_file(fvalue) < 0) /* log to file */
return -1;
- }
}
dlt_with_session_id(1);
@@ -283,68 +270,55 @@ int main(int argc, char* argv[])
dlt_with_ecu_id(1);
dlt_verbose_mode();
- DLT_REGISTER_APP("LOG","Test Application for Logging");
+ DLT_REGISTER_APP("LOG", "Test Application for Logging");
DLT_REGISTER_CONTEXT(mycontext1, "TEST", "Test Context for Logging");
DLT_REGISTER_CONTEXT_LLCCB(mycontext2, "TS1", "Test Context1 for injection", dlt_user_log_level_changed_callback);
DLT_REGISTER_CONTEXT_LLCCB(mycontext3, "TS2", "Test Context2 for injection", dlt_user_log_level_changed_callback);
DLT_REGISTER_INJECTION_CALLBACK(mycontext1, 0x1000, dlt_user_injection_callback);
- DLT_REGISTER_INJECTION_CALLBACK_WITH_ID(mycontext2, 0x1000, dlt_user_injection_callback_with_specific_data, (void*)"TS1 context");
+ DLT_REGISTER_INJECTION_CALLBACK_WITH_ID(mycontext2,
+ 0x1000,
+ dlt_user_injection_callback_with_specific_data,
+ (void *)"TS1 context");
DLT_REGISTER_INJECTION_CALLBACK(mycontext2, 0x1001, dlt_user_injection_callback);
- DLT_REGISTER_INJECTION_CALLBACK_WITH_ID(mycontext3, 0x1000, dlt_user_injection_callback_with_specific_data, (void*)"TS2 context");
+ DLT_REGISTER_INJECTION_CALLBACK_WITH_ID(mycontext3,
+ 0x1000,
+ dlt_user_injection_callback_with_specific_data,
+ (void *)"TS2 context");
DLT_REGISTER_INJECTION_CALLBACK(mycontext3, 0x1001, dlt_user_injection_callback);
DLT_REGISTER_LOG_LEVEL_CHANGED_CALLBACK(mycontext1, dlt_user_log_level_changed_callback);
text = message;
- if(mvalue)
- {
- printf("Set log mode to %d\n",atoi(mvalue));
+ if (mvalue) {
+ printf("Set log mode to %d\n", atoi(mvalue));
dlt_set_log_mode(atoi(mvalue));
}
-
if (gflag)
- {
DLT_NONVERBOSE_MODE();
- }
if (aflag)
- {
DLT_ENABLE_LOCAL_PRINT();
- }
if (kflag)
- {
DLT_LOG_MARKER();
- }
if (nvalue)
- {
maxnum = atoi(nvalue);
- }
else
- {
maxnum = 10;
- }
if (dvalue)
- {
delay = atoi(dvalue) * 1000;
- }
else
- {
delay = 500 * 1000;
- }
if (tvalue)
- {
- dlt_set_resend_timeout_atexit(atoi(tvalue));
- }
+ dlt_set_resend_timeout_atexit(atoi(tvalue));
- if (gflag)
- {
+ if (gflag) {
/* DLT messages to test Fibex non-verbose description: dlt-example-non-verbose.xml */
DLT_LOG_ID(mycontext1, DLT_LOG_INFO, 10);
DLT_LOG_ID(mycontext1, DLT_LOG_INFO, 11, DLT_UINT16(1011));
@@ -354,69 +328,58 @@ int main(int argc, char* argv[])
}
#ifdef DLT_TEST_ENABLE
+
if (cflag)
- {
dlt_user_test_corrupt_user_header(1);
- }
+
if (svalue)
- {
- dlt_user_test_corrupt_message_size(1,atoi(svalue));
- }
- if (zvalue)
- {
- char* buffer = malloc(atoi(zvalue));
- if(buffer==0)
- {
+ dlt_user_test_corrupt_message_size(1, atoi(svalue));
+
+ if (zvalue) {
+ char *buffer = malloc(atoi(zvalue));
+
+ if (buffer == 0) {
/* no message, show usage and terminate */
- fprintf(stderr,"Cannot allocate buffer memory!\n");
+ fprintf(stderr, "Cannot allocate buffer memory!\n");
return -1;
}
+
DLT_LOG(mycontext1, DLT_LOG_WARN, DLT_STRING(text), DLT_RAW(buffer, atoi(zvalue)));
free(buffer);
}
+
#endif /* DLT_TEST_ENABLE */
- for (num=0;num<maxnum;num++)
- {
+ for (num = 0; num < maxnum; num++) {
printf("Send %d %s\n", num, text);
newstate = dlt_get_log_state();
- if(state!=newstate)
- {
+
+ if (state != newstate) {
state = newstate;
- if(state == -1) {
+
+ if (state == -1)
printf("Client unknown state!\n");
- }
- else if(state == 0) {
+ else if (state == 0)
printf("Client disconnected!\n");
- }
- else if(state == 1) {
+ else if (state == 1)
printf("Client connected!\n");
- }
}
- if (gflag)
- {
+ if (gflag) {
/* Non-verbose mode */
DLT_LOG_ID(mycontext1, lvalue, num, DLT_INT(num), DLT_STRING(text));
}
- else
- {
+ else {
if (rvalue == -1)
- {
/* Verbose mode */
DLT_LOG(mycontext1, lvalue, DLT_INT(num), DLT_STRING(text));
- }
else
- {
DLT_LOG(mycontext1, lvalue, DLT_RAW(text, rvalue));
- }
}
- if (delay>0)
- {
+ if (delay > 0)
usleep(delay);
- }
}
sleep(1);
@@ -436,8 +399,7 @@ int dlt_user_injection_callback(uint32_t service_id, void *data, uint32_t length
DLT_LOG(mycontext1, DLT_LOG_INFO, DLT_STRING("Injection: "), DLT_UINT32(service_id));
printf("Injection %d, Length=%d \n", service_id, length);
- if (length > 0)
- {
+ if (length > 0) {
dlt_print_mixed_string(text, 1024, data, length, 0);
DLT_LOG(mycontext1, DLT_LOG_INFO, DLT_STRING("Data: "), DLT_STRING(text));
printf("%s \n", text);
@@ -453,8 +415,7 @@ int dlt_user_injection_callback_with_specific_data(uint32_t service_id, void *da
DLT_LOG(mycontext1, DLT_LOG_INFO, DLT_STRING("Injection: "), DLT_UINT32(service_id));
printf("Injection %d, Length=%d \n", service_id, length);
- if (length > 0)
- {
+ if (length > 0) {
dlt_print_mixed_string(text, 1024, data, length, 0);
DLT_LOG(mycontext1, DLT_LOG_INFO, DLT_STRING("Data: "), DLT_STRING(text), DLT_STRING(priv_data));
printf("%s \n", text);
@@ -463,13 +424,13 @@ int dlt_user_injection_callback_with_specific_data(uint32_t service_id, void *da
return 0;
}
-void dlt_user_log_level_changed_callback(char context_id[DLT_ID_SIZE],uint8_t log_level,uint8_t trace_status)
+void dlt_user_log_level_changed_callback(char context_id[DLT_ID_SIZE], uint8_t log_level, uint8_t trace_status)
{
char text[5];
- text[4]=0;
+ text[4] = 0;
- memcpy(text,context_id,DLT_ID_SIZE);
+ memcpy(text, context_id, DLT_ID_SIZE);
- printf("Log level changed of context %s, LogLevel=%u, TraceState=%u \n",text,log_level,trace_status);
+ printf("Log level changed of context %s, LogLevel=%u, TraceState=%u \n", text, log_level, trace_status);
}
diff --git a/src/gateway/dlt_gateway.c b/src/gateway/dlt_gateway.c
index 2bc535e..6b7a629 100644
--- a/src/gateway/dlt_gateway.c
+++ b/src/gateway/dlt_gateway.c
@@ -61,8 +61,7 @@ DLT_STATIC DltReturnValue dlt_gateway_check_ip(DltGatewayConnection *con, char *
struct sockaddr_in sa;
int ret = DLT_RETURN_ERROR;
- if ((con == NULL) || (value == NULL))
- {
+ if ((con == NULL) || (value == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -70,20 +69,17 @@ DLT_STATIC DltReturnValue dlt_gateway_check_ip(DltGatewayConnection *con, char *
ret = inet_pton(AF_INET, value, &(sa.sin_addr));
/* valid IP address */
- if (ret != 0)
- {
+ if (ret != 0) {
con->ip_address = strdup(value);
- if (con->ip_address == NULL)
- {
+ if (con->ip_address == NULL) {
dlt_log(LOG_ERR, "Cannot copy passive node IP address string\n");
return DLT_RETURN_ERROR;
}
return DLT_RETURN_OK;
}
- else
- {
+ else {
dlt_log(LOG_ERR, "IP address is not valid\n");
}
@@ -98,26 +94,23 @@ DLT_STATIC DltReturnValue dlt_gateway_check_ip(DltGatewayConnection *con, char *
* @return Value from DltReturnValue enum
*/
DLT_STATIC DltReturnValue dlt_gateway_check_port(DltGatewayConnection *con,
- char *value)
+ char *value)
{
int tmp = -1;
- if ((con == NULL) || (value == NULL))
- {
+ if ((con == NULL) || (value == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- tmp = (int) strtol(value, NULL, 10);
+ tmp = (int)strtol(value, NULL, 10);
/* port ranges for unprivileged applications */
- if ((tmp > IPPORT_RESERVED) && (tmp <= USHRT_MAX))
- {
+ if ((tmp > IPPORT_RESERVED) && (tmp <= USHRT_MAX)) {
con->port = tmp;
return DLT_RETURN_OK;
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Port number is invalid\n");
}
@@ -132,10 +125,9 @@ DLT_STATIC DltReturnValue dlt_gateway_check_port(DltGatewayConnection *con,
* @return Value from DltReturnValue enum
*/
DLT_STATIC DltReturnValue dlt_gateway_check_ecu(DltGatewayConnection *con,
- char *value)
+ char *value)
{
- if ((con == NULL) || (value == NULL))
- {
+ if ((con == NULL) || (value == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -143,9 +135,7 @@ DLT_STATIC DltReturnValue dlt_gateway_check_ecu(DltGatewayConnection *con,
con->ecuid = strdup(value);
if (con->ecuid == NULL)
- {
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
}
@@ -160,22 +150,19 @@ DLT_STATIC DltReturnValue dlt_gateway_check_ecu(DltGatewayConnection *con,
DLT_STATIC DltReturnValue dlt_gateway_check_connect_trigger(DltGatewayConnection *con,
char *value)
{
- if ((con == NULL) || (value == NULL))
- {
+ if ((con == NULL) || (value == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (strncasecmp(value, "OnStartup", strlen("OnStartup")) == 0)
- {
+ if (strncasecmp(value, "OnStartup", strlen("OnStartup")) == 0) {
con->trigger = DLT_GATEWAY_ON_STARTUP;
}
else if (strncasecmp(value, "OnDemand", strlen("OnDemand")) == 0)
{
con->trigger = DLT_GATEWAY_ON_DEMAND;
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Wrong connection trigger state given.\n");
con->trigger = DLT_GATEWAY_UNDEFINED;
return DLT_RETURN_ERROR;
@@ -192,20 +179,17 @@ DLT_STATIC DltReturnValue dlt_gateway_check_connect_trigger(DltGatewayConnection
* @return Value from DltReturnValue enum
*/
DLT_STATIC DltReturnValue dlt_gateway_check_timeout(DltGatewayConnection *con,
- char *value)
+ char *value)
{
- if ((con == NULL) || (value == NULL))
- {
+ if ((con == NULL) || (value == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- con->timeout = (int) strtol(value, NULL, 10);
+ con->timeout = (int)strtol(value, NULL, 10);
if (con->timeout > 0)
- {
return DLT_RETURN_OK;
- }
return DLT_RETURN_ERROR;
}
@@ -218,15 +202,14 @@ DLT_STATIC DltReturnValue dlt_gateway_check_timeout(DltGatewayConnection *con,
* @return Value from DltReturnValue enum
*/
DLT_STATIC DltReturnValue dlt_gateway_check_send_serial(DltGatewayConnection *con,
- char *value)
+ char *value)
{
- if ((con == NULL) || (value == NULL))
- {
+ if ((con == NULL) || (value == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- con->send_serial = !!((int) strtol(value, NULL, 10));
+ con->send_serial = !!((int)strtol(value, NULL, 10));
return DLT_RETURN_OK;
}
@@ -239,29 +222,24 @@ DLT_STATIC DltReturnValue dlt_gateway_check_send_serial(DltGatewayConnection *co
*/
DLT_STATIC DltReturnValue dlt_gateway_allocate_control_messages(DltGatewayConnection *con)
{
- if (con == NULL)
- {
+ if (con == NULL) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (con->p_control_msgs == NULL)
- {
+ if (con->p_control_msgs == NULL) {
con->p_control_msgs = calloc(1, sizeof(DltPassiveControlMessage));
- if (!con->p_control_msgs)
- {
+ if (!con->p_control_msgs) {
dlt_log(LOG_ERR,
"Passive Control Message could not be allocated\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
con->p_control_msgs->next = calloc(1, sizeof(DltPassiveControlMessage));
- if (!con->p_control_msgs->next)
- {
+ if (!con->p_control_msgs->next) {
dlt_log(LOG_ERR,
"Passive Control Message could not be allocated\n");
return DLT_RETURN_ERROR;
@@ -288,24 +266,19 @@ DLT_STATIC DltReturnValue dlt_gateway_check_control_messages(DltGatewayConnectio
char *rest = NULL;
DltPassiveControlMessage *head = NULL;
- if ((con == NULL) || (value == NULL))
- {
+ if ((con == NULL) || (value == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
if (strlen(value) == 0)
- {
return DLT_RETURN_OK;
- }
/* set on startup control msg id and interval*/
token = strtok_r(value, ",", &rest);
- while (token != NULL)
- {
- if (dlt_gateway_allocate_control_messages(con) != DLT_RETURN_OK)
- {
+ while (token != NULL) {
+ if (dlt_gateway_allocate_control_messages(con) != DLT_RETURN_OK) {
dlt_log(LOG_ERR,
"Passive Control Message could not be allocated\n");
return DLT_RETURN_ERROR;
@@ -318,12 +291,9 @@ DLT_STATIC DltReturnValue dlt_gateway_check_control_messages(DltGatewayConnectio
con->p_control_msgs->interval = -1;
if (head == NULL)
- {
head = con->p_control_msgs;
- }
- if ((errno == EINVAL) || (errno == ERANGE))
- {
+ if ((errno == EINVAL) || (errno == ERANGE)) {
dlt_vlog(LOG_ERR,
"Control message ID is not an integer: %s\n",
token);
@@ -356,23 +326,20 @@ DLT_STATIC DltReturnValue dlt_gateway_check_control_messages(DltGatewayConnectio
* @return Value from DltReturnValue enum
*/
DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages(
- DltGatewayConnection *con,
- char *value)
+ DltGatewayConnection *con,
+ char *value)
{
char *token = NULL;
char *rest = NULL;
DltPassiveControlMessage *head = NULL;
- if ((con == NULL) || (value == NULL))
- {
+ if ((con == NULL) || (value == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
if (strlen(value) == 0)
- {
return DLT_RETURN_OK;
- }
/* store head address */
head = con->p_control_msgs;
@@ -380,35 +347,31 @@ DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages(
/* set periodic control msg id and interval*/
token = strtok_r(value, ",", &rest);
- while (token != NULL)
- {
+ while (token != NULL) {
char *p_token = NULL;
char *p_rest = NULL;
uint32_t id = 0;
p_token = strtok_r(token, ":", &p_rest);
- if ((p_token != NULL) && (strlen(p_token) != 0))
- {
+ if ((p_token != NULL) && (strlen(p_token) != 0)) {
id = strtol(p_token, NULL, 16);
/* get back to head */
con->p_control_msgs = head;
/* check if there is already id set in p_control_msgs */
- while (con->p_control_msgs != NULL)
- {
- if (con->p_control_msgs->id == id)
- {
+ while (con->p_control_msgs != NULL) {
+ if (con->p_control_msgs->id == id) {
con->p_control_msgs->type = CONTROL_MESSAGE_BOTH;
con->p_control_msgs->interval = strtol(p_rest, NULL, 10);
+
if (con->p_control_msgs->interval <= 0)
- {
dlt_vlog(LOG_WARNING,
"%s interval is %d. It won't be send periodically.\n",
dlt_get_service_name(con->p_control_msgs->id),
con->p_control_msgs->interval);
- }
+
break;
}
@@ -416,24 +379,19 @@ DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages(
}
/* if the id is not added yet, p_control_msgs supposed to be NULL */
- if (con->p_control_msgs == NULL)
- {
+ if (con->p_control_msgs == NULL) {
/* get back to head */
con->p_control_msgs = head;
/* go to last pointer */
- while (con->p_control_msgs != NULL)
- {
+ while (con->p_control_msgs != NULL) {
if (con->p_control_msgs->next == NULL)
- {
break;
- }
con->p_control_msgs = con->p_control_msgs->next;
}
- if (dlt_gateway_allocate_control_messages(con) != DLT_RETURN_OK)
- {
+ if (dlt_gateway_allocate_control_messages(con) != DLT_RETURN_OK) {
dlt_log(LOG_ERR,
"Passive Control Message could not be allocated\n");
return DLT_RETURN_ERROR;
@@ -444,23 +402,19 @@ DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages(
con->p_control_msgs->type = CONTROL_MESSAGE_PERIODIC;
con->p_control_msgs->req = CONTROL_MESSAGE_NOT_REQUESTED;
con->p_control_msgs->interval = strtol(p_rest, NULL, 10);
+
if (con->p_control_msgs->interval <= 0)
- {
dlt_vlog(LOG_WARNING,
"%s interval is %d. It won't be send periodically.\n",
dlt_get_service_name(con->p_control_msgs->id),
con->p_control_msgs->interval);
- }
if (head == NULL)
- {
head = con->p_control_msgs;
- }
}
}
- if ((errno == EINVAL) || (errno == ERANGE))
- {
+ if ((errno == EINVAL) || (errno == ERANGE)) {
dlt_vlog(LOG_ERR,
"Control message ID is not an integer: %s\n",
p_token);
@@ -490,40 +444,47 @@ DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages(
* Caution: after changing entries here,
* dlt_gateway_check_param needs to be updated as well
* */
-DLT_STATIC DltGatewayConf configuration_entries[GW_CONF_COUNT] =
-{
+DLT_STATIC DltGatewayConf configuration_entries[GW_CONF_COUNT] = {
[GW_CONF_IP_ADDRESS] = {
.key = "IPaddress",
.func = dlt_gateway_check_ip,
- .is_opt = 0 },
+ .is_opt = 0
+ },
[GW_CONF_PORT] = {
.key = "Port",
.func = dlt_gateway_check_port,
- .is_opt = 1 },
+ .is_opt = 1
+ },
[GW_CONF_ECUID] = {
.key = "EcuID",
.func = dlt_gateway_check_ecu,
- .is_opt = 0 },
+ .is_opt = 0
+ },
[GW_CONF_CONNECT] = {
.key = "Connect",
.func = dlt_gateway_check_connect_trigger,
- .is_opt = 1 },
+ .is_opt = 1
+ },
[GW_CONF_TIMEOUT] = {
.key = "Timeout",
.func = dlt_gateway_check_timeout,
- .is_opt = 0 },
+ .is_opt = 0
+ },
[GW_CONF_SEND_CONTROL] = {
.key = "SendControl",
.func = dlt_gateway_check_control_messages,
- .is_opt = 1 },
+ .is_opt = 1
+ },
[GW_CONF_SEND_PERIODIC_CONTROL] = {
.key = "SendPeriodicControl",
.func = dlt_gateway_check_periodic_control_messages,
- .is_opt = 1 },
+ .is_opt = 1
+ },
[GW_CONF_SEND_SERIAL_HEADER] = {
.key = "SendSerialHeader",
.func = dlt_gateway_check_send_serial,
- .is_opt = 1 }
+ .is_opt = 1
+ }
};
#define DLT_GATEWAY_NUM_PROPERTIES_MAX GW_CONF_COUNT
@@ -542,8 +503,7 @@ DLT_STATIC DltReturnValue dlt_gateway_check_param(DltGateway *gateway,
DltGatewayConfType ctype,
char *value)
{
- if ((gateway == NULL) || (con == NULL) || (value == NULL))
- {
+ if ((gateway == NULL) || (con == NULL) || (value == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -570,27 +530,21 @@ int dlt_gateway_store_connection(DltGateway *gateway,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((gateway == NULL) || (tmp == NULL))
- {
+ if ((gateway == NULL) || (tmp == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
/* find next free entry in connection array */
- while (i < gateway->num_connections)
- {
+ while (i < gateway->num_connections) {
if (gateway->connections[i].status == DLT_GATEWAY_UNINITIALIZED)
- {
break;
- }
i++;
}
if (&(gateway->connections[i]) == NULL)
- {
return DLT_RETURN_ERROR;
- }
/* store values */
gateway->connections[i].ip_address = strdup(tmp->ip_address);
@@ -609,8 +563,7 @@ int dlt_gateway_store_connection(DltGateway *gateway,
if (dlt_client_init_port(&gateway->connections[i].client,
gateway->connections[i].port,
- verbose) != 0)
- {
+ verbose) != 0) {
free(gateway->connections[i].ip_address);
gateway->connections[i].ip_address = NULL;
free(gateway->connections[i].ecuid);
@@ -622,9 +575,8 @@ int dlt_gateway_store_connection(DltGateway *gateway,
}
/* setup DltClient Structure */
- if(dlt_client_set_server_ip(&gateway->connections[i].client,
- gateway->connections[i].ip_address) == -1)
- {
+ if (dlt_client_set_server_ip(&gateway->connections[i].client,
+ gateway->connections[i].ip_address) == -1) {
dlt_log(LOG_ERR,
"dlt_client_set_server_ip() failed for gateway connection \n");
return DLT_RETURN_ERROR;
@@ -649,8 +601,7 @@ int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
- if ((gateway == NULL) || (config_file == 0) || (config_file[0] == '\0'))
- {
+ if ((gateway == NULL) || (config_file == 0) || (config_file[0] == '\0')) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -661,8 +612,7 @@ int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose)
/* get number of entries and allocate memory to store information */
ret = dlt_config_file_get_num_sections(file, &gateway->num_connections);
- if (ret != 0)
- {
+ if (ret != 0) {
dlt_config_file_release(file);
dlt_log(LOG_ERR, "Invalid number of sections in configuration file\n");
return DLT_RETURN_ERROR;
@@ -671,20 +621,18 @@ int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose)
gateway->connections = calloc(sizeof(DltGatewayConnection),
gateway->num_connections);
- if (gateway->connections == NULL)
- {
+ if (gateway->connections == NULL) {
dlt_config_file_release(file);
dlt_log(LOG_CRIT, "Memory allocation for gateway connections failed\n");
return DLT_RETURN_ERROR;
}
- for (i = 0; i < gateway->num_connections; i++)
- {
+ for (i = 0; i < gateway->num_connections; i++) {
DltGatewayConnection tmp;
int invalid = 0;
DltGatewayConfType j = 0;
- char section[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = {'\0'};
- char value[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = {'\0'};
+ char section[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+ char value[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
memset(&tmp, 0, sizeof(tmp));
@@ -694,15 +642,13 @@ int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose)
ret = dlt_config_file_get_section_name(file, i, section);
- for (j = 0; j < GW_CONF_COUNT; j++)
- {
+ for (j = 0; j < GW_CONF_COUNT; j++) {
ret = dlt_config_file_get_value(file,
section,
configuration_entries[j].key,
value);
- if ((ret != 0) && configuration_entries[j].is_opt)
- {
+ if ((ret != 0) && configuration_entries[j].is_opt) {
/* Use default values for this key */
dlt_vlog(LOG_WARNING,
"Using default for %s.\n",
@@ -722,29 +668,23 @@ int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose)
ret = dlt_gateway_check_param(gateway, &tmp, j, value);
if (ret != 0)
- {
dlt_vlog(LOG_ERR,
"Configuration %s = %s is invalid.\n"
"Using default.\n",
configuration_entries[j].key, value);
- }
}
- if (invalid)
- {
+ if (invalid) {
dlt_vlog(LOG_ERR,
"%s configuration is invalid.\n"
"Ignoring.\n",
section);
}
- else
- {
+ else {
ret = dlt_gateway_store_connection(gateway, &tmp, verbose);
if (ret != 0)
- {
dlt_log(LOG_ERR, "Storing gateway connection data failed\n");
- }
}
/* strdup used inside some get_value function */
@@ -762,29 +702,25 @@ int dlt_gateway_init(DltDaemonLocal *daemon_local, int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon_local == NULL)
- {
+ if (daemon_local == NULL) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
DltGateway *gateway = &daemon_local->pGateway;
- if (gateway != NULL)
- {
+ if (gateway != NULL) {
/* Get default value from daemon_local */
gateway->send_serial = daemon_local->flags.lflag;
if (dlt_gateway_configure(gateway,
daemon_local->flags.gatewayConfigFile,
- verbose) != 0)
- {
+ verbose) != 0) {
dlt_log(LOG_ERR, "Gateway initialization failed\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
dlt_log(LOG_CRIT, "Pointer to Gateway structure is NULL\n");
return DLT_RETURN_ERROR;
}
@@ -800,24 +736,22 @@ void dlt_gateway_deinit(DltGateway *gateway, int verbose)
DltPassiveControlMessage *msg;
int i = 0;
- if (gateway == NULL)
- {
+ if (gateway == NULL) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return;
}
PRINT_FUNCTION_VERBOSE(verbose);
- for (i = 0; i < gateway->num_connections; i++)
- {
+ for (i = 0; i < gateway->num_connections; i++) {
DltGatewayConnection *c = &gateway->connections[i];
dlt_client_cleanup(&c->client, verbose);
free(c->ip_address);
c->ip_address = NULL;
free(c->ecuid);
c->ecuid = NULL;
- while (c->p_control_msgs != NULL)
- {
+
+ while (c->p_control_msgs != NULL) {
msg = c->p_control_msgs->next;
free(c->p_control_msgs);
c->p_control_msgs = msg;
@@ -837,14 +771,13 @@ void dlt_gateway_deinit(DltGateway *gateway, int verbose)
* @return 0 on success, -1 otherwise
*/
DLT_STATIC int dlt_gateway_add_to_event_loop(DltDaemonLocal *daemon_local,
- DltGatewayConnection *con,
- int verbose)
+ DltGatewayConnection *con,
+ int verbose)
{
DltPassiveControlMessage *control_msg = NULL;
int sendtime = 1;
- if ((daemon_local == NULL) || (con == NULL))
- {
+ if ((daemon_local == NULL) || (con == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -860,8 +793,7 @@ DLT_STATIC int dlt_gateway_add_to_event_loop(DltDaemonLocal *daemon_local,
&daemon_local->pEvent,
con->client.sock,
POLLIN,
- DLT_CONNECTION_GATEWAY) != 0)
- {
+ DLT_CONNECTION_GATEWAY) != 0) {
dlt_log(LOG_ERR, "Gateway connection creation failed\n");
return DLT_RETURN_ERROR;
}
@@ -869,27 +801,22 @@ DLT_STATIC int dlt_gateway_add_to_event_loop(DltDaemonLocal *daemon_local,
/* immediately send configured control messages */
control_msg = con->p_control_msgs;
- while (control_msg != NULL)
- {
+ while (control_msg != NULL) {
if ((control_msg->type == CONTROL_MESSAGE_ON_STARTUP) ||
- (control_msg->type == CONTROL_MESSAGE_BOTH))
- {
+ (control_msg->type == CONTROL_MESSAGE_BOTH)) {
if (dlt_gateway_send_control_message(con,
control_msg,
NULL,
verbose) == DLT_RETURN_OK)
- {
control_msg->req = CONTROL_MESSAGE_REQUESTED;
- }
}
/* multiply periodic sending time */
if (((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
(control_msg->type == CONTROL_MESSAGE_BOTH)) &&
(control_msg->interval > 0))
- {
sendtime *= control_msg->interval;
- }
+
control_msg = control_msg->next;
}
@@ -909,46 +836,39 @@ int dlt_gateway_establish_connections(DltGateway *gateway,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((gateway == NULL) || (daemon_local == NULL))
- {
+ if ((gateway == NULL) || (daemon_local == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- for (i = 0; i < gateway->num_connections; i++)
- {
+ for (i = 0; i < gateway->num_connections; i++) {
DltGatewayConnection *con = &(gateway->connections[i]);
DltPassiveControlMessage *control_msg = NULL;
- if (con == NULL)
- {
+ if (con == NULL) {
dlt_log(LOG_CRIT, "Cannot retrieve gateway connection details\n");
return DLT_RETURN_ERROR;
}
if ((con->status != DLT_GATEWAY_CONNECTED) &&
(con->trigger != DLT_GATEWAY_ON_DEMAND) &&
- (con->trigger != DLT_GATEWAY_DISABLED))
- {
+ (con->trigger != DLT_GATEWAY_DISABLED)) {
ret = dlt_client_connect(&con->client, verbose);
- if (ret == 0)
- {
+ if (ret == 0) {
/* setup dlt connection and add to poll event loop here */
- if (dlt_gateway_add_to_event_loop(daemon_local, con, verbose) != DLT_RETURN_OK)
- {
+ if (dlt_gateway_add_to_event_loop(daemon_local, con, verbose) != DLT_RETURN_OK) {
dlt_log(LOG_ERR, "Gateway connection creation failed\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
dlt_log(LOG_DEBUG,
"Passive Node is not up. Connection failed.\n");
con->timeout_cnt++;
- if (con->timeout_cnt > con->timeout)
- {
+
+ if (con->timeout_cnt > con->timeout) {
con->trigger = DLT_GATEWAY_DISABLED;
dlt_log(LOG_WARNING,
"Passive Node connection retry timed out. "
@@ -961,11 +881,10 @@ int dlt_gateway_establish_connections(DltGateway *gateway,
{
/* setup dlt connection and add to poll event loop here */
if (dlt_connection_create(daemon_local,
- &daemon_local->pEvent,
- con->client.sock,
- POLLIN,
- DLT_CONNECTION_GATEWAY) != 0)
- {
+ &daemon_local->pEvent,
+ con->client.sock,
+ POLLIN,
+ DLT_CONNECTION_GATEWAY) != 0) {
dlt_log(LOG_ERR, "Gateway connection creation failed\n");
return DLT_RETURN_ERROR;
}
@@ -973,32 +892,25 @@ int dlt_gateway_establish_connections(DltGateway *gateway,
/* immediately send periodic configured control messages */
control_msg = con->p_control_msgs;
- while (control_msg != NULL)
- {
+ while (control_msg != NULL) {
if ((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
- (control_msg->type == CONTROL_MESSAGE_BOTH))
- {
+ (control_msg->type == CONTROL_MESSAGE_BOTH)) {
if (dlt_gateway_send_control_message(con,
control_msg,
NULL,
verbose) == DLT_RETURN_OK)
- {
control_msg->req = CONTROL_MESSAGE_REQUESTED;
- }
}
+
control_msg = control_msg->next;
}
/* check sendtime counter */
if (con->sendtime_cnt > 0)
- {
con->sendtime_cnt--;
- }
if (con->sendtime_cnt == 0)
- {
con->sendtime_cnt = con->sendtime;
- }
}
}
@@ -1009,19 +921,16 @@ DltReceiver *dlt_gateway_get_connection_receiver(DltGateway *gateway, int fd)
{
int i = 0;
- if (gateway == NULL)
- {
+ if (gateway == NULL) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return NULL;
}
- for (i = 0; i < gateway->num_connections; i++)
- {
+ for (i = 0; i < gateway->num_connections; i++) {
DltGatewayConnection *c = &gateway->connections[i];
- if (c->status == DLT_GATEWAY_CONNECTED && c->client.sock == fd)
- {
+
+ if ((c->status == DLT_GATEWAY_CONNECTED) && (c->client.sock == fd))
return &c->client.receiver;
- }
}
return NULL;
@@ -1043,7 +952,7 @@ DLT_STATIC DltReturnValue dlt_gateway_parse_get_log_info(DltDaemon *daemon,
int req,
int verbose)
{
- char resp_text[DLT_RECEIVE_BUFSIZE] = {'\0'};
+ char resp_text[DLT_RECEIVE_BUFSIZE] = { '\0' };
DltServiceGetLogInfoResponse *resp = NULL;
AppIDsType app;
ContextIDsInfoType con;
@@ -1052,30 +961,24 @@ DLT_STATIC DltReturnValue dlt_gateway_parse_get_log_info(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((msg == NULL) || (msg->databuffer == NULL))
- {
+ if ((msg == NULL) || (msg->databuffer == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceGetLogInfoResponse)) < 0)
- {
return DLT_RETURN_ERROR;
- }
/* if the request was send from gateway, clear all application and context list */
- if (req == CONTROL_MESSAGE_REQUESTED)
- {
+ if (req == CONTROL_MESSAGE_REQUESTED) {
/* clear application list */
- if (dlt_daemon_applications_clear(daemon, ecu, verbose) == DLT_RETURN_ERROR)
- {
+ if (dlt_daemon_applications_clear(daemon, ecu, verbose) == DLT_RETURN_ERROR) {
dlt_log(LOG_ERR, "Cannot clear applications list\n");
return DLT_RETURN_ERROR;
}
/* clear context list */
- if (dlt_daemon_contexts_clear(daemon, ecu, verbose) == DLT_RETURN_ERROR)
- {
+ if (dlt_daemon_contexts_clear(daemon, ecu, verbose) == DLT_RETURN_ERROR) {
dlt_log(LOG_ERR, "Cannot clear contexts list\n");
return DLT_RETURN_ERROR;
}
@@ -1085,49 +988,43 @@ DLT_STATIC DltReturnValue dlt_gateway_parse_get_log_info(DltDaemon *daemon,
if (dlt_message_payload(msg,
resp_text,
DLT_RECEIVE_BUFSIZE,
- DLT_OUTPUT_ASCII, 0) != DLT_RETURN_OK)
- {
+ DLT_OUTPUT_ASCII, 0) != DLT_RETURN_OK) {
dlt_log(LOG_ERR, "GET_LOG_INFO payload failed\n");
return DLT_RETURN_ERROR;
}
/* prepare pointer to message request */
- resp = (DltServiceGetLogInfoResponse*) calloc(1, sizeof(DltServiceGetLogInfoResponse));
+ resp = (DltServiceGetLogInfoResponse *)calloc(1, sizeof(DltServiceGetLogInfoResponse));
- if (resp == NULL)
- {
+ if (resp == NULL) {
dlt_log(LOG_ERR,
"Get Log Info Response could not be allocated\n");
return DLT_RETURN_ERROR;
}
- if (dlt_set_loginfo_parse_service_id(resp_text, &resp->service_id, &resp->status) != DLT_RETURN_OK)
- {
+ if (dlt_set_loginfo_parse_service_id(resp_text, &resp->service_id, &resp->status) != DLT_RETURN_OK) {
dlt_log(LOG_ERR, "Parsing GET_LOG_INFO failed\n");
dlt_client_cleanup_get_log_info(resp);
return DLT_RETURN_ERROR;
}
- if (dlt_client_parse_get_log_info_resp_text(resp, resp_text) != DLT_RETURN_OK)
- {
+ if (dlt_client_parse_get_log_info_resp_text(resp, resp_text) != DLT_RETURN_OK) {
dlt_log(LOG_ERR, "Parsing GET_LOG_INFO failed\n");
dlt_client_cleanup_get_log_info(resp);
return DLT_RETURN_ERROR;
}
- for (i = 0; i < resp->log_info_type.count_app_ids; i++)
- {
+ for (i = 0; i < resp->log_info_type.count_app_ids; i++) {
app = resp->log_info_type.app_ids[i];
/* add application */
if (dlt_daemon_application_add(daemon,
- app.app_id,
- 0,
- app.app_description,
- -1,
- ecu,
- verbose) == 0)
- {
+ app.app_id,
+ 0,
+ app.app_description,
+ -1,
+ ecu,
+ verbose) == 0) {
dlt_vlog(LOG_WARNING,
"%s: dlt_daemon_application_add failed\n",
__func__);
@@ -1135,22 +1032,20 @@ DLT_STATIC DltReturnValue dlt_gateway_parse_get_log_info(DltDaemon *daemon,
return DLT_RETURN_ERROR;
}
- for (j = 0; j < app.count_context_ids; j++)
- {
+ for (j = 0; j < app.count_context_ids; j++) {
con = app.context_id_info[j];
/* add context */
if (dlt_daemon_context_add(daemon,
- app.app_id,
- con.context_id,
- con.log_level,
- con.trace_status,
- 0,
- -1,
- con.context_description,
- ecu,
- verbose) == 0)
- {
+ app.app_id,
+ con.context_id,
+ con.log_level,
+ con.trace_status,
+ 0,
+ -1,
+ con.context_description,
+ ecu,
+ verbose) == 0) {
dlt_vlog(LOG_WARNING,
"%s: dlt_daemon_context_add failed for %4s\n",
__func__,
@@ -1177,38 +1072,35 @@ DLT_STATIC DltReturnValue dlt_gateway_parse_get_log_info(DltDaemon *daemon,
* @return 0 on success, -1 otherwise
*/
DLT_STATIC int dlt_gateway_parse_get_default_log_level(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *ecu,
- DltMessage *msg,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *ecu,
+ DltMessage *msg,
+ int verbose)
{
DltServiceGetDefaultLogLevelResponse *resp = NULL;
DltGatewayConnection *con = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize,
- sizeof(DltServiceGetDefaultLogLevelResponse)) < 0)
- {
+ sizeof(DltServiceGetDefaultLogLevelResponse)) < 0) {
dlt_log(LOG_ERR, "Received data incomplete.\n");
return DLT_RETURN_ERROR;
}
/* prepare pointer to message request */
- resp = (DltServiceGetDefaultLogLevelResponse *) (msg->databuffer);
+ resp = (DltServiceGetDefaultLogLevelResponse *)(msg->databuffer);
con = dlt_gateway_get_connection(&daemon_local->pGateway,
ecu,
verbose);
- if (con == NULL)
- {
+ if (con == NULL) {
dlt_vlog(LOG_ERR, "No information about passive ECU: %s\n",
ecu);
@@ -1229,48 +1121,43 @@ DLT_STATIC int dlt_gateway_parse_get_default_log_level(DltDaemon *daemon,
* @return 0 on success, -1 otherwise
*/
DLT_STATIC int dlt_gateway_control_service_logstorage(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ int verbose)
{
unsigned int connection_type = 0;
int i = 0;
- if (daemon_local->flags.offlineLogstorageMaxDevices <= 0)
- {
+ if (daemon_local->flags.offlineLogstorageMaxDevices <= 0) {
dlt_log(LOG_INFO,
"Logstorage functionality not enabled or MAX device set is 0\n");
return DLT_RETURN_ERROR;
}
- for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
+ for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
connection_type = daemon->storage_handle[i].connection_type;
if (connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
- {
/* Check if log level of running application needs an update */
dlt_daemon_logstorage_update_application_loglevel(daemon,
daemon_local,
i,
verbose);
- }
}
return DLT_RETURN_OK;
}
DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltReceiver *receiver,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ DltReceiver *receiver,
+ int verbose)
{
int i = 0;
DltGateway *gateway = NULL;
DltGatewayConnection *con = NULL;
- DltMessage msg = {0};
+ DltMessage msg = { 0 };
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -1278,63 +1165,56 @@ DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
gateway = &daemon_local->pGateway;
- if (gateway == NULL)
- {
+
+ if (gateway == NULL) {
dlt_log(LOG_ERR, "Gateway structure is NULL\n");
return DLT_RETURN_ERROR;
}
for (i = 0; i < gateway->num_connections; i++)
- {
- if (gateway->connections[i].client.sock == receiver->fd)
- {
+ if (gateway->connections[i].client.sock == receiver->fd) {
con = &gateway->connections[i];
break;
}
- }
- if (con == NULL)
- {
+
+
+ if (con == NULL) {
dlt_log(LOG_ERR, "Cannot associate fd to passive Node connection\n");
return DLT_RETURN_ERROR;
}
/* now the corresponding passive node connection is available */
- if (dlt_message_init(&msg, verbose) == -1)
- {
+ if (dlt_message_init(&msg, verbose) == -1) {
dlt_log(LOG_ERR,
"Cannot initialize DLT message for passive node forwarding\n");
return DLT_RETURN_ERROR;
}
/* nearly copy and paste of dlt_client_main_loop function */
- if (dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET) <= 0)
- {
+ if (dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET) <= 0) {
/* No more data to be received */
- if (dlt_message_free(&msg, verbose) < 0)
- {
+ if (dlt_message_free(&msg, verbose) < 0) {
dlt_log(LOG_ERR, "Cannot free DLT message\n");
return DLT_RETURN_ERROR;
}
dlt_log(LOG_WARNING, "Connection to passive node lost\n");
- if (con->reconnect_cnt < DLT_GATEWAY_RECONNECT_MAX)
- {
+ if (con->reconnect_cnt < DLT_GATEWAY_RECONNECT_MAX) {
dlt_log(LOG_WARNING, "Try to reconnect.\n");
con->reconnect_cnt += 1;
con->timeout_cnt = 0;
}
- else
- {
+ else {
con->status = DLT_GATEWAY_DISCONNECTED;
+
if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
- daemon_local,
- receiver->fd) != 0)
- {
+ daemon_local,
+ receiver->fd) != 0)
dlt_log(LOG_ERR, "Remove passive node Connection failed\n");
- }
}
+
return DLT_RETURN_OK;
}
@@ -1342,16 +1222,14 @@ DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
(unsigned char *)receiver->buf,
receiver->bytesRcvd,
0,
- verbose) == DLT_MESSAGE_ERROR_OK)
- {
+ verbose) == DLT_MESSAGE_ERROR_OK) {
DltStandardHeaderExtra *header = (DltStandardHeaderExtra *)
- (msg.headerbuffer +
- sizeof(DltStorageHeader) +
- sizeof(DltStandardHeader));
+ (msg.headerbuffer +
+ sizeof(DltStorageHeader) +
+ sizeof(DltStandardHeader));
/* only forward messages if the received ECUid is the expected one */
- if (strncmp(header->ecu, con->ecuid, strlen(con->ecuid)) == 0)
- {
+ if (strncmp(header->ecu, con->ecuid, strlen(con->ecuid)) == 0) {
uint32_t id;
uint32_t id_tmp;
DltPassiveControlMessage *control_msg = con->p_control_msgs;
@@ -1363,24 +1241,19 @@ DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
con->ecuid,
msg.databuffer);
- id_tmp = *((uint32_t*)(msg.databuffer));
+ id_tmp = *((uint32_t *)(msg.databuffer));
id = DLT_ENDIAN_GET_32(msg.standardheader->htyp, id_tmp);
/* if ID is GET_LOG_INFO, parse msg */
- if (id == DLT_SERVICE_ID_GET_LOG_INFO)
- {
- while (control_msg)
- {
- if (control_msg->id == id)
- {
+ if (id == DLT_SERVICE_ID_GET_LOG_INFO) {
+ while (control_msg) {
+ if (control_msg->id == id) {
if (dlt_gateway_parse_get_log_info(daemon,
header->ecu,
&msg,
control_msg->req,
verbose) == DLT_RETURN_ERROR)
- {
dlt_log(LOG_WARNING, "Parsing GET_LOG_INFO message failed!\n");
- }
/* Check for logstorage */
dlt_gateway_control_service_logstorage(daemon,
@@ -1391,6 +1264,7 @@ DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
control_msg->req = CONTROL_MESSAGE_NOT_REQUESTED;
break;
}
+
control_msg = control_msg->next;
}
}
@@ -1402,95 +1276,79 @@ DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
header->ecu,
&msg,
verbose) == DLT_RETURN_ERROR)
- {
dlt_log(LOG_WARNING,
"Parsing GET_DEFAULT_LOG_LEVEL message failed!\n");
- }
}
/* prepare storage header */
if (dlt_set_storageheader(msg.storageheader,
- msg.headerextra.ecu) == DLT_RETURN_ERROR)
- {
+ msg.headerextra.ecu) == DLT_RETURN_ERROR) {
dlt_vlog(LOG_ERR, "%s: Can't set storage header\n", __func__);
return DLT_RETURN_ERROR;
}
if (dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,
- daemon,
- daemon_local,
- msg.headerbuffer,
- sizeof(DltStorageHeader),
- msg.headerbuffer + sizeof(DltStorageHeader),
- msg.headersize - sizeof(DltStorageHeader),
- msg.databuffer,
- msg.datasize,
- verbose) != DLT_DAEMON_ERROR_OK)
- {
+ daemon,
+ daemon_local,
+ msg.headerbuffer,
+ sizeof(DltStorageHeader),
+ msg.headerbuffer + sizeof(DltStorageHeader),
+ msg.headersize - sizeof(DltStorageHeader),
+ msg.databuffer,
+ msg.datasize,
+ verbose) != DLT_DAEMON_ERROR_OK)
dlt_log(LOG_WARNING, "Forward message to clients failed!\n");
- }
}
- else /* otherwise remove this connection and do not connect again */
- {
+ else { /* otherwise remove this connection and do not connect again */
dlt_vlog(LOG_WARNING,
"Received ECUid (%s) differs to configured ECUid(%s). "
"Discard this message.\n",
header->ecu,
con->ecuid);
- /* disconnect from passive node */
+ /* disconnect from passive node */
con->status = DLT_GATEWAY_DISCONNECTED;
con->trigger = DLT_GATEWAY_DISABLED;
+
if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
- daemon_local,
- receiver->fd)
+ daemon_local,
+ receiver->fd)
!= 0)
- {
dlt_log(LOG_ERR, "Remove passive node Connection failed\n");
- }
dlt_log(LOG_WARNING,
"Disconnect from passive node due to invalid ECUid\n");
}
- if (msg.found_serialheader)
- {
+ if (msg.found_serialheader) {
if (dlt_receiver_remove(receiver,
msg.headersize +
msg.datasize -
sizeof(DltStorageHeader) +
- sizeof(dltSerialHeader)) == -1)
- {
- /* Return value ignored */
- dlt_message_free(&msg,verbose);
- return DLT_RETURN_ERROR;
- }
- }
- else
- {
- if (dlt_receiver_remove(receiver,
- msg.headersize +
- msg.datasize -
- sizeof(DltStorageHeader)) == -1)
- {
+ sizeof(dltSerialHeader)) == -1) {
/* Return value ignored */
- dlt_message_free(&msg,verbose);
+ dlt_message_free(&msg, verbose);
return DLT_RETURN_ERROR;
}
}
+ else if (dlt_receiver_remove(receiver,
+ msg.headersize +
+ msg.datasize -
+ sizeof(DltStorageHeader)) == -1) {
+ /* Return value ignored */
+ dlt_message_free(&msg, verbose);
+ return DLT_RETURN_ERROR;
+ }
}
- if (dlt_receiver_move_to_begin(receiver) == -1)
- {
+ if (dlt_receiver_move_to_begin(receiver) == -1) {
/* Return value ignored */
dlt_message_free(&msg, verbose);
return DLT_RETURN_ERROR;
}
if (dlt_message_free(&msg, verbose) == -1)
- {
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
}
@@ -1505,8 +1363,7 @@ int dlt_gateway_process_gateway_timer(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL))
- {
+ if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
dlt_vlog(LOG_ERR,
"%s: invalid parameters\n",
__func__);
@@ -1515,15 +1372,13 @@ int dlt_gateway_process_gateway_timer(DltDaemon *daemon,
res = read(receiver->fd, &expir, sizeof(expir));
- if(res < 0)
- {
+ if (res < 0)
dlt_vlog(LOG_WARNING,
"%s: Fail to read timer (%s)\n",
__func__,
strerror(errno));
/* Activity received on timer_wd, but unable to read the fd:
- let's go on sending notification */
- }
+ * let's go on sending notification */
/* try to connect to passive nodes */
dlt_gateway_establish_connections(&daemon_local->pGateway,
@@ -1549,69 +1404,62 @@ int dlt_gateway_forward_control_message(DltGateway *gateway,
PRINT_FUNCTION_VERBOSE(verbose);
- if (gateway == NULL || daemon_local == NULL || msg == NULL || ecu == NULL)
- {
+ if ((gateway == NULL) || (daemon_local == NULL) || (msg == NULL) || (ecu == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
for (i = 0; i < gateway->num_connections; i++)
- {
if (strncmp(gateway->connections[i].ecuid,
ecu,
- strlen(gateway->connections[i].ecuid)) == 0)
- {
+ strlen(gateway->connections[i].ecuid)) == 0) {
con = &gateway->connections[i];
break;
}
- }
- if (con == NULL)
- {
+
+
+ if (con == NULL) {
dlt_log(LOG_WARNING, "Unknown passive node identifier\n");
return DLT_RETURN_ERROR;
}
- if (con->status != DLT_GATEWAY_CONNECTED)
- {
+ if (con->status != DLT_GATEWAY_CONNECTED) {
dlt_log(LOG_INFO, "Passive node is not connected\n");
return DLT_RETURN_ERROR;
}
- if (con->send_serial) /* send serial header */
- {
+ if (con->send_serial) { /* send serial header */
ret = send(con->client.sock,
(void *)dltSerialHeader,
sizeof(dltSerialHeader),
0);
- if (ret == -1)
- {
+ if (ret == -1) {
dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
return DLT_RETURN_ERROR;
}
}
ret = send(con->client.sock,
- msg->headerbuffer + sizeof(DltStorageHeader),
- msg->headersize - sizeof(DltStorageHeader),
- 0);
- if (ret == -1)
- {
+ msg->headerbuffer + sizeof(DltStorageHeader),
+ msg->headersize - sizeof(DltStorageHeader),
+ 0);
+
+ if (ret == -1) {
dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
return DLT_RETURN_ERROR;
}
- else
- {
+ else {
ret = send(con->client.sock, msg->databuffer, msg->datasize, 0);
- if (ret == -1)
- {
+
+ if (ret == -1) {
dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
return DLT_RETURN_ERROR;
}
}
- id_tmp = *((uint32_t*)(msg->databuffer));
+ id_tmp = *((uint32_t *)(msg->databuffer));
id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
dlt_vlog(LOG_INFO,
@@ -1631,49 +1479,41 @@ int dlt_gateway_process_on_demand_request(DltGateway *gateway,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((gateway == NULL) || (daemon_local == NULL) || (node_id == NULL))
- {
+ if ((gateway == NULL) || (daemon_local == NULL) || (node_id == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
/* find connection by ECU id */
for (i = 0; i < gateway->num_connections; i++)
- {
- if (strncmp(node_id, gateway->connections->ecuid, DLT_ID_SIZE) == 0)
- {
+ if (strncmp(node_id, gateway->connections->ecuid, DLT_ID_SIZE) == 0) {
con = &gateway->connections[i];
break;
}
- }
- if (con == NULL)
- {
+
+
+ if (con == NULL) {
dlt_log(LOG_WARNING, "Specified ECUid not found\n");
return DLT_RETURN_ERROR;
}
- if (connection_status == 1) /* try to connect */
- {
- if (con->status != DLT_GATEWAY_CONNECTED)
- {
- if (dlt_client_connect(&con->client, verbose) == 0)
- {
+ if (connection_status == 1) { /* try to connect */
+
+ if (con->status != DLT_GATEWAY_CONNECTED) {
+ if (dlt_client_connect(&con->client, verbose) == 0) {
/* setup dlt connection and add to poll event loop here */
- if (dlt_gateway_add_to_event_loop(daemon_local, con, verbose) != DLT_RETURN_OK)
- {
+ if (dlt_gateway_add_to_event_loop(daemon_local, con, verbose) != DLT_RETURN_OK) {
dlt_log(LOG_ERR, "Gateway connection creation failed\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Could not connect to passive node\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
dlt_log(LOG_INFO, "Passive node already connected\n");
}
}
@@ -1682,16 +1522,14 @@ int dlt_gateway_process_on_demand_request(DltGateway *gateway,
con->status = DLT_GATEWAY_DISCONNECTED;
con->trigger = DLT_GATEWAY_ON_DEMAND;
+
if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
- daemon_local,
- con->client.sock) != 0)
- {
+ daemon_local,
+ con->client.sock) != 0)
dlt_log(LOG_ERR,
"Remove passive node event handler connection failed\n");
- }
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Unknown command (connection_status)\n");
return DLT_RETURN_ERROR;
}
@@ -1708,8 +1546,7 @@ int dlt_gateway_send_control_message(DltGatewayConnection *con,
PRINT_FUNCTION_VERBOSE(verbose);
- if (con == NULL)
- {
+ if (con == NULL) {
dlt_vlog(LOG_WARNING,
"%s: Invalid parameter given\n",
__func__);
@@ -1718,45 +1555,34 @@ int dlt_gateway_send_control_message(DltGatewayConnection *con,
/* no (more) control message to be send */
if (control_msg->id == 0)
- {
return DLT_RETURN_ERROR;
- }
/* check sendtime counter and message interval */
/* sendtime counter is 0 on startup, otherwise positive value */
- if ((control_msg->type != CONTROL_MESSAGE_ON_DEMAND) && (con->sendtime_cnt > 0))
- {
+ if ((control_msg->type != CONTROL_MESSAGE_ON_DEMAND) && (con->sendtime_cnt > 0)) {
if (control_msg->interval <= 0)
- {
return DLT_RETURN_ERROR;
- }
if ((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
- (control_msg->type == CONTROL_MESSAGE_BOTH))
- {
+ (control_msg->type == CONTROL_MESSAGE_BOTH)) {
if ((con->sendtime_cnt - 1) % control_msg->interval != 0)
- {
return DLT_RETURN_ERROR;
- }
}
}
- if (con->send_serial) /* send serial header */
- {
+ if (con->send_serial) { /* send serial header */
ret = send(con->client.sock,
(void *)dltSerialHeader,
sizeof(dltSerialHeader),
0);
- if (ret == -1)
- {
+ if (ret == -1) {
dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
return DLT_RETURN_ERROR;
}
}
- switch(control_msg->id)
- {
+ switch (control_msg->id) {
case DLT_SERVICE_ID_GET_LOG_INFO:
return dlt_client_get_log_info(&con->client);
break;
@@ -1767,15 +1593,15 @@ int dlt_gateway_send_control_message(DltGatewayConnection *con,
return dlt_client_get_software_version(&con->client);
break;
case DLT_SERVICE_ID_SET_LOG_LEVEL:
- if (data == NULL)
- {
+
+ if (data == NULL) {
dlt_vlog(LOG_WARNING,
"Insufficient data for %s received. Send control request failed.\n",
dlt_get_service_name(control_msg->id));
return DLT_RETURN_ERROR;
}
- DltServiceSetLogLevel *req = (DltServiceSetLogLevel *) data;
+ DltServiceSetLogLevel *req = (DltServiceSetLogLevel *)data;
return dlt_client_send_log_level(&con->client,
req->apid,
req->ctid,
@@ -1799,19 +1625,16 @@ DltGatewayConnection *dlt_gateway_get_connection(DltGateway *gateway,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((gateway == NULL) || (ecu == NULL))
- {
+ if ((gateway == NULL) || (ecu == NULL)) {
dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
return con;
}
- for (i = 0; i < gateway->num_connections; i++)
- {
+ for (i = 0; i < gateway->num_connections; i++) {
con = &gateway->connections[i];
+
if (strncmp(con->ecuid, ecu, DLT_ID_SIZE) == 0)
- {
return con;
- }
}
dlt_vlog(LOG_ERR, "%s: No connection found\n", ecu);
diff --git a/src/gateway/dlt_gateway_internal.h b/src/gateway/dlt_gateway_internal.h
index c0f9241..a473f11 100644
--- a/src/gateway/dlt_gateway_internal.h
+++ b/src/gateway/dlt_gateway_internal.h
@@ -59,22 +59,22 @@
#define DLT_GATEWAY_INTERNAL_H_
DLT_STATIC DltReturnValue dlt_gateway_check_ip(DltGatewayConnection *con,
- char *value);
+ char *value);
DLT_STATIC DltReturnValue dlt_gateway_check_port(DltGatewayConnection *con,
- char *value);
+ char *value);
DLT_STATIC DltReturnValue dlt_gateway_check_ecu(DltGatewayConnection *con,
- char *value);
+ char *value);
DLT_STATIC DltReturnValue dlt_gateway_check_connect_trigger(DltGatewayConnection *con,
char *value);
DLT_STATIC DltReturnValue dlt_gateway_check_timeout(DltGatewayConnection *con,
- char *value);
+ char *value);
DLT_STATIC DltReturnValue dlt_gateway_check_send_serial(DltGatewayConnection *con,
- char *value);
+ char *value);
DLT_STATIC DltReturnValue dlt_gateway_allocate_control_messages(DltGatewayConnection *con);
diff --git a/src/kpi/dlt-kpi-common.c b/src/kpi/dlt-kpi-common.c
index fa131dc..53298b1 100644
--- a/src/kpi/dlt-kpi-common.c
+++ b/src/kpi/dlt-kpi-common.c
@@ -30,19 +30,18 @@ static int dlt_kpi_cpu_count = -1;
DltReturnValue dlt_kpi_read_file_compact(char *filename, char **target)
{
- if(filename == NULL || target == NULL)
- {
- fprintf(stderr, "%s: Nullpointer parameter!\n",__func__);
+ if ((filename == NULL) || (target == NULL)) {
+ fprintf(stderr, "%s: Nullpointer parameter!\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- char buffer[BUFFER_SIZE];
+ char buffer[BUFFER_SIZE];
int ret = dlt_kpi_read_file(filename, buffer, BUFFER_SIZE);
- if(ret < DLT_RETURN_OK)
+
+ if (ret < DLT_RETURN_OK)
return ret;
- if((*target = malloc(strlen(buffer) + 1)) == NULL)
- {
+ if ((*target = malloc(strlen(buffer) + 1)) == NULL) {
fprintf(stderr, "Out of memory!\n");
return DLT_RETURN_ERROR;
}
@@ -52,22 +51,20 @@ DltReturnValue dlt_kpi_read_file_compact(char *filename, char **target)
return DLT_RETURN_OK;
}
-DltReturnValue dlt_kpi_read_file(char* filename, char* buffer, uint maxLength)
+DltReturnValue dlt_kpi_read_file(char *filename, char *buffer, uint maxLength)
{
- if(filename == NULL || buffer == NULL)
- {
- fprintf(stderr, "%s: Nullpointer parameter!\n",__func__);
+ if ((filename == NULL) || (buffer == NULL)) {
+ fprintf(stderr, "%s: Nullpointer parameter!\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- FILE* file = fopen(filename, "r");
- if(file == NULL)
- {
- // fprintf(stderr, "Could not read file %s\n", filename);
+ FILE *file = fopen(filename, "r");
+
+ if (file == NULL)
+ /* fprintf(stderr, "Could not read file %s\n", filename); */
return DLT_RETURN_ERROR;
- }
- int buflen = fread(buffer, 1, maxLength-1, file);
+ int buflen = fread(buffer, 1, maxLength - 1, file);
buffer[buflen] = '\0';
fclose(file);
@@ -79,40 +76,38 @@ int dlt_kpi_read_cpu_count()
{
char buffer[BUFFER_SIZE];
int ret = dlt_kpi_read_file("/proc/cpuinfo", buffer, sizeof(buffer));
- if(ret != 0)
- {
+
+ if (ret != 0) {
fprintf(stderr, "dlt_kpi_get_cpu_count(): Could not read /proc/cpuinfo\n");
return -1;
}
- char* delim = "[] \t\n";
- char* tok = strtok(buffer, delim);
- if(tok == NULL)
- {
+ char *delim = "[] \t\n";
+ char *tok = strtok(buffer, delim);
+
+ if (tok == NULL) {
fprintf(stderr, "dlt_kpi_get_cpu_count(): Could not extract token\n");
return -1;
}
int num = 0;
- do
- {
- if(strcmp(tok, "processor") == 0)
+
+ do {
+ if (strcmp(tok, "processor") == 0)
num++;
tok = strtok(NULL, delim);
- }
- while(tok != NULL);
+ } while (tok != NULL);
return num;
}
int dlt_kpi_get_cpu_count()
{
- if(dlt_kpi_cpu_count <= 0)
- {
+ if (dlt_kpi_cpu_count <= 0) {
dlt_kpi_cpu_count = dlt_kpi_read_cpu_count();
- if(dlt_kpi_cpu_count <= 0)
- {
+
+ if (dlt_kpi_cpu_count <= 0) {
fprintf(stderr, "Could not get CPU count\n");
dlt_kpi_cpu_count = -1;
}
diff --git a/src/kpi/dlt-kpi-common.h b/src/kpi/dlt-kpi-common.h
index 4777d6f..db05b24 100644
--- a/src/kpi/dlt-kpi-common.h
+++ b/src/kpi/dlt-kpi-common.h
@@ -34,7 +34,7 @@
#define BUFFER_SIZE 4096
-DltReturnValue dlt_kpi_read_file(char* filename, char* buffer, uint maxLength);
+DltReturnValue dlt_kpi_read_file(char *filename, char *buffer, uint maxLength);
DltReturnValue dlt_kpi_read_file_compact(char *filename, char **target);
int dlt_kpi_get_cpu_count();
diff --git a/src/kpi/dlt-kpi-interrupt.c b/src/kpi/dlt-kpi-interrupt.c
index b8e4e80..7274cc0 100644
--- a/src/kpi/dlt-kpi-interrupt.c
+++ b/src/kpi/dlt-kpi-interrupt.c
@@ -28,9 +28,8 @@
DltReturnValue dlt_kpi_log_interrupts(DltContext *ctx, DltLogLevelType log_level)
{
- if(ctx == NULL)
- {
- fprintf(stderr, "%s: Nullpointer parameter (NULL) !\n",__func__);
+ if (ctx == NULL) {
+ fprintf(stderr, "%s: Nullpointer parameter (NULL) !\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -42,52 +41,60 @@ DltReturnValue dlt_kpi_log_interrupts(DltContext *ctx, DltLogLevelType log_level
int head_line = 1, first_row = 1, cpu_count = 0, column = 0, buffer_offset = 0;
DltReturnValue ret;
- if((ret = dlt_kpi_read_file("/proc/interrupts", file_buffer, BUFFER_SIZE)) < DLT_RETURN_OK) return ret;
+ if ((ret = dlt_kpi_read_file("/proc/interrupts", file_buffer, BUFFER_SIZE)) < DLT_RETURN_OK) return ret;
token = strtok(file_buffer, delim);
- while(token != NULL)
- {
- if(head_line)
- {
- if(strlen(token) > 3 && token[0]=='C' && token[1]=='P' && token[2]=='U')
+
+ while (token != NULL) {
+ if (head_line) {
+ if ((strlen(token) > 3) && (token[0] == 'C') && (token[1] == 'P') && (token[2] == 'U')) {
cpu_count++;
- else if(cpu_count <= 0)
+ }
+ else if (cpu_count <= 0)
{
- fprintf(stderr, "%s: Could not parse CPU count !\n",__func__);
+ fprintf(stderr, "%s: Could not parse CPU count !\n", __func__);
return DLT_RETURN_ERROR;
}
- else if(strcmp(token, "\n") == 0)
+ else if (strcmp(token, "\n") == 0)
+ {
head_line = 0;
+ }
token = strtok(NULL, delim);
}
- else
- {
+ else {
int tokenlen = strlen(token);
- if(token[tokenlen - 1] == ':')
- {
+
+ if (token[tokenlen - 1] == ':') {
column = 0;
- if(first_row)
+ if (first_row)
first_row = 0;
else
buffer_offset += snprintf(buffer + buffer_offset, BUFFER_SIZE - buffer_offset, "\n");
}
- if(column == 0) // IRQ number
- {
- buffer_offset += snprintf(buffer + buffer_offset, BUFFER_SIZE - buffer_offset, "%.*s;", tokenlen-1, token);
+ if (column == 0) { /* IRQ number */
+ buffer_offset += snprintf(buffer + buffer_offset,
+ BUFFER_SIZE - buffer_offset,
+ "%.*s;",
+ tokenlen - 1,
+ token);
}
- else if(column <= cpu_count)
+ else if (column <= cpu_count)
{
long int interrupt_count = strtol(token, &check, 10);
- if(*check != '\0')
- {
- fprintf(stderr, "%s: Could not parse interrupt count for CPU !\n",__func__);
+
+ if (*check != '\0') {
+ fprintf(stderr, "%s: Could not parse interrupt count for CPU !\n", __func__);
return DLT_RETURN_ERROR;
}
- buffer_offset += snprintf(buffer + buffer_offset, BUFFER_SIZE - buffer_offset, "cpu%d:%ld;", column - 1, interrupt_count);
+ buffer_offset += snprintf(buffer + buffer_offset,
+ BUFFER_SIZE - buffer_offset,
+ "cpu%d:%ld;",
+ column - 1,
+ interrupt_count);
}
column++;
@@ -96,57 +103,52 @@ DltReturnValue dlt_kpi_log_interrupts(DltContext *ctx, DltLogLevelType log_level
}
}
- // synchronization message
+ /* synchronization message */
DLT_LOG(*ctx, log_level, DLT_STRING("IRQ"), DLT_STRING("BEG"));
DltContextData ctx_data;
- if((ret = dlt_user_log_write_start(ctx, &ctx_data, log_level)) < DLT_RETURN_OK)
- {
+
+ if ((ret = dlt_user_log_write_start(ctx, &ctx_data, log_level)) < DLT_RETURN_OK) {
fprintf(stderr, "%s: dlt_user_log_write_start() returned error\n", __func__);
return ret;
}
- if((ret = dlt_user_log_write_string(&ctx_data, "IRQ")) < DLT_RETURN_OK)
- {
+ if ((ret = dlt_user_log_write_string(&ctx_data, "IRQ")) < DLT_RETURN_OK) {
fprintf(stderr, "%s: dlt_user_log_write_string() returned error\n", __func__);
return ret;
}
token = strtok(buffer, "\n");
- while(token != NULL)
- {
- if(dlt_user_log_write_string(&ctx_data, token) < DLT_RETURN_OK)
- {
+
+ while (token != NULL) {
+ if (dlt_user_log_write_string(&ctx_data, token) < DLT_RETURN_OK) {
/* message buffer full, start new one */
- if((ret = dlt_user_log_write_finish(&ctx_data)) < DLT_RETURN_OK)
- {
+ if ((ret = dlt_user_log_write_finish(&ctx_data)) < DLT_RETURN_OK) {
fprintf(stderr, "%s: dlt_user_log_write_finish() returned error\n", __func__);
return ret;
}
- if((ret = dlt_user_log_write_start(ctx, &ctx_data, log_level)) < DLT_RETURN_OK)
- {
+ if ((ret = dlt_user_log_write_start(ctx, &ctx_data, log_level)) < DLT_RETURN_OK) {
fprintf(stderr, "%s: dlt_user_log_write_start() returned error\n", __func__);
return ret;
}
- if((ret = dlt_user_log_write_string(&ctx_data, "IRQ")) < DLT_RETURN_OK)
- {
+ if ((ret = dlt_user_log_write_string(&ctx_data, "IRQ")) < DLT_RETURN_OK) {
fprintf(stderr, "%s: dlt_user_log_write_string() returned error\n", __func__);
return ret;
}
}
- else
+ else {
token = strtok(NULL, "\n");
+ }
}
- if((ret = dlt_user_log_write_finish(&ctx_data)) < DLT_RETURN_OK)
- {
+ if ((ret = dlt_user_log_write_finish(&ctx_data)) < DLT_RETURN_OK) {
fprintf(stderr, "%s: dlt_user_log_write_finish() returned error\n", __func__);
return ret;
}
- // synchronization message
+ /* synchronization message */
DLT_LOG(*ctx, log_level, DLT_STRING("IRQ"), DLT_STRING("END"));
return DLT_RETURN_OK;
diff --git a/src/kpi/dlt-kpi-options.c b/src/kpi/dlt-kpi-options.c
index 0f6938c..14f0681 100644
--- a/src/kpi/dlt-kpi-options.c
+++ b/src/kpi/dlt-kpi-options.c
@@ -32,13 +32,13 @@
void usage(char *prog_name)
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: %s [options]\n", prog_name);
printf("Application to forward information from the /proc/ file system to DLT.\n");
printf("%s\n", version);
printf("Options:\n");
- //printf(" -d Daemonize. Detach from terminal and run in background.\n");
+ /*printf(" -d Daemonize. Detach from terminal and run in background.\n"); */
printf(" -c filename Use configuration file. \n");
printf(" Default: %s\n", DEFAULT_CONF_FILE);
printf(" -h This help message.\n");
@@ -55,48 +55,46 @@ void dlt_kpi_init_cli_options(DltKpiOptions *options)
void dlt_kpi_free_cli_options(DltKpiOptions *options)
{
- if(options->customConfigFile)
+ if (options->customConfigFile)
free(options->configurationFileName);
}
DltReturnValue dlt_kpi_read_command_line(DltKpiOptions *options, int argc, char **argv)
{
- if(options == NULL)
- {
+ if (options == NULL) {
fprintf(stderr, "%s: Nullpointer parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
+
dlt_kpi_init_cli_options(options);
int opt;
- while((opt = getopt(argc, argv, "c:h")) != -1)
- {
- switch(opt) {
- case 'c':
- {
- if((options->configurationFileName = malloc(strlen(optarg)+1)) == 0)
- {
- fprintf(stderr, "Out of memory!\n");
- return DLT_RETURN_ERROR;
- }
- strcpy(options->configurationFileName, optarg); /* strcpy unritical here, because size matches exactly the size to be copied */
- options->customConfigFile = 1;
- break;
- }
- case 'h':
- {
- usage(argv[0]);
- exit(0);
- return -1;//for parasoft
- }
- default:
- {
- fprintf(stderr, "Unknown option: %c\n", optopt);
- usage(argv[0]);
+ while ((opt = getopt(argc, argv, "c:h")) != -1)
+ switch (opt) {
+ case 'c':
+ {
+ if ((options->configurationFileName = malloc(strlen(optarg) + 1)) == 0) {
+ fprintf(stderr, "Out of memory!\n");
return DLT_RETURN_ERROR;
}
+
+ strcpy(options->configurationFileName, optarg); /* strcpy unritical here, because size matches exactly the size to be copied */
+ options->customConfigFile = 1;
+ break;
+ }
+ case 'h':
+ {
+ usage(argv[0]);
+ exit(0);
+ return -1; /*for parasoft */
+ }
+ default:
+ {
+ fprintf(stderr, "Unknown option: %c\n", optopt);
+ usage(argv[0]);
+ return DLT_RETURN_ERROR;
+ }
}
- }
return DLT_RETURN_OK;
}
@@ -123,8 +121,7 @@ DltReturnValue dlt_kpi_read_configuration_file(DltKpiConfig *config, char *file_
char *pch, *strchk;
int tmp;
- if(config == NULL || file_name == NULL)
- {
+ if ((config == NULL) || (file_name == NULL)) {
fprintf(stderr, "%s: Nullpointer parameter!\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -133,17 +130,14 @@ DltReturnValue dlt_kpi_read_configuration_file(DltKpiConfig *config, char *file_
file = fopen(file_name, "r");
- if(file == NULL)
- {
+ if (file == NULL) {
fprintf(stderr, "%s: Could not open configuration file!\n", __func__);
return DLT_RETURN_ERROR;
}
- if(((line = malloc(COMMAND_LINE_SIZE)) == 0) ||
- ((token = malloc(COMMAND_LINE_SIZE)) == 0) ||
- ((value = malloc(COMMAND_LINE_SIZE)) == 0))
-
- {
+ if (((line = malloc(COMMAND_LINE_SIZE)) == 0) ||
+ ((token = malloc(COMMAND_LINE_SIZE)) == 0) ||
+ ((value = malloc(COMMAND_LINE_SIZE)) == 0)) {
fclose(file);
free(line);
free(token);
@@ -153,66 +147,61 @@ DltReturnValue dlt_kpi_read_configuration_file(DltKpiConfig *config, char *file_
return DLT_RETURN_ERROR;
}
- while(fgets(line, COMMAND_LINE_SIZE, file) != NULL)
- {
+ while (fgets(line, COMMAND_LINE_SIZE, file) != NULL) {
token[0] = '\0';
value[0] = '\0';
pch = strtok (line, " =\r\n");
- while(pch != NULL)
- {
- if(pch[0] == '#')
+
+ while (pch != NULL) {
+ if (pch[0] == '#')
break;
- if(token[0] == '\0')
- {
- strncpy(token, pch, COMMAND_LINE_SIZE-1);
- token[COMMAND_LINE_SIZE-1] = '\0';
+ if (token[0] == '\0') {
+ strncpy(token, pch, COMMAND_LINE_SIZE - 1);
+ token[COMMAND_LINE_SIZE - 1] = '\0';
}
- else
- {
- strncpy(value, pch, COMMAND_LINE_SIZE-1);
- value[COMMAND_LINE_SIZE-1] = '\0';
+ else {
+ strncpy(value, pch, COMMAND_LINE_SIZE - 1);
+ value[COMMAND_LINE_SIZE - 1] = '\0';
break;
}
pch = strtok(NULL, " =\r\n");
}
- if(token[0] != '\0' && value[0] != '\0')
- {
- if(strcmp(token, "process_interval") == '\0')
- {
+ if ((token[0] != '\0') && (value[0] != '\0')) {
+ if (strcmp(token, "process_interval") == '\0') {
tmp = strtol(value, &strchk, 10);
- if(strchk[0] == '\0' && tmp > 0)
+ if ((strchk[0] == '\0') && (tmp > 0))
config->process_log_interval = tmp;
else
fprintf(stderr, "Error reading configuration file: %s is not a valid value for %s\n", value, token);
}
- else if(strcmp(token, "irq_interval") == '\0')
+ else if (strcmp(token, "irq_interval") == '\0')
{
tmp = strtol(value, &strchk, 10);
- if(strchk[0] == '\0' && tmp > 0)
+ if ((strchk[0] == '\0') && (tmp > 0))
config->irq_log_interval = tmp;
else
fprintf(stderr, "Error reading configuration file: %s is not a valid value for %s\n", value, token);
}
- else if(strcmp(token, "check_interval") == '\0')
+ else if (strcmp(token, "check_interval") == '\0')
{
tmp = strtol(value, &strchk, 10);
- if(strchk[0] == '\0' && tmp > 0)
+ if ((strchk[0] == '\0') && (tmp > 0))
config->check_log_interval = tmp;
else
fprintf(stderr, "Error reading configuration file: %s is not a valid value for %s\n", value, token);
}
- else if(strcmp(token, "log_level") == '\0')
+ else if (strcmp(token, "log_level") == '\0')
{
tmp = strtol(value, &strchk, 10);
- if(strchk[0] == '\0' && tmp >= -1 && tmp <= 6)
+ if ((strchk[0] == '\0') && (tmp >= -1) && (tmp <= 6))
config->log_level = tmp;
else
fprintf(stderr, "Error reading configuration file: %s is not a valid value for %s\n", value, token);
@@ -234,20 +223,17 @@ DltReturnValue dlt_kpi_init(int argc, char **argv, DltKpiConfig *config)
DltReturnValue ret;
- if(config == NULL)
- {
+ if (config == NULL) {
fprintf(stderr, "%s: Invalid Parameter!", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if((ret = dlt_kpi_read_command_line(&options, argc, argv)) < DLT_RETURN_OK)
- {
+ if ((ret = dlt_kpi_read_command_line(&options, argc, argv)) < DLT_RETURN_OK) {
fprintf(stderr, "Failed to read command line!");
return ret;
}
- if((ret = dlt_kpi_read_configuration_file(config, options.configurationFileName)) < DLT_RETURN_OK)
- {
+ if ((ret = dlt_kpi_read_configuration_file(config, options.configurationFileName)) < DLT_RETURN_OK) {
fprintf(stderr, "Failed to read configuration file!");
return ret;
}
diff --git a/src/kpi/dlt-kpi-process-list.c b/src/kpi/dlt-kpi-process-list.c
index 2d77c91..66d149e 100644
--- a/src/kpi/dlt-kpi-process-list.c
+++ b/src/kpi/dlt-kpi-process-list.c
@@ -29,8 +29,8 @@
DltKpiProcessList *dlt_kpi_create_process_list()
{
DltKpiProcessList *new_list = malloc(sizeof(DltKpiProcessList));
- if(new_list == NULL)
- {
+
+ if (new_list == NULL) {
fprintf(stderr, "%s: Cannot create process list, out of memory\n", __func__);
return NULL;
}
@@ -43,9 +43,8 @@ DltKpiProcessList *dlt_kpi_create_process_list()
DltReturnValue dlt_kpi_free_process_list_soft(DltKpiProcessList *list)
{
- if(list == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (list == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -56,17 +55,16 @@ DltReturnValue dlt_kpi_free_process_list_soft(DltKpiProcessList *list)
DltReturnValue dlt_kpi_free_process_list(DltKpiProcessList *list)
{
- if(list == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (list == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
DltKpiProcess *tmp;
list->cursor = list->start;
- while(list->cursor != NULL)
- {
+
+ while (list->cursor != NULL) {
tmp = list->cursor->next;
dlt_kpi_free_process(list->cursor);
list->cursor = tmp;
@@ -77,9 +75,8 @@ DltReturnValue dlt_kpi_free_process_list(DltKpiProcessList *list)
DltKpiProcess *dlt_kpi_get_process_at_cursor(DltKpiProcessList *list)
{
- if(list == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (list == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return NULL;
}
@@ -88,9 +85,8 @@ DltKpiProcess *dlt_kpi_get_process_at_cursor(DltKpiProcessList *list)
DltReturnValue dlt_kpi_reset_cursor(DltKpiProcessList *list)
{
- if(list == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (list == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -100,17 +96,17 @@ DltReturnValue dlt_kpi_reset_cursor(DltKpiProcessList *list)
DltReturnValue dlt_kpi_set_cursor_at_end(DltKpiProcessList *list)
{
- if(list == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (list == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
list->cursor = list->start;
- if(list->cursor == NULL)
+
+ if (list->cursor == NULL)
return DLT_RETURN_OK;
- while(list->cursor->next != NULL)
+ while (list->cursor->next != NULL)
dlt_kpi_increment_cursor(list);
return DLT_RETURN_OK;
@@ -118,13 +114,12 @@ DltReturnValue dlt_kpi_set_cursor_at_end(DltKpiProcessList *list)
DltReturnValue dlt_kpi_increment_cursor(DltKpiProcessList *list)
{
- if(list == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (list == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if(list->cursor == NULL)
+ if (list->cursor == NULL)
return DLT_RETURN_ERROR;
list->cursor = list->cursor->next;
@@ -134,13 +129,12 @@ DltReturnValue dlt_kpi_increment_cursor(DltKpiProcessList *list)
DltReturnValue dlt_kpi_decrement_cursor(DltKpiProcessList *list)
{
- if(list == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (list == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if(list->cursor == NULL)
+ if (list->cursor == NULL)
return DLT_RETURN_ERROR;
list->cursor = list->cursor->prev;
@@ -150,13 +144,12 @@ DltReturnValue dlt_kpi_decrement_cursor(DltKpiProcessList *list)
DltReturnValue dlt_kpi_add_process_at_start(DltKpiProcessList *list, DltKpiProcess *process)
{
- if(list == NULL || process == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if ((list == NULL) || (process == NULL)) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if(list->start != NULL)
+ if (list->start != NULL)
list->start->prev = process;
process->next = list->start;
@@ -167,19 +160,17 @@ DltReturnValue dlt_kpi_add_process_at_start(DltKpiProcessList *list, DltKpiProce
DltReturnValue dlt_kpi_add_process_before_cursor(DltKpiProcessList *list, DltKpiProcess *process)
{
- if(list == NULL || process == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if ((list == NULL) || (process == NULL)) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if(list->start == NULL) // Empty list?
- {
+ if (list->start == NULL) { /* Empty list? */
DltReturnValue ret = dlt_kpi_add_process_at_start(list, process);
list->cursor = NULL;
return ret;
}
- else if(list->cursor == NULL)
+ else if (list->cursor == NULL)
{
dlt_kpi_set_cursor_at_end(list);
DltReturnValue ret = dlt_kpi_add_process_after_cursor(list, process);
@@ -187,7 +178,7 @@ DltReturnValue dlt_kpi_add_process_before_cursor(DltKpiProcessList *list, DltKpi
return ret;
}
- if(list->cursor->prev != NULL)
+ if (list->cursor->prev != NULL)
list->cursor->prev->next = process;
else
list->start = process;
@@ -201,16 +192,15 @@ DltReturnValue dlt_kpi_add_process_before_cursor(DltKpiProcessList *list, DltKpi
DltReturnValue dlt_kpi_add_process_after_cursor(DltKpiProcessList *list, DltKpiProcess *process)
{
- if(list == NULL || process == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if ((list == NULL) || (process == NULL)) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_ERROR;
}
- if(list->cursor == NULL)
+ if (list->cursor == NULL)
return dlt_kpi_add_process_at_start(list, process);
- if(list->cursor->next != NULL)
+ if (list->cursor->next != NULL)
list->cursor->next->prev = process;
process->next = list->cursor->next;
@@ -222,63 +212,58 @@ DltReturnValue dlt_kpi_add_process_after_cursor(DltKpiProcessList *list, DltKpiP
DltReturnValue dlt_kpi_remove_process_at_cursor_soft(DltKpiProcessList *list)
{
- if(list == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (list == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if(list->cursor == NULL)
- {
- fprintf(stderr, "%s: Cursor is Invalid (NULL)\n", __func__);
+ if (list->cursor == NULL) {
+ fprintf(stderr, "%s: Cursor is Invalid (NULL)\n", __func__);
return DLT_RETURN_ERROR;
}
DltKpiProcess *tmp = list->cursor;
- if(tmp->prev != NULL)
- {
- if(tmp->next != NULL)
- {
+ if (tmp->prev != NULL) {
+ if (tmp->next != NULL) {
tmp->prev->next = tmp->next;
tmp->next->prev = tmp->prev;
}
- else
+ else {
tmp->prev->next = NULL;
+ }
}
- else
- {
- if(tmp->next != NULL)
- {
+ else {
+ if (tmp->next != NULL) {
tmp->next->prev = NULL;
list->start = tmp->next;
}
- else
+ else {
list->start = NULL;
+ }
}
- list->cursor = tmp->next; // becomes NULL if list is at end
+ list->cursor = tmp->next; /* becomes NULL if list is at end */
return DLT_RETURN_OK;
}
DltReturnValue dlt_kpi_remove_process_at_cursor(DltKpiProcessList *list)
{
- if(list == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (list == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if(list->cursor == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (list->cursor == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_ERROR;
}
DltKpiProcess *tmp = list->cursor;
DltReturnValue ret = dlt_kpi_remove_process_at_cursor_soft(list);
- if(ret < DLT_RETURN_OK)
+
+ if (ret < DLT_RETURN_OK)
return ret;
dlt_kpi_free_process(tmp);
diff --git a/src/kpi/dlt-kpi-process-list.h b/src/kpi/dlt-kpi-process-list.h
index 52eb11f..2fc80b6 100644
--- a/src/kpi/dlt-kpi-process-list.h
+++ b/src/kpi/dlt-kpi-process-list.h
@@ -48,7 +48,7 @@ DltReturnValue dlt_kpi_add_process_after_cursor(DltKpiProcessList *list, DltKpiP
DltReturnValue dlt_kpi_remove_process_at_cursor_soft(DltKpiProcessList *list);
DltReturnValue dlt_kpi_remove_process_at_cursor(DltKpiProcessList *list);
-// DltReturnValue dlt_kpi_remove_process_after_cursor(DltKpiProcessList *list);
-// DltReturnValue dlt_kpi_remove_first_process(DltKpiProcessList *list);
+/* DltReturnValue dlt_kpi_remove_process_after_cursor(DltKpiProcessList *list); */
+/* DltReturnValue dlt_kpi_remove_first_process(DltKpiProcessList *list); */
#endif /* SRC_KPI_DLT_KPI_PROCESS_LIST_H_ */
diff --git a/src/kpi/dlt-kpi-process.c b/src/kpi/dlt-kpi-process.c
index 22a46e6..062a667 100644
--- a/src/kpi/dlt-kpi-process.c
+++ b/src/kpi/dlt-kpi-process.c
@@ -35,8 +35,7 @@ DltReturnValue dlt_kpi_read_process_stat_cmdline(pid_t pid, char **buffer);
DltReturnValue dlt_kpi_process_update_io_wait(DltKpiProcess *process, unsigned long int time_dif_ms)
{
- if(process == NULL)
- {
+ if (process == NULL) {
fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -45,9 +44,10 @@ DltReturnValue dlt_kpi_process_update_io_wait(DltKpiProcess *process, unsigned l
int cpu_count = dlt_kpi_get_cpu_count();
- process->io_wait = (total_io_wait - process->last_io_wait) * 1000 / sysconf(_SC_CLK_TCK); // busy milliseconds since last update
- if(time_dif_ms > 0 && cpu_count > 0)
- process->io_wait = process->io_wait * 1000 / time_dif_ms / cpu_count; // busy milliseconds per second per CPU
+ process->io_wait = (total_io_wait - process->last_io_wait) * 1000 / sysconf(_SC_CLK_TCK); /* busy milliseconds since last update */
+
+ if ((time_dif_ms > 0) && (cpu_count > 0))
+ process->io_wait = process->io_wait * 1000 / time_dif_ms / cpu_count; /* busy milliseconds per second per CPU */
process->last_io_wait = total_io_wait;
@@ -56,8 +56,7 @@ DltReturnValue dlt_kpi_process_update_io_wait(DltKpiProcess *process, unsigned l
DltReturnValue dlt_kpi_process_update_cpu_time(DltKpiProcess *process, unsigned long int time_dif_ms)
{
- if(process == NULL)
- {
+ if (process == NULL) {
fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -67,16 +66,18 @@ DltReturnValue dlt_kpi_process_update_cpu_time(DltKpiProcess *process, unsigned
unsigned long total_cpu_time = utime + stime;
- if(process->last_cpu_time > 0 && process->last_cpu_time <= total_cpu_time)
- {
+ if ((process->last_cpu_time > 0) && (process->last_cpu_time <= total_cpu_time)) {
int cpu_count = dlt_kpi_get_cpu_count();
- process->cpu_time = (total_cpu_time - process->last_cpu_time) * 1000 / sysconf(_SC_CLK_TCK); // busy milliseconds since last update
- if(time_dif_ms > 0 && cpu_count > 0)
- process->cpu_time = process->cpu_time * 1000 / time_dif_ms / cpu_count; // busy milliseconds per second per CPU
+ process->cpu_time = (total_cpu_time - process->last_cpu_time) * 1000 / sysconf(_SC_CLK_TCK); /* busy milliseconds since last update */
+
+ if ((time_dif_ms > 0) && (cpu_count > 0))
+ process->cpu_time = process->cpu_time * 1000 / time_dif_ms / cpu_count; /* busy milliseconds per second per CPU */
+
}
- else
+ else {
process->cpu_time = 0;
+ }
process->last_cpu_time = total_cpu_time;
@@ -85,9 +86,8 @@ DltReturnValue dlt_kpi_process_update_cpu_time(DltKpiProcess *process, unsigned
DltReturnValue dlt_kpi_process_update_rss(DltKpiProcess *process)
{
- if(process == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (process == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -98,9 +98,8 @@ DltReturnValue dlt_kpi_process_update_rss(DltKpiProcess *process)
DltReturnValue dlt_kpi_process_update_ctx_switches(DltKpiProcess *process)
{
- if(process == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (process == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -109,22 +108,21 @@ DltReturnValue dlt_kpi_process_update_ctx_switches(DltKpiProcess *process)
last_tok = NULL;
DltReturnValue ret;
- if((ret = dlt_kpi_read_process_file_to_str(process->pid, &buffer, "status")) < DLT_RETURN_OK) return ret;
+
+ if ((ret = dlt_kpi_read_process_file_to_str(process->pid, &buffer, "status")) < DLT_RETURN_OK) return ret;
process->ctx_switches = 0;
tok = strtok(buffer, delim);
- while(tok != NULL)
- {
- if(last_tok != NULL)
- {
- if(strcmp(last_tok, "voluntary_ctxt_switches") == 0 || strcmp(last_tok, "nonvoluntary_ctxt_switches") == 0)
- {
+
+ while (tok != NULL) {
+ if (last_tok != NULL) {
+ if ((strcmp(last_tok,
+ "voluntary_ctxt_switches") == 0) || (strcmp(last_tok, "nonvoluntary_ctxt_switches") == 0)) {
char *chk;
process->ctx_switches += strtol(tok, &chk, 10);
- if(*chk != '\0')
- {
+ if (*chk != '\0') {
fprintf(stderr, "Could not parse ctx_switches info from /proc/%d/status", process->pid);
free(buffer);
return DLT_RETURN_ERROR;
@@ -143,9 +141,8 @@ DltReturnValue dlt_kpi_process_update_ctx_switches(DltKpiProcess *process)
DltReturnValue dlt_kpi_process_update_io_bytes(DltKpiProcess *process)
{
- if(process == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (process == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -154,23 +151,21 @@ DltReturnValue dlt_kpi_process_update_io_bytes(DltKpiProcess *process)
last_tok = NULL;
DltReturnValue ret;
- if((ret = dlt_kpi_read_process_file_to_str(process->pid, &buffer, "io")) < DLT_RETURN_OK)
+
+ if ((ret = dlt_kpi_read_process_file_to_str(process->pid, &buffer, "io")) < DLT_RETURN_OK)
return ret;
process->io_bytes = 0;
tok = strtok(buffer, delim);
- while(tok != NULL)
- {
- if(last_tok != NULL)
- {
- if(strcmp(last_tok, "rchar") == 0 || strcmp(last_tok, "wchar") == 0)
- {
+
+ while (tok != NULL) {
+ if (last_tok != NULL) {
+ if ((strcmp(last_tok, "rchar") == 0) || (strcmp(last_tok, "wchar") == 0)) {
char *chk;
process->io_bytes += strtoul(tok, &chk, 10);
- if(*chk != '\0')
- {
+ if (*chk != '\0') {
fprintf(stderr, "Could not parse io_bytes info from /proc/%d/io", process->pid);
free(buffer);
return DLT_RETURN_ERROR;
@@ -190,9 +185,8 @@ DltReturnValue dlt_kpi_process_update_io_bytes(DltKpiProcess *process)
DltReturnValue dlt_kpi_update_process(DltKpiProcess *process, unsigned long int time_dif_ms)
{
- if(process == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (process == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -208,9 +202,9 @@ DltReturnValue dlt_kpi_update_process(DltKpiProcess *process, unsigned long int
DltKpiProcess *dlt_kpi_create_process(int pid)
{
DltKpiProcess *new_process = malloc(sizeof(DltKpiProcess));
- if(new_process == NULL)
- {
- fprintf(stderr, "%s: Out of Memory \n", __func__);
+
+ if (new_process == NULL) {
+ fprintf(stderr, "%s: Out of Memory \n", __func__);
return NULL;
}
@@ -220,9 +214,9 @@ DltKpiProcess *dlt_kpi_create_process(int pid)
new_process->ppid = (pid_t)dlt_kpi_read_process_stat_to_ulong(pid, 4);
dlt_kpi_read_process_file_to_str(pid, &(new_process->command_line), "cmdline");
- if(new_process->command_line != NULL)
- if(strlen(new_process->command_line) == 0)
- {
+
+ if (new_process->command_line != NULL)
+ if (strlen(new_process->command_line) == 0) {
free(new_process->command_line);
dlt_kpi_read_process_stat_cmdline(pid, &(new_process->command_line));
}
@@ -234,35 +228,35 @@ DltKpiProcess *dlt_kpi_create_process(int pid)
DltKpiProcess *dlt_kpi_clone_process(DltKpiProcess *original)
{
- if(original == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (original == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return NULL;
}
- // DltKpiProcess *new_process = dlt_kpi_create_process(original->pid);
+ /* DltKpiProcess *new_process = dlt_kpi_create_process(original->pid); */
DltKpiProcess *new_process = malloc(sizeof(DltKpiProcess));
- if(new_process == NULL)
- {
- fprintf(stderr, "%s: Out of Memory\n", __func__);
+
+ if (new_process == NULL) {
+ fprintf(stderr, "%s: Out of Memory\n", __func__);
return NULL;
}
memcpy(new_process, original, sizeof(DltKpiProcess));
- if(original->command_line != NULL)
- {
+ if (original->command_line != NULL) {
new_process->command_line = malloc(strlen(original->command_line) + 1);
- if(new_process->command_line == NULL)
- {
+
+ if (new_process->command_line == NULL) {
fprintf(stderr, "%s: Out of Memory\n", __func__);
free(new_process);
return NULL;
}
+
strncpy(new_process->command_line, original->command_line, strlen(original->command_line) + 1);
}
- else
+ else {
new_process->command_line = NULL;
+ }
new_process->next = new_process->prev = NULL;
@@ -271,13 +265,12 @@ DltKpiProcess *dlt_kpi_clone_process(DltKpiProcess *original)
DltReturnValue dlt_kpi_free_process(DltKpiProcess *process)
{
- if(process == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (process == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if(process->command_line != NULL)
+ if (process->command_line != NULL)
free(process->command_line);
free(process);
@@ -287,9 +280,8 @@ DltReturnValue dlt_kpi_free_process(DltKpiProcess *process)
DltReturnValue dlt_kpi_print_process(DltKpiProcess *process)
{
- if(process == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (process == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -307,23 +299,20 @@ DltReturnValue dlt_kpi_print_process(DltKpiProcess *process)
DltReturnValue dlt_kpi_read_process_file_to_str(pid_t pid, char **target_str, char *subdir)
{
- if(target_str == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (target_str == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_ERROR;
}
*target_str = NULL;
- if(pid <= 0)
- {
- fprintf(stderr, "%s: Invalid Parameter (PID)\n", __func__);
+ if (pid <= 0) {
+ fprintf(stderr, "%s: Invalid Parameter (PID)\n", __func__);
return DLT_RETURN_ERROR;
}
- if(subdir == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (subdir == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_ERROR;
}
@@ -335,18 +324,17 @@ DltReturnValue dlt_kpi_read_process_file_to_str(pid_t pid, char **target_str, ch
unsigned long int dlt_kpi_read_process_stat_to_ulong(pid_t pid, unsigned int index)
{
- if(pid <= 0)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (pid <= 0) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return 0;
}
char *buffer = NULL;
- if(dlt_kpi_read_process_file_to_str(pid, &buffer, "stat") < DLT_RETURN_OK)
- {
- // fprintf(stderr, "dlt_kpi_read_process_stat_to_ulong(): Error while reading process stat file. Pid: %d. Requested index: %u\n", pid, index); // can happen if process closed shortly before
- if(buffer != NULL)
+ if (dlt_kpi_read_process_file_to_str(pid, &buffer, "stat") < DLT_RETURN_OK) {
+ /* fprintf(stderr, "dlt_kpi_read_process_stat_to_ulong(): Error while reading process stat file. Pid: %d. Requested index: %u\n", pid, index); // can happen if process closed shortly before */
+
+ if (buffer != NULL)
free(buffer);
return 0;
@@ -355,31 +343,30 @@ unsigned long int dlt_kpi_read_process_stat_to_ulong(pid_t pid, unsigned int ind
char *tok = strtok(buffer, " \t\n");
unsigned int i = 1, found = 0;
- while(tok != NULL)
- {
- if(i == index)
- {
+ while (tok != NULL) {
+ if (i == index) {
found = 1;
break;
}
+
i++;
tok = strtok(NULL, " \t\n");
}
unsigned long int ret = 0;
- if(found)
- {
+ if (found) {
char *check = NULL;
ret = strtoul(tok, &check, 10);
- if(*check != '\0')
- {
+
+ if (*check != '\0') {
fprintf(stderr, "dlt_kpi_read_process_stat_to_ulong(): Could not extract token\n");
ret = 0;
}
}
- else
+ else {
fprintf(stderr, "dlt_kpi_read_process_stat_to_ulong(): Index not found\n");
+ }
free(buffer);
@@ -388,23 +375,21 @@ unsigned long int dlt_kpi_read_process_stat_to_ulong(pid_t pid, unsigned int ind
DltReturnValue dlt_kpi_read_process_stat_cmdline(pid_t pid, char **buffer)
{
- if(pid <= 0)
- {
- fprintf(stderr, "%s: Invalid Parameter (PID)\n", __func__);
+ if (pid <= 0) {
+ fprintf(stderr, "%s: Invalid Parameter (PID)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if(buffer == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if (buffer == NULL) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
char *tmp_buffer = NULL;
DltReturnValue tmp = dlt_kpi_read_process_file_to_str(pid, &tmp_buffer, "stat");
- if(tmp < DLT_RETURN_OK)
- {
- if(tmp_buffer != NULL)
+
+ if (tmp < DLT_RETURN_OK) {
+ if (tmp_buffer != NULL)
free(tmp_buffer);
return tmp;
@@ -413,23 +398,19 @@ DltReturnValue dlt_kpi_read_process_stat_cmdline(pid_t pid, char **buffer)
char *tok = strtok(tmp_buffer, " \t\n");
unsigned int i = 1;
- while(tok != NULL)
- {
- if(i == 2)
- {
+ while (tok != NULL) {
+ if (i == 2)
break;
- }
+
i++;
tok = strtok(NULL, " \t\n");
}
- if(i == 2)
- {
+ if (i == 2) {
(*buffer) = malloc(strlen(tok) + 1);
strncpy(*buffer, tok, strlen(tok) + 1);
}
- else
- {
+ else {
fprintf(stderr, "dlt_kpi_read_process_stat_cmdline(): cmdline entry not found\n");
return DLT_RETURN_ERROR;
}
@@ -441,22 +422,28 @@ DltReturnValue dlt_kpi_read_process_stat_cmdline(pid_t pid, char **buffer)
DltReturnValue dlt_kpi_get_msg_process_update(DltKpiProcess *process, char *buffer, int maxlen)
{
- if(process == NULL || buffer == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if ((process == NULL) || (buffer == NULL)) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- snprintf(buffer, maxlen, "%d;%lu;%ld;%ld;%lu;%lu", process->pid, process->cpu_time, process->rss, process->ctx_switches, process->io_bytes, process->io_wait);
+ snprintf(buffer,
+ maxlen,
+ "%d;%lu;%ld;%ld;%lu;%lu",
+ process->pid,
+ process->cpu_time,
+ process->rss,
+ process->ctx_switches,
+ process->io_bytes,
+ process->io_wait);
return DLT_RETURN_OK;
}
DltReturnValue dlt_kpi_get_msg_process_new(DltKpiProcess *process, char *buffer, int maxlen)
{
- if(process == NULL || buffer == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if ((process == NULL) || (buffer == NULL)) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -467,9 +454,8 @@ DltReturnValue dlt_kpi_get_msg_process_new(DltKpiProcess *process, char *buffer,
DltReturnValue dlt_kpi_get_msg_process_stop(DltKpiProcess *process, char *buffer, int maxlen)
{
- if(process == NULL || buffer == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if ((process == NULL) || (buffer == NULL)) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -480,9 +466,8 @@ DltReturnValue dlt_kpi_get_msg_process_stop(DltKpiProcess *process, char *buffer
DltReturnValue dlt_kpi_get_msg_process_commandline(DltKpiProcess *process, char *buffer, int maxlen)
{
- if(process == NULL || buffer == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if ((process == NULL) || (buffer == NULL)) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
diff --git a/src/kpi/dlt-kpi-process.h b/src/kpi/dlt-kpi-process.h
index 50d5fbc..6ad1b4e 100644
--- a/src/kpi/dlt-kpi-process.h
+++ b/src/kpi/dlt-kpi-process.h
@@ -31,7 +31,7 @@
#include <stdlib.h>
#include "dlt-kpi-common.h"
-typedef struct DltKpiEventWatch DltKpiEventWatch; // forward declaration
+typedef struct DltKpiEventWatch DltKpiEventWatch; /* forward declaration */
typedef struct DltKpiProcess
{
diff --git a/src/kpi/dlt-kpi.c b/src/kpi/dlt-kpi.c
index 8ba019e..0fbff3a 100644
--- a/src/kpi/dlt-kpi.c
+++ b/src/kpi/dlt-kpi.c
@@ -69,22 +69,19 @@ int main(int argc, char **argv)
{
printf("Launching dlt-kpi...\n");
- if(dlt_kpi_init(argc, argv, &config) < DLT_RETURN_OK)
- {
+ if (dlt_kpi_init(argc, argv, &config) < DLT_RETURN_OK) {
fprintf(stderr, "Initialization error!\n");
return -1;
}
dlt_kpi_init_sigterm_handler();
- if(dlt_kpi_init_process_lists() < DLT_RETURN_OK)
- {
+ if (dlt_kpi_init_process_lists() < DLT_RETURN_OK) {
fprintf(stderr, "Error occurred initializing process lists\n");
return -1;
}
- if(pthread_mutex_init(&process_list_mutex, NULL) < 0)
- {
+ if (pthread_mutex_init(&process_list_mutex, NULL) < 0) {
fprintf(stderr, "Error occurred initializing mutex\n");
return -1;
}
@@ -96,18 +93,17 @@ int main(int argc, char **argv)
pthread_t irq_thread;
pthread_t check_thread;
- if(pthread_create(&process_thread, NULL, &dlt_kpi_start_process_thread, NULL) != 0)
- {
+ if (pthread_create(&process_thread, NULL, &dlt_kpi_start_process_thread, NULL) != 0) {
fprintf(stderr, "Could not create thread\n");
return -1;
}
- if(pthread_create(&irq_thread, NULL, &dlt_kpi_start_irq_thread, NULL) != 0)
- {
+
+ if (pthread_create(&irq_thread, NULL, &dlt_kpi_start_irq_thread, NULL) != 0) {
fprintf(stderr, "Could not create thread\n");
return -1;
}
- if(pthread_create(&check_thread, NULL, &dlt_kpi_start_check_thread, NULL) != 0)
- {
+
+ if (pthread_create(&check_thread, NULL, &dlt_kpi_start_check_thread, NULL) != 0) {
fprintf(stderr, "Could not create thread\n");
return -1;
}
@@ -124,7 +120,7 @@ int main(int argc, char **argv)
dlt_kpi_free_process_lists();
printf("Done.\n");
-
+
return 0;
}
@@ -139,7 +135,7 @@ void dlt_kpi_init_sigterm_handler()
void dlt_kpi_stop_loops(int sig)
{
- if(sig > -1)
+ if (sig > -1)
fprintf(stderr, "dlt-kpi is now terminating due to signal %d...\n", sig);
else
fprintf(stderr, "dlt-kpi is now terminating due to an error...\n");
@@ -149,10 +145,13 @@ void dlt_kpi_stop_loops(int sig)
DltReturnValue dlt_kpi_init_process_lists()
{
- if((list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR;
- if((new_process_list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR;
- if((stopped_process_list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR;
- if((update_process_list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR;
+ if ((list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR;
+
+ if ((new_process_list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR;
+
+ if ((stopped_process_list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR;
+
+ if ((update_process_list = dlt_kpi_create_process_list()) == NULL) return DLT_RETURN_ERROR;
return DLT_RETURN_OK;
}
@@ -161,16 +160,16 @@ DltReturnValue dlt_kpi_free_process_lists()
{
DltReturnValue ret = DLT_RETURN_OK;
- if(dlt_kpi_free_process_list(list) < DLT_RETURN_OK)
+ if (dlt_kpi_free_process_list(list) < DLT_RETURN_OK)
ret = DLT_RETURN_ERROR;
- if(dlt_kpi_free_process_list(new_process_list) < DLT_RETURN_OK)
+ if (dlt_kpi_free_process_list(new_process_list) < DLT_RETURN_OK)
ret = DLT_RETURN_ERROR;
- if(dlt_kpi_free_process_list(stopped_process_list) < DLT_RETURN_OK)
+ if (dlt_kpi_free_process_list(stopped_process_list) < DLT_RETURN_OK)
ret = DLT_RETURN_ERROR;
- if(dlt_kpi_free_process_list(update_process_list) < DLT_RETURN_OK)
+ if (dlt_kpi_free_process_list(update_process_list) < DLT_RETURN_OK)
ret = DLT_RETURN_ERROR;
return ret;
@@ -178,7 +177,7 @@ DltReturnValue dlt_kpi_free_process_lists()
void *dlt_kpi_start_process_thread()
{
- if(dlt_kpi_process_loop() < DLT_RETURN_OK)
+ if (dlt_kpi_process_loop() < DLT_RETURN_OK)
dlt_kpi_stop_loops(-1);
return NULL;
@@ -190,15 +189,14 @@ DltReturnValue dlt_kpi_process_loop()
old_millis = get_millis();
- while(!stop_loop)
- {
+ while (!stop_loop) {
/*DltReturnValue ret = */ dlt_kpi_update_process_list(list, config.process_log_interval);
- //if(ret < DLT_RETURN_OK)
- // return ret;
+ /*if(ret < DLT_RETURN_OK) */
+ /* return ret; */
dif_millis = get_millis() - old_millis;
- if(dif_millis >= (unsigned long)(config.process_log_interval))
+ if (dif_millis >= (unsigned long)(config.process_log_interval))
sleep_millis = 0;
else
sleep_millis = config.process_log_interval - dif_millis;
@@ -211,19 +209,22 @@ DltReturnValue dlt_kpi_process_loop()
return DLT_RETURN_OK;
}
-DltReturnValue dlt_kpi_log_list(DltKpiProcessList *list, DltReturnValue(*process_callback)(DltKpiProcess*, char*, int), char *title, int delete_elements)
+DltReturnValue dlt_kpi_log_list(DltKpiProcessList *list,
+ DltReturnValue (*process_callback)(DltKpiProcess *, char *, int),
+ char *title,
+ int delete_elements)
{
- if(list == NULL || process_callback == NULL || title == NULL)
- {
- fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
+ if ((list == NULL) || (process_callback == NULL) || (title == NULL)) {
+ fprintf(stderr, "%s: Invalid Parameter (NULL)\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
dlt_kpi_reset_cursor(list);
- if(list->cursor == NULL)
- return DLT_RETURN_OK; // list empty; nothing to do
- // Synchronization message
+ if (list->cursor == NULL)
+ return DLT_RETURN_OK; /* list empty; nothing to do */
+
+ /* Synchronization message */
DLT_LOG(kpi_ctx, config.log_level, DLT_STRING(title), DLT_STRING("BEG"));
DltReturnValue ret;
@@ -232,63 +233,53 @@ DltReturnValue dlt_kpi_log_list(DltKpiProcessList *list, DltReturnValue(*process
char buffer[BUFFER_SIZE];
buffer[0] = '\0';
- if((ret = dlt_user_log_write_start(&kpi_ctx, &data, config.log_level)) < DLT_RETURN_OK)
- {
- fprintf(stderr, "%s: dlt_user_log_write_start() returned error.\n", __func__);
+ if ((ret = dlt_user_log_write_start(&kpi_ctx, &data, config.log_level)) < DLT_RETURN_OK) {
+ fprintf(stderr, "%s: dlt_user_log_write_start() returned error.\n", __func__);
return ret;
}
- if((ret = dlt_user_log_write_string(&data, title)) < DLT_RETURN_OK)
- {
- fprintf(stderr, "%s: dlt_user_log_write_string() returned error.\n", __func__);
+ if ((ret = dlt_user_log_write_string(&data, title)) < DLT_RETURN_OK) {
+ fprintf(stderr, "%s: dlt_user_log_write_string() returned error.\n", __func__);
return ret;
}
- do
- {
- if((ret = (*process_callback)(list->cursor, buffer, sizeof(buffer) - 1)) < DLT_RETURN_OK)
+ do {
+ if ((ret = (*process_callback)(list->cursor, buffer, sizeof(buffer) - 1)) < DLT_RETURN_OK)
return ret;
- if((ret = dlt_user_log_write_string(&data, buffer)) < DLT_RETURN_OK)
- {
+ if ((ret = dlt_user_log_write_string(&data, buffer)) < DLT_RETURN_OK) {
/* Log buffer full => Write log and start new one*/
- if((ret = dlt_user_log_write_finish(&data)) < DLT_RETURN_OK)
- {
- fprintf(stderr, "%s: dlt_user_log_write_finish() returned error.\n",__func__);
+ if ((ret = dlt_user_log_write_finish(&data)) < DLT_RETURN_OK) {
+ fprintf(stderr, "%s: dlt_user_log_write_finish() returned error.\n", __func__);
return ret;
}
- if((ret = dlt_user_log_write_start(&kpi_ctx, &data, config.log_level)) < DLT_RETURN_OK)
- {
- fprintf(stderr, "%s: dlt_user_log_write_start() returned error.\n",__func__);
+ if ((ret = dlt_user_log_write_start(&kpi_ctx, &data, config.log_level)) < DLT_RETURN_OK) {
+ fprintf(stderr, "%s: dlt_user_log_write_start() returned error.\n", __func__);
return ret;
}
- if((ret = dlt_user_log_write_string(&data, title)) < DLT_RETURN_OK)
- {
- fprintf(stderr, "%s: dlt_user_log_write_string() returned error.\n",__func__);
+ if ((ret = dlt_user_log_write_string(&data, title)) < DLT_RETURN_OK) {
+ fprintf(stderr, "%s: dlt_user_log_write_string() returned error.\n", __func__);
return ret;
}
}
- else if(delete_elements)
+ else if (delete_elements)
{
- if((ret = dlt_kpi_remove_process_at_cursor(list)) < DLT_RETURN_OK)
+ if ((ret = dlt_kpi_remove_process_at_cursor(list)) < DLT_RETURN_OK)
return ret;
}
- else
- {
+ else {
list->cursor = list->cursor->next;
}
- }
- while(list->cursor != NULL);
+ } while (list->cursor != NULL);
- if((ret = dlt_user_log_write_finish(&data)) < DLT_RETURN_OK)
- {
- fprintf(stderr, "%s: dlt_user_log_write_finish() returned error.\n",__func__);
+ if ((ret = dlt_user_log_write_finish(&data)) < DLT_RETURN_OK) {
+ fprintf(stderr, "%s: dlt_user_log_write_finish() returned error.\n", __func__);
return ret;
}
- // Synchronization message
+ /* Synchronization message */
DLT_LOG(kpi_ctx, config.log_level, DLT_STRING(title), DLT_STRING("END"));
return DLT_RETURN_OK;
@@ -301,15 +292,14 @@ DltReturnValue dlt_kpi_update_process_list(DltKpiProcessList *list, unsigned lon
static struct dirent *current_dir;
static pid_t current_dir_pid;
- if(list == NULL)
- {
+ if (list == NULL) {
fprintf(stderr, "dlt_kpi_update_process_list(): Nullpointer parameter");
return DLT_RETURN_WRONG_PARAMETER;
}
DIR *proc_dir = opendir("/proc");
- if(proc_dir == NULL)
- {
+
+ if (proc_dir == NULL) {
dlt_log(LOG_ERR, "Could not open /proc/ !\n");
return DLT_RETURN_ERROR;
}
@@ -319,21 +309,19 @@ DltReturnValue dlt_kpi_update_process_list(DltKpiProcessList *list, unsigned lon
int debug_process_count = 0;
- if(pthread_mutex_lock(&process_list_mutex) < 0)
- {
+ if (pthread_mutex_lock(&process_list_mutex) < 0) {
fprintf(stderr, "Can't lock mutex\n");
return DLT_RETURN_ERROR;
}
- while(1)
- {
- if(current_dir == NULL)
- {
+ while (1) {
+ if (current_dir == NULL) {
/* no more active processes.. delete all remaining processes in the list */
- if(list->cursor != NULL)
- while(list->cursor != NULL)
- {
- if((tmp_ret = dlt_kpi_add_process_after_cursor(stopped_process_list, dlt_kpi_clone_process(list->cursor))) < DLT_RETURN_OK)
+ if (list->cursor != NULL)
+ while (list->cursor != NULL) {
+ if ((tmp_ret =
+ dlt_kpi_add_process_after_cursor(stopped_process_list,
+ dlt_kpi_clone_process(list->cursor))) < DLT_RETURN_OK)
return tmp_ret;
dlt_kpi_remove_process_at_cursor(list);
@@ -343,80 +331,83 @@ DltReturnValue dlt_kpi_update_process_list(DltKpiProcessList *list, unsigned lon
}
current_dir_pid = strtol(current_dir->d_name, &strchk, 10);
- if(*strchk != '\0' || current_dir_pid <= 0)
- {
+
+ if ((*strchk != '\0') || (current_dir_pid <= 0)) {
/* no valid PID */
- current_dir = readdir(proc_dir); // next process in proc-fs
+ current_dir = readdir(proc_dir); /* next process in proc-fs */
continue;
}
/* compare the /proc/-filesystem with our process-list */
- if(list->cursor == NULL || current_dir_pid < list->cursor->pid) // New Process
- {
+ if ((list->cursor == NULL) || (current_dir_pid < list->cursor->pid)) { /* New Process */
DltKpiProcess *new_process = dlt_kpi_create_process(current_dir_pid);
- if(new_process == NULL)
- {
+
+ if (new_process == NULL) {
fprintf(stderr, "Error: Could not create process (out of memory?)\n");
return DLT_RETURN_ERROR;
}
- if((tmp_ret = dlt_kpi_add_process_before_cursor(list, new_process)) < DLT_RETURN_OK)
+ if ((tmp_ret = dlt_kpi_add_process_before_cursor(list, new_process)) < DLT_RETURN_OK)
return tmp_ret;
- if((tmp_ret = dlt_kpi_add_process_before_cursor(new_process_list, dlt_kpi_clone_process(new_process))) < DLT_RETURN_OK)
+ if ((tmp_ret =
+ dlt_kpi_add_process_before_cursor(new_process_list,
+ dlt_kpi_clone_process(new_process))) < DLT_RETURN_OK)
return tmp_ret;
- current_dir = readdir(proc_dir); // next process in proc-fs
+ current_dir = readdir(proc_dir); /* next process in proc-fs */
debug_process_count++;
}
- else if(current_dir_pid > list->cursor->pid) // Process ended
+ else if (current_dir_pid > list->cursor->pid) /* Process ended */
{
- if((tmp_ret = dlt_kpi_add_process_after_cursor(stopped_process_list, dlt_kpi_clone_process(list->cursor))) < DLT_RETURN_OK)
+ if ((tmp_ret =
+ dlt_kpi_add_process_after_cursor(stopped_process_list,
+ dlt_kpi_clone_process(list->cursor))) < DLT_RETURN_OK)
return tmp_ret;
- if((tmp_ret = dlt_kpi_remove_process_at_cursor(list)) < DLT_RETURN_OK)
+ if ((tmp_ret = dlt_kpi_remove_process_at_cursor(list)) < DLT_RETURN_OK)
return tmp_ret;
}
- else if(current_dir_pid == list->cursor->pid) // Staying process
+ else if (current_dir_pid == list->cursor->pid) /* Staying process */
{
/* update data */
- if((tmp_ret = dlt_kpi_update_process(list->cursor, time_dif_ms)) < DLT_RETURN_OK)
- return tmp_ret;
+ if ((tmp_ret = dlt_kpi_update_process(list->cursor, time_dif_ms)) < DLT_RETURN_OK)
+ return tmp_ret;
- if(list->cursor->cpu_time > 0) // only log active processes
- if((tmp_ret = dlt_kpi_add_process_after_cursor(update_process_list, dlt_kpi_clone_process(list->cursor))) < DLT_RETURN_OK)
- {
+ if (list->cursor->cpu_time > 0) /* only log active processes */
+ if ((tmp_ret =
+ dlt_kpi_add_process_after_cursor(update_process_list,
+ dlt_kpi_clone_process(list->cursor))) < DLT_RETURN_OK) {
fprintf(stderr, "dlt_kpi_update_process_list: Can't add process to list updateProcessList\n");
return tmp_ret;
}
- if((tmp_ret = dlt_kpi_increment_cursor(list)) < DLT_RETURN_OK) // next process in list
+ if ((tmp_ret = dlt_kpi_increment_cursor(list)) < DLT_RETURN_OK) /* next process in list */
return tmp_ret;
- current_dir = readdir(proc_dir); // next process in proc-fs
+ current_dir = readdir(proc_dir); /* next process in proc-fs */
debug_process_count++;
}
}
- if(pthread_mutex_unlock(&process_list_mutex) < 0)
- {
+ if (pthread_mutex_unlock(&process_list_mutex) < 0) {
fprintf(stderr, "Can't unlock mutex\n");
return DLT_RETURN_ERROR;
}
/* Log new processes */
- if((tmp_ret = dlt_kpi_log_list(new_process_list, &dlt_kpi_get_msg_process_new, "NEW", 1)) < DLT_RETURN_OK)
+ if ((tmp_ret = dlt_kpi_log_list(new_process_list, &dlt_kpi_get_msg_process_new, "NEW", 1)) < DLT_RETURN_OK)
return tmp_ret;
/* Log stopped processes */
- if((tmp_ret = dlt_kpi_log_list(stopped_process_list, &dlt_kpi_get_msg_process_stop, "STP", 1)) < DLT_RETURN_OK)
+ if ((tmp_ret = dlt_kpi_log_list(stopped_process_list, &dlt_kpi_get_msg_process_stop, "STP", 1)) < DLT_RETURN_OK)
return tmp_ret;
/* Log active processes */
- if((tmp_ret = dlt_kpi_log_list(update_process_list, &dlt_kpi_get_msg_process_update, "ACT", 1)) < DLT_RETURN_OK)
+ if ((tmp_ret = dlt_kpi_log_list(update_process_list, &dlt_kpi_get_msg_process_update, "ACT", 1)) < DLT_RETURN_OK)
return tmp_ret;
- if(closedir(proc_dir) < 0)
+ if (closedir(proc_dir) < 0)
fprintf(stderr, "Could not close /proc/ directory\n");
return DLT_RETURN_OK;
@@ -424,7 +415,7 @@ DltReturnValue dlt_kpi_update_process_list(DltKpiProcessList *list, unsigned lon
void *dlt_kpi_start_irq_thread()
{
- if(dlt_kpi_irq_loop() < DLT_RETURN_OK)
+ if (dlt_kpi_irq_loop() < DLT_RETURN_OK)
dlt_kpi_stop_loops(-1);
return NULL;
@@ -436,15 +427,14 @@ DltReturnValue dlt_kpi_irq_loop()
old_millis = get_millis();
- while(!stop_loop)
- {
+ while (!stop_loop) {
/*DltReturnValue ret = */ dlt_kpi_log_interrupts(&kpi_ctx, config.log_level);
- //if(ret < DLT_RETURN_OK)
- // return ret;
+ /*if(ret < DLT_RETURN_OK) */
+ /* return ret; */
dif_millis = get_millis() - old_millis;
- if(dif_millis >= (unsigned long)(config.irq_log_interval))
+ if (dif_millis >= (unsigned long)(config.irq_log_interval))
sleep_millis = 0;
else
sleep_millis = config.irq_log_interval - dif_millis;
@@ -459,7 +449,7 @@ DltReturnValue dlt_kpi_irq_loop()
void *dlt_kpi_start_check_thread()
{
- if(dlt_kpi_check_loop() < DLT_RETURN_OK)
+ if (dlt_kpi_check_loop() < DLT_RETURN_OK)
dlt_kpi_stop_loops(-1);
return NULL;
@@ -471,15 +461,14 @@ DltReturnValue dlt_kpi_check_loop()
old_millis = get_millis();
- while(!stop_loop)
- {
+ while (!stop_loop) {
/*DltReturnValue ret = */ dlt_kpi_log_check_commandlines();
- //if(ret < DLT_RETURN_OK)
- // return ret;
+ /*if(ret < DLT_RETURN_OK) */
+ /* return ret; */
dif_millis = get_millis() - old_millis;
- if(dif_millis >= (unsigned long)(config.check_log_interval))
+ if (dif_millis >= (unsigned long)(config.check_log_interval))
sleep_millis = 0;
else
sleep_millis = config.check_log_interval - dif_millis;
@@ -494,16 +483,14 @@ DltReturnValue dlt_kpi_check_loop()
DltReturnValue dlt_kpi_log_check_commandlines()
{
- if(pthread_mutex_lock(&process_list_mutex) < 0)
- {
+ if (pthread_mutex_lock(&process_list_mutex) < 0) {
fprintf(stderr, "Can't lock mutex\n");
return DLT_RETURN_ERROR;
}
DltReturnValue ret = dlt_kpi_log_list(list, dlt_kpi_get_msg_process_commandline, "CHK", 0);
- if(pthread_mutex_unlock(&process_list_mutex) < 0)
- {
+ if (pthread_mutex_unlock(&process_list_mutex) < 0) {
fprintf(stderr, "Can't unlock mutex\n");
return DLT_RETURN_ERROR;
}
diff --git a/src/kpi/dlt-kpi.h b/src/kpi/dlt-kpi.h
index bb5b48c..ff647d4 100644
--- a/src/kpi/dlt-kpi.h
+++ b/src/kpi/dlt-kpi.h
@@ -35,12 +35,12 @@
#include "dlt-kpi-process.h"
#include "dlt-kpi-process-list.h"
-// CONSTANT DEFINITIONS
-#define DEFAULT_CONF_FILE ( CONFIGURATION_FILES_DIR "/dlt-kpi.conf")
+/* CONSTANT DEFINITIONS */
+#define DEFAULT_CONF_FILE (CONFIGURATION_FILES_DIR "/dlt-kpi.conf")
#define COMMAND_LINE_SIZE 1024
-// STRUCTURES
+/* STRUCTURES */
typedef struct
{
char *configurationFileName;
@@ -53,7 +53,7 @@ typedef struct
DltLogLevelType log_level;
} DltKpiConfig;
-// FUNCTION DECLARATIONS:
+/* FUNCTION DECLARATIONS: */
DltReturnValue dlt_kpi_read_command_line(DltKpiOptions *options, int argc, char **argv);
DltReturnValue dlt_kpi_read_configuration_file(DltKpiConfig *config, char *file_name);
void dlt_kpi_free_cli_options(DltKpiOptions *options);
diff --git a/src/lib/dlt_client.c b/src/lib/dlt_client.c
index 4723e00..745aa4f 100644
--- a/src/lib/dlt_client.c
+++ b/src/lib/dlt_client.c
@@ -63,28 +63,28 @@
* $LastChangedRevision$
* $LastChangedDate$
* $LastChangedBy$
- Initials Date Comment
- aw 12.07.2010 initial
+ * Initials Date Comment
+ * aw 12.07.2010 initial
*/
#include <stdio.h>
#if defined (__WIN32__) || defined (_MSC_VER)
-#pragma warning(disable : 4996) /* Switch off C4996 warnings */
-#include <winsock2.h> /* for socket(), connect(), send(), and recv() */
+# pragma warning(disable : 4996) /* Switch off C4996 warnings */
+# include <winsock2.h> /* for socket(), connect(), send(), and recv() */
#else
-#include <sys/socket.h> /* for socket(), connect(), send(), and recv() */
-#include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
-#include <netdb.h>
-#include <sys/stat.h>
-#include <sys/un.h>
+# include <sys/socket.h> /* for socket(), connect(), send(), and recv() */
+# include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
+# include <netdb.h>
+# include <sys/stat.h>
+# include <sys/un.h>
#endif
#if defined(_MSC_VER)
-#include <io.h>
+# include <io.h>
#else
-#include <unistd.h>
-#include <syslog.h>
+# include <unistd.h>
+# include <syslog.h>
#endif
#include <fcntl.h>
@@ -98,34 +98,31 @@
#include "dlt_client.h"
#include "dlt_client_cfg.h"
-static int (*message_callback_function) (DltMessage *message, void *data) = NULL;
+static int (*message_callback_function)(DltMessage *message, void *data) = NULL;
static char str[DLT_CLIENT_TEXTBUFSIZE];
-void dlt_client_register_message_callback(int (*registerd_callback) (DltMessage *message, void *data)){
+void dlt_client_register_message_callback(int (*registerd_callback)(DltMessage *message, void *data))
+{
message_callback_function = registerd_callback;
}
DltReturnValue dlt_client_init_port(DltClient *client, int port, int verbose)
{
- if (verbose && port != DLT_DAEMON_TCP_PORT)
- {
+ if (verbose && (port != DLT_DAEMON_TCP_PORT))
dlt_vlog(LOG_INFO, "Init dlt client struct with port %d\n", port);
- }
if (client == NULL)
- {
return DLT_RETURN_ERROR;
- }
- client->sock=-1;
- client->servIP=0;
- client->serialDevice=0;
- client->baudrate=DLT_CLIENT_INITIAL_BAUDRATE;
+ client->sock = -1;
+ client->servIP = 0;
+ client->serialDevice = 0;
+ client->baudrate = DLT_CLIENT_INITIAL_BAUDRATE;
client->port = port;
client->socketPath = 0;
- client->mode=DLT_CLIENT_MODE_TCP;
- client->receiver.buffer=0;
+ client->mode = DLT_CLIENT_MODE_TCP;
+ client->receiver.buffer = 0;
return DLT_RETURN_OK;
}
@@ -139,28 +136,25 @@ DltReturnValue dlt_client_init(DltClient *client, int verbose)
/* the port may be specified by an environment variable */
env_daemon_port = getenv(DLT_CLIENT_ENV_DAEMON_TCP_PORT);
- if (env_daemon_port != NULL)
- {
+
+ if (env_daemon_port != NULL) {
tmp_port = atoi(env_daemon_port);
- if ((tmp_port < IPPORT_RESERVED) || (tmp_port > USHRT_MAX))
- {
+
+ if ((tmp_port < IPPORT_RESERVED) || (tmp_port > USHRT_MAX)) {
dlt_vlog(LOG_ERR,
"Specified port is out of possible range: %d.\n",
tmp_port);
return DLT_RETURN_ERROR;
}
- else
- {
+ else {
servPort = tmp_port;
}
}
if (verbose)
- {
dlt_vlog(LOG_INFO,
"Init dlt client struct with default port: %hu.\n",
servPort);
- }
return dlt_client_init_port(client, servPort, verbose);
}
@@ -174,21 +168,19 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose)
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
- if (client==0)
- {
+ if (client == 0)
return DLT_RETURN_ERROR;
- }
- switch (client->mode)
- {
+ switch (client->mode) {
case DLT_CLIENT_MODE_TCP:
snprintf(portnumbuffer, 32, "%d", client->port);
+
if ((rv = getaddrinfo(client->servIP, portnumbuffer, &hints, &servinfo)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
return DLT_RETURN_ERROR;
}
- for(p = servinfo; p != NULL; p = p->ai_next) {
+ for (p = servinfo; p != NULL; p = p->ai_next) {
if ((client->sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) {
snprintf(str, DLT_CLIENT_TEXTBUFSIZE,
"socket() failed! %s\n",
@@ -196,6 +188,7 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose)
dlt_log(LOG_WARNING, str);
continue;
}
+
if (connect(client->sock, p->ai_addr, p->ai_addrlen) < 0) {
snprintf(str, DLT_CLIENT_TEXTBUFSIZE,
"connect() failed! %s\n",
@@ -216,81 +209,79 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose)
}
if (verbose)
- {
- printf("Connected to DLT daemon (%s)\n",client->servIP);
- }
+ printf("Connected to DLT daemon (%s)\n", client->servIP);
+
break;
case DLT_CLIENT_MODE_SERIAL:
/* open serial connection */
- client->sock=open(client->serialDevice,O_RDWR);
- if (client->sock<0)
- {
- fprintf(stderr,"ERROR: Failed to open device %s\n", client->serialDevice);
+ client->sock = open(client->serialDevice, O_RDWR);
+
+ if (client->sock < 0) {
+ fprintf(stderr, "ERROR: Failed to open device %s\n", client->serialDevice);
return DLT_RETURN_ERROR;
}
- if (isatty(client->sock))
- {
+ if (isatty(client->sock)) {
#if !defined (__WIN32__)
- if (dlt_setup_serial(client->sock,client->baudrate) < DLT_RETURN_OK)
- {
- fprintf(stderr,"ERROR: Failed to configure serial device %s (%s) \n", client->serialDevice, strerror(errno));
+
+ if (dlt_setup_serial(client->sock, client->baudrate) < DLT_RETURN_OK) {
+ fprintf(stderr, "ERROR: Failed to configure serial device %s (%s) \n", client->serialDevice,
+ strerror(errno));
return DLT_RETURN_ERROR;
}
+
#else
- return DLT_RETURN_ERROR;
+ return DLT_RETURN_ERROR;
#endif
}
- else
- {
+ else {
if (verbose)
- {
- fprintf(stderr,"ERROR: Device is not a serial device, device = %s (%s) \n", client->serialDevice, strerror(errno));
- }
+ fprintf(stderr,
+ "ERROR: Device is not a serial device, device = %s (%s) \n",
+ client->serialDevice,
+ strerror(errno));
+
return DLT_RETURN_ERROR;
}
if (verbose)
- {
printf("Connected to %s\n", client->serialDevice);
- }
+
break;
case DLT_CLIENT_MODE_UNIX:
- if ((client->sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
- {
+
+ if ((client->sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
fprintf(stderr, "ERROR: (unix) socket error: %s\n", strerror(errno));
return DLT_RETURN_ERROR;
}
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- memcpy(addr.sun_path, client->socketPath, sizeof(addr.sun_path)-1);
+ memcpy(addr.sun_path, client->socketPath, sizeof(addr.sun_path) - 1);
if (connect(client->sock,
(struct sockaddr_un *)&addr,
- sizeof(addr)) == -1)
- {
+ sizeof(addr)) == -1) {
fprintf(stderr, "ERROR: (unix) connect error: %s\n", strerror(errno));
return DLT_RETURN_ERROR;
}
- if (client->sock < 0)
- {
- fprintf(stderr,"ERROR: Failed to open device %s\n",
+ if (client->sock < 0) {
+ fprintf(stderr, "ERROR: Failed to open device %s\n",
client->socketPath);
return DLT_RETURN_ERROR;
}
+
break;
default:
+
if (verbose)
- {
fprintf(stderr, "ERROR: Mode not supported: %d\n", client->mode);
- }
+
return DLT_RETURN_ERROR;
}
- if (dlt_receiver_init(&(client->receiver), client->sock, DLT_RECEIVE_BUFSIZE) != DLT_RETURN_OK)
- {
+ if (dlt_receiver_init(&(client->receiver), client->sock, DLT_RECEIVE_BUFSIZE) != DLT_RETURN_OK) {
fprintf(stderr, "ERROR initializing receiver\n");
return DLT_RETURN_ERROR;
}
@@ -303,37 +294,30 @@ DltReturnValue dlt_client_cleanup(DltClient *client, int verbose)
int ret = DLT_RETURN_OK;
if (verbose)
- {
printf("Cleanup dlt client\n");
- }
if (client == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (client->sock!=-1)
- {
+ if (client->sock != -1)
close(client->sock);
- }
- if (dlt_receiver_free(&(client->receiver)) != DLT_RETURN_OK)
- {
+ if (dlt_receiver_free(&(client->receiver)) != DLT_RETURN_OK) {
dlt_vlog(LOG_WARNING, "Failed to free receiver\n");
ret = DLT_RETURN_ERROR;
}
- if (client->serialDevice)
- {
+
+ if (client->serialDevice) {
free(client->serialDevice);
client->serialDevice = NULL;
}
- if (client->servIP)
- {
+
+ if (client->servIP) {
free(client->servIP);
client->servIP = NULL;
}
- if (client->socketPath)
- {
+
+ if (client->socketPath) {
free(client->socketPath);
client->socketPath = NULL;
}
@@ -346,72 +330,58 @@ DltReturnValue dlt_client_main_loop(DltClient *client, void *data, int verbose)
DltMessage msg;
int ret;
- if (client==0)
- {
+ if (client == 0)
return DLT_RETURN_ERROR;
- }
- if (dlt_message_init(&msg,verbose) == DLT_RETURN_ERROR)
- {
+ if (dlt_message_init(&msg, verbose) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
- while (1)
- {
+ while (1) {
/* wait for data from socket or serial connection */
ret = dlt_receiver_receive(&(client->receiver), client->mode);
- if (ret<=0)
- {
+ if (ret <= 0) {
/* No more data to be received */
- if (dlt_message_free(&msg,verbose) == DLT_RETURN_ERROR)
- {
+ if (dlt_message_free(&msg, verbose) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_TRUE;
}
- while (dlt_message_read(&msg,(unsigned char*)(client->receiver.buf),client->receiver.bytesRcvd,0,verbose) == DLT_MESSAGE_ERROR_OK)
- {
+ while (dlt_message_read(&msg, (unsigned char *)(client->receiver.buf), client->receiver.bytesRcvd, 0,
+ verbose) == DLT_MESSAGE_ERROR_OK) {
/* Call callback function */
if (message_callback_function)
- {
- (*message_callback_function)(&msg,data);
- }
+ (*message_callback_function)(&msg, data);
- if (msg.found_serialheader)
- {
- if (dlt_receiver_remove(&(client->receiver),msg.headersize+msg.datasize-sizeof(DltStorageHeader)+sizeof(dltSerialHeader)) == DLT_RETURN_ERROR)
- {
+ if (msg.found_serialheader) {
+ if (dlt_receiver_remove(&(client->receiver),
+ msg.headersize + msg.datasize - sizeof(DltStorageHeader) +
+ sizeof(dltSerialHeader)) ==
+ DLT_RETURN_ERROR) {
/* Return value ignored */
- dlt_message_free(&msg,verbose);
+ dlt_message_free(&msg, verbose);
return DLT_RETURN_ERROR;
}
}
- else
- {
- if (dlt_receiver_remove(&(client->receiver),msg.headersize+msg.datasize-sizeof(DltStorageHeader)) == DLT_RETURN_ERROR)
- {
- /* Return value ignored */
- dlt_message_free(&msg,verbose);
- return DLT_RETURN_ERROR;
- }
+ else if (dlt_receiver_remove(&(client->receiver),
+ msg.headersize + msg.datasize - sizeof(DltStorageHeader)) ==
+ DLT_RETURN_ERROR) {
+ /* Return value ignored */
+ dlt_message_free(&msg, verbose);
+ return DLT_RETURN_ERROR;
}
}
- if (dlt_receiver_move_to_begin(&(client->receiver)) == DLT_RETURN_ERROR)
- {
+ if (dlt_receiver_move_to_begin(&(client->receiver)) == DLT_RETURN_ERROR) {
/* Return value ignored */
- dlt_message_free(&msg,verbose);
+ dlt_message_free(&msg, verbose);
return DLT_RETURN_ERROR;
}
}
- if (dlt_message_free(&msg,verbose) == DLT_RETURN_ERROR)
- {
+ if (dlt_message_free(&msg, verbose) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
}
@@ -425,92 +395,87 @@ DltReturnValue dlt_client_send_ctrl_msg(DltClient *client, char *apid, char *cti
uint32_t id_tmp;
uint32_t id;
- if ((client==0) || (client->sock<0) || (apid==0) || (ctid==0))
- {
+ if ((client == 0) || (client->sock < 0) || (apid == 0) || (ctid == 0))
return DLT_RETURN_ERROR;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
/* prepare payload of data */
msg.datasize = size;
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
msg.databuffersize = msg.datasize;
}
- if(msg.databuffer == 0)
- {
- dlt_message_free(&msg,0);
+
+ if (msg.databuffer == 0) {
+ dlt_message_free(&msg, 0);
return DLT_RETURN_ERROR;
}
/* copy data */
- memcpy(msg.databuffer,payload,size);
+ memcpy(msg.databuffer, payload, size);
/* prepare storage header */
- msg.storageheader = (DltStorageHeader*)msg.headerbuffer;
+ msg.storageheader = (DltStorageHeader *)msg.headerbuffer;
- if (dlt_set_storageheader(msg.storageheader,"") == DLT_RETURN_ERROR)
- {
- dlt_message_free(&msg,0);
+ if (dlt_set_storageheader(msg.storageheader, "") == DLT_RETURN_ERROR) {
+ dlt_message_free(&msg, 0);
return DLT_RETURN_ERROR;
}
/* prepare standard header */
- msg.standardheader = (DltStandardHeader*)(msg.headerbuffer + sizeof(DltStorageHeader));
- msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1 ;
+ msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+ msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
- #if (BYTE_ORDER==BIG_ENDIAN)
- msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_MSBF);
+ #if (BYTE_ORDER == BIG_ENDIAN)
+ msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_MSBF);
#endif
msg.standardheader->mcnt = 0;
/* Set header extra parameters */
- dlt_set_id(msg.headerextra.ecu,client->ecuid);
- //msg.headerextra.seid = 0;
+ dlt_set_id(msg.headerextra.ecu, client->ecuid);
+ /*msg.headerextra.seid = 0; */
msg.headerextra.tmsp = dlt_uptime();
/* Copy header extra parameters to headerbuffer */
- if (dlt_message_set_extraparameters(&msg,0) == DLT_RETURN_ERROR)
- {
- dlt_message_free(&msg,0);
+ if (dlt_message_set_extraparameters(&msg, 0) == DLT_RETURN_ERROR) {
+ dlt_message_free(&msg, 0);
return DLT_RETURN_ERROR;
}
/* prepare extended header */
- msg.extendedheader = (DltExtendedHeader*)(msg.headerbuffer +
- sizeof(DltStorageHeader) +
- sizeof(DltStandardHeader) +
- DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp) );
+ msg.extendedheader = (DltExtendedHeader *)(msg.headerbuffer +
+ sizeof(DltStorageHeader) +
+ sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
msg.extendedheader->msin = DLT_MSIN_CONTROL_REQUEST;
msg.extendedheader->noar = 1; /* number of arguments */
- dlt_set_id(msg.extendedheader->apid,(apid[0]=='\0')?DLT_CLIENT_DUMMY_APP_ID:apid);
- dlt_set_id(msg.extendedheader->ctid,(ctid[0]=='\0')?DLT_CLIENT_DUMMY_CON_ID:ctid);
+ dlt_set_id(msg.extendedheader->apid, (apid[0] == '\0') ? DLT_CLIENT_DUMMY_APP_ID : apid);
+ dlt_set_id(msg.extendedheader->ctid, (ctid[0] == '\0') ? DLT_CLIENT_DUMMY_CON_ID : ctid);
/* prepare length information */
msg.headersize = sizeof(DltStorageHeader) +
- sizeof(DltStandardHeader) +
- sizeof(DltExtendedHeader) +
- DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
+ sizeof(DltStandardHeader) +
+ sizeof(DltExtendedHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
- len=msg.headersize - sizeof(DltStorageHeader) + msg.datasize;
- if (len>UINT16_MAX)
- {
- fprintf(stderr,"Critical: Huge injection message discarded!\n");
- dlt_message_free(&msg,0);
+ len = msg.headersize - sizeof(DltStorageHeader) + msg.datasize;
+
+ if (len > UINT16_MAX) {
+ fprintf(stderr, "Critical: Huge injection message discarded!\n");
+ dlt_message_free(&msg, 0);
return DLT_RETURN_ERROR;
}
@@ -518,69 +483,71 @@ DltReturnValue dlt_client_send_ctrl_msg(DltClient *client, char *apid, char *cti
msg.standardheader->len = DLT_HTOBE_16(len);
/* Send data (without storage header) */
- if ((client->mode == DLT_CLIENT_MODE_TCP) || (client->mode == DLT_CLIENT_MODE_SERIAL))
- {
+ if ((client->mode == DLT_CLIENT_MODE_TCP) || (client->mode == DLT_CLIENT_MODE_SERIAL)) {
/* via FileDescriptor */
- ret=write(client->sock, msg.headerbuffer+sizeof(DltStorageHeader),msg.headersize-sizeof(DltStorageHeader));
- if (0 > ret)
- {
+ ret =
+ write(client->sock, msg.headerbuffer + sizeof(DltStorageHeader), msg.headersize - sizeof(DltStorageHeader));
+
+ if (0 > ret) {
dlt_log(LOG_ERR, "Sending message failed\n");
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return DLT_RETURN_ERROR;
}
- ret=write(client->sock, msg.databuffer,msg.datasize);
- if (0 > ret){
+ ret = write(client->sock, msg.databuffer, msg.datasize);
+
+ if (0 > ret) {
dlt_log(LOG_ERR, "Sending message failed\n");
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return DLT_RETURN_ERROR;
}
- id_tmp = *((uint32_t*)(msg.databuffer));
+ id_tmp = *((uint32_t *)(msg.databuffer));
id = DLT_ENDIAN_GET_32(msg.standardheader->htyp, id_tmp);
dlt_vlog(LOG_INFO,
"Control message forwarded : %s\n",
dlt_get_service_name(id));
}
- else
- {
+ else {
/* via Socket */
- send(client->sock, (const char *)(msg.headerbuffer+sizeof(DltStorageHeader)),msg.headersize-sizeof(DltStorageHeader),0);
- send(client->sock, (const char *)msg.databuffer,msg.datasize,0);
+ send(client->sock, (const char *)(msg.headerbuffer + sizeof(DltStorageHeader)),
+ msg.headersize - sizeof(DltStorageHeader), 0);
+ send(client->sock, (const char *)msg.databuffer, msg.datasize, 0);
}
/* free message */
- if (dlt_message_free(&msg,0) == DLT_RETURN_ERROR)
- {
+ if (dlt_message_free(&msg, 0) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
}
-DltReturnValue dlt_client_send_inject_msg(DltClient *client, char *apid, char *ctid, uint32_t serviceID, uint8_t *buffer, uint32_t size)
+DltReturnValue dlt_client_send_inject_msg(DltClient *client,
+ char *apid,
+ char *ctid,
+ uint32_t serviceID,
+ uint8_t *buffer,
+ uint32_t size)
{
uint8_t *payload;
int offset;
- payload = (uint8_t *) malloc(sizeof(uint32_t) + sizeof(uint32_t) + size);
+ payload = (uint8_t *)malloc(sizeof(uint32_t) + sizeof(uint32_t) + size);
- if(payload==0)
- {
+ if (payload == 0)
return DLT_RETURN_ERROR;
- }
offset = 0;
- memcpy(payload , &serviceID,sizeof(serviceID));
- offset+=sizeof(uint32_t);
- memcpy(payload+offset, &size, sizeof(size));
- offset+=sizeof(uint32_t);
- memcpy(payload+offset, buffer, size);
+ memcpy(payload, &serviceID, sizeof(serviceID));
+ offset += sizeof(uint32_t);
+ memcpy(payload + offset, &size, sizeof(size));
+ offset += sizeof(uint32_t);
+ memcpy(payload + offset, buffer, size);
/* free message */
- if (dlt_client_send_ctrl_msg(client,apid,ctid,payload,sizeof(uint32_t) + sizeof(uint32_t) + size) == DLT_RETURN_ERROR)
- {
+ if (dlt_client_send_ctrl_msg(client, apid, ctid, payload,
+ sizeof(uint32_t) + sizeof(uint32_t) + size) == DLT_RETURN_ERROR) {
free(payload);
return DLT_RETURN_ERROR;
}
@@ -597,28 +564,25 @@ DltReturnValue dlt_client_send_log_level(DltClient *client, char *apid, char *ct
int ret = DLT_RETURN_ERROR;
if (client == NULL)
- {
return ret;
- }
+ req = (DltServiceSetLogLevel *)malloc(sizeof(DltServiceSetLogLevel));
- req = (DltServiceSetLogLevel *) malloc(sizeof(DltServiceSetLogLevel));
if (req == NULL)
- {
return ret;
- }
+
memset(req, 0, sizeof(DltServiceSetLogLevel));
req->service_id = DLT_SERVICE_ID_SET_LOG_LEVEL;
- dlt_set_id(req->apid,apid);
- dlt_set_id(req->ctid,ctid);
- req->log_level=logLevel;
- dlt_set_id(req->com,"remo");
+ dlt_set_id(req->apid, apid);
+ dlt_set_id(req->ctid, ctid);
+ req->log_level = logLevel;
+ dlt_set_id(req->com, "remo");
- /* free message */
+ /* free message */
ret = dlt_client_send_ctrl_msg(client,
"APP",
"CON",
- (uint8_t*) req,
+ (uint8_t *)req,
sizeof(DltServiceSetLogLevel));
@@ -633,16 +597,12 @@ DltReturnValue dlt_client_get_log_info(DltClient *client)
int ret = DLT_RETURN_ERROR;
if (client == NULL)
- {
return ret;
- }
- req = (DltServiceGetLogInfoRequest *) malloc(sizeof(DltServiceGetLogInfoRequest));
+ req = (DltServiceGetLogInfoRequest *)malloc(sizeof(DltServiceGetLogInfoRequest));
if (req == NULL)
- {
return ret;
- }
req->service_id = DLT_SERVICE_ID_GET_LOG_INFO;
req->options = 7;
@@ -654,7 +614,7 @@ DltReturnValue dlt_client_get_log_info(DltClient *client)
ret = dlt_client_send_ctrl_msg(client,
"",
"",
- (uint8_t *) req,
+ (uint8_t *)req,
sizeof(DltServiceGetLogInfoRequest));
free(req);
@@ -668,17 +628,13 @@ DltReturnValue dlt_client_get_default_log_level(DltClient *client)
int ret = DLT_RETURN_ERROR;
if (client == NULL)
- {
return ret;
- }
req = (DltServiceGetDefaultLogLevelRequest *)
- malloc(sizeof(DltServiceGetDefaultLogLevelRequest));
+ malloc(sizeof(DltServiceGetDefaultLogLevelRequest));
if (req == NULL)
- {
return ret;
- }
req->service_id = DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL;
@@ -686,7 +642,7 @@ DltReturnValue dlt_client_get_default_log_level(DltClient *client)
ret = dlt_client_send_ctrl_msg(client,
"",
"",
- (uint8_t *) req,
+ (uint8_t *)req,
sizeof(DltServiceGetDefaultLogLevelRequest));
free(req);
@@ -700,11 +656,9 @@ DltReturnValue dlt_client_get_software_version(DltClient *client)
int ret = DLT_RETURN_ERROR;
if (client == NULL)
- {
return ret;
- }
- req = (DltServiceGetSoftwareVersion *) malloc(sizeof(DltServiceGetSoftwareVersion));
+ req = (DltServiceGetSoftwareVersion *)malloc(sizeof(DltServiceGetSoftwareVersion));
req->service_id = DLT_SERVICE_ID_GET_SOFTWARE_VERSION;
@@ -712,7 +666,7 @@ DltReturnValue dlt_client_get_software_version(DltClient *client)
ret = dlt_client_send_ctrl_msg(client,
"",
"",
- (uint8_t *) req,
+ (uint8_t *)req,
sizeof(DltServiceGetSoftwareVersion));
free(req);
@@ -725,24 +679,21 @@ DltReturnValue dlt_client_send_trace_status(DltClient *client, char *apid, char
DltServiceSetLogLevel *req;
uint8_t *payload;
- payload = (uint8_t *) malloc(sizeof(DltServiceSetLogLevel));
+ payload = (uint8_t *)malloc(sizeof(DltServiceSetLogLevel));
- if(payload==0)
- {
+ if (payload == 0)
return DLT_RETURN_ERROR;
- }
- req = (DltServiceSetLogLevel *) payload;
+ req = (DltServiceSetLogLevel *)payload;
memset(req, 0, sizeof(DltServiceSetLogLevel));
req->service_id = DLT_SERVICE_ID_SET_TRACE_STATUS;
- dlt_set_id(req->apid,apid);
- dlt_set_id(req->ctid,ctid);
- req->log_level=traceStatus;
- dlt_set_id(req->com,"remo");
-
- /* free message */
- if (dlt_client_send_ctrl_msg(client,"APP","CON",payload,sizeof(DltServiceSetLogLevel)) == DLT_RETURN_ERROR)
- {
+ dlt_set_id(req->apid, apid);
+ dlt_set_id(req->ctid, ctid);
+ req->log_level = traceStatus;
+ dlt_set_id(req->com, "remo");
+
+ /* free message */
+ if (dlt_client_send_ctrl_msg(client, "APP", "CON", payload, sizeof(DltServiceSetLogLevel)) == DLT_RETURN_ERROR) {
free(payload);
return DLT_RETURN_ERROR;
}
@@ -757,22 +708,20 @@ DltReturnValue dlt_client_send_default_log_level(DltClient *client, uint8_t defa
DltServiceSetDefaultLogLevel *req;
uint8_t *payload;
- payload = (uint8_t *) malloc(sizeof(DltServiceSetDefaultLogLevel));
+ payload = (uint8_t *)malloc(sizeof(DltServiceSetDefaultLogLevel));
- if(payload==0)
- {
+ if (payload == 0)
return DLT_RETURN_ERROR;
- }
- req = (DltServiceSetDefaultLogLevel *) payload;
+ req = (DltServiceSetDefaultLogLevel *)payload;
req->service_id = DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL;
- req->log_level=defaultLogLevel;
- dlt_set_id(req->com,"remo");
+ req->log_level = defaultLogLevel;
+ dlt_set_id(req->com, "remo");
- /* free message */
- if (dlt_client_send_ctrl_msg(client,"APP","CON",payload,sizeof(DltServiceSetDefaultLogLevel)) == DLT_RETURN_ERROR)
- {
+ /* free message */
+ if (dlt_client_send_ctrl_msg(client, "APP", "CON", payload,
+ sizeof(DltServiceSetDefaultLogLevel)) == DLT_RETURN_ERROR) {
free(payload);
return DLT_RETURN_ERROR;
}
@@ -787,22 +736,19 @@ DltReturnValue dlt_client_send_all_log_level(DltClient *client, uint8_t LogLevel
DltServiceSetDefaultLogLevel *req;
uint8_t *payload;
- payload = (uint8_t *) malloc(sizeof(DltServiceSetDefaultLogLevel));
+ payload = (uint8_t *)malloc(sizeof(DltServiceSetDefaultLogLevel));
if (payload == 0)
- {
return DLT_RETURN_ERROR;
- }
- req = (DltServiceSetDefaultLogLevel *) payload;
+ req = (DltServiceSetDefaultLogLevel *)payload;
req->service_id = DLT_SERVICE_ID_SET_ALL_LOG_LEVEL;
req->log_level = LogLevel;
dlt_set_id(req->com, "remo");
/* free message */
- if (dlt_client_send_ctrl_msg(client, "APP", "CON", payload, sizeof(DltServiceSetDefaultLogLevel)) == -1)
- {
+ if (dlt_client_send_ctrl_msg(client, "APP", "CON", payload, sizeof(DltServiceSetDefaultLogLevel)) == -1) {
free(payload);
return DLT_RETURN_ERROR;
}
@@ -817,22 +763,20 @@ DltReturnValue dlt_client_send_default_trace_status(DltClient *client, uint8_t d
DltServiceSetDefaultLogLevel *req;
uint8_t *payload;
- payload = (uint8_t *) malloc(sizeof(DltServiceSetDefaultLogLevel));
+ payload = (uint8_t *)malloc(sizeof(DltServiceSetDefaultLogLevel));
- if(payload==0)
- {
+ if (payload == 0)
return DLT_RETURN_ERROR;
- }
- req = (DltServiceSetDefaultLogLevel *) payload;
+ req = (DltServiceSetDefaultLogLevel *)payload;
req->service_id = DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS;
- req->log_level=defaultTraceStatus;
- dlt_set_id(req->com,"remo");
+ req->log_level = defaultTraceStatus;
+ dlt_set_id(req->com, "remo");
- /* free message */
- if (dlt_client_send_ctrl_msg(client,"APP","CON",payload,sizeof(DltServiceSetDefaultLogLevel)) == DLT_RETURN_ERROR)
- {
+ /* free message */
+ if (dlt_client_send_ctrl_msg(client, "APP", "CON", payload,
+ sizeof(DltServiceSetDefaultLogLevel)) == DLT_RETURN_ERROR) {
free(payload);
return DLT_RETURN_ERROR;
}
@@ -847,29 +791,26 @@ DltReturnValue dlt_client_send_all_trace_status(DltClient *client, uint8_t trace
DltServiceSetDefaultLogLevel *req;
uint8_t *payload;
- if (client == NULL)
- {
+ if (client == NULL) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return DLT_RETURN_ERROR;
}
- payload = (uint8_t *) malloc(sizeof(DltServiceSetDefaultLogLevel));
+ payload = (uint8_t *)malloc(sizeof(DltServiceSetDefaultLogLevel));
- if (payload == 0)
- {
+ if (payload == 0) {
dlt_vlog(LOG_ERR, "%s: Could not allocate memory %d\n", __func__, sizeof(DltServiceSetDefaultLogLevel));
return DLT_RETURN_ERROR;
}
- req = (DltServiceSetDefaultLogLevel *) payload;
+ req = (DltServiceSetDefaultLogLevel *)payload;
req->service_id = DLT_SERVICE_ID_SET_ALL_TRACE_STATUS;
req->log_level = traceStatus;
dlt_set_id(req->com, "remo");
/* free message */
- if (dlt_client_send_ctrl_msg(client, "APP", "CON", payload, sizeof(DltServiceSetDefaultLogLevel)) == -1)
- {
+ if (dlt_client_send_ctrl_msg(client, "APP", "CON", payload, sizeof(DltServiceSetDefaultLogLevel)) == -1) {
free(payload);
return DLT_RETURN_ERROR;
}
@@ -884,21 +825,18 @@ DltReturnValue dlt_client_send_timing_pakets(DltClient *client, uint8_t timingPa
DltServiceSetVerboseMode *req;
uint8_t *payload;
- payload = (uint8_t *) malloc(sizeof(DltServiceSetVerboseMode));
+ payload = (uint8_t *)malloc(sizeof(DltServiceSetVerboseMode));
- if(payload==0)
- {
+ if (payload == 0)
return DLT_RETURN_ERROR;
- }
- req = (DltServiceSetVerboseMode *) payload;
+ req = (DltServiceSetVerboseMode *)payload;
req->service_id = DLT_SERVICE_ID_SET_TIMING_PACKETS;
- req->new_status=timingPakets;
+ req->new_status = timingPakets;
- /* free message */
- if (dlt_client_send_ctrl_msg(client,"APP","CON",payload,sizeof(DltServiceSetVerboseMode)) == DLT_RETURN_ERROR)
- {
+ /* free message */
+ if (dlt_client_send_ctrl_msg(client, "APP", "CON", payload, sizeof(DltServiceSetVerboseMode)) == DLT_RETURN_ERROR) {
free(payload);
return DLT_RETURN_ERROR;
}
@@ -914,11 +852,9 @@ DltReturnValue dlt_client_send_store_config(DltClient *client)
service_id = DLT_SERVICE_ID_STORE_CONFIG;
- /* free message */
- if (dlt_client_send_ctrl_msg(client,"APP","CON",(uint8_t*)&service_id,sizeof(uint32_t)) == DLT_RETURN_ERROR)
- {
+ /* free message */
+ if (dlt_client_send_ctrl_msg(client, "APP", "CON", (uint8_t *)&service_id, sizeof(uint32_t)) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
}
@@ -929,21 +865,17 @@ DltReturnValue dlt_client_send_reset_to_factory_default(DltClient *client)
service_id = DLT_SERVICE_ID_RESET_TO_FACTORY_DEFAULT;
- /* free message */
- if (dlt_client_send_ctrl_msg(client,"APP","CON",(uint8_t*)&service_id,sizeof(uint32_t)) == DLT_RETURN_ERROR)
- {
+ /* free message */
+ if (dlt_client_send_ctrl_msg(client, "APP", "CON", (uint8_t *)&service_id, sizeof(uint32_t)) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
}
DltReturnValue dlt_client_setbaudrate(DltClient *client, int baudrate)
{
- if (client==0)
- {
+ if (client == 0)
return DLT_RETURN_ERROR;
- }
client->baudrate = dlt_convert_serial_speed(baudrate);
@@ -953,33 +885,36 @@ DltReturnValue dlt_client_setbaudrate(DltClient *client, int baudrate)
int dlt_client_set_server_ip(DltClient *client, char *ipaddr)
{
client->servIP = strdup(ipaddr);
- if (client->servIP == NULL)
- {
+
+ if (client->servIP == NULL) {
dlt_log(LOG_ERR, "ERROR: failed to duplicate server IP\n");
return DLT_RETURN_ERROR;
}
+
return DLT_RETURN_OK;
}
int dlt_client_set_serial_device(DltClient *client, char *serial_device)
{
client->serialDevice = strdup(serial_device);
- if (client->serialDevice == NULL)
- {
+
+ if (client->serialDevice == NULL) {
dlt_log(LOG_ERR, "ERROR: failed to duplicate serial device\n");
return DLT_RETURN_ERROR;
}
+
return DLT_RETURN_OK;
}
int dlt_client_set_socket_path(DltClient *client, char *socket_path)
{
client->socketPath = strdup(socket_path);
- if (client->socketPath == NULL)
- {
+
+ if (client->socketPath == NULL) {
dlt_log(LOG_ERR, "ERROR: failed to duplicate socket path\n");
return DLT_RETURN_ERROR;
}
+
return DLT_RETURN_OK;
}
/**
@@ -989,19 +924,17 @@ int dlt_client_set_socket_path(DltClient *client, char *socket_path)
* @param count_app_ids number of app_ids which needs to be freed
*/
DLT_STATIC void dlt_client_free_calloc_failed_get_log_info(DltServiceGetLogInfoResponse *resp,
- int count_app_ids)
+ int count_app_ids)
{
AppIDsType *app = NULL;
ContextIDsInfoType *con = NULL;
int i = 0;
int j = 0;
- for (i = 0; i < count_app_ids; i++)
- {
+ for (i = 0; i < count_app_ids; i++) {
app = &(resp->log_info_type.app_ids[i]);
- for (j = 0; j < app->count_context_ids; j++)
- {
+ for (j = 0; j < app->count_context_ids; j++) {
con = &(app->context_id_info[j]);
free(con->context_description);
@@ -1022,7 +955,7 @@ DLT_STATIC void dlt_client_free_calloc_failed_get_log_info(DltServiceGetLogInfoR
}
DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoResponse *resp,
- char *resp_text)
+ char *resp_text)
{
AppIDsType *app = NULL;
ContextIDsInfoType *con = NULL;
@@ -1032,56 +965,48 @@ DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoRespo
int rp_count = 0;
if ((resp == NULL) || (resp_text == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* ------------------------------------------------------
- get_log_info data structure(all data is ascii)
-
- get_log_info, aa, bb bb cc cc cc cc dd dd ee ee ee ee ff gg hh hh ii ii ii .. ..
- ~~ ~~~~~ ~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~
- cc cc cc cc dd dd ee ee ee ee ff gg hh hh ii ii ii .. ..
- jj jj kk kk kk .. ..
- ~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~
- aa : get mode (fix value at 0x07)
- bb bb : list num of apid (little endian)
- cc cc cc cc: apid
- dd dd : list num of ctid (little endian)
- ee ee ee ee: ctid
- ff : log level
- gg : trace status
- hh hh : description length of ctid
- ii ii .. : description text of ctid
- jj jj : description length of apid
- kk kk .. : description text of apid
- ------------------------------------------------------ */
+ * get_log_info data structure(all data is ascii)
+ *
+ * get_log_info, aa, bb bb cc cc cc cc dd dd ee ee ee ee ff gg hh hh ii ii ii .. ..
+ * ~~ ~~~~~ ~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~
+ * cc cc cc cc dd dd ee ee ee ee ff gg hh hh ii ii ii .. ..
+ * jj jj kk kk kk .. ..
+ * ~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~
+ * aa : get mode (fix value at 0x07)
+ * bb bb : list num of apid (little endian)
+ * cc cc cc cc: apid
+ * dd dd : list num of ctid (little endian)
+ * ee ee ee ee: ctid
+ * ff : log level
+ * gg : trace status
+ * hh hh : description length of ctid
+ * ii ii .. : description text of ctid
+ * jj jj : description length of apid
+ * kk kk .. : description text of apid
+ * ------------------------------------------------------ */
rp = resp_text + DLT_GET_LOG_INFO_HEADER;
rp_count = 0;
/* check if status is acceptable */
if ((resp->status < GET_LOG_INFO_STATUS_MIN) ||
- (resp->status > GET_LOG_INFO_STATUS_MAX))
- {
+ (resp->status > GET_LOG_INFO_STATUS_MAX)) {
if (resp->status == GET_LOG_INFO_STATUS_NO_MATCHING_CTX)
- {
dlt_vlog(LOG_WARNING,
"The status(%d) is invalid: NO matching Context IDs\n",
resp->status);
- }
else if (resp->status == GET_LOG_INFO_STATUS_RESP_DATA_OVERFLOW)
- {
dlt_vlog(LOG_WARNING,
"The status(%d) is invalid: Response data over flow\n",
resp->status);
- }
else
- {
dlt_vlog(LOG_WARNING,
"The status(%d) is invalid\n",
resp->status);
- }
+
return DLT_RETURN_ERROR;
}
@@ -1090,17 +1015,15 @@ DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoRespo
&rp_count);
resp->log_info_type.app_ids = (AppIDsType *)calloc
- (resp->log_info_type.count_app_ids, sizeof(AppIDsType));
+ (resp->log_info_type.count_app_ids, sizeof(AppIDsType));
- if (resp->log_info_type.app_ids == NULL)
- {
+ if (resp->log_info_type.app_ids == NULL) {
dlt_vlog(LOG_ERR, "calloc failed for app_ids\n");
dlt_client_free_calloc_failed_get_log_info(resp, 0);
return DLT_RETURN_ERROR;
}
- for (i = 0; i < resp->log_info_type.count_app_ids; i++)
- {
+ for (i = 0; i < resp->log_info_type.count_app_ids; i++) {
app = &(resp->log_info_type.app_ids[i]);
/* get app id */
dlt_getloginfo_conv_ascii_to_id(rp, &rp_count, app->app_id, DLT_ID_SIZE);
@@ -1110,18 +1033,16 @@ DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoRespo
&rp_count);
app->context_id_info = (ContextIDsInfoType *)calloc
- (app->count_context_ids, sizeof(ContextIDsInfoType));
+ (app->count_context_ids, sizeof(ContextIDsInfoType));
- if (app->context_id_info == NULL)
- {
+ if (app->context_id_info == NULL) {
dlt_vlog(LOG_ERR,
"calloc failed for context_id_info\n");
dlt_client_free_calloc_failed_get_log_info(resp, i);
return DLT_RETURN_ERROR;
}
- for (j = 0; j < app->count_context_ids; j++)
- {
+ for (j = 0; j < app->count_context_ids; j++) {
con = &(app->context_id_info[j]);
/* get con id */
dlt_getloginfo_conv_ascii_to_id(rp,
@@ -1131,30 +1052,27 @@ DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoRespo
/* log_level */
if ((resp->status == 4) || (resp->status == 6) || (resp->status == 7))
- {
con->log_level = dlt_getloginfo_conv_ascii_to_int16_t(rp,
&rp_count);
- }
/* trace status */
if ((resp->status == 5) || (resp->status == 6) || (resp->status == 7))
- {
con->trace_status = dlt_getloginfo_conv_ascii_to_int16_t(rp,
&rp_count);
- }
/* context desc */
- if (resp->status == 7){
+ if (resp->status == 7) {
con->len_context_description = dlt_getloginfo_conv_ascii_to_uint16_t(rp,
&rp_count);
con->context_description = (char *)calloc
- (con->len_context_description + 1, sizeof(char));
- if (con->context_description == 0)
- {
+ (con->len_context_description + 1, sizeof(char));
+
+ if (con->context_description == 0) {
dlt_log(LOG_ERR, "calloc failed for context description\n");
dlt_client_free_calloc_failed_get_log_info(resp, i);
return DLT_RETURN_ERROR;
}
+
dlt_getloginfo_conv_ascii_to_id(rp,
&rp_count,
con->context_description,
@@ -1163,18 +1081,18 @@ DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoRespo
}
/* application desc */
- if (resp->status == 7)
- {
+ if (resp->status == 7) {
app->len_app_description = dlt_getloginfo_conv_ascii_to_uint16_t(rp,
&rp_count);
app->app_description = (char *)calloc
- (app->len_app_description + 1, sizeof(char));
- if (app->app_description == 0)
- {
+ (app->len_app_description + 1, sizeof(char));
+
+ if (app->app_description == 0) {
dlt_log(LOG_ERR, "calloc failed for application description\n");
dlt_client_free_calloc_failed_get_log_info(resp, i);
return DLT_RETURN_ERROR;
}
+
dlt_getloginfo_conv_ascii_to_id(rp,
&rp_count,
app->app_description,
@@ -1192,16 +1110,12 @@ int dlt_client_cleanup_get_log_info(DltServiceGetLogInfoResponse *resp)
int j = 0;
if (resp == NULL)
- {
return DLT_RETURN_OK;
- }
- for (i = 0; i < resp->log_info_type.count_app_ids; i++)
- {
+ for (i = 0; i < resp->log_info_type.count_app_ids; i++) {
app = resp->log_info_type.app_ids[i];
- for (j = 0; j < app.count_context_ids; j++)
- {
+ for (j = 0; j < app.count_context_ids; j++) {
free(app.context_id_info[j].context_description);
app.context_id_info[j].context_description = NULL;
}
diff --git a/src/lib/dlt_client_cfg.h b/src/lib/dlt_client_cfg.h
index bfa4d96..7ff473f 100644
--- a/src/lib/dlt_client_cfg.h
+++ b/src/lib/dlt_client_cfg.h
@@ -84,9 +84,9 @@
/* Initial baudrate */
#if !defined (__WIN32__) && !defined(_MSC_VER)
-#define DLT_CLIENT_INITIAL_BAUDRATE B115200
+# define DLT_CLIENT_INITIAL_BAUDRATE B115200
#else
-#define DLT_CLIENT_INITIAL_BAUDRATE 0
+# define DLT_CLIENT_INITIAL_BAUDRATE 0
#endif
/* Name of environment variable for specifying the daemon port */
diff --git a/src/lib/dlt_env_ll.c b/src/lib/dlt_env_ll.c
index 8972747..85d2250 100644
--- a/src/lib/dlt_env_ll.c
+++ b/src/lib/dlt_env_ll.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_env_ll.c
-*/
+ */
#include "dlt_user.h"
#include <string.h>
@@ -55,33 +55,26 @@
*
* @return 0 if successful, -1 else
*/
-int dlt_env_extract_id(char ** const env, char * id)
+int dlt_env_extract_id(char **const env, char *id)
{
- int i;
- if (!env || !id)
- {
- return -1;
- }
+ int i;
- if (!(*env))
- {
- return -1;
- }
+ if (!env || !id)
+ return -1;
- memset(id, 0, 4);
+ if (!(*env))
+ return -1;
- for (i = 0; (i<4) && (**env != ':') && (**env != 0); ++i)
- {
- *id++ = *((*env)++);
- }
+ memset(id, 0, 4);
- /* the next/last character must be ':' */
- if ((0 != **env) && (':' == **env))
- {
- return 0;
- }
+ for (i = 0; (i < 4) && (**env != ':') && (**env != 0); ++i)
+ *id++ = *((*env)++);
- return -1;
+ /* the next/last character must be ':' */
+ if ((0 != **env) && (':' == **env))
+ return 0;
+
+ return -1;
}
@@ -90,112 +83,77 @@ int dlt_env_extract_id(char ** const env, char * id)
*
* Stops end of string or if ';' is detected
*/
-int dlt_env_helper_to_lower(char ** const env, char *result, int const res_len)
+int dlt_env_helper_to_lower(char **const env, char *result, int const res_len)
{
- int count = 0;
- char ch = *(*env);
+ int count = 0;
+ char ch = *(*env);
- if (!env || !result)
- {
- return -1;
- }
+ if (!env || !result)
+ return -1;
- if (!(*env))
- {
- return -1;
- }
-
- count = 0;
- ch = *(*env);
- while (ch && (count < res_len-1) && (ch != ';'))
- {
- if (ch >= 'A' && ch <= 'Z')
- {
- result[count] = ch + 'a' - 'A';
- }
- else
- {
- result[count] = ch;
+ if (!(*env))
+ return -1;
+
+ count = 0;
+ ch = *(*env);
+
+ while (ch && (count < res_len - 1) && (ch != ';')) {
+ if ((ch >= 'A') && (ch <= 'Z'))
+ result[count] = ch + 'a' - 'A';
+ else
+ result[count] = ch;
+
+ ch = *(++(*env));
+ ++count;
}
- ch = *(++(*env));
- ++count;
- }
- result[count] = 0;
- if (!ch || (ch == ';')) /* full input was parsed */
- {
- return 0;
- }
- else
- {
- return -1;
- }
+ result[count] = 0;
+
+ if (!ch || (ch == ';')) /* full input was parsed */
+ return 0;
+ else
+ return -1;
}
-int dlt_env_extract_symbolic_ll(char ** const env, int8_t * ll)
+int dlt_env_extract_symbolic_ll(char **const env, int8_t *ll)
{
- char result[strlen("verbose")+1];
- if (!env || !ll)
- {
- return -1;
- }
+ char result[strlen("verbose") + 1];
- if (!(*env))
- {
- return -1;
- }
+ if (!env || !ll)
+ return -1;
- if (dlt_env_helper_to_lower(env, &result[0], sizeof(result)) == 0)
- {
- if (strncmp("default", result, sizeof(result)) == 0)
- {
- *ll = -1;
- }
- else if (strncmp("off", result, sizeof(result)) == 0)
- {
- *ll = 0;
- }
- else if (strncmp("fatal", result, sizeof(result)) == 0)
- {
- *ll = 1;
- }
- else if (strncmp("error", result, sizeof(result)) == 0)
- {
- *ll = 2;
- }
- else if (strncmp("warning", result, sizeof(result)) == 0)
- {
- *ll = 3;
- }
- else if (strncmp("info", result, sizeof(result)) == 0)
- {
- *ll = 4;
- }
- else if (strncmp("debug", result, sizeof(result)) == 0)
- {
- *ll = 5;
- }
- else if (strncmp("verbose", result, sizeof(result)) == 0)
- {
- *ll = 6;
- }
- else
- {
- return -1;
- }
+ if (!(*env))
+ return -1;
- if (**env != 0)
- {
- (*env)++;
+ if (dlt_env_helper_to_lower(env, &result[0], sizeof(result)) == 0) {
+ if (strncmp("default", result, sizeof(result)) == 0)
+ *ll = -1;
+ else if (strncmp("off", result, sizeof(result)) == 0)
+ *ll = 0;
+ else if (strncmp("fatal", result, sizeof(result)) == 0)
+ *ll = 1;
+ else if (strncmp("error", result, sizeof(result)) == 0)
+ *ll = 2;
+ else if (strncmp("warning", result, sizeof(result)) == 0)
+ *ll = 3;
+ else if (strncmp("info", result, sizeof(result)) == 0)
+ *ll = 4;
+ else if (strncmp("debug", result, sizeof(result)) == 0)
+ *ll = 5;
+ else if (strncmp("verbose", result, sizeof(result)) == 0)
+ *ll = 6;
+ else
+ return -1;
+
+ if (**env != 0)
+ (*env)++;
+
+ return 0;
+ }
+ else {
+ return -1;
}
- return 0;
- }
- else
- {
- return -1;
- }
-
}
@@ -225,51 +183,37 @@ int dlt_env_extract_symbolic_ll(char ** const env, int8_t * ll)
*
* @return 0 if successful, -1 else
*/
-int dlt_env_extract_ll(char ** const env, int8_t * ll)
+int dlt_env_extract_ll(char **const env, int8_t *ll)
{
- if (!env || !ll)
- {
- return -1;
- }
+ if (!env || !ll)
+ return -1;
- if (!(*env))
- {
- return -1;
- }
+ if (!(*env))
+ return -1;
- /* extract number */
- if (**env == '-')
- {
- (*env)++;
- if (**env == '1')
- {
- *ll = -1;
- (*env)++;
+ /* extract number */
+ if (**env == '-') {
+ (*env)++;
+
+ if (**env == '1') {
+ *ll = -1;
+ (*env)++;
+ }
}
- }
- else
- {
- if ((**env >= '0') && (**env < '7'))
- {
- *ll = **env - '0';
- (*env)++;
+ else {
+ if ((**env >= '0') && (**env < '7')) {
+ *ll = **env - '0';
+ (*env)++;
+ }
+ else if (dlt_env_extract_symbolic_ll(env, ll) != 0)
+ return -1;
}
- else
- {
- if (dlt_env_extract_symbolic_ll(env, ll) != 0)
- {
- return -1;
- }
- }
- }
- /* check end, either next char is NULL or ';' */
- if ((**env == ';') || (**env == 0))
- {
- return 0;
- }
+ /* check end, either next char is NULL or ';' */
+ if ((**env == ';') || (**env == 0))
+ return 0;
- return -1;
+ return -1;
}
@@ -278,41 +222,35 @@ int dlt_env_extract_ll(char ** const env, int8_t * ll)
*
* @return 0 if successful, -1 else
*/
-int dlt_env_extract_ll_item(char ** const env, dlt_env_ll_item * const item)
+int dlt_env_extract_ll_item(char **const env, dlt_env_ll_item *const item)
{
- int ret = -1;
- if (!env || !item)
- {
- return -1;
- }
+ int ret = -1;
- if (!(*env))
- {
- return -1;
- }
+ if (!env || !item)
+ return -1;
- memset(item, 0, sizeof(dlt_env_ll_item));
- ret = dlt_env_extract_id(env, item->appId);
- if (ret == -1)
- {
- return -1;
- }
+ if (!(*env))
+ return -1;
- (*env)++;
- ret = dlt_env_extract_id(env, item->ctxId);
- if (ret == -1)
- {
- return -1;
- }
+ memset(item, 0, sizeof(dlt_env_ll_item));
+ ret = dlt_env_extract_id(env, item->appId);
- (*env)++;
- ret = dlt_env_extract_ll(env, &item->ll);
- if (ret == -1)
- {
- return -1;
- }
+ if (ret == -1)
+ return -1;
+
+ (*env)++;
+ ret = dlt_env_extract_id(env, item->ctxId);
+
+ if (ret == -1)
+ return -1;
+
+ (*env)++;
+ ret = dlt_env_extract_ll(env, &item->ll);
- return 0;
+ if (ret == -1)
+ return -1;
+
+ return 0;
}
@@ -324,43 +262,40 @@ int dlt_env_extract_ll_item(char ** const env, dlt_env_ll_item * const item)
* @return -1 if memory could not be allocated
* @return 0 on success
*/
-int dlt_env_init_ll_set(dlt_env_ll_set * const ll_set)
+int dlt_env_init_ll_set(dlt_env_ll_set *const ll_set)
{
- if (!ll_set)
- {
- return -1;
- }
-
- ll_set->array_size = DLT_ENV_LL_SET_INCREASE;
- ll_set->item = (dlt_env_ll_item *)malloc(sizeof(dlt_env_ll_item) * ll_set->array_size);
- if (!ll_set->item)
- {
- /* should trigger a warning: no memory left */
- ll_set->array_size = 0;
- return -1;
- }
- ll_set->num_elem = 0u;
- return 0;
+ if (!ll_set)
+ return -1;
+
+ ll_set->array_size = DLT_ENV_LL_SET_INCREASE;
+ ll_set->item = (dlt_env_ll_item *)malloc(sizeof(dlt_env_ll_item) * ll_set->array_size);
+
+ if (!ll_set->item) {
+ /* should trigger a warning: no memory left */
+ ll_set->array_size = 0;
+ return -1;
+ }
+
+ ll_set->num_elem = 0u;
+ return 0;
}
/**
* @brief release ll_set
*/
-void dlt_env_free_ll_set(dlt_env_ll_set * const ll_set)
+void dlt_env_free_ll_set(dlt_env_ll_set *const ll_set)
{
- if (!ll_set)
- {
- return;
- }
-
- if (ll_set->item != NULL)
- {
- free(ll_set->item);
- ll_set->item = NULL;
- }
- ll_set->array_size = 0u;
- ll_set->num_elem = 0u;
+ if (!ll_set)
+ return;
+
+ if (ll_set->item != NULL) {
+ free(ll_set->item);
+ ll_set->item = NULL;
+ }
+
+ ll_set->array_size = 0u;
+ ll_set->num_elem = 0u;
}
@@ -370,33 +305,30 @@ void dlt_env_free_ll_set(dlt_env_ll_set * const ll_set)
* @return -1 if memory could not be allocated
* @return 0 on success
*/
-int dlt_env_increase_ll_set(dlt_env_ll_set * const ll_set)
+int dlt_env_increase_ll_set(dlt_env_ll_set *const ll_set)
{
- dlt_env_ll_item * old_set;
- size_t old_size;
+ dlt_env_ll_item *old_set;
+ size_t old_size;
- if (!ll_set)
- {
- return -1;
- }
+ if (!ll_set)
+ return -1;
- old_set = ll_set->item;
- old_size = ll_set->array_size;
+ old_set = ll_set->item;
+ old_size = ll_set->array_size;
- ll_set->array_size += DLT_ENV_LL_SET_INCREASE;
- ll_set->item = (dlt_env_ll_item *)malloc(sizeof(dlt_env_ll_item) * ll_set->array_size);
- if (!ll_set->item)
- {
- /* should trigger a warning: no memory left */
- ll_set->array_size -= DLT_ENV_LL_SET_INCREASE;
- return -1;
- }
- else
- {
- memcpy(ll_set->item, old_set, sizeof(dlt_env_ll_item)*old_size);
- free(old_set);
- return 0;
- }
+ ll_set->array_size += DLT_ENV_LL_SET_INCREASE;
+ ll_set->item = (dlt_env_ll_item *)malloc(sizeof(dlt_env_ll_item) * ll_set->array_size);
+
+ if (!ll_set->item) {
+ /* should trigger a warning: no memory left */
+ ll_set->array_size -= DLT_ENV_LL_SET_INCREASE;
+ return -1;
+ }
+ else {
+ memcpy(ll_set->item, old_set, sizeof(dlt_env_ll_item) * old_size);
+ free(old_set);
+ return 0;
+ }
}
@@ -408,44 +340,31 @@ int dlt_env_increase_ll_set(dlt_env_ll_set * const ll_set)
*
* @return 0 if successful, -1 else
*/
-int dlt_env_extract_ll_set(char ** const env, dlt_env_ll_set * const ll_set)
+int dlt_env_extract_ll_set(char **const env, dlt_env_ll_set *const ll_set)
{
- if (!env || !ll_set)
- {
- return -1;
- }
+ if (!env || !ll_set)
+ return -1;
- if (!(*env))
- {
- return -1;
- }
+ if (!(*env))
+ return -1;
- if (dlt_env_init_ll_set(ll_set) == -1)
- {
- return -1;
- }
-
- do
- {
- if (ll_set->num_elem == ll_set->array_size)
- {
- if (dlt_env_increase_ll_set(ll_set) == -1)
- {
+ if (dlt_env_init_ll_set(ll_set) == -1)
return -1;
- }
- }
- if (dlt_env_extract_ll_item(env, &ll_set->item[ll_set->num_elem++]) == -1)
- {
- return -1;
- }
- if (**env == ';')
- {
- (*env)++;
- }
- } while (**env != 0);
+ do {
+ if (ll_set->num_elem == ll_set->array_size) {
+ if (dlt_env_increase_ll_set(ll_set) == -1)
+ return -1;
+ }
+
+ if (dlt_env_extract_ll_item(env, &ll_set->item[ll_set->num_elem++]) == -1)
+ return -1;
+
+ if (**env == ';')
+ (*env)++;
+ } while (**env != 0);
- return 0;
+ return 0;
}
@@ -454,26 +373,21 @@ int dlt_env_extract_ll_set(char ** const env, dlt_env_ll_set * const ll_set)
*
* @return 1 if matching, 0 if not
*/
-int dlt_env_ids_match(char const * const a, char const * const b)
+int dlt_env_ids_match(char const *const a, char const *const b)
{
- if (a[0] != b[0])
- {
- return 0;
- }
- if (a[1] != b[1])
- {
- return 0;
- }
- if (a[2] != b[2])
- {
- return 0;
- }
- if (a[3] != b[3])
- {
- return 0;
- }
+ if (a[0] != b[0])
+ return 0;
+
+ if (a[1] != b[1])
+ return 0;
+
+ if (a[2] != b[2])
+ return 0;
- return 1;
+ if (a[3] != b[3])
+ return 0;
+
+ return 1;
}
@@ -488,43 +402,26 @@ int dlt_env_ids_match(char const * const a, char const * const b)
*
* In case of error, -1 is returned.
*/
-int dlt_env_ll_item_get_matching_prio(dlt_env_ll_item const * const item, char const * const apid, char const * const ctid)
+int dlt_env_ll_item_get_matching_prio(dlt_env_ll_item const *const item, char const *const apid, char const *const ctid)
{
- if ((!item) || (!apid) || (!ctid))
- {
- return -1;
- }
+ if ((!item) || (!apid) || (!ctid))
+ return -1;
- if (item->appId[0] == 0)
- {
- if (item->ctxId[0] == 0)
- {
- return 1;
+ if (item->appId[0] == 0) {
+ if (item->ctxId[0] == 0) {
+ return 1;
+ }
+ else if (dlt_env_ids_match(item->ctxId, ctid))
+ return 2;
}
- else
- {
- if (dlt_env_ids_match(item->ctxId, ctid))
- {
- return 2;
- }
- }
- }
- else
- {
- if (dlt_env_ids_match(item->appId, apid))
- {
- if (item->ctxId[0] == 0)
- {
- return 3;
- }
- else if (dlt_env_ids_match(item->ctxId, ctid))
- {
- return 4;
- }
+ else if (dlt_env_ids_match(item->appId, apid)) {
+ if (item->ctxId[0] == 0)
+ return 3;
+ else if (dlt_env_ids_match(item->ctxId, ctid))
+ return 4;
}
- }
- return 0;
+ return 0;
}
@@ -537,31 +434,31 @@ int dlt_env_ll_item_get_matching_prio(dlt_env_ll_item const * const item, char c
*
* If no item matches or in case of error, the original log-level (\param ll) is returned
*/
-int dlt_env_adjust_ll_from_env(dlt_env_ll_set const * const ll_set, char const * const apid, char const * const ctid, int const ll)
+int dlt_env_adjust_ll_from_env(dlt_env_ll_set const *const ll_set,
+ char const *const apid,
+ char const *const ctid,
+ int const ll)
{
- if ((!ll_set) || (!apid) || (!ctid))
- {
- return ll;
- }
-
- int res = ll;
- int prio = 0; /* no match so far */
- size_t i;
- for (i = 0; i<ll_set->num_elem; ++i)
- {
- int p = dlt_env_ll_item_get_matching_prio(&ll_set->item[i], apid, ctid);
- if (p > prio)
- {
- prio = p;
- res = ll_set->item[i].ll;
- if (p == 4) /* maximum reached, immediate return */
- {
- return res;
- }
+ if ((!ll_set) || (!apid) || (!ctid))
+ return ll;
+
+ int res = ll;
+ int prio = 0; /* no match so far */
+ size_t i;
+
+ for (i = 0; i < ll_set->num_elem; ++i) {
+ int p = dlt_env_ll_item_get_matching_prio(&ll_set->item[i], apid, ctid);
+
+ if (p > prio) {
+ prio = p;
+ res = ll_set->item[i].ll;
+
+ if (p == 4) /* maximum reached, immediate return */
+ return res;
+ }
}
- }
- return res;
+ return res;
}
diff --git a/src/lib/dlt_filetransfer.c b/src/lib/dlt_filetransfer.c
index 1038e0a..7844de2 100644
--- a/src/lib/dlt_filetransfer.c
+++ b/src/lib/dlt_filetransfer.c
@@ -59,34 +59,35 @@
#include "dlt_filetransfer.h"
#include "dlt_common.h"
-//!Defines the buffer size of a single file package which will be logged to dlt
+/*!Defines the buffer size of a single file package which will be logged to dlt */
#define BUFFER_SIZE 1024
-//!Defines the minimum timeout between two dlt logs. This is important because dlt should not be flooded with too many logs in a short period of time.
+/*!Defines the minimum timeout between two dlt logs. This is important because dlt should not be flooded with too many logs in a short period of time. */
#define MIN_TIMEOUT 20
#define DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES INT_MAX
-//!Buffer for dlt file transfer. The size is defined by BUFFER_SIZE
+/*!Buffer for dlt file transfer. The size is defined by BUFFER_SIZE */
unsigned char buffer[BUFFER_SIZE];
-//!Get some information about the file size of a file
+/*!Get some information about the file size of a file */
/**See stat(2) for more informations.
* @param file Absolute file path
* @return Returns the size of the file (if it is a regular file or a symbolic link) in bytes.
*/
-uint32_t getFilesize(const char* file, int *ok){
+uint32_t getFilesize(const char *file, int *ok)
+{
struct stat st;
- if ( -1 == stat(file, &st))
- {
- //we can only return 0, as the value is unsigned
+ if (-1 == stat(file, &st)) {
+ /*we can only return 0, as the value is unsigned */
*ok = 0;
return 0;
}
+
*ok = 1;
return (uint32_t)st.st_size;
}
@@ -96,95 +97,98 @@ uint32_t getFilesize(const char* file, int *ok){
* @param hash start and result value for hash computation
*
*/
-void stringHash(const char* str, uint32_t *hash )
+void stringHash(const char *str, uint32_t *hash)
{
if (!str || !hash)
return;
- unsigned int len = strlen(str);
- unsigned int i = 0;
- if (len <= 0){
- return;
- }
+ unsigned int len = strlen(str);
- for(i = 0; i < len; i++)
- {
- *hash = 53 * *hash + str[i];
- }
+ unsigned int i = 0;
+
+ if (len <= 0)
+ return;
+ for (i = 0; i < len; i++)
+ *hash = 53 * *hash + str[i];
}
-//!Get some information about the file serial number of a file
+/*!Get some information about the file serial number of a file */
/** See stat(2) for more informations.
* @param file Absolute file path
* @param value *ok == 0 -> error; *ok == 1 -> ok
* @return Returns a unique number associated with each filename
*/
-uint32_t getFileSerialNumber(const char* file, int *ok){
+uint32_t getFileSerialNumber(const char *file, int *ok)
+{
struct stat st;
uint32_t ret;
- if ( -1 == stat(file, &st))
- {
+
+ if (-1 == stat(file, &st)) {
*ok = 0;
ret = 0;
}
- else
- {
+ else {
*ok = 1;
ret = st.st_ino;
- ret = ret << (sizeof(ret)*8)/2;
+ ret = ret << (sizeof(ret) * 8) / 2;
ret |= st.st_size;
ret ^= st.st_ctime;
stringHash(file, &ret);
}
+
return ret;
}
-//!Returns the creation date of a file
+/*!Returns the creation date of a file */
/** See stat(2) for more informations.
* @param file Absolute file path
* @return Returns the creation date of a file
-*/
-time_t getFileCreationDate(const char* file,int *ok){
+ */
+time_t getFileCreationDate(const char *file, int *ok)
+{
struct stat st;
- if (-1 == stat(file, &st))
- {
+
+ if (-1 == stat(file, &st)) {
*ok = 0;
return 0;
}
+
*ok = 1;
return st.st_ctime;
}
-//!Returns the creation date of a file
+/*!Returns the creation date of a file */
/** Format of the creation date is Day Mon dd hh:mm:ss yyyy
* @param file Absolute file path
* @return Returns the creation date of a file
-*/
-char* getFileCreationDate2(const char* file,int *ok){
+ */
+char *getFileCreationDate2(const char *file, int *ok)
+{
struct stat st;
- if (-1 == stat(file, &st))
- {
+
+ if (-1 == stat(file, &st)) {
*ok = 0;
return 0;
}
+
*ok = 1;
- struct tm *ts= localtime(&st.st_ctime);
+ struct tm *ts = localtime(&st.st_ctime);
return asctime(ts);
}
-//!Checks if the file exists
+/*!Checks if the file exists */
/**@param file Absolute file path
* @return Returns 1 if the file exists, 0 if the file does not exist
*/
-int isFile (const char* file)
+int isFile (const char *file)
{
- struct stat st;
- return (stat (file, &st) == 0);
+ struct stat st;
+ return stat (file, &st) == 0;
}
-//!Waits a period of time
+/*!Waits a period of time */
/**Waits a period of time. The minimal time to wait is MIN_TIMEOUT. This makes sure that the FIFO of dlt is not flooded.
* @param timeout Timeout to in ms but can not be smaller as MIN_TIMEOUT
*/
@@ -193,7 +197,7 @@ void doTimeout(int timeout)
usleep(timeout * 1000);
}
-//!Checks free space of the user buffer
+/*!Checks free space of the user buffer */
/**
* @param returns -1 if more than 50% space in the user buffer is free. Otherwise 1 will be returned.
*/
@@ -203,106 +207,132 @@ int checkUserBufferForFreeSpace()
dlt_user_check_buffer(&total_size, &used_size);
- if((total_size - used_size) < (total_size/2))
- {
+ if ((total_size - used_size) < (total_size / 2))
return -1;
- }
+
return 1;
}
-//!Deletes the given file
+/*!Deletes the given file */
/**
* @param filename Absolute file path
* @return If the file is successfully deleted, a zero value is returned.If the file can not be deleted a nonzero value is returned.
*/
-int doRemoveFile(const char*filename){
- return remove( filename);
+int doRemoveFile(const char *filename)
+{
+ return remove(filename);
}
-void dlt_user_log_file_errorMessage(DltContext *fileContext, const char *filename, int errorCode){
+void dlt_user_log_file_errorMessage(DltContext *fileContext, const char *filename, int errorCode)
+{
- if(errno != ENOENT)
- {
+ if (errno != ENOENT) {
int ok = 0;
- uint32_t fserial = getFileSerialNumber(filename,&ok);
+ uint32_t fserial = getFileSerialNumber(filename, &ok);
+
if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_errorMessage, error in getFileSerialNumber for: "),DLT_STRING(filename));
- uint32_t fsize = getFilesize(filename,&ok);
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_errorMessage, error in getFileSerialNumber for: "),
+ DLT_STRING(filename));
+
+ uint32_t fsize = getFilesize(filename, &ok);
+
if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_errorMessage, error in getFilesize for: "),DLT_STRING(filename));
- char *fcreationdate = getFileCreationDate2(filename,&ok);
+ DLT_LOG(*fileContext,
+ DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_errorMessage, error in getFilesize for: "),
+ DLT_STRING(filename));
+
+ char *fcreationdate = getFileCreationDate2(filename, &ok);
+
if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_errorMessage, error in getFilesize for: "),DLT_STRING(filename));
-
- int package_count = dlt_user_log_file_packagesCount(fileContext,filename);
-
- DLT_LOG(*fileContext,DLT_LOG_ERROR,
- DLT_STRING("FLER"),
- DLT_INT(errorCode),
- DLT_INT(-errno),
- DLT_UINT(fserial),
- DLT_STRING(filename),
- DLT_UINT(fsize),
- DLT_STRING(fcreationdate),
- DLT_INT(package_count),
- DLT_UINT(BUFFER_SIZE),
- DLT_STRING("FLER")
- );
- } else {
- DLT_LOG(*fileContext,DLT_LOG_ERROR,
- DLT_STRING("FLER"),
- DLT_INT(errorCode),
- DLT_INT(-errno),
- DLT_STRING(filename),
- DLT_STRING("FLER")
- );
+ DLT_LOG(*fileContext,
+ DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_errorMessage, error in getFilesize for: "),
+ DLT_STRING(filename));
+
+ int package_count = dlt_user_log_file_packagesCount(fileContext, filename);
+
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("FLER"),
+ DLT_INT(errorCode),
+ DLT_INT(-errno),
+ DLT_UINT(fserial),
+ DLT_STRING(filename),
+ DLT_UINT(fsize),
+ DLT_STRING(fcreationdate),
+ DLT_INT(package_count),
+ DLT_UINT(BUFFER_SIZE),
+ DLT_STRING("FLER")
+ );
+ }
+ else {
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("FLER"),
+ DLT_INT(errorCode),
+ DLT_INT(-errno),
+ DLT_STRING(filename),
+ DLT_STRING("FLER")
+ );
}
}
-//!Logs specific file inforamtions to dlt
+/*!Logs specific file inforamtions to dlt */
/**The filename, file size, file serial number and the number of packages will be logged to dlt.
* @param fileContext Specific context
* @param filename Absolute file path
* @return Returns 0 if everything was okey.If there was a failure a value < 0 will be returned.
*/
-int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename){
+int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename)
+{
- if(isFile(filename))
- {
+ if (isFile(filename)) {
int ok;
- uint32_t fsize = getFilesize(filename,&ok);
+ uint32_t fsize = getFilesize(filename, &ok);
+
if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_infoAbout, Error getting size of file:"),DLT_STRING(filename));
+ DLT_LOG(*fileContext,
+ DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_infoAbout, Error getting size of file:"),
+ DLT_STRING(filename));
+
+ uint32_t fserialnumber = getFileSerialNumber(filename, &ok);
- uint32_t fserialnumber = getFileSerialNumber(filename,&ok);
if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_infoAbout, Error getting serial number of file:"),DLT_STRING(filename));
+ DLT_LOG(*fileContext,
+ DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_infoAbout, Error getting serial number of file:"),
+ DLT_STRING(filename));
+ char *creationdate = getFileCreationDate2(filename, &ok);
- char *creationdate = getFileCreationDate2(filename,&ok);
if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_infoAbout, Error getting creation date of file:"),DLT_STRING(filename));
-
- DLT_LOG(*fileContext,DLT_LOG_INFO,
- DLT_STRING("FLIF"),
- DLT_STRING("file serialnumber"),DLT_UINT(fserialnumber),
- DLT_STRING("filename"),DLT_STRING(filename),
- DLT_STRING("file size in bytes"),DLT_UINT(fsize),
- DLT_STRING("file creation date"),DLT_STRING(creationdate),
- DLT_STRING("number of packages"),DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
- DLT_STRING("FLIF")
- );
+ DLT_LOG(*fileContext,
+ DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_infoAbout, Error getting creation date of file:"),
+ DLT_STRING(filename));
+
+ DLT_LOG(*fileContext, DLT_LOG_INFO,
+ DLT_STRING("FLIF"),
+ DLT_STRING("file serialnumber"), DLT_UINT(fserialnumber),
+ DLT_STRING("filename"), DLT_STRING(filename),
+ DLT_STRING("file size in bytes"), DLT_UINT(fsize),
+ DLT_STRING("file creation date"), DLT_STRING(creationdate),
+ DLT_STRING("number of packages"), DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
+ DLT_STRING("FLIF")
+ );
return 0;
- } else {
- dlt_user_log_file_errorMessage(fileContext,filename,DLT_FILETRANSFER_ERROR_INFO_ABOUT);
+ }
+ else {
+ dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_INFO_ABOUT);
return DLT_FILETRANSFER_ERROR_INFO_ABOUT;
}
}
-//!Transfer the complete file as several dlt logs.
+/*!Transfer the complete file as several dlt logs. */
/**This method transfer the complete file as several dlt logs. At first it will be checked that the file exist.
* In the next step some generic informations about the file will be logged to dlt.
* Now the header will be logged to dlt. See the method dlt_user_log_file_header for more informations.
@@ -316,31 +346,24 @@ int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename){
*/
int dlt_user_log_file_complete(DltContext *fileContext, const char *filename, int deleteFlag, int timeout)
{
- if(!isFile(filename))
- {
- dlt_user_log_file_errorMessage(fileContext,filename, DLT_FILETRANSFER_ERROR_FILE_COMPLETE);
+ if (!isFile(filename)) {
+ dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_COMPLETE);
return DLT_FILETRANSFER_ERROR_FILE_COMPLETE;
}
- if(dlt_user_log_file_header(fileContext,filename) != 0)
- {
+ if (dlt_user_log_file_header(fileContext, filename) != 0)
return DLT_FILETRANSFER_ERROR_FILE_COMPLETE1;
- }
- if(dlt_user_log_file_data(fileContext, filename,DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES,timeout) != 0)
- {
+ if (dlt_user_log_file_data(fileContext, filename, DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES, timeout) != 0)
return DLT_FILETRANSFER_ERROR_FILE_COMPLETE2;
- }
- if(dlt_user_log_file_end(fileContext,filename, deleteFlag) != 0)
- {
+ if (dlt_user_log_file_end(fileContext, filename, deleteFlag) != 0)
return DLT_FILETRANSFER_ERROR_FILE_COMPLETE3;
- }
return 0;
}
-//!This method gives information about the number of packages the file have
+/*!This method gives information about the number of packages the file have */
/**Every file will be divided into several packages. Every package will be logged as a single dlt log.
* The number of packages depends on the BUFFER_SIZE.
* At first it will be checked if the file exist. Then the file will be divided into
@@ -349,43 +372,48 @@ int dlt_user_log_file_complete(DltContext *fileContext, const char *filename, in
* @param filename Absolute file path
* @return Returns the number of packages if everything was okey. If there was a failure a value < 0 will be returned.
*/
-int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filename){
+int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filename)
+{
int packages;
uint32_t filesize;
- if(isFile(filename))
- {
+ if (isFile(filename)) {
packages = 1;
int ok;
- filesize = getFilesize(filename,&ok);
- if (!ok){
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("Error in: dlt_user_log_file_packagesCount, isFile"),DLT_STRING(filename),DLT_INT(DLT_FILETRANSFER_ERROR_PACKAGE_COUNT));
+ filesize = getFilesize(filename, &ok);
+
+ if (!ok) {
+ DLT_LOG(*fileContext,
+ DLT_LOG_ERROR,
+ DLT_STRING("Error in: dlt_user_log_file_packagesCount, isFile"),
+ DLT_STRING(filename),
+ DLT_INT(DLT_FILETRANSFER_ERROR_PACKAGE_COUNT));
return -1;
}
- if(filesize < BUFFER_SIZE)
- {
+
+ if (filesize < BUFFER_SIZE) {
return packages;
}
- else
- {
- packages = filesize/BUFFER_SIZE;
+ else {
+ packages = filesize / BUFFER_SIZE;
- if(filesize%BUFFER_SIZE == 0)
- {
+ if (filesize % BUFFER_SIZE == 0)
return packages;
- }
else
- {
- return packages+1;
- }
+ return packages + 1;
}
- } else {
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("Error in: dlt_user_log_file_packagesCount, !isFile"),DLT_STRING(filename),DLT_INT(DLT_FILETRANSFER_ERROR_PACKAGE_COUNT));
+ }
+ else {
+ DLT_LOG(*fileContext,
+ DLT_LOG_ERROR,
+ DLT_STRING("Error in: dlt_user_log_file_packagesCount, !isFile"),
+ DLT_STRING(filename),
+ DLT_INT(DLT_FILETRANSFER_ERROR_PACKAGE_COUNT));
return -1;
}
}
-//!Transfer the head of the file as a dlt logs.
+/*!Transfer the head of the file as a dlt logs. */
/**The head of the file must be logged to dlt because the head contains inforamtion about the file serial number,
* the file name, the file size, package number the file have and the buffer size.
* All these informations are needed from the plugin of the dlt viewer.
@@ -395,47 +423,52 @@ int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filenam
* @param alias Alias for the file. An alternative name to show in the receiving end
* @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
*/
-int dlt_user_log_file_header_alias(DltContext *fileContext,const char *filename, const char *alias){
+int dlt_user_log_file_header_alias(DltContext *fileContext, const char *filename, const char *alias)
+{
- if(isFile(filename))
- {
+ if (isFile(filename)) {
int ok;
- uint32_t fserialnumber = getFileSerialNumber(filename,&ok);
- if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_header_alias, Error getting serial number of file:"),DLT_STRING(filename));
+ uint32_t fserialnumber = getFileSerialNumber(filename, &ok);
- uint32_t fsize = getFilesize(filename,&ok);
if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_header_alias, Error getting size of file:"),DLT_STRING(filename));
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_header_alias, Error getting serial number of file:"),
+ DLT_STRING(filename));
+
+ uint32_t fsize = getFilesize(filename, &ok);
- char *fcreationdate = getFileCreationDate2(filename,&ok);
if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_header_alias, Error getting creation date of file:"),DLT_STRING(filename));
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_header_alias, Error getting size of file:"), DLT_STRING(filename));
+ char *fcreationdate = getFileCreationDate2(filename, &ok);
+ if (!ok)
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_header_alias, Error getting creation date of file:"),
+ DLT_STRING(filename));
- DLT_LOG(*fileContext,DLT_LOG_INFO,
+ DLT_LOG(*fileContext, DLT_LOG_INFO,
DLT_STRING("FLST"),
DLT_UINT(fserialnumber),
DLT_STRING(alias),
DLT_UINT(fsize),
DLT_STRING(fcreationdate);
- DLT_UINT(dlt_user_log_file_packagesCount(fileContext,filename)),
+ DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
DLT_UINT(BUFFER_SIZE),
DLT_STRING("FLST")
);
return 0;
}
- else
- {
- dlt_user_log_file_errorMessage(fileContext,filename, DLT_FILETRANSFER_ERROR_FILE_HEAD);
+ else {
+ dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_HEAD);
return DLT_FILETRANSFER_ERROR_FILE_HEAD;
}
}
-//!Transfer the head of the file as a dlt logs.
+/*!Transfer the head of the file as a dlt logs. */
/**The head of the file must be logged to dlt because the head contains inforamtion about the file serial number,
* the file name, the file size, package number the file have and the buffer size.
* All these informations are needed from the plugin of the dlt viewer.
@@ -444,48 +477,52 @@ int dlt_user_log_file_header_alias(DltContext *fileContext,const char *filename,
* @param filename Absolute file path
* @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
*/
-int dlt_user_log_file_header(DltContext *fileContext,const char *filename){
+int dlt_user_log_file_header(DltContext *fileContext, const char *filename)
+{
- if(isFile(filename))
- {
+ if (isFile(filename)) {
int ok;
- uint32_t fserialnumber = getFileSerialNumber(filename,&ok);
- if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_header, Error getting serial number of file:"),DLT_STRING(filename));
+ uint32_t fserialnumber = getFileSerialNumber(filename, &ok);
- uint32_t fsize = getFilesize(filename,&ok);
if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_header, Error getting size of file:"),DLT_STRING(filename));
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_header, Error getting serial number of file:"), DLT_STRING(filename));
- char *fcreationdate = getFileCreationDate2(filename,&ok);
- if (!ok)
- DLT_LOG(*fileContext,DLT_LOG_ERROR,DLT_STRING("dlt_user_log_file_header, Error getting creation date of file:"),DLT_STRING(filename));
+ uint32_t fsize = getFilesize(filename, &ok);
+ if (!ok)
+ DLT_LOG(*fileContext,
+ DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_header, Error getting size of file:"),
+ DLT_STRING(filename));
+ char *fcreationdate = getFileCreationDate2(filename, &ok);
+ if (!ok)
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("dlt_user_log_file_header, Error getting creation date of file:"), DLT_STRING(filename));
- DLT_LOG(*fileContext,DLT_LOG_INFO,
- DLT_STRING("FLST"),
- DLT_UINT(fserialnumber),
- DLT_STRING(filename),
- DLT_UINT(fsize),
- DLT_STRING(fcreationdate);
- DLT_UINT(dlt_user_log_file_packagesCount(fileContext,filename)),
- DLT_UINT(BUFFER_SIZE),
- DLT_STRING("FLST")
+ DLT_LOG(*fileContext, DLT_LOG_INFO,
+ DLT_STRING("FLST"),
+ DLT_UINT(fserialnumber),
+ DLT_STRING(filename),
+ DLT_UINT(fsize),
+ DLT_STRING(fcreationdate);
+ DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
+ DLT_UINT(BUFFER_SIZE),
+ DLT_STRING("FLST")
);
return 0;
}
- else
- {
- dlt_user_log_file_errorMessage(fileContext,filename, DLT_FILETRANSFER_ERROR_FILE_HEAD);
+ else {
+ dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_HEAD);
return DLT_FILETRANSFER_ERROR_FILE_HEAD;
}
}
-//!Transfer the content data of a file.
+/*!Transfer the content data of a file. */
/**See the Mainpages.c for more informations.
* @param fileContext Specific context to log the file to dlt
* @param filename Absolute file path
@@ -493,108 +530,105 @@ int dlt_user_log_file_header(DltContext *fileContext,const char *filename){
* @param timeout Timeout to wait between dlt logs. Important because the dlt FIFO should not be flooded. Default is defined by MIN_TIMEOUT. The given timeout in ms can not be smaller than MIN_TIMEOUT.
* @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
*/
-int dlt_user_log_file_data(DltContext *fileContext,const char *filename, int packageToTransfer, int timeout){
+int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int packageToTransfer, int timeout)
+{
FILE *file;
int pkgNumber;
uint32_t readBytes;
- if(isFile(filename))
- {
+ if (isFile(filename)) {
+
+ file = fopen (filename, "rb");
- file = fopen (filename,"rb");
- if (file == NULL)
- {
- dlt_user_log_file_errorMessage(fileContext,filename,DLT_FILETRANSFER_ERROR_FILE_DATA);
+ if (file == NULL) {
+ dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_DATA);
return DLT_FILETRANSFER_ERROR_FILE_DATA;
}
- if( (packageToTransfer != DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES && packageToTransfer > dlt_user_log_file_packagesCount(fileContext,filename)) || packageToTransfer <= 0)
- {
- DLT_LOG(*fileContext,DLT_LOG_ERROR,
- DLT_STRING("Error at dlt_user_log_file_data: packageToTransfer out of scope"),
- DLT_STRING("packageToTransfer:"),
- DLT_UINT(packageToTransfer),
- DLT_STRING("numberOfMaximalPackages:"),
- DLT_UINT(dlt_user_log_file_packagesCount(fileContext,filename)),
- DLT_STRING("for File:"),
- DLT_STRING(filename)
- );
+ if (((packageToTransfer != DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES) &&
+ (packageToTransfer >
+ dlt_user_log_file_packagesCount(fileContext, filename))) || (packageToTransfer <= 0)) {
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("Error at dlt_user_log_file_data: packageToTransfer out of scope"),
+ DLT_STRING("packageToTransfer:"),
+ DLT_UINT(packageToTransfer),
+ DLT_STRING("numberOfMaximalPackages:"),
+ DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
+ DLT_STRING("for File:"),
+ DLT_STRING(filename)
+ );
fclose(file);
return DLT_FILETRANSFER_ERROR_FILE_DATA;
}
readBytes = 0;
- if(packageToTransfer != DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES)
- {
-// If a single package should be transferred. The user has to check that the free space in the user buffer > 50%
-// if(checkUserBufferForFreeSpace()<0)
-// return DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED;
+ if (packageToTransfer != DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES) {
+/* If a single package should be transferred. The user has to check that the free space in the user buffer > 50% */
+/* if(checkUserBufferForFreeSpace()<0) */
+/* return DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED; */
- if ( 0 != fseek ( file , (packageToTransfer-1)*BUFFER_SIZE , SEEK_SET ) )
- {
- DLT_LOG(*fileContext,DLT_LOG_ERROR,
+ if (0 != fseek (file, (packageToTransfer - 1) * BUFFER_SIZE, SEEK_SET)) {
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
DLT_STRING("failed to fseek in file: "),
DLT_STRING(filename),
DLT_STRING("ferror:"),
DLT_INT(ferror(file))
- );
+ );
- fclose (file);
- return -1;
+ fclose (file);
+ return -1;
- }
- readBytes = fread(buffer, sizeof(char), BUFFER_SIZE, file);
- int ok;
+ }
- uint32_t fserial = getFileSerialNumber(filename,&ok);
+ readBytes = fread(buffer, sizeof(char), BUFFER_SIZE, file);
+ int ok;
- if (1 != ok)
- {
- DLT_LOG(*fileContext,DLT_LOG_ERROR,
- DLT_STRING("failed to get FileSerialNumber for: "),
- DLT_STRING(filename));
- }
+ uint32_t fserial = getFileSerialNumber(filename, &ok);
- DLT_LOG(*fileContext,DLT_LOG_INFO,
- DLT_STRING("FLDA"),
- DLT_UINT(fserial),
- DLT_UINT(packageToTransfer),
- DLT_RAW(buffer,readBytes),
- DLT_STRING("FLDA")
- );
+ if (1 != ok)
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("failed to get FileSerialNumber for: "),
+ DLT_STRING(filename));
- doTimeout(timeout);
+ DLT_LOG(*fileContext, DLT_LOG_INFO,
+ DLT_STRING("FLDA"),
+ DLT_UINT(fserial),
+ DLT_UINT(packageToTransfer),
+ DLT_RAW(buffer, readBytes),
+ DLT_STRING("FLDA")
+ );
+
+ doTimeout(timeout);
- } else {
+ }
+ else {
pkgNumber = 0;
- while( !feof( file ) )
- {
-// If the complete file should be transferred, the user buffer will be checked.
-// If free space < 50% the package won't be transferred.
- if(checkUserBufferForFreeSpace()>0)
- {
+
+ while (!feof(file)) {
+/* If the complete file should be transferred, the user buffer will be checked. */
+/* If free space < 50% the package won't be transferred. */
+ if (checkUserBufferForFreeSpace() > 0) {
pkgNumber++;
readBytes = fread(buffer, sizeof(char), BUFFER_SIZE, file);
int ok;
- uint32_t fserial = getFileSerialNumber(filename,&ok);
+ uint32_t fserial = getFileSerialNumber(filename, &ok);
if (1 != ok)
- {
- DLT_LOG(*fileContext,DLT_LOG_ERROR,
- DLT_STRING("failed to get FileSerialNumber for: "),
- DLT_STRING(filename));
- }
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("failed to get FileSerialNumber for: "),
+ DLT_STRING(filename));
- DLT_LOG(*fileContext,DLT_LOG_INFO,
+ DLT_LOG(*fileContext, DLT_LOG_INFO,
DLT_STRING("FLDA"),
DLT_UINT(fserial),
DLT_UINT(pkgNumber),
- DLT_RAW(buffer,readBytes),
+ DLT_RAW(buffer, readBytes),
DLT_STRING("FLDA")
- );
+ );
}
+
doTimeout(timeout);
}
}
@@ -603,13 +637,13 @@ int dlt_user_log_file_data(DltContext *fileContext,const char *filename, int pac
return 0;
- } else {
- dlt_user_log_file_errorMessage(fileContext,filename,DLT_FILETRANSFER_ERROR_FILE_DATA);
+ }
+ else {
+ dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_DATA);
return DLT_FILETRANSFER_ERROR_FILE_DATA;
}
-
}
-//!Transfer the end of the file as a dlt logs.
+/*!Transfer the end of the file as a dlt logs. */
/**The end of the file must be logged to dlt because the end contains inforamtion about the file serial number.
* This informations is needed from the plugin of the dlt viewer.
* See the Mainpages.c for more informations.
@@ -618,37 +652,36 @@ int dlt_user_log_file_data(DltContext *fileContext,const char *filename, int pac
* @param deleteFlag Flag to delete the file after the whole file is transferred (logged to dlt).1->delete,0->NotDelete
* @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
*/
-int dlt_user_log_file_end(DltContext *fileContext,const char *filename,int deleteFlag){
+int dlt_user_log_file_end(DltContext *fileContext, const char *filename, int deleteFlag)
+{
- if(isFile(filename))
- {
+ if (isFile(filename)) {
int ok;
- uint32_t fserial = getFileSerialNumber(filename,&ok);
+ uint32_t fserial = getFileSerialNumber(filename, &ok);
if (1 != ok)
- {
- DLT_LOG(*fileContext,DLT_LOG_ERROR,
- DLT_STRING("failed to get FileSerialNumber for: "),
- DLT_STRING(filename));
- }
+ DLT_LOG(*fileContext, DLT_LOG_ERROR,
+ DLT_STRING("failed to get FileSerialNumber for: "),
+ DLT_STRING(filename));
- DLT_LOG(*fileContext,DLT_LOG_INFO,
+ DLT_LOG(*fileContext, DLT_LOG_INFO,
DLT_STRING("FLFI"),
DLT_UINT(fserial),
DLT_STRING("FLFI")
- );
+ );
- if(deleteFlag){
- if( doRemoveFile(filename) != 0 ){
- dlt_user_log_file_errorMessage(fileContext,filename,DLT_FILETRANSFER_ERROR_FILE_END);
- return -1;
- }
+ if (deleteFlag) {
+ if (doRemoveFile(filename) != 0) {
+ dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_END);
+ return -1;
+ }
}
return 0;
- }else{
- dlt_user_log_file_errorMessage(fileContext,filename,DLT_FILETRANSFER_ERROR_FILE_END);
+ }
+ else {
+ dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_END);
return DLT_FILETRANSFER_ERROR_FILE_END;
}
}
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index 418e1cf..d45bb91 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -32,9 +32,9 @@
#include <signal.h> /* for signal(), SIGPIPE, SIG_IGN */
#if !defined (__WIN32__)
-#include <syslog.h> /* for LOG_... */
-#include <semaphore.h>
-#include <pthread.h> /* POSIX Threads */
+# include <syslog.h> /* for LOG_... */
+# include <semaphore.h>
+# include <pthread.h> /* POSIX Threads */
#endif
#include <sys/time.h>
@@ -48,7 +48,7 @@
#include <limits.h>
#ifdef linux
-#include <sys/prctl.h>
+# include <sys/prctl.h>
#endif
#include <sys/types.h> /* needed for getpid() */
@@ -56,8 +56,8 @@
#include <stdbool.h>
#ifdef DLT_USE_UNIX_SOCKET_IPC
-#include <sys/un.h>
-#include <sys/socket.h>
+# include <sys/un.h>
+# include <sys/socket.h>
#endif
#include "dlt_user.h"
@@ -67,15 +67,15 @@
#include "dlt_user_cfg.h"
#ifdef DLT_FATAL_LOG_RESET_ENABLE
-#define DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL) \
+# define DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL) \
do { \
if (LOGLEVEL == DLT_LOG_FATAL) { \
int *p = NULL; \
*p = 0; \
} \
- } while(0)
+ } while (0)
#else /* DLT_FATAL_LOG_RESET_ENABLE */
-#define DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL)
+# define DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL)
#endif /* DLT_FATAL_LOG_RESET_ENABLE */
static DltUser dlt_user;
@@ -92,11 +92,11 @@ static char str[DLT_USER_BUFFER_LENGTH];
static sem_t dlt_mutex;
static pthread_t dlt_receiverthread_handle;
-// calling dlt_user_atexit_handler() second time fails with error message
-static int atexit_registered = 0;
+/* calling dlt_user_atexit_handler() second time fails with error message */
+static int atexit_registered = 0;
-// calling atfork_handler() only once
-static int atfork_registered = 0;
+/* calling atfork_handler() only once */
+static int atfork_registered = 0;
/* Segmented Network Trace */
@@ -106,19 +106,23 @@ static int atfork_registered = 0;
/* Mutex to wait on while message queue is not initialized */
pthread_mutex_t mq_mutex;
-pthread_cond_t mq_init_condition;
+pthread_cond_t mq_init_condition;
void dlt_lock_mutex(pthread_mutex_t *mutex)
{
int32_t lock_mutex_result = pthread_mutex_lock(mutex);
- if (lock_mutex_result == EOWNERDEAD)
- {
+
+ if (lock_mutex_result == EOWNERDEAD) {
pthread_mutex_consistent(mutex);
lock_mutex_result = 0;
}
- else if ( lock_mutex_result != 0 )
+ else if (lock_mutex_result != 0)
{
- snprintf(str,DLT_USER_BUFFER_LENGTH, "Mutex lock failed unexpected pid=%i with result %i!\n", getpid(), lock_mutex_result);
+ snprintf(str,
+ DLT_USER_BUFFER_LENGTH,
+ "Mutex lock failed unexpected pid=%i with result %i!\n",
+ getpid(),
+ lock_mutex_result);
dlt_log(LOG_ERR, str);
}
}
@@ -131,13 +135,13 @@ void dlt_unlock_mutex(pthread_mutex_t *mutex)
/* Structure to pass data to segmented thread */
typedef struct
{
- DltContext *handle;
- uint32_t id;
- DltNetworkTraceType nw_trace_type;
- uint32_t header_len;
- void *header;
- uint32_t payload_len;
- void *payload;
+ DltContext *handle;
+ uint32_t id;
+ DltNetworkTraceType nw_trace_type;
+ uint32_t header_len;
+ void *header;
+ uint32_t payload_len;
+ void *payload;
} s_segmented_data;
/* Function prototypes for internally used functions */
@@ -149,7 +153,9 @@ static DltReturnValue dlt_user_log_send_register_application(void);
static DltReturnValue dlt_user_log_send_unregister_application(void);
static DltReturnValue dlt_user_log_send_register_context(DltContextData *log);
static DltReturnValue dlt_user_log_send_unregister_context(DltContextData *log);
-static DltReturnValue dlt_send_app_ll_ts_limit(const char *appid, DltLogLevelType loglevel, DltTraceStatusType tracestatus);
+static DltReturnValue dlt_send_app_ll_ts_limit(const char *appid,
+ DltLogLevelType loglevel,
+ DltTraceStatusType tracestatus);
static DltReturnValue dlt_user_log_send_log_mode(DltUserLogMode mode);
static DltReturnValue dlt_user_log_send_marker();
static DltReturnValue dlt_user_print_msg(DltMessage *msg, DltContextData *log);
@@ -159,7 +165,12 @@ static DltReturnValue dlt_user_log_send_overflow(void);
static void dlt_user_trace_network_segmented_thread(void *unused);
static void dlt_user_trace_network_segmented_thread_segmenter(s_segmented_data *data);
static DltReturnValue dlt_user_queue_resend(void);
-static DltReturnValue dlt_user_log_out_error_handling(void *ptr1, size_t len1, void* ptr2, size_t len2, void *ptr3, size_t len3);
+static DltReturnValue dlt_user_log_out_error_handling(void *ptr1,
+ size_t len1,
+ void *ptr2,
+ size_t len2,
+ void *ptr3,
+ size_t len3);
static int dlt_start_threads();
static void dlt_stop_threads();
@@ -168,22 +179,22 @@ static void dlt_fork_parent_fork_handler();
static void dlt_fork_child_fork_handler();
-DltReturnValue dlt_user_check_library_version(const char *user_major_version,const char *user_minor_version)
+DltReturnValue dlt_user_check_library_version(const char *user_major_version, const char *user_minor_version)
{
- char lib_major_version[DLT_USER_MAX_LIB_VERSION_LENGTH];
- char lib_minor_version[DLT_USER_MAX_LIB_VERSION_LENGTH];
+ char lib_major_version[DLT_USER_MAX_LIB_VERSION_LENGTH];
+ char lib_minor_version[DLT_USER_MAX_LIB_VERSION_LENGTH];
- dlt_get_major_version( lib_major_version,DLT_USER_MAX_LIB_VERSION_LENGTH);
- dlt_get_minor_version( lib_minor_version,DLT_USER_MAX_LIB_VERSION_LENGTH);
+ dlt_get_major_version(lib_major_version, DLT_USER_MAX_LIB_VERSION_LENGTH);
+ dlt_get_minor_version(lib_minor_version, DLT_USER_MAX_LIB_VERSION_LENGTH);
- if( (strcmp(lib_major_version,user_major_version) != 0) || (strcmp(lib_minor_version,user_minor_version) != 0))
- {
- dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH,
- "DLT Library version check failed! Installed DLT library version is %s.%s - Application using DLT library version %s.%s\n",
- lib_major_version,
- lib_minor_version,
- user_major_version,
- user_minor_version);
+ if ((strcmp(lib_major_version, user_major_version) != 0) || (strcmp(lib_minor_version, user_minor_version) != 0)) {
+ dlt_vnlog(LOG_WARNING,
+ DLT_USER_BUFFER_LENGTH,
+ "DLT Library version check failed! Installed DLT library version is %s.%s - Application using DLT library version %s.%s\n",
+ lib_major_version,
+ lib_minor_version,
+ user_major_version,
+ user_minor_version);
return DLT_RETURN_ERROR;
}
@@ -202,19 +213,18 @@ static DltReturnValue dlt_initialize_socket_connection(void)
DLT_SEM_LOCK();
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (sockfd == DLT_FD_INIT)
- {
+ if (sockfd == DLT_FD_INIT) {
dlt_log(LOG_CRIT, "Failed to create socket\n");
- DLT_SEM_FREE();
+ DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
status = fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL, 0) | O_NONBLOCK);
- if (status == -1)
- {
+
+ if (status == -1) {
dlt_vlog(LOG_INFO,
- "Socket %s/dlt cannot be changed to NON BLOCK\n",
- DLT_USER_IPC_PATH);
+ "Socket %s/dlt cannot be changed to NON BLOCK\n",
+ DLT_USER_IPC_PATH);
return DLT_RETURN_ERROR;
}
@@ -223,45 +233,38 @@ static DltReturnValue dlt_initialize_socket_connection(void)
l_opt.l_linger = 10;
if (setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &l_opt, sizeof l_opt) < 0)
- {
dlt_log(LOG_WARNING, "Failed to set linger option\n");
- }
remote.sun_family = AF_UNIX;
snprintf(dltSockBaseDir, DLT_IPC_PATH_MAX, "%s/dlt", DLT_USER_IPC_PATH);
strncpy(remote.sun_path, dltSockBaseDir, sizeof(dltSockBaseDir));
if (strlen(DLT_USER_IPC_PATH) > DLT_IPC_PATH_MAX)
- {
dlt_vlog(LOG_INFO,
"Provided path too long...trimming it to path[%s]\n",
dltSockBaseDir);
- }
- if (connect(sockfd, (struct sockaddr*) &remote, sizeof(remote)) == -1)
- {
- if (dlt_user.connection_state != DLT_USER_RETRY_CONNECT)
- {
+ if (connect(sockfd, (struct sockaddr *)&remote, sizeof(remote)) == -1) {
+ if (dlt_user.connection_state != DLT_USER_RETRY_CONNECT) {
dlt_vlog(LOG_INFO,
"Socket %s cannot be opened. Retrying later...\n",
dltSockBaseDir);
dlt_user.connection_state = DLT_USER_RETRY_CONNECT;
}
}
- else
- {
+ else {
dlt_user.dlt_log_handle = sockfd;
dlt_user.connection_state = DLT_USER_CONNECTED;
if (dlt_receiver_init(&(dlt_user.receiver),
sockfd,
- DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR)
- {
+ DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR) {
dlt_user_initialised = false;
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
}
+
DLT_SEM_FREE();
return DLT_RETURN_OK;
@@ -274,68 +277,69 @@ static DltReturnValue dlt_initialize_fifo_connection(void)
snprintf(dlt_user_dir, NAME_MAX, "%s/dltpipes", dltFifoBaseDir);
snprintf(dlt_daemon_fifo, NAME_MAX, "%s/dlt", dltFifoBaseDir);
- ret=mkdir(dlt_user_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_ISVTX );
- if (ret==-1 && errno != EEXIST)
- {
+ ret = mkdir(dlt_user_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_ISVTX);
+
+ if ((ret == -1) && (errno != EEXIST)) {
dlt_vnlog(LOG_ERR, DLT_USER_BUFFER_LENGTH, "FIFO user dir %s cannot be created!\n", dlt_user_dir);
return DLT_RETURN_ERROR;
}
/* if dlt pipes directory is created by the application also chmod the directory */
- if(ret == 0)
- {
- // S_ISGID cannot be set by mkdir, let's reassign right bits
- ret=chmod(dlt_user_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH | S_ISGID | S_ISVTX );
- if (ret==-1)
- {
+ if (ret == 0) {
+ /* S_ISGID cannot be set by mkdir, let's reassign right bits */
+ ret = chmod(dlt_user_dir,
+ S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH | S_ISGID |
+ S_ISVTX);
+
+ if (ret == -1) {
dlt_vnlog(LOG_ERR, DLT_USER_BUFFER_LENGTH, "FIFO user dir %s cannot be chmoded!\n", dlt_user_dir);
return DLT_RETURN_ERROR;
}
}
/* create and open DLT user FIFO */
- snprintf(filename,DLT_USER_MAX_FILENAME_LENGTH,"%s/dlt%d",dlt_user_dir,getpid());
+ snprintf(filename, DLT_USER_MAX_FILENAME_LENGTH, "%s/dlt%d", dlt_user_dir, getpid());
/* Try to delete existing pipe, ignore result of unlink */
unlink(filename);
- ret=mkfifo(filename, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP );
- if (ret==-1)
- {
+ ret = mkfifo(filename, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP);
+
+ if (ret == -1)
dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Loging disabled, FIFO user %s cannot be created!\n", filename);
/* return DLT_RETURN_OK; */ /* removed to prevent error, when FIFO already exists */
- }
- // S_IWGRP cannot be set by mkfifo (???), let's reassign right bits
- ret=chmod(filename, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP );
- if (ret==-1)
- {
+ /* S_IWGRP cannot be set by mkfifo (???), let's reassign right bits */
+ ret = chmod(filename, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP);
+
+ if (ret == -1) {
dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "FIFO user %s cannot be chmoded!\n", dlt_user_dir);
return DLT_RETURN_ERROR;
}
dlt_user.dlt_user_handle = open(filename, O_RDWR | O_CLOEXEC);
- if (dlt_user.dlt_user_handle == DLT_FD_INIT)
- {
+
+ if (dlt_user.dlt_user_handle == DLT_FD_INIT) {
dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Logging disabled, FIFO user %s cannot be opened!\n", filename);
unlink(filename);
return DLT_RETURN_OK;
}
/* open DLT output FIFO */
- dlt_user.dlt_log_handle = open(dlt_daemon_fifo, O_WRONLY | O_NONBLOCK | O_CLOEXEC );
- if (dlt_user.dlt_log_handle==-1)
- {
-
- if (dlt_user.connection_state != DLT_USER_RETRY_CONNECT)
- {
+ dlt_user.dlt_log_handle = open(dlt_daemon_fifo, O_WRONLY | O_NONBLOCK | O_CLOEXEC);
+
+ if (dlt_user.dlt_log_handle == -1) {
+
+ if (dlt_user.connection_state != DLT_USER_RETRY_CONNECT) {
/* This is a normal usecase. It is OK that the daemon (and thus the FIFO /tmp/dlt)
- starts later and some DLT users have already been started before.
- Thus it is OK if the FIFO can't be opened. */
- dlt_vnlog(LOG_INFO, DLT_USER_BUFFER_LENGTH, "FIFO %s cannot be opened. Retrying later...\n",dlt_daemon_fifo);
+ * starts later and some DLT users have already been started before.
+ * Thus it is OK if the FIFO can't be opened. */
+ dlt_vnlog(LOG_INFO, DLT_USER_BUFFER_LENGTH, "FIFO %s cannot be opened. Retrying later...\n",
+ dlt_daemon_fifo);
dlt_user.connection_state = DLT_USER_RETRY_CONNECT;
}
- //return DLT_RETURN_OK;
+
+ /*return DLT_RETURN_OK; */
}
return DLT_RETURN_OK;
@@ -344,23 +348,21 @@ static DltReturnValue dlt_initialize_fifo_connection(void)
DltReturnValue dlt_init(void)
{
- // process is exiting. Do not allocate new resources.
+ /* process is exiting. Do not allocate new resources. */
if (dlt_user_freeing != 0)
- {
- // return negative value, to stop the current log
+ /* return negative value, to stop the current log */
return DLT_RETURN_ERROR;
- }
- // WARNING: multithread unsafe !
- // Another thread will check that dlt_user_initialised != 0, but the lib is not initialised !
+ /* WARNING: multithread unsafe ! */
+ /* Another thread will check that dlt_user_initialised != 0, but the lib is not initialised ! */
dlt_user_initialised = true;
/* Initialize common part of dlt_init()/dlt_init_file() */
- if (dlt_init_common() == DLT_RETURN_ERROR)
- {
+ if (dlt_init_common() == DLT_RETURN_ERROR) {
dlt_user_initialised = false;
return DLT_RETURN_ERROR;
}
+
strncpy(dltFifoBaseDir, DLT_USER_IPC_PATH, sizeof(DLT_USER_IPC_PATH));
/* check environment variables */
dlt_check_envvar();
@@ -369,33 +371,36 @@ DltReturnValue dlt_init(void)
dlt_user.overflow = 0;
dlt_user.overflow_counter = 0;
#ifdef DLT_SHM_ENABLE
- memset(&(dlt_user.dlt_shm),0,sizeof(DltShm));
+ memset(&(dlt_user.dlt_shm), 0, sizeof(DltShm));
+
/* init shared memory */
- if (dlt_shm_init_client(&(dlt_user.dlt_shm),DLT_SHM_KEY) < 0)
- {
- snprintf(str,DLT_USER_BUFFER_LENGTH,"Logging disabled, Shared memory %d cannot be created!\n",DLT_SHM_KEY);
+ if (dlt_shm_init_client(&(dlt_user.dlt_shm), DLT_SHM_KEY) < 0) {
+ snprintf(str, DLT_USER_BUFFER_LENGTH, "Logging disabled, Shared memory %d cannot be created!\n", DLT_SHM_KEY);
dlt_log(LOG_WARNING, str);
- //return 0;
+ /*return 0; */
}
+
#elif defined DLT_USE_UNIX_SOCKET_IPC
+
if (dlt_initialize_socket_connection() != DLT_RETURN_OK)
- {
- // We could connect to the pipe, but not to the socket, which is normally
- // open before by the DLT daemon => bad failure => return error code
- // in case application is started before daemon, it is expected behaviour
+ /* We could connect to the pipe, but not to the socket, which is normally */
+ /* open before by the DLT daemon => bad failure => return error code */
+ /* in case application is started before daemon, it is expected behaviour */
return DLT_RETURN_ERROR;
- }
+
#else /* FIFO connection */
+
if (dlt_initialize_fifo_connection() != DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
+
dlt_user.connection_state = DLT_USER_CONNECTED;
- if (dlt_receiver_init(&(dlt_user.receiver),dlt_user.dlt_user_handle, DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR)
- {
+
+ if (dlt_receiver_init(&(dlt_user.receiver), dlt_user.dlt_user_handle,
+ DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR) {
dlt_user_initialised = false;
return DLT_RETURN_ERROR;
}
+
#endif
/* These will be lazy initialized only when needed */
@@ -404,14 +409,14 @@ DltReturnValue dlt_init(void)
/* Wait mutext for segmented thread */
pthread_mutexattr_t attr;
- if (pthread_mutexattr_init(&attr) != 0)
- {
+
+ if (pthread_mutexattr_init(&attr) != 0) {
dlt_user_initialised = false;
return DLT_RETURN_ERROR;
}
+
/* make mutex robust to prevent from deadlock when the segmented thread was cancelled, but held the mutex */
- if ( pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST) != 0 )
- {
+ if (pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST) != 0) {
dlt_user_initialised = false;
return DLT_RETURN_ERROR;
}
@@ -420,17 +425,15 @@ DltReturnValue dlt_init(void)
pthread_mutexattr_destroy(&attr);
pthread_cond_init(&mq_init_condition, NULL);
- if (dlt_start_threads() < 0)
- {
+ if (dlt_start_threads() < 0) {
dlt_user_initialised = false;
return DLT_RETURN_ERROR;
}
- // prepare for fork() call
- if (atfork_registered == 0)
- {
- atfork_registered = 1;
- pthread_atfork(&dlt_fork_pre_fork_handler, &dlt_fork_parent_fork_handler, &dlt_fork_child_fork_handler);
+ /* prepare for fork() call */
+ if (atfork_registered == 0) {
+ atfork_registered = 1;
+ pthread_atfork(&dlt_fork_pre_fork_handler, &dlt_fork_parent_fork_handler, &dlt_fork_child_fork_handler);
}
return DLT_RETURN_OK;
@@ -438,15 +441,14 @@ DltReturnValue dlt_init(void)
DltReturnValue dlt_init_file(const char *name)
{
- // check null pointer
- if(!name)
+ /* check null pointer */
+ if (!name)
return DLT_RETURN_WRONG_PARAMETER;
dlt_user_initialised = true;
/* Initialize common part of dlt_init()/dlt_init_file() */
- if (dlt_init_common() == DLT_RETURN_ERROR)
- {
+ if (dlt_init_common() == DLT_RETURN_ERROR) {
dlt_user_initialised = false;
return DLT_RETURN_ERROR;
}
@@ -454,9 +456,9 @@ DltReturnValue dlt_init_file(const char *name)
dlt_user.dlt_is_file = 1;
/* open DLT output file */
- dlt_user.dlt_log_handle = open(name,O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
- if (dlt_user.dlt_log_handle == -1)
- {
+ dlt_user.dlt_log_handle = open(name, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
+
+ if (dlt_user.dlt_log_handle == -1) {
dlt_vnlog(LOG_ERR, DLT_USER_BUFFER_LENGTH, "Log file %s cannot be opened!\n", name);
return DLT_RETURN_ERROR;
}
@@ -466,62 +468,62 @@ DltReturnValue dlt_init_file(const char *name)
DltReturnValue dlt_init_message_queue(void)
{
- dlt_lock_mutex(&mq_mutex);
- if(dlt_user.dlt_segmented_queue_read_handle >= 0 &&
- dlt_user.dlt_segmented_queue_write_handle >= 0)
- {
- // Already intialized
- dlt_unlock_mutex(&mq_mutex);
- return DLT_RETURN_OK;
- }
+ dlt_lock_mutex(&mq_mutex);
+
+ if ((dlt_user.dlt_segmented_queue_read_handle >= 0) &&
+ (dlt_user.dlt_segmented_queue_write_handle >= 0)) {
+ /* Already intialized */
+ dlt_unlock_mutex(&mq_mutex);
+ return DLT_RETURN_OK;
+ }
/* Generate per process name for queue */
char queue_name[NAME_MAX];
- snprintf(queue_name,NAME_MAX, "%s.%d", DLT_MESSAGE_QUEUE_NAME, getpid());
+ snprintf(queue_name, NAME_MAX, "%s.%d", DLT_MESSAGE_QUEUE_NAME, getpid());
/* Maximum queue size is 10, limit to size of pointers */
struct mq_attr mqatr;
- mqatr.mq_flags = 0;
- mqatr.mq_maxmsg = 10;
- mqatr.mq_msgsize = sizeof(s_segmented_data *);
- mqatr.mq_curmsgs = 0;
+ mqatr.mq_flags = 0;
+ mqatr.mq_maxmsg = 10;
+ mqatr.mq_msgsize = sizeof(s_segmented_data *);
+ mqatr.mq_curmsgs = 0;
/**
* Create the message queue. It must be newly created
* if old one was left by a crashing process.
* */
- dlt_user.dlt_segmented_queue_read_handle = mq_open(queue_name, O_CREAT| O_RDONLY | O_EXCL,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, &mqatr);
- if(dlt_user.dlt_segmented_queue_read_handle < 0)
- {
- if(errno == EEXIST)
- {
- dlt_log(LOG_WARNING, "Old message queue exists, trying to delete.\n");
- if(mq_unlink(queue_name) < 0)
- {
+ dlt_user.dlt_segmented_queue_read_handle = mq_open(queue_name, O_CREAT | O_RDONLY | O_EXCL,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
+ &mqatr);
+
+ if (dlt_user.dlt_segmented_queue_read_handle < 0) {
+ if (errno == EEXIST) {
+ dlt_log(LOG_WARNING, "Old message queue exists, trying to delete.\n");
+
+ if (mq_unlink(queue_name) < 0)
dlt_vnlog(LOG_CRIT, 256, "Could not delete existing message queue!: %s \n", strerror(errno));
- }
- else // Retry
- {
- dlt_user.dlt_segmented_queue_read_handle = mq_open(queue_name, O_CREAT| O_RDONLY | O_EXCL,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, &mqatr);
- }
- }
- if(dlt_user.dlt_segmented_queue_read_handle < 0)
- {
+ else /* Retry */
+
+ dlt_user.dlt_segmented_queue_read_handle = mq_open(queue_name,
+ O_CREAT | O_RDONLY | O_EXCL,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
+ &mqatr);
+ }
+
+ if (dlt_user.dlt_segmented_queue_read_handle < 0) {
dlt_vnlog(LOG_CRIT, 256, "Can't create message queue read handle!: %s \n", strerror(errno));
dlt_unlock_mutex(&mq_mutex);
return DLT_RETURN_ERROR;
- }
+ }
}
- dlt_user.dlt_segmented_queue_write_handle = mq_open(queue_name, O_WRONLY|O_NONBLOCK);
- if(dlt_user.dlt_segmented_queue_write_handle < 0)
- {
+ dlt_user.dlt_segmented_queue_write_handle = mq_open(queue_name, O_WRONLY | O_NONBLOCK);
+
+ if (dlt_user.dlt_segmented_queue_write_handle < 0) {
dlt_vnlog(LOG_CRIT, 256, "Can't open message queue write handle!: %s \n", strerror(errno));
- dlt_unlock_mutex(&mq_mutex);
- return DLT_RETURN_ERROR;
+ dlt_unlock_mutex(&mq_mutex);
+ return DLT_RETURN_ERROR;
}
pthread_cond_signal(&mq_init_condition);
@@ -532,7 +534,7 @@ DltReturnValue dlt_init_message_queue(void)
DltReturnValue dlt_init_common(void)
{
char *env_local_print;
- char * env_initial_log_level;
+ char *env_initial_log_level;
char *env_buffer_min;
uint32_t buffer_min = DLT_USER_RINGBUFFER_MIN_SIZE;
char *env_buffer_max;
@@ -543,8 +545,7 @@ DltReturnValue dlt_init_common(void)
uint32_t buffer_max_configured = 0;
/* Binary semaphore for threads */
- if (sem_init(&dlt_mutex, 0, 1)==-1)
- {
+ if (sem_init(&dlt_mutex, 0, 1) == -1) {
dlt_user_initialised = false;
return DLT_RETURN_ERROR;
}
@@ -552,11 +553,11 @@ DltReturnValue dlt_init_common(void)
/* set to unknown state of connected client */
dlt_user.log_state = -1;
- dlt_user.dlt_log_handle=-1;
- dlt_user.dlt_user_handle=DLT_FD_INIT;
+ dlt_user.dlt_log_handle = -1;
+ dlt_user.dlt_user_handle = DLT_FD_INIT;
- dlt_set_id(dlt_user.ecuID,DLT_USER_DEFAULT_ECU_ID);
- dlt_set_id(dlt_user.appID,"");
+ dlt_set_id(dlt_user.ecuID, DLT_USER_DEFAULT_ECU_ID);
+ dlt_set_id(dlt_user.appID, "");
dlt_user.application_description = NULL;
@@ -570,10 +571,10 @@ DltReturnValue dlt_init_common(void)
dlt_user.with_session_id = DLT_USER_WITH_SESSION_ID;
/* With timestamp is enabled by default */
- dlt_user.with_timestamp= DLT_USER_WITH_TIMESTAMP;
+ dlt_user.with_timestamp = DLT_USER_WITH_TIMESTAMP;
/* With timestamp is enabled by default */
- dlt_user.with_ecu_id= DLT_USER_WITH_ECU_ID;
+ dlt_user.with_ecu_id = DLT_USER_WITH_ECU_ID;
/* Local print is disabled by default */
dlt_user.enable_local_print = 0;
@@ -583,28 +584,24 @@ DltReturnValue dlt_init_common(void)
dlt_user.timeout_at_exit_handler = DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT;
env_local_print = getenv(DLT_USER_ENV_LOCAL_PRINT_MODE);
- if (env_local_print)
- {
- if (strcmp(env_local_print,"AUTOMATIC")==0)
- {
+
+ if (env_local_print) {
+ if (strcmp(env_local_print, "AUTOMATIC") == 0)
dlt_user.local_print_mode = DLT_PM_AUTOMATIC;
- }
- else if (strcmp(env_local_print,"FORCE_ON")==0)
- {
+ else if (strcmp(env_local_print, "FORCE_ON") == 0)
dlt_user.local_print_mode = DLT_PM_FORCE_ON;
- }
- else if (strcmp(env_local_print,"FORCE_OFF")==0)
- {
+ else if (strcmp(env_local_print, "FORCE_OFF") == 0)
dlt_user.local_print_mode = DLT_PM_FORCE_OFF;
- }
}
env_initial_log_level = getenv("DLT_INITIAL_LOG_LEVEL");
- if( env_initial_log_level != NULL )
- {
- if (dlt_env_extract_ll_set(&env_initial_log_level, &dlt_user.initial_ll_set) != 0)
- {
- snprintf(str, DLT_USER_BUFFER_LENGTH, "Unable to parse initial set of log-levels from environment! Env:\n%s\n", getenv("DLT_INITIAL_LOG_LEVEL"));
+
+ if (env_initial_log_level != NULL) {
+ if (dlt_env_extract_ll_set(&env_initial_log_level, &dlt_user.initial_ll_set) != 0) {
+ snprintf(str,
+ DLT_USER_BUFFER_LENGTH,
+ "Unable to parse initial set of log-levels from environment! Env:\n%s\n",
+ getenv("DLT_INITIAL_LOG_LEVEL"));
dlt_log(LOG_WARNING, str);
}
}
@@ -620,11 +617,10 @@ DltReturnValue dlt_init_common(void)
env_buffer_max = getenv(DLT_USER_ENV_BUFFER_MAX_SIZE);
env_buffer_step = getenv(DLT_USER_ENV_BUFFER_STEP_SIZE);
- if (env_buffer_min != NULL)
- {
- buffer_min = (uint32_t) strtol(env_buffer_min, NULL, 10);
- if (errno == EINVAL || errno == ERANGE)
- {
+ if (env_buffer_min != NULL) {
+ buffer_min = (uint32_t)strtol(env_buffer_min, NULL, 10);
+
+ if ((errno == EINVAL) || (errno == ERANGE)) {
dlt_vlog(LOG_ERR,
"Wrong value specified for %s. Using default\n",
DLT_USER_ENV_BUFFER_MIN_SIZE);
@@ -632,11 +628,10 @@ DltReturnValue dlt_init_common(void)
}
}
- if (env_buffer_max != NULL)
- {
- buffer_max = (uint32_t) strtol(env_buffer_max, NULL, 10);
- if (errno == EINVAL || errno == ERANGE)
- {
+ if (env_buffer_max != NULL) {
+ buffer_max = (uint32_t)strtol(env_buffer_max, NULL, 10);
+
+ if ((errno == EINVAL) || (errno == ERANGE)) {
dlt_vlog(LOG_ERR,
"Wrong value specified for %s. Using default\n",
DLT_USER_ENV_BUFFER_MAX_SIZE);
@@ -644,11 +639,10 @@ DltReturnValue dlt_init_common(void)
}
}
- if (env_buffer_step != NULL)
- {
- buffer_step = (uint32_t) strtol(env_buffer_step, NULL, 10);
- if (errno == EINVAL || errno == ERANGE)
- {
+ if (env_buffer_step != NULL) {
+ buffer_step = (uint32_t)strtol(env_buffer_step, NULL, 10);
+
+ if ((errno == EINVAL) || (errno == ERANGE)) {
dlt_vlog(LOG_ERR,
"Wrong value specified for %s. Using default\n",
DLT_USER_ENV_BUFFER_STEP_SIZE);
@@ -660,50 +654,47 @@ DltReturnValue dlt_init_common(void)
dlt_user.log_buf_len = DLT_USER_BUF_MAX_SIZE;
env_log_buffer_len = getenv(DLT_USER_ENV_LOG_MSG_BUF_LEN);
- if (env_log_buffer_len != NULL)
- {
- buffer_max_configured = (uint32_t) strtol(env_log_buffer_len, NULL, 10);
+ if (env_log_buffer_len != NULL) {
+ buffer_max_configured = (uint32_t)strtol(env_log_buffer_len, NULL, 10);
- if (buffer_max_configured > DLT_LOG_MSG_BUF_MAX_SIZE)
- {
+ if (buffer_max_configured > DLT_LOG_MSG_BUF_MAX_SIZE) {
dlt_user.log_buf_len = DLT_LOG_MSG_BUF_MAX_SIZE;
dlt_vlog(LOG_WARNING,
"Configured size exceeds maximum allowed size,restricting to max [65535 bytes]\n");
}
- else
- {
+ else {
dlt_user.log_buf_len = buffer_max_configured;
dlt_vlog(LOG_INFO,
"Configured buffer size to [%d bytes]\n",
buffer_max_configured);
}
}
- if (dlt_user.resend_buffer == NULL)
- {
+
+ if (dlt_user.resend_buffer == NULL) {
dlt_user.resend_buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
- if (dlt_user.resend_buffer == NULL)
- {
+
+ if (dlt_user.resend_buffer == NULL) {
dlt_user_initialised = false;
DLT_SEM_FREE();
dlt_vlog(LOG_ERR, "cannot allocate memory for resend buffer\n");
return DLT_RETURN_ERROR;
}
}
+
if (dlt_buffer_init_dynamic(&(dlt_user.startup_buffer),
buffer_min,
buffer_max,
- buffer_step) == DLT_RETURN_ERROR)
- {
+ buffer_step) == DLT_RETURN_ERROR) {
dlt_user_initialised = false;
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
+
DLT_SEM_FREE();
- signal(SIGPIPE,SIG_IGN); /* ignore pipe signals */
+ signal(SIGPIPE, SIG_IGN); /* ignore pipe signals */
- if (atexit_registered == 0)
- {
+ if (atexit_registered == 0) {
atexit_registered = 1;
atexit(dlt_user_atexit_handler);
}
@@ -719,10 +710,9 @@ DltReturnValue dlt_init_common(void)
void dlt_user_atexit_handler(void)
{
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
- // close file
+ /* close file */
dlt_log_free();
return;
}
@@ -730,7 +720,7 @@ void dlt_user_atexit_handler(void)
/* Try to resend potential log messages in the user buffer */
int count = dlt_user_atexit_blow_out_user_buffer();
- if(count != 0)
+ if (count != 0)
dlt_vnlog(LOG_WARNING, 128, "Lost log messages in user buffer when exiting: %i\n", count);
/* Unregister app (this also unregisters all contexts in daemon) */
@@ -742,42 +732,39 @@ void dlt_user_atexit_handler(void)
dlt_free();
}
-int dlt_user_atexit_blow_out_user_buffer(void){
+int dlt_user_atexit_blow_out_user_buffer(void)
+{
- int count,ret;
+ int count, ret;
- uint32_t exitTime = dlt_uptime() + dlt_user.timeout_at_exit_handler;
+ uint32_t exitTime = dlt_uptime() + dlt_user.timeout_at_exit_handler;
/* Send content of ringbuffer */
DLT_SEM_LOCK();
count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
DLT_SEM_FREE();
- if (count > 0)
- {
- while(dlt_uptime() < exitTime )
- {
- if (dlt_user.dlt_log_handle == -1)
- {
+ if (count > 0) {
+ while (dlt_uptime() < exitTime) {
+ if (dlt_user.dlt_log_handle == -1) {
/* Reattach to daemon if neccesary */
dlt_user_log_reattach_to_daemon();
- if ((dlt_user.dlt_log_handle != -1) && (dlt_user.overflow_counter))
- {
- if (dlt_user_log_send_overflow()==0)
- {
- dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "%u messages discarded!\n", dlt_user.overflow_counter);
- dlt_user.overflow_counter=0;
+ if ((dlt_user.dlt_log_handle != -1) && (dlt_user.overflow_counter)) {
+ if (dlt_user_log_send_overflow() == 0) {
+ dlt_vnlog(LOG_WARNING,
+ DLT_USER_BUFFER_LENGTH,
+ "%u messages discarded!\n",
+ dlt_user.overflow_counter);
+ dlt_user.overflow_counter = 0;
}
}
}
- if (dlt_user.dlt_log_handle != -1)
- {
+ if (dlt_user.dlt_log_handle != -1) {
ret = dlt_user_log_resend_buffer();
- if(ret == 0)
- {
+ if (ret == 0) {
DLT_SEM_LOCK();
count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
DLT_SEM_FREE();
@@ -799,8 +786,7 @@ int dlt_user_atexit_blow_out_user_buffer(void){
static void dlt_user_free_buffer(unsigned char **buffer)
{
- if (*buffer)
- {
+ if (*buffer) {
free(*buffer);
*buffer = NULL;
}
@@ -814,30 +800,31 @@ DltReturnValue dlt_free(void)
char filename[DLT_USER_MAX_FILENAME_LENGTH];
#endif
- if( dlt_user_freeing != 0 )
- // resources are already being freed. Do nothing and return.
+ if (dlt_user_freeing != 0)
+ /* resources are already being freed. Do nothing and return. */
return DLT_RETURN_ERROR;
- // library is freeing its resources. Avoid to allocate it in dlt_init()
+ /* library is freeing its resources. Avoid to allocate it in dlt_init() */
dlt_user_freeing = 1;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_user_freeing = 0;
return DLT_RETURN_ERROR;
}
+
dlt_user_initialised = false;
dlt_stop_threads();
#ifndef DLT_USE_UNIX_SOCKET_IPC
- if (dlt_user.dlt_user_handle!=DLT_FD_INIT)
- {
+
+ if (dlt_user.dlt_user_handle != DLT_FD_INIT) {
close(dlt_user.dlt_user_handle);
- dlt_user.dlt_user_handle=DLT_FD_INIT;
- snprintf(filename,DLT_USER_MAX_FILENAME_LENGTH,"%s/dlt%d",dlt_user_dir,getpid());
+ dlt_user.dlt_user_handle = DLT_FD_INIT;
+ snprintf(filename, DLT_USER_MAX_FILENAME_LENGTH, "%s/dlt%d", dlt_user_dir, getpid());
unlink(filename);
}
+
#endif
#ifdef DLT_SHM_ENABLE
@@ -845,41 +832,38 @@ DltReturnValue dlt_free(void)
dlt_shm_free_client(&dlt_user.dlt_shm);
#endif
- if (dlt_user.dlt_log_handle!=-1)
- {
+ if (dlt_user.dlt_log_handle != -1) {
/* close log file/output fifo to daemon */
#ifdef DLT_USE_UNIX_SOCKET_IPC
ret = shutdown(dlt_user.dlt_log_handle, SHUT_WR);
- if (ret < 0)
- {
+
+ if (ret < 0) {
dlt_vlog(LOG_WARNING, "%s: shutdown failed: %s\n", __func__, strerror(errno));
}
- else
- {
- while (1)
- {
+ else {
+ while (1) {
ssize_t bytes_read;
bytes_read = read(dlt_user.dlt_log_handle, dlt_user.resend_buffer, dlt_user.log_buf_len);
- if (bytes_read < 0)
- {
+
+ if (bytes_read < 0) {
dlt_vlog(LOG_DEBUG, "%s - %d: Reading...\n", __func__, __LINE__);
break;
}
- else
- {
+ else {
dlt_vlog(LOG_DEBUG, "%s - %d: %d bytes read from resend buffer\n", __func__, __LINE__);
+
if (!bytes_read)
break;
}
}
}
+
#endif
ret = close(dlt_user.dlt_log_handle);
+
if (ret < 0)
- {
dlt_vlog(LOG_WARNING, "%s: close failed: %s\n", __func__, strerror(errno));
- }
dlt_user.dlt_log_handle = -1;
}
@@ -896,34 +880,30 @@ DltReturnValue dlt_free(void)
DLT_SEM_FREE();
DLT_SEM_LOCK();
- if (dlt_user.dlt_ll_ts)
- {
- for (i=0;i<dlt_user.dlt_ll_ts_max_num_entries;i++)
- {
- if( dlt_user.dlt_ll_ts[i].context_description != NULL)
- {
+
+ if (dlt_user.dlt_ll_ts) {
+ for (i = 0; i < dlt_user.dlt_ll_ts_max_num_entries; i++) {
+ if (dlt_user.dlt_ll_ts[i].context_description != NULL) {
free (dlt_user.dlt_ll_ts[i].context_description);
dlt_user.dlt_ll_ts[i].context_description = NULL;
}
- if (dlt_user.dlt_ll_ts[i].log_level_ptr != NULL)
- {
+ if (dlt_user.dlt_ll_ts[i].log_level_ptr != NULL) {
free(dlt_user.dlt_ll_ts[i].log_level_ptr);
dlt_user.dlt_ll_ts[i].log_level_ptr = NULL;
}
- if (dlt_user.dlt_ll_ts[i].trace_status_ptr != NULL)
- {
+ if (dlt_user.dlt_ll_ts[i].trace_status_ptr != NULL) {
free(dlt_user.dlt_ll_ts[i].trace_status_ptr);
dlt_user.dlt_ll_ts[i].trace_status_ptr = NULL;
}
- if (dlt_user.dlt_ll_ts[i].injection_table != NULL)
- {
+ if (dlt_user.dlt_ll_ts[i].injection_table != NULL) {
free(dlt_user.dlt_ll_ts[i].injection_table);
dlt_user.dlt_ll_ts[i].injection_table = NULL;
}
- dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
+
+ dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
dlt_user.dlt_ll_ts[i].log_level_changed_callback = 0;
}
@@ -937,7 +917,7 @@ DltReturnValue dlt_free(void)
DLT_SEM_FREE();
char queue_name[NAME_MAX];
- snprintf(queue_name,NAME_MAX, "%s.%d", DLT_MESSAGE_QUEUE_NAME, getpid());
+ snprintf(queue_name, NAME_MAX, "%s.%d", DLT_MESSAGE_QUEUE_NAME, getpid());
/**
* Ignore errors from these, to not to spam user if dlt_free
@@ -953,27 +933,25 @@ DltReturnValue dlt_free(void)
pthread_mutex_destroy(&mq_mutex);
sem_destroy(&dlt_mutex);
- // allow the user app to do dlt_init() again.
- // The flag is unset only to keep almost the same behaviour as before, on EntryNav
- // This should be removed for other projects (see documentation of dlt_free()
+ /* allow the user app to do dlt_init() again. */
+ /* The flag is unset only to keep almost the same behaviour as before, on EntryNav */
+ /* This should be removed for other projects (see documentation of dlt_free() */
dlt_user_freeing = 0;
return DLT_RETURN_OK;
}
-DltReturnValue dlt_check_library_version(const char * user_major_version,const char * user_minor_version)
+DltReturnValue dlt_check_library_version(const char *user_major_version, const char *user_minor_version)
{
return dlt_user_check_library_version(user_major_version, user_minor_version);
}
-DltReturnValue dlt_register_app(const char *appid, const char * description)
+DltReturnValue dlt_register_app(const char *appid, const char *description)
{
DltReturnValue ret = DLT_RETURN_OK;
- if (!dlt_user_initialised)
- {
- if (dlt_init() < 0)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < 0) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -984,32 +962,28 @@ DltReturnValue dlt_register_app(const char *appid, const char * description)
/* check if application already registered */
/* if yes do not register again */
- if (appid[1] == 0)
- {
+ if (appid[1] == 0) {
if (appid[0] == dlt_user.appID[0])
return DLT_RETURN_OK;
}
else if (appid[2] == 0)
{
- if (appid[0] == dlt_user.appID[0] &&
- appid[1] == dlt_user.appID[1])
+ if ((appid[0] == dlt_user.appID[0]) &&
+ (appid[1] == dlt_user.appID[1]))
return DLT_RETURN_OK;
}
else if (appid[3] == 0)
{
- if (appid[0] == dlt_user.appID[0] &&
- appid[1] == dlt_user.appID[1] &&
- appid[2] == dlt_user.appID[2])
- return DLT_RETURN_OK;
- }
- else
- {
- if (appid[0] == dlt_user.appID[0] &&
- appid[1] == dlt_user.appID[1] &&
- appid[2] == dlt_user.appID[2] &&
- appid[3] == dlt_user.appID[3])
+ if ((appid[0] == dlt_user.appID[0]) &&
+ (appid[1] == dlt_user.appID[1]) &&
+ (appid[2] == dlt_user.appID[2]))
return DLT_RETURN_OK;
}
+ else if ((appid[0] == dlt_user.appID[0]) &&
+ (appid[1] == dlt_user.appID[1]) &&
+ (appid[2] == dlt_user.appID[2]) &&
+ (appid[3] == dlt_user.appID[3]))
+ return DLT_RETURN_OK;
DLT_SEM_LOCK();
@@ -1021,17 +995,15 @@ DltReturnValue dlt_register_app(const char *appid, const char * description)
dlt_user.application_description = NULL;
- if (description != NULL)
- {
+ if (description != NULL) {
size_t desc_len = strlen(description);
dlt_user.application_description = malloc(desc_len + 1);
- if (dlt_user.application_description)
- {
+
+ if (dlt_user.application_description) {
strncpy(dlt_user.application_description, description, desc_len);
dlt_user.application_description[desc_len] = '\0';
}
- else
- {
+ else {
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
@@ -1041,40 +1013,38 @@ DltReturnValue dlt_register_app(const char *appid, const char * description)
ret = dlt_user_log_send_register_application();
- if (( ret == DLT_RETURN_OK ) && (dlt_user.dlt_log_handle!=-1))
- {
+ if ((ret == DLT_RETURN_OK) && (dlt_user.dlt_log_handle != -1))
ret = dlt_user_log_resend_buffer();
- }
return ret;
}
-DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, const char * description)
+DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, const char *description)
{
- // check nullpointer
- if(handle == NULL)
+ /* check nullpointer */
+ if (handle == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
- if (dlt_init() < 0)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < 0) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
}
if ((contextid == NULL) || (contextid[0] == '\0'))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- return dlt_register_context_ll_ts(handle, contextid, description, DLT_USER_LOG_LEVEL_NOT_SET, DLT_USER_TRACE_STATUS_NOT_SET);
+ return dlt_register_context_ll_ts(handle,
+ contextid,
+ description,
+ DLT_USER_LOG_LEVEL_NOT_SET,
+ DLT_USER_TRACE_STATUS_NOT_SET);
}
DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle,
const char *contextid,
- const char * description,
+ const char *description,
int loglevel,
int tracestatus,
void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],
@@ -1085,29 +1055,22 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle,
uint32_t i;
int envLogLevel = DLT_USER_LOG_LEVEL_NOT_SET;
- //check nullpointer
- if ((handle ==NULL) || (contextid == NULL) || (contextid[0] == '\0'))
- {
+ /*check nullpointer */
+ if ((handle == NULL) || (contextid == NULL) || (contextid[0] == '\0'))
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (loglevel < DLT_USER_LOG_LEVEL_NOT_SET || loglevel >= DLT_LOG_MAX)
- {
+ if ((loglevel < DLT_USER_LOG_LEVEL_NOT_SET) || (loglevel >= DLT_LOG_MAX)) {
dlt_vlog(LOG_ERR, "Loglevel %d is outside valid range", loglevel);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (tracestatus < DLT_USER_TRACE_STATUS_NOT_SET || tracestatus >= DLT_TRACE_STATUS_MAX)
- {
+ if ((tracestatus < DLT_USER_TRACE_STATUS_NOT_SET) || (tracestatus >= DLT_TRACE_STATUS_MAX)) {
dlt_vlog(LOG_ERR, "Tracestatus %d is outside valid range", tracestatus);
return DLT_RETURN_WRONG_PARAMETER;
}
-
if (dlt_user_log_init(handle, &log) == -1)
- {
return DLT_RETURN_ERROR;
- }
/* Reset message counter */
handle->mcnt = 0;
@@ -1121,11 +1084,10 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle,
/* Double registration is already checked by daemon */
/* Allocate or expand context array */
- if (dlt_user.dlt_ll_ts == 0)
- {
- dlt_user.dlt_ll_ts = (dlt_ll_ts_type*) malloc(sizeof(dlt_ll_ts_type) * DLT_USER_CONTEXT_ALLOC_SIZE);
- if (dlt_user.dlt_ll_ts == 0)
- {
+ if (dlt_user.dlt_ll_ts == 0) {
+ dlt_user.dlt_ll_ts = (dlt_ll_ts_type *)malloc(sizeof(dlt_ll_ts_type) * DLT_USER_CONTEXT_ALLOC_SIZE);
+
+ if (dlt_user.dlt_ll_ts == 0) {
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
@@ -1133,71 +1095,65 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle,
dlt_user.dlt_ll_ts_max_num_entries = DLT_USER_CONTEXT_ALLOC_SIZE;
/* Initialize new entries */
- for (i = 0; i < dlt_user.dlt_ll_ts_max_num_entries; i++)
- {
+ for (i = 0; i < dlt_user.dlt_ll_ts_max_num_entries; i++) {
dlt_set_id(dlt_user.dlt_ll_ts[i].contextID, "");
/* At startup, logging and tracing is locally enabled */
/* the correct log level/status is set after received from daemon */
- dlt_user.dlt_ll_ts[i].log_level = DLT_USER_INITIAL_LOG_LEVEL;
+ dlt_user.dlt_ll_ts[i].log_level = DLT_USER_INITIAL_LOG_LEVEL;
dlt_user.dlt_ll_ts[i].trace_status = DLT_USER_INITIAL_TRACE_STATUS;
- dlt_user.dlt_ll_ts[i].log_level_ptr = 0;
+ dlt_user.dlt_ll_ts[i].log_level_ptr = 0;
dlt_user.dlt_ll_ts[i].trace_status_ptr = 0;
dlt_user.dlt_ll_ts[i].context_description = 0;
dlt_user.dlt_ll_ts[i].injection_table = 0;
- dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
+ dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
dlt_user.dlt_ll_ts[i].log_level_changed_callback = 0;
}
}
- else
- {
- if ((dlt_user.dlt_ll_ts_num_entries % DLT_USER_CONTEXT_ALLOC_SIZE) == 0)
- {
- /* allocate memory in steps of DLT_USER_CONTEXT_ALLOC_SIZE, e.g. 500 */
- dlt_ll_ts_type *old_ll_ts;
- uint32_t old_max_entries;
-
- old_ll_ts = dlt_user.dlt_ll_ts;
- old_max_entries = dlt_user.dlt_ll_ts_max_num_entries;
-
- dlt_user.dlt_ll_ts_max_num_entries = ((dlt_user.dlt_ll_ts_num_entries
- / DLT_USER_CONTEXT_ALLOC_SIZE) + 1)
- * DLT_USER_CONTEXT_ALLOC_SIZE;
- dlt_user.dlt_ll_ts = (dlt_ll_ts_type*) malloc(sizeof(dlt_ll_ts_type)*
- dlt_user.dlt_ll_ts_max_num_entries);
- if (dlt_user.dlt_ll_ts == 0)
- {
- dlt_user.dlt_ll_ts = old_ll_ts;
- dlt_user.dlt_ll_ts_max_num_entries = old_max_entries;
- DLT_SEM_FREE();
- return DLT_RETURN_ERROR;
- }
+ else if ((dlt_user.dlt_ll_ts_num_entries % DLT_USER_CONTEXT_ALLOC_SIZE) == 0) {
+ /* allocate memory in steps of DLT_USER_CONTEXT_ALLOC_SIZE, e.g. 500 */
+ dlt_ll_ts_type *old_ll_ts;
+ uint32_t old_max_entries;
- memcpy(dlt_user.dlt_ll_ts, old_ll_ts, sizeof(dlt_ll_ts_type) * dlt_user.dlt_ll_ts_num_entries);
- free(old_ll_ts);
+ old_ll_ts = dlt_user.dlt_ll_ts;
+ old_max_entries = dlt_user.dlt_ll_ts_max_num_entries;
- /* Initialize new entries */
- for (i = dlt_user.dlt_ll_ts_num_entries; i < dlt_user.dlt_ll_ts_max_num_entries; i++)
- {
- dlt_set_id(dlt_user.dlt_ll_ts[i].contextID, "");
+ dlt_user.dlt_ll_ts_max_num_entries = ((dlt_user.dlt_ll_ts_num_entries
+ / DLT_USER_CONTEXT_ALLOC_SIZE) + 1)
+ * DLT_USER_CONTEXT_ALLOC_SIZE;
+ dlt_user.dlt_ll_ts = (dlt_ll_ts_type *)malloc(sizeof(dlt_ll_ts_type) *
+ dlt_user.dlt_ll_ts_max_num_entries);
- /* At startup, logging and tracing is locally enabled */
- /* the correct log level/status is set after received from daemon */
- dlt_user.dlt_ll_ts[i].log_level = DLT_USER_INITIAL_LOG_LEVEL;
- dlt_user.dlt_ll_ts[i].trace_status = DLT_USER_INITIAL_TRACE_STATUS;
+ if (dlt_user.dlt_ll_ts == 0) {
+ dlt_user.dlt_ll_ts = old_ll_ts;
+ dlt_user.dlt_ll_ts_max_num_entries = old_max_entries;
+ DLT_SEM_FREE();
+ return DLT_RETURN_ERROR;
+ }
- dlt_user.dlt_ll_ts[i].log_level_ptr = 0;
- dlt_user.dlt_ll_ts[i].trace_status_ptr = 0;
+ memcpy(dlt_user.dlt_ll_ts, old_ll_ts, sizeof(dlt_ll_ts_type) * dlt_user.dlt_ll_ts_num_entries);
+ free(old_ll_ts);
- dlt_user.dlt_ll_ts[i].context_description = 0;
+ /* Initialize new entries */
+ for (i = dlt_user.dlt_ll_ts_num_entries; i < dlt_user.dlt_ll_ts_max_num_entries; i++) {
+ dlt_set_id(dlt_user.dlt_ll_ts[i].contextID, "");
- dlt_user.dlt_ll_ts[i].injection_table = 0;
- dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
- dlt_user.dlt_ll_ts[i].log_level_changed_callback = 0;
- }
+ /* At startup, logging and tracing is locally enabled */
+ /* the correct log level/status is set after received from daemon */
+ dlt_user.dlt_ll_ts[i].log_level = DLT_USER_INITIAL_LOG_LEVEL;
+ dlt_user.dlt_ll_ts[i].trace_status = DLT_USER_INITIAL_TRACE_STATUS;
+
+ dlt_user.dlt_ll_ts[i].log_level_ptr = 0;
+ dlt_user.dlt_ll_ts[i].trace_status_ptr = 0;
+
+ dlt_user.dlt_ll_ts[i].context_description = 0;
+
+ dlt_user.dlt_ll_ts[i].injection_table = 0;
+ dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
+ dlt_user.dlt_ll_ts[i].log_level_changed_callback = 0;
}
}
@@ -1205,18 +1161,15 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle,
dlt_set_id(dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].contextID, contextid);
if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].context_description != 0)
- {
free(dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].context_description);
- }
dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].context_description = 0;
- if (description != 0)
- {
+ if (description != 0) {
size_t desc_len = strlen(description);
dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].context_description = malloc(desc_len + 1);
- if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].context_description == 0)
- {
+
+ if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].context_description == 0) {
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
@@ -1225,41 +1178,41 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle,
dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].context_description[desc_len] = '\0';
}
- if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level_ptr == 0)
- {
+ if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level_ptr == 0) {
dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level_ptr = malloc(sizeof(int8_t));
- if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level_ptr == 0)
- {
+
+ if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level_ptr == 0) {
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
}
- if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].trace_status_ptr == 0)
- {
+
+ if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].trace_status_ptr == 0) {
dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].trace_status_ptr = malloc(sizeof(int8_t));
- if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].trace_status_ptr == 0)
- {
+
+ if (dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].trace_status_ptr == 0) {
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
}
/* check if the log level is set in the environement */
- envLogLevel = dlt_env_adjust_ll_from_env(&dlt_user.initial_ll_set, dlt_user.appID, contextid, DLT_USER_LOG_LEVEL_NOT_SET);
- if (envLogLevel != DLT_USER_LOG_LEVEL_NOT_SET)
- {
+ envLogLevel = dlt_env_adjust_ll_from_env(&dlt_user.initial_ll_set,
+ dlt_user.appID,
+ contextid,
+ DLT_USER_LOG_LEVEL_NOT_SET);
+
+ if (envLogLevel != DLT_USER_LOG_LEVEL_NOT_SET) {
dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level = envLogLevel;
loglevel = envLogLevel;
}
else if (loglevel != DLT_USER_LOG_LEVEL_NOT_SET)
{
- dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level = loglevel;
+ dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level = loglevel;
}
if (tracestatus != DLT_USER_TRACE_STATUS_NOT_SET)
- {
dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].trace_status = tracestatus;
- }
/* Prepare transfer struct */
dlt_set_id(handle->contextID, contextid);
@@ -1270,12 +1223,14 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle,
log.context_description = dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].context_description;
- *(dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level_ptr) = dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level;
- *(dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].trace_status_ptr) = dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].trace_status = tracestatus;
+ *(dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level_ptr) =
+ dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level;
+ *(dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].trace_status_ptr) =
+ dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].trace_status = tracestatus;
dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries].log_level_changed_callback = dlt_log_level_changed_callback;
log.log_level = loglevel;
- log.trace_status = tracestatus;
+ log.trace_status = tracestatus;
dlt_user.dlt_ll_ts_num_entries++;
@@ -1286,8 +1241,8 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle,
DltReturnValue dlt_register_context_ll_ts(DltContext *handle,
const char *contextid,
- const char * description,
- int loglevel,
+ const char *description,
+ int loglevel,
int tracestatus)
{
return dlt_register_context_ll_ts_llccb(handle,
@@ -1301,20 +1256,16 @@ DltReturnValue dlt_register_context_ll_ts(DltContext *handle,
DltReturnValue dlt_register_context_llccb(DltContext *handle,
const char *contextid,
- const char * description,
+ const char *description,
void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],
uint8_t log_level,
uint8_t trace_status))
{
if ((handle == NULL) || (contextid == NULL) || (contextid[0] == '\0'))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (!dlt_user_initialised)
- {
- if (dlt_init() < 0)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < 0) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -1332,8 +1283,7 @@ DltReturnValue dlt_unregister_app(void)
{
DltReturnValue ret = DLT_RETURN_OK;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -1347,9 +1297,7 @@ DltReturnValue dlt_unregister_app(void)
dlt_set_id(dlt_user.appID, "");
if (dlt_user.application_description != NULL)
- {
free(dlt_user.application_description);
- }
dlt_user.application_description = NULL;
@@ -1362,18 +1310,15 @@ DltReturnValue dlt_unregister_app_flush_buffered_logs(void)
{
DltReturnValue ret = DLT_RETURN_OK;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_ERR, "%s dlt_user_initialised false\n", __func__);
return DLT_RETURN_ERROR;
}
- if (dlt_user.dlt_log_handle != -1)
- {
+ if (dlt_user.dlt_log_handle != -1) {
do
- {
ret = dlt_user_log_resend_buffer();
- }while ((ret != DLT_RETURN_OK) && (dlt_user.dlt_log_handle != -1));
+ while ((ret != DLT_RETURN_OK) && (dlt_user.dlt_log_handle != -1));
}
return dlt_unregister_app();
@@ -1386,6 +1331,7 @@ DltReturnValue dlt_unregister_context(DltContext *handle)
log.handle = NULL;
log.context_description = NULL;
+
if (dlt_user_log_init(handle, &log) <= DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
@@ -1394,8 +1340,7 @@ DltReturnValue dlt_unregister_context(DltContext *handle)
handle->log_level_ptr = NULL;
handle->trace_status_ptr = NULL;
- if (dlt_user.dlt_ll_ts != NULL)
- {
+ if (dlt_user.dlt_ll_ts != NULL) {
/* Clear and free local stored context information */
dlt_set_id(dlt_user.dlt_ll_ts[handle->log_level_pos].contextID, "");
@@ -1403,31 +1348,26 @@ DltReturnValue dlt_unregister_context(DltContext *handle)
dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status = DLT_USER_INITIAL_TRACE_STATUS;
if (dlt_user.dlt_ll_ts[handle->log_level_pos].context_description != NULL)
- {
free(dlt_user.dlt_ll_ts[handle->log_level_pos].context_description);
- }
- if (dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr != NULL)
- {
+ if (dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr != NULL) {
free(dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr);
dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr = NULL;
}
- if (dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status_ptr != NULL)
- {
+ if (dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status_ptr != NULL) {
free(dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status_ptr);
dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status_ptr = NULL;
}
dlt_user.dlt_ll_ts[handle->log_level_pos].context_description = NULL;
- if (dlt_user.dlt_ll_ts[handle->log_level_pos].injection_table != NULL)
- {
+ if (dlt_user.dlt_ll_ts[handle->log_level_pos].injection_table != NULL) {
free(dlt_user.dlt_ll_ts[handle->log_level_pos].injection_table);
dlt_user.dlt_ll_ts[handle->log_level_pos].injection_table = NULL;
}
- dlt_user.dlt_ll_ts[handle->log_level_pos].nrcallbacks = 0;
+ dlt_user.dlt_ll_ts[handle->log_level_pos].nrcallbacks = 0;
dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_changed_callback = 0;
}
@@ -1443,61 +1383,58 @@ DltReturnValue dlt_set_application_ll_ts_limit(DltLogLevelType loglevel, DltTrac
{
uint32_t i;
- if (loglevel < DLT_USER_LOG_LEVEL_NOT_SET || loglevel >= DLT_LOG_MAX)
- {
+ if ((loglevel < DLT_USER_LOG_LEVEL_NOT_SET) || (loglevel >= DLT_LOG_MAX)) {
dlt_vlog(LOG_ERR, "Loglevel %d is outside valid range", loglevel);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (tracestatus < DLT_USER_TRACE_STATUS_NOT_SET || tracestatus >= DLT_TRACE_STATUS_MAX)
- {
+ if ((tracestatus < DLT_USER_TRACE_STATUS_NOT_SET) || (tracestatus >= DLT_TRACE_STATUS_MAX)) {
dlt_vlog(LOG_ERR, "Tracestatus %d is outside valid range", tracestatus);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (!dlt_user_initialised)
- {
- if (dlt_init() < 0)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < 0) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
}
/* Removed because of DltLogLevelType and DltTraceStatusType
-
- if ((loglevel<DLT_LOG_DEFAULT) || (loglevel>DLT_LOG_VERBOSE))
- {
- return DLT_RETURN_ERROR;
- }
-
- if ((tracestatus<DLT_TRACE_STATUS_DEFAULT) || (tracestatus>DLT_TRACE_STATUS_ON))
- {
- return DLT_RETURN_ERROR;
- }
-
- if (dlt_user.dlt_ll_ts==0)
- {
- return DLT_RETURN_ERROR;
- }
-
- */
+ *
+ * if ((loglevel<DLT_LOG_DEFAULT) || (loglevel>DLT_LOG_VERBOSE))
+ * {
+ * return DLT_RETURN_ERROR;
+ * }
+ *
+ * if ((tracestatus<DLT_TRACE_STATUS_DEFAULT) || (tracestatus>DLT_TRACE_STATUS_ON))
+ * {
+ * return DLT_RETURN_ERROR;
+ * }
+ *
+ * if (dlt_user.dlt_ll_ts==0)
+ * {
+ * return DLT_RETURN_ERROR;
+ * }
+ *
+ */
DLT_SEM_LOCK();
- if (dlt_user.dlt_ll_ts == NULL)
- {
+
+ if (dlt_user.dlt_ll_ts == NULL) {
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
/* Update local structures */
- for (i=0; i<dlt_user.dlt_ll_ts_num_entries;i++)
- {
+ for (i = 0; i < dlt_user.dlt_ll_ts_num_entries; i++) {
dlt_user.dlt_ll_ts[i].log_level = loglevel;
dlt_user.dlt_ll_ts[i].trace_status = tracestatus;
- if(dlt_user.dlt_ll_ts[i].log_level_ptr)
+
+ if (dlt_user.dlt_ll_ts[i].log_level_ptr)
*(dlt_user.dlt_ll_ts[i].log_level_ptr) = loglevel;
- if(dlt_user.dlt_ll_ts[i].trace_status_ptr)
+
+ if (dlt_user.dlt_ll_ts[i].trace_status_ptr)
*(dlt_user.dlt_ll_ts[i].trace_status_ptr) = tracestatus;
}
@@ -1514,16 +1451,13 @@ int dlt_get_log_state()
DltReturnValue dlt_set_log_mode(DltUserLogMode mode)
{
- if (mode < DLT_USER_MODE_UNDEFINED || mode >= DLT_USER_MODE_MAX)
- {
+ if ((mode < DLT_USER_MODE_UNDEFINED) || (mode >= DLT_USER_MODE_MAX)) {
dlt_vlog(LOG_ERR, "User log mode %d is outside valid range", mode);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (!dlt_user_initialised)
- {
- if (dlt_init() < 0)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < 0) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -1534,50 +1468,43 @@ DltReturnValue dlt_set_log_mode(DltUserLogMode mode)
int dlt_set_resend_timeout_atexit(uint32_t timeout_in_milliseconds)
{
- if (dlt_user_initialised==0)
- {
- if (dlt_init()<0)
- {
- return -1;
+ if (dlt_user_initialised == 0) {
+ if (dlt_init() < 0)
+ return -1;
}
- }
- dlt_user.timeout_at_exit_handler = timeout_in_milliseconds * 10;
- return 0;
+
+ dlt_user.timeout_at_exit_handler = timeout_in_milliseconds * 10;
+ return 0;
}
-DltReturnValue dlt_forward_msg(void *msgdata,size_t size)
+DltReturnValue dlt_forward_msg(void *msgdata, size_t size)
{
DltUserHeader userheader;
DltReturnValue ret;
if ((msgdata == NULL) || (size == 0))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG) < DLT_RETURN_OK)
- {
/* Type of internal user message; same value for Trace messages */
return DLT_RETURN_ERROR;
- }
- if (dlt_user.dlt_is_file)
- {
+ if (dlt_user.dlt_is_file) {
/* log to file */
return dlt_user_log_out2(dlt_user.dlt_log_handle, msgdata, size, 0, 0);
}
- else
- {
+ else {
/* Reattach to daemon if neccesary */
dlt_user_log_reattach_to_daemon();
- if (dlt_user.overflow_counter)
- {
- if (dlt_user_log_send_overflow()==0)
- {
- dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Buffer full! %u messages discarded!\n", dlt_user.overflow_counter);
- dlt_user.overflow_counter=0;
+ if (dlt_user.overflow_counter) {
+ if (dlt_user_log_send_overflow() == 0) {
+ dlt_vnlog(LOG_WARNING,
+ DLT_USER_BUFFER_LENGTH,
+ "Buffer full! %u messages discarded!\n",
+ dlt_user.overflow_counter);
+ dlt_user.overflow_counter = 0;
}
}
@@ -1586,77 +1513,66 @@ DltReturnValue dlt_forward_msg(void *msgdata,size_t size)
msgdata, size, 0, 0);
/* store message in ringbuffer, if an error has occured */
- if (ret < DLT_RETURN_OK)
- {
+ if (ret < DLT_RETURN_OK) {
DLT_SEM_LOCK();
-
- if (ret == DLT_RETURN_PIPE_ERROR)
- {
+
+ if (ret == DLT_RETURN_PIPE_ERROR) {
/* handle not open or pipe error */
- close(dlt_user.dlt_log_handle);
- dlt_user.dlt_log_handle = -1;
+ close(dlt_user.dlt_log_handle);
+ dlt_user.dlt_log_handle = -1;
}
if (dlt_buffer_push3(&(dlt_user.startup_buffer),
- (unsigned char *)&(userheader), sizeof(DltUserHeader),
- msgdata, size, 0, 0) == DLT_RETURN_ERROR)
- {
- if(dlt_user.overflow_counter==0)
- {
- dlt_log(LOG_WARNING,"Buffer full! First message discarded!\n");
- }
+ (unsigned char *)&(userheader), sizeof(DltUserHeader),
+ msgdata, size, 0, 0) == DLT_RETURN_ERROR) {
+ if (dlt_user.overflow_counter == 0)
+ dlt_log(LOG_WARNING, "Buffer full! First message discarded!\n");
ret = DLT_RETURN_BUFFER_FULL;
}
DLT_SEM_FREE();
-
- if(dlt_user_queue_resend() < DLT_RETURN_OK && dlt_user.dlt_log_handle >= 0)
- {
- ;//dlt_log(LOG_WARNING, "dlt_forward_msg: Failed to queue resending.\n");
- }
}
- switch (ret)
+ switch (ret) {
+ case DLT_RETURN_WRONG_PARAMETER:
{
- case DLT_RETURN_WRONG_PARAMETER:
- {
- /* wrong parameters */
- return DLT_RETURN_WRONG_PARAMETER;
- }
- case DLT_RETURN_BUFFER_FULL:
- {
- /* Buffer full */
- dlt_user.overflow_counter += 1;
- return DLT_RETURN_ERROR;
- }
- case DLT_RETURN_PIPE_FULL:
- {
- /* data could not be written */
- return DLT_RETURN_ERROR;
- }
- case DLT_RETURN_PIPE_ERROR:
- {
- /* handle not open or pipe error */
- close(dlt_user.dlt_log_handle);
- dlt_user.dlt_log_handle = -1;
+ /* wrong parameters */
+ return DLT_RETURN_WRONG_PARAMETER;
+ }
+ case DLT_RETURN_BUFFER_FULL:
+ {
+ /* Buffer full */
+ dlt_user.overflow_counter += 1;
+ return DLT_RETURN_ERROR;
+ }
+ case DLT_RETURN_PIPE_FULL:
+ {
+ /* data could not be written */
+ return DLT_RETURN_ERROR;
+ }
+ case DLT_RETURN_PIPE_ERROR:
+ {
+ /* handle not open or pipe error */
+ close(dlt_user.dlt_log_handle);
+ dlt_user.dlt_log_handle = -1;
- return DLT_RETURN_ERROR;
- }
- case DLT_RETURN_ERROR:
- {
- /* other error condition */
- return DLT_RETURN_ERROR;
- }
- case DLT_RETURN_OK:
- {
- return DLT_RETURN_OK;
- }
- default:
- {
- /* This case should not occur */
- return DLT_RETURN_ERROR;
- }
+ return DLT_RETURN_ERROR;
+ }
+ case DLT_RETURN_ERROR:
+ {
+ /* other error condition */
+ return DLT_RETURN_ERROR;
+ }
+ case DLT_RETURN_OK:
+ {
+ return DLT_RETURN_OK;
+ }
+ default:
+ {
+ /* This case should not occur */
+ return DLT_RETURN_ERROR;
+ }
}
}
@@ -1665,39 +1581,42 @@ DltReturnValue dlt_forward_msg(void *msgdata,size_t size)
/* ********************************************************************************************* */
-inline DltReturnValue dlt_user_log_write_start(DltContext *handle, DltContextData *log,DltLogLevelType loglevel)
+inline DltReturnValue dlt_user_log_write_start(DltContext *handle, DltContextData *log, DltLogLevelType loglevel)
{
- return dlt_user_log_write_start_id(handle,log,loglevel,DLT_USER_DEFAULT_MSGID);
+ return dlt_user_log_write_start_id(handle, log, loglevel, DLT_USER_DEFAULT_MSGID);
}
-DltReturnValue dlt_user_log_write_start_id(DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid)
+DltReturnValue dlt_user_log_write_start_id(DltContext *handle,
+ DltContextData *log,
+ DltLogLevelType loglevel,
+ uint32_t messageid)
{
DLT_LOG_FATAL_RESET_TRAP(loglevel);
DltReturnValue ret = DLT_RETURN_OK;
- // check nullpointer
- if (handle == NULL || log == NULL)
+ /* check nullpointer */
+ if ((handle == NULL) || (log == NULL))
return DLT_RETURN_WRONG_PARAMETER;
/* check log levels */
ret = dlt_user_is_logLevel_enabled(handle, loglevel);
+
if (ret == DLT_RETURN_WRONG_PARAMETER)
return DLT_RETURN_WRONG_PARAMETER;
else if (ret == DLT_RETURN_LOGGING_DISABLED)
return DLT_RETURN_OK;
else
- /* Do nothing */
+ /* Do nothing */
/* initialize values */
- if (dlt_user_log_init(handle, log) < DLT_RETURN_OK || dlt_user.dlt_ll_ts == NULL)
+ if ((dlt_user_log_init(handle, log) < DLT_RETURN_OK) || (dlt_user.dlt_ll_ts == NULL))
return DLT_RETURN_ERROR;
/* initialize values */
- if (log->buffer == NULL)
- {
+ if (log->buffer == NULL) {
log->buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
- if (log->buffer == NULL)
- {
+
+ if (log->buffer == NULL) {
dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
return DLT_RETURN_ERROR;
}
@@ -1708,8 +1627,7 @@ DltReturnValue dlt_user_log_write_start_id(DltContext *handle, DltContextData *l
log->size = 0;
/* In non-verbose mode, insert message id */
- if (dlt_user.verbose_mode == 0)
- {
+ if (dlt_user.verbose_mode == 0) {
if ((sizeof(uint32_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
@@ -1718,7 +1636,7 @@ DltReturnValue dlt_user_log_write_start_id(DltContext *handle, DltContextData *l
log->size = sizeof(uint32_t);
/* as the message id is part of each message in non-verbose mode,
- it doesn't increment the argument counter in extended header (if used) */
+ * it doesn't increment the argument counter in extended header (if used) */
}
return DLT_RETURN_TRUE;
@@ -1746,21 +1664,19 @@ DltReturnValue dlt_user_log_write_raw(DltContextData *log, void *data, uint16_t
DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log, void *data, uint16_t length, DltFormatType type)
{
size_t new_log_size = 0;
- uint32_t type_info = 0;
+ uint32_t type_info = 0;
- // check nullpointer
- if (log == NULL || (data == NULL && length!=0))
+ /* check nullpointer */
+ if ((log == NULL) || ((data == NULL) && (length != 0)))
return DLT_RETURN_WRONG_PARAMETER;
- // Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning
- if ((int16_t)type < DLT_FORMAT_DEFAULT || type >= DLT_FORMAT_MAX)
- {
+ /* Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning */
+ if (((int16_t)type < DLT_FORMAT_DEFAULT) || (type >= DLT_FORMAT_MAX)) {
dlt_vlog(LOG_ERR, "Format type %d is outside valid range", type);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -1770,23 +1686,20 @@ DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log, void *data,
if (new_log_size > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
+ if (dlt_user.verbose_mode) {
new_log_size = log->size + length + sizeof(uint32_t) + sizeof(uint16_t);
if (new_log_size > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
-
/* Transmit type information */
type_info = DLT_TYPE_INFO_RAWD;
- if (type >= DLT_FORMAT_HEX8 && type <= DLT_FORMAT_HEX64)
- {
+ if ((type >= DLT_FORMAT_HEX8) && (type <= DLT_FORMAT_HEX64)) {
type_info |= DLT_SCOD_HEX;
type_info += type;
}
- else if (type >= DLT_FORMAT_BIN8 && type <= DLT_FORMAT_BIN16)
+ else if ((type >= DLT_FORMAT_BIN8) && (type <= DLT_FORMAT_BIN16))
{
type_info |= DLT_SCOD_BIN;
type_info += type - DLT_FORMAT_BIN8 + 1;
@@ -1815,35 +1728,31 @@ DltReturnValue dlt_user_log_write_float32(DltContextData *log, float32_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if (sizeof(float32_t)!=4)
- {
+ if (sizeof(float32_t) != 4)
return DLT_RETURN_ERROR;
- }
- if ((log->size+sizeof(float32_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(float32_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(float32_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(float32_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_FLOA | DLT_TYLE_32BIT;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data, sizeof(float32_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(float32_t));
log->size += sizeof(float32_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -1855,52 +1764,46 @@ DltReturnValue dlt_user_log_write_float64(DltContextData *log, float64_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if (sizeof(float64_t)!=8)
- {
+ if (sizeof(float64_t) != 8)
return DLT_RETURN_ERROR;
- }
- if ((log->size+sizeof(float64_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(float64_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(float64_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(float64_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_FLOA | DLT_TYLE_64BIT;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data, sizeof(float64_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(float64_t));
log->size += sizeof(float64_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
-DltReturnValue dlt_user_log_write_uint( DltContextData *log, unsigned int data)
+DltReturnValue dlt_user_log_write_uint(DltContextData *log, unsigned int data)
{
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- switch (sizeof(unsigned int))
- {
+ switch (sizeof(unsigned int)) {
case 1:
{
return dlt_user_log_write_uint8(log, (uint8_t)data);
@@ -1938,30 +1841,28 @@ DltReturnValue dlt_user_log_write_uint8(DltContextData *log, uint8_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(uint8_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(uint8_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(uint8_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(uint8_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_8BIT;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(uint8_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(uint8_t));
log->size += sizeof(uint8_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -1973,30 +1874,28 @@ DltReturnValue dlt_user_log_write_uint16(DltContextData *log, uint16_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(uint16_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(uint16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(uint16_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(uint16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_16BIT;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(uint16_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(uint16_t));
log->size += sizeof(uint16_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2008,30 +1907,28 @@ DltReturnValue dlt_user_log_write_uint32(DltContextData *log, uint32_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(uint32_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(uint32_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(uint32_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(uint32_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_32BIT;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data, sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(uint32_t));
log->size += sizeof(uint32_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2043,30 +1940,28 @@ DltReturnValue dlt_user_log_write_uint64(DltContextData *log, uint64_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(uint64_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(uint64_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(uint64_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(uint64_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_64BIT;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
- log->size +=sizeof(uint32_t);
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
+ log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(uint64_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(uint64_t));
log->size += sizeof(uint64_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2078,47 +1973,40 @@ DltReturnValue dlt_user_log_write_uint8_formatted(DltContextData *log, uint8_t d
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- // Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning
- if ((int16_t)type < DLT_FORMAT_DEFAULT || type >= DLT_FORMAT_MAX)
- {
+ /* Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning */
+ if (((int16_t)type < DLT_FORMAT_DEFAULT) || (type >= DLT_FORMAT_MAX)) {
dlt_vlog(LOG_ERR, "Format type %d is outside valid range", type);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(uint16_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(uint16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(uint16_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(uint16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_8BIT;
- if(type>=DLT_FORMAT_HEX8 && type<=DLT_FORMAT_HEX64)
- {
+ if ((type >= DLT_FORMAT_HEX8) && (type <= DLT_FORMAT_HEX64))
type_info |= DLT_SCOD_HEX;
- }
- else if(type>=DLT_FORMAT_BIN8 && type<=DLT_FORMAT_BIN16)
- {
+ else if ((type >= DLT_FORMAT_BIN8) && (type <= DLT_FORMAT_BIN16))
type_info |= DLT_SCOD_BIN;
- }
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(uint8_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(uint8_t));
log->size += sizeof(uint8_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2130,47 +2018,40 @@ DltReturnValue dlt_user_log_write_uint16_formatted(DltContextData *log, uint16_t
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- // Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning
- if ((int16_t)type < DLT_FORMAT_DEFAULT || type >= DLT_FORMAT_MAX)
- {
+ /* Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning */
+ if (((int16_t)type < DLT_FORMAT_DEFAULT) || (type >= DLT_FORMAT_MAX)) {
dlt_vlog(LOG_ERR, "Format type %d is outside valid range", type);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(uint16_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(uint16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(uint16_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(uint16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_16BIT;
- if(type>=DLT_FORMAT_HEX8 && type<=DLT_FORMAT_HEX64)
- {
+ if ((type >= DLT_FORMAT_HEX8) && (type <= DLT_FORMAT_HEX64))
type_info |= DLT_SCOD_HEX;
- }
- else if(type>=DLT_FORMAT_BIN8 && type<=DLT_FORMAT_BIN16)
- {
+ else if ((type >= DLT_FORMAT_BIN8) && (type <= DLT_FORMAT_BIN16))
type_info |= DLT_SCOD_BIN;
- }
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(uint16_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(uint16_t));
log->size += sizeof(uint16_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2182,47 +2063,40 @@ DltReturnValue dlt_user_log_write_uint32_formatted(DltContextData *log, uint32_t
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- // Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning
- if ((int16_t)type < DLT_FORMAT_DEFAULT || type >= DLT_FORMAT_MAX)
- {
+ /* Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning */
+ if (((int16_t)type < DLT_FORMAT_DEFAULT) || (type >= DLT_FORMAT_MAX)) {
dlt_vlog(LOG_ERR, "Format type %d is outside valid range", type);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(uint16_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(uint16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(uint16_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(uint16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_32BIT;
- if(type>=DLT_FORMAT_HEX8 && type<=DLT_FORMAT_HEX64)
- {
+ if ((type >= DLT_FORMAT_HEX8) && (type <= DLT_FORMAT_HEX64))
type_info |= DLT_SCOD_HEX;
- }
- else if(type>=DLT_FORMAT_BIN8 && type<=DLT_FORMAT_BIN16)
- {
+ else if ((type >= DLT_FORMAT_BIN8) && (type <= DLT_FORMAT_BIN16))
type_info |= DLT_SCOD_BIN;
- }
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(uint32_t));
log->size += sizeof(uint32_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2234,47 +2108,40 @@ DltReturnValue dlt_user_log_write_uint64_formatted(DltContextData *log, uint64_t
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- // Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning
- if ((int16_t)type < DLT_FORMAT_DEFAULT || type >= DLT_FORMAT_MAX)
- {
+ /* Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning */
+ if (((int16_t)type < DLT_FORMAT_DEFAULT) || (type >= DLT_FORMAT_MAX)) {
dlt_vlog(LOG_ERR, "Format type %d is outside valid range", type);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(uint16_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(uint16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(uint16_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(uint16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_64BIT;
- if(type>=DLT_FORMAT_HEX8 && type<=DLT_FORMAT_HEX64)
- {
+ if ((type >= DLT_FORMAT_HEX8) && (type <= DLT_FORMAT_HEX64))
type_info |= DLT_SCOD_HEX;
- }
- else if(type>=DLT_FORMAT_BIN8 && type<=DLT_FORMAT_BIN16)
- {
+ else if ((type >= DLT_FORMAT_BIN8) && (type <= DLT_FORMAT_BIN16))
type_info |= DLT_SCOD_BIN;
- }
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(uint64_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(uint64_t));
log->size += sizeof(uint64_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2282,30 +2149,26 @@ DltReturnValue dlt_user_log_write_uint64_formatted(DltContextData *log, uint64_t
DltReturnValue dlt_user_log_write_ptr(DltContextData *log, void *data)
{
if (log == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- switch(sizeof(void *))
- {
- case 4:
- return dlt_user_log_write_uint32_formatted(log,
- (uintptr_t)data,
- DLT_FORMAT_HEX32);
- break;
- case 8:
- return dlt_user_log_write_uint64_formatted(log,
- (uintptr_t)data,
- DLT_FORMAT_HEX64);
- break;
- default:
- ; /* skip */
+ switch (sizeof(void *)) {
+ case 4:
+ return dlt_user_log_write_uint32_formatted(log,
+ (uintptr_t)data,
+ DLT_FORMAT_HEX32);
+ break;
+ case 8:
+ return dlt_user_log_write_uint64_formatted(log,
+ (uintptr_t)data,
+ DLT_FORMAT_HEX64);
+ break;
+ default:
+ ; /* skip */
}
return DLT_RETURN_OK;
@@ -2316,14 +2179,12 @@ DltReturnValue dlt_user_log_write_int(DltContextData *log, int data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- switch (sizeof(int))
- {
+ switch (sizeof(int)) {
case 1:
{
return dlt_user_log_write_int8(log, (int8_t)data);
@@ -2361,30 +2222,28 @@ DltReturnValue dlt_user_log_write_int8(DltContextData *log, int8_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(int8_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(int8_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(int8_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(int8_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_8BIT;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(int8_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(int8_t));
log->size += sizeof(int8_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2396,30 +2255,28 @@ DltReturnValue dlt_user_log_write_int16(DltContextData *log, int16_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(int16_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(int16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(int16_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(int16_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_16BIT;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(int16_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(int16_t));
log->size += sizeof(int16_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2431,30 +2288,28 @@ DltReturnValue dlt_user_log_write_int32(DltContextData *log, int32_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(int32_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(int32_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(int32_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(int32_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_32BIT;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data, sizeof(int32_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(int32_t));
log->size += sizeof(int32_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2466,30 +2321,28 @@ DltReturnValue dlt_user_log_write_int64(DltContextData *log, int64_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(int64_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(int64_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(int64_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(int64_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_64BIT;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(int64_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(int64_t));
log->size += sizeof(int64_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2501,30 +2354,28 @@ DltReturnValue dlt_user_log_write_bool(DltContextData *log, uint8_t data)
if (log == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if ((log->size+sizeof(uint8_t))>dlt_user.log_buf_len)
+ if ((log->size + sizeof(uint8_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
- if ((log->size+sizeof(uint32_t)+sizeof(uint8_t))>dlt_user.log_buf_len)
+ if (dlt_user.verbose_mode) {
+ if ((log->size + sizeof(uint32_t) + sizeof(uint8_t)) > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
type_info = DLT_TYPE_INFO_BOOL;
- memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
+ memcpy((log->buffer) + log->size, &(type_info), sizeof(uint32_t));
log->size += sizeof(uint32_t);
}
- memcpy((log->buffer)+log->size,&data,sizeof(uint8_t));
+ memcpy((log->buffer) + log->size, &data, sizeof(uint8_t));
log->size += sizeof(uint8_t);
- log->args_num ++;
+ log->args_num++;
return DLT_RETURN_OK;
}
@@ -2535,11 +2386,10 @@ DltReturnValue dlt_user_log_write_string(DltContextData *log, const char *text)
uint32_t type_info = 0;
size_t new_log_size = 0;
- if (log == NULL || text == NULL)
+ if ((log == NULL) || (text == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -2551,8 +2401,7 @@ DltReturnValue dlt_user_log_write_string(DltContextData *log, const char *text)
if (new_log_size > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
+ if (dlt_user.verbose_mode) {
new_log_size = log->size + arg_size + sizeof(uint32_t) + sizeof(uint16_t);
if (new_log_size > dlt_user.log_buf_len)
@@ -2587,11 +2436,10 @@ DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *t
uint32_t type_info;
size_t new_log_size = 0;
- if (log == NULL || text == NULL)
+ if ((log == NULL) || (text == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -2602,8 +2450,7 @@ DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *t
if (new_log_size > dlt_user.log_buf_len)
return DLT_RETURN_USER_BUFFER_FULL;
- if (dlt_user.verbose_mode)
- {
+ if (dlt_user.verbose_mode) {
new_log_size = log->size + arg_size + sizeof(uint32_t) + sizeof(uint16_t);
if (new_log_size > dlt_user.log_buf_len)
@@ -2627,10 +2474,10 @@ DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *t
}
DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint32_t service_id,
- dlt_injection_callback_id dlt_injection_cbk, void *priv)
+ dlt_injection_callback_id dlt_injection_cbk, void *priv)
{
DltContextData log;
- uint32_t i,j,k;
+ uint32_t i, j, k;
int found = 0;
DltUserInjectionCallback *old;
@@ -2638,65 +2485,62 @@ DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint3
if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
return DLT_RETURN_ERROR;
- if (service_id<DLT_USER_INJECTION_MIN)
+ if (service_id < DLT_USER_INJECTION_MIN)
return DLT_RETURN_WRONG_PARAMETER;
/* This function doesn't make sense storing to local file is choosen;
- so terminate this function */
+ * so terminate this function */
if (dlt_user.dlt_is_file)
return DLT_RETURN_OK;
DLT_SEM_LOCK();
- if (dlt_user.dlt_ll_ts == NULL)
- {
+ if (dlt_user.dlt_ll_ts == NULL) {
DLT_SEM_FREE();
return DLT_RETURN_OK;
}
/* Insert callback in corresponding table */
- i=handle->log_level_pos;
+ i = handle->log_level_pos;
/* Insert each service_id only once */
- for (k=0;k<dlt_user.dlt_ll_ts[i].nrcallbacks;k++)
- {
+ for (k = 0; k < dlt_user.dlt_ll_ts[i].nrcallbacks; k++)
if ((dlt_user.dlt_ll_ts[i].injection_table) &&
- (dlt_user.dlt_ll_ts[i].injection_table[k].service_id == service_id))
- {
+ (dlt_user.dlt_ll_ts[i].injection_table[k].service_id == service_id)) {
found = 1;
break;
}
- }
- if (found)
- {
+
+
+ if (found) {
j = k;
}
- else
- {
- j=dlt_user.dlt_ll_ts[i].nrcallbacks;
+ else {
+ j = dlt_user.dlt_ll_ts[i].nrcallbacks;
/* Allocate or expand injection table */
- if (dlt_user.dlt_ll_ts[i].injection_table == NULL)
- {
- dlt_user.dlt_ll_ts[i].injection_table = (DltUserInjectionCallback*) malloc(sizeof(DltUserInjectionCallback));
- if(dlt_user.dlt_ll_ts[i].injection_table == NULL)
- {
+ if (dlt_user.dlt_ll_ts[i].injection_table == NULL) {
+ dlt_user.dlt_ll_ts[i].injection_table =
+ (DltUserInjectionCallback *)malloc(sizeof(DltUserInjectionCallback));
+
+ if (dlt_user.dlt_ll_ts[i].injection_table == NULL) {
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
old = dlt_user.dlt_ll_ts[i].injection_table;
- dlt_user.dlt_ll_ts[i].injection_table = (DltUserInjectionCallback*) malloc(sizeof(DltUserInjectionCallback)*(j+1));
- if(dlt_user.dlt_ll_ts[i].injection_table == NULL)
- {
+ dlt_user.dlt_ll_ts[i].injection_table = (DltUserInjectionCallback *)malloc(
+ sizeof(DltUserInjectionCallback) * (j + 1));
+
+ if (dlt_user.dlt_ll_ts[i].injection_table == NULL) {
dlt_user.dlt_ll_ts[i].injection_table = old;
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
- memcpy(dlt_user.dlt_ll_ts[i].injection_table,old,sizeof(DltUserInjectionCallback)*j);
+
+ memcpy(dlt_user.dlt_ll_ts[i].injection_table, old, sizeof(DltUserInjectionCallback) * j);
free(old);
}
@@ -2705,14 +2549,13 @@ DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint3
/* Store service_id and corresponding function pointer for callback function */
dlt_user.dlt_ll_ts[i].injection_table[j].service_id = service_id;
- if (priv == NULL)
- {
+
+ if (priv == NULL) {
dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback = (dlt_injection_callback)dlt_injection_cbk;
dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback_with_id = NULL;
dlt_user.dlt_ll_ts[i].injection_table[j].data = NULL;
}
- else
- {
+ else {
dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback = NULL;
dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback_with_id = dlt_injection_cbk;
dlt_user.dlt_ll_ts[i].injection_table[j].data = priv;
@@ -2724,7 +2567,9 @@ DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint3
}
DltReturnValue dlt_register_injection_callback(DltContext *handle, uint32_t service_id,
- int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length))
+ int (*dlt_injection_callback)(uint32_t service_id,
+ void *data,
+ uint32_t length))
{
return dlt_register_injection_callback_with_id(handle,
service_id,
@@ -2733,9 +2578,10 @@ DltReturnValue dlt_register_injection_callback(DltContext *handle, uint32_t serv
}
DltReturnValue dlt_register_log_level_changed_callback(DltContext *handle,
- void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],
- uint8_t log_level,
- uint8_t trace_status))
+ void (*dlt_log_level_changed_callback)(
+ char context_id[DLT_ID_SIZE],
+ uint8_t log_level,
+ uint8_t trace_status))
{
DltContextData log;
uint32_t i;
@@ -2744,20 +2590,19 @@ DltReturnValue dlt_register_log_level_changed_callback(DltContext *handle,
return DLT_RETURN_ERROR;
/* This function doesn't make sense storing to local file is choosen;
- so terminate this function */
+ * so terminate this function */
if (dlt_user.dlt_is_file)
return DLT_RETURN_OK;
DLT_SEM_LOCK();
- if (dlt_user.dlt_ll_ts == NULL)
- {
+ if (dlt_user.dlt_ll_ts == NULL) {
DLT_SEM_FREE();
return DLT_RETURN_OK;
}
/* Insert callback in corresponding table */
- i=handle->log_level_pos;
+ i = handle->log_level_pos;
/* Store new callback function */
dlt_user.dlt_ll_ts[i].log_level_changed_callback = dlt_log_level_changed_callback;
@@ -2784,17 +2629,22 @@ int check_buffer(void)
* Send the start of a segment chain.
* Returns DLT_RETURN_ERROR on failure
*/
-DltReturnValue dlt_user_trace_network_segmented_start(uint32_t *id, DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len)
+DltReturnValue dlt_user_trace_network_segmented_start(uint32_t *id,
+ DltContext *handle,
+ DltNetworkTraceType nw_trace_type,
+ uint16_t header_len,
+ void *header,
+ uint16_t payload_len)
{
DltContextData log;
struct timeval tv;
int ret = DLT_RETURN_ERROR;
- // check null pointer
- if(id == NULL)
+
+ /* check null pointer */
+ if (id == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (nw_trace_type < DLT_NW_TRACE_IPC || nw_trace_type >= DLT_NW_TRACE_MAX)
- {
+ if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
dlt_vlog(LOG_ERR, "Network trace type %d is outside valid range", nw_trace_type);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -2802,16 +2652,15 @@ DltReturnValue dlt_user_trace_network_segmented_start(uint32_t *id, DltContext *
if (dlt_user.dlt_ll_ts == NULL)
return DLT_RETURN_ERROR;
- if (handle->trace_status_ptr && *(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)
- {
+ if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
/* initialize values */
if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
return DLT_RETURN_ERROR;
- if (log.buffer == NULL)
- {
+
+ if (log.buffer == NULL) {
log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
- if (log.buffer == NULL)
- {
+
+ if (log.buffer == NULL) {
dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
return DLT_RETURN_ERROR;
}
@@ -2825,59 +2674,47 @@ DltReturnValue dlt_user_trace_network_segmented_start(uint32_t *id, DltContext *
*id = tv.tv_usec;
/* Write identifier */
- if(dlt_user_log_write_string(&log, "NWST") < 0)
- {
+ if (dlt_user_log_write_string(&log, "NWST") < 0) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Write stream handle */
- if(dlt_user_log_write_uint32(&log, *id) < 0)
- {
+ if (dlt_user_log_write_uint32(&log, *id) < 0) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Write header */
- if(dlt_user_log_write_raw(&log, header, header_len) < 0)
- {
+ if (dlt_user_log_write_raw(&log, header, header_len) < 0) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Write size of payload */
- if(dlt_user_log_write_uint32(&log, payload_len) < 0)
- {
+ if (dlt_user_log_write_uint32(&log, payload_len) < 0) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Write expected segment count */
- uint16_t segment_count = payload_len/DLT_MAX_TRACE_SEGMENT_SIZE+1;
+ uint16_t segment_count = payload_len / DLT_MAX_TRACE_SEGMENT_SIZE + 1;
/* If segments align perfectly with segment size, avoid sending empty segment */
- if((payload_len % DLT_MAX_TRACE_SEGMENT_SIZE) == 0)
+ if ((payload_len % DLT_MAX_TRACE_SEGMENT_SIZE) == 0)
segment_count--;
- if(dlt_user_log_write_uint16(&log, segment_count) < 0)
- {
+ if (dlt_user_log_write_uint16(&log, segment_count) < 0) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Write length of one segment */
- if(dlt_user_log_write_uint16(&log, DLT_MAX_TRACE_SEGMENT_SIZE) < 0)
- {
+ if (dlt_user_log_write_uint16(&log, DLT_MAX_TRACE_SEGMENT_SIZE) < 0) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Send log */
ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE);
@@ -2889,35 +2726,39 @@ DltReturnValue dlt_user_trace_network_segmented_start(uint32_t *id, DltContext *
return DLT_RETURN_OK;
}
-DltReturnValue dlt_user_trace_network_segmented_segment(uint32_t id, DltContext *handle, DltNetworkTraceType nw_trace_type, int sequence, uint16_t payload_len, void *payload)
+DltReturnValue dlt_user_trace_network_segmented_segment(uint32_t id,
+ DltContext *handle,
+ DltNetworkTraceType nw_trace_type,
+ int sequence,
+ uint16_t payload_len,
+ void *payload)
{
int ret = DLT_RETURN_ERROR;
- if (nw_trace_type < DLT_NW_TRACE_IPC || nw_trace_type >= DLT_NW_TRACE_MAX)
- {
+
+ if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
dlt_vlog(LOG_ERR, "Network trace type %d is outside valid range", nw_trace_type);
return DLT_RETURN_WRONG_PARAMETER;
}
- while(check_buffer() < 0)
- {
- usleep(1000*50); // Wait 50ms
+ while (check_buffer() < 0) {
+ usleep(1000 * 50); /* Wait 50ms */
dlt_user_log_resend_buffer();
}
if (dlt_user.dlt_ll_ts == NULL)
return DLT_RETURN_ERROR;
- if (handle->trace_status_ptr && *(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)
- {
+ if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
DltContextData log;
+
if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
return DLT_RETURN_ERROR;
+
/* initialize values */
- if (log.buffer == NULL)
- {
+ if (log.buffer == NULL) {
log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
- if (log.buffer == NULL)
- {
+
+ if (log.buffer == NULL) {
dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
return DLT_RETURN_ERROR;
}
@@ -2928,35 +2769,29 @@ DltReturnValue dlt_user_trace_network_segmented_segment(uint32_t id, DltContext
log.size = 0;
/* Write identifier */
- if(dlt_user_log_write_string(&log, "NWCH") < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_string(&log, "NWCH") < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
+
/* Write stream handle */
- if(dlt_user_log_write_uint32(&log, id) < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_uint32(&log, id) < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Write segment sequence number */
- if(dlt_user_log_write_uint16(&log, sequence) < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_uint16(&log, sequence) < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Write data */
- if(dlt_user_log_write_raw(&log, payload, payload_len) < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_raw(&log, payload, payload_len) < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE);
/* Send log */
@@ -2975,8 +2810,7 @@ DltReturnValue dlt_user_trace_network_segmented_end(uint32_t id, DltContext *han
DltContextData log;
int ret = DLT_RETURN_ERROR;
- if (nw_trace_type < DLT_NW_TRACE_IPC || nw_trace_type >= DLT_NW_TRACE_MAX)
- {
+ if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
dlt_vlog(LOG_ERR, "Network trace type %d is outside valid range", nw_trace_type);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -2984,42 +2818,37 @@ DltReturnValue dlt_user_trace_network_segmented_end(uint32_t id, DltContext *han
if (dlt_user.dlt_ll_ts == NULL)
return DLT_RETURN_ERROR;
- if (handle->trace_status_ptr && *(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)
- {
+ if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
/* initialize values */
if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
return DLT_RETURN_ERROR;
- /* initialize values */
- if (log.buffer == NULL)
- {
+ /* initialize values */
+ if (log.buffer == NULL) {
log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
- if (log.buffer == NULL)
- {
+
+ if (log.buffer == NULL) {
dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
return DLT_RETURN_ERROR;
}
}
+
log.args_num = 0;
log.trace_status = nw_trace_type;
log.size = 0;
/* Write identifier */
- if(dlt_user_log_write_string(&log, "NWEN") < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_string(&log, "NWEN") < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Write stream handle */
- if(dlt_user_log_write_uint32(&log, id) < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_uint32(&log, id) < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE);
/* Send log */
@@ -3036,231 +2865,239 @@ DltReturnValue dlt_user_trace_network_segmented_end(uint32_t id, DltContext *han
void dlt_user_trace_network_segmented_thread(void *unused)
{
/* Unused on purpose. */
- (void) unused;
+ (void)unused;
#ifdef linux
prctl(PR_SET_NAME, "dlt_segmented", 0, 0, 0);
#endif
s_segmented_data *data;
- while(1)
- {
- // Wait until message queue is initialized
- dlt_lock_mutex(&mq_mutex);
- if(dlt_user.dlt_segmented_queue_read_handle < 0)
- {
- pthread_cond_wait(&mq_init_condition, &mq_mutex);
- }
- dlt_unlock_mutex(&mq_mutex);
+ while (1) {
+ /* Wait until message queue is initialized */
+ dlt_lock_mutex(&mq_mutex);
- ssize_t read = mq_receive(dlt_user.dlt_segmented_queue_read_handle, (char *)&data,
- sizeof(s_segmented_data * ), NULL);
- if (read < 0)
- {
- if (errno != EINTR)
- {
- dlt_vlog(LOG_WARNING, "NWTSegmented: Error while reading queue: %s\n", strerror(errno));
- usleep(DLT_USER_MQ_ERROR_RETRY_INTERVAL);
- }
- continue;
- }
+ if (dlt_user.dlt_segmented_queue_read_handle < 0)
+ pthread_cond_wait(&mq_init_condition, &mq_mutex);
- if(read != sizeof(s_segmented_data *))
- {
- // This case will not happen.
- // When this thread is interrupted by signal, mq_receive() will not return
- // partial read length and will return -1. And also no data is removed from mq.
- dlt_vlog(LOG_WARNING, "NWTSegmented: Could not read data fully from queue: %d\n", read);
- continue;
- }
+ dlt_unlock_mutex(&mq_mutex);
- /* Indicator just to try to flush the buffer */
- if(data->payload_len == DLT_DELAYED_RESEND_INDICATOR_PATTERN)
- {
- // Sleep 100ms, to allow other process to read FIFO
- usleep(100*1000);
- if(dlt_user_log_resend_buffer() < 0)
- {
- // Requeue if still not empty
- if ( dlt_user_queue_resend() < 0 )
- {
- //dlt_log(LOG_WARNING, "Failed to queue resending in dlt_user_trace_network_segmented_thread.\n");
- }
- }
- free(data);
- continue;
- }
+ ssize_t read = mq_receive(dlt_user.dlt_segmented_queue_read_handle, (char *)&data,
+ sizeof(s_segmented_data *), NULL);
- dlt_user_trace_network_segmented_thread_segmenter(data);
+ if (read < 0) {
+ if (errno != EINTR) {
+ dlt_vlog(LOG_WARNING, "NWTSegmented: Error while reading queue: %s\n", strerror(errno));
+ usleep(DLT_USER_MQ_ERROR_RETRY_INTERVAL);
+ }
- /* Send the end message */
- DltReturnValue err = dlt_user_trace_network_segmented_end(data->id, data->handle, data->nw_trace_type);
- if(err == DLT_RETURN_BUFFER_FULL || err == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"NWTSegmented: Could not send end segment.\n");
+ continue;
+ }
+
+ if (read != sizeof(s_segmented_data *)) {
+ /* This case will not happen. */
+ /* When this thread is interrupted by signal, mq_receive() will not return */
+ /* partial read length and will return -1. And also no data is removed from mq. */
+ dlt_vlog(LOG_WARNING, "NWTSegmented: Could not read data fully from queue: %d\n", read);
+ continue;
+ }
+
+ /* Indicator just to try to flush the buffer */
+ if (data->payload_len == DLT_DELAYED_RESEND_INDICATOR_PATTERN) {
+ /* Sleep 100ms, to allow other process to read FIFO */
+ usleep(100 * 1000);
+
+ if (dlt_user_log_resend_buffer() < 0) {
+ /* Requeue if still not empty */
+ if (dlt_user_queue_resend() < 0) {
+ /*dlt_log(LOG_WARNING, "Failed to queue resending in dlt_user_trace_network_segmented_thread.\n"); */
}
+ }
- /* Free resources */
- free(data->header);
- free(data->payload);
- free(data);
+ free(data);
+ continue;
}
+
+ dlt_user_trace_network_segmented_thread_segmenter(data);
+
+ /* Send the end message */
+ DltReturnValue err = dlt_user_trace_network_segmented_end(data->id, data->handle, data->nw_trace_type);
+
+ if ((err == DLT_RETURN_BUFFER_FULL) || (err == DLT_RETURN_ERROR))
+ dlt_log(LOG_WARNING, "NWTSegmented: Could not send end segment.\n");
+
+ /* Free resources */
+ free(data->header);
+ free(data->payload);
+ free(data);
+ }
}
void dlt_user_trace_network_segmented_thread_segmenter(s_segmented_data *data)
{
- /* Segment the data and send the chunks */
- void *ptr = NULL;
- uint32_t offset = 0;
- uint16_t sequence = 0;
- do
- {
- uint16_t len = 0;
- if(offset + DLT_MAX_TRACE_SEGMENT_SIZE > data->payload_len)
- {
- len = data->payload_len - offset;
- }
- else
- {
- len = DLT_MAX_TRACE_SEGMENT_SIZE;
- }
- /* If payload size aligns perfectly with segment size, avoid sending empty segment */
- if(len == 0)
- {
- break;
- }
+ /* Segment the data and send the chunks */
+ void *ptr = NULL;
+ uint32_t offset = 0;
+ uint16_t sequence = 0;
- ptr = data->payload + offset;
- DltReturnValue err = dlt_user_trace_network_segmented_segment(data->id, data->handle, data->nw_trace_type, sequence++, len, ptr);
- if(err == DLT_RETURN_BUFFER_FULL || err == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_ERR,"NWTSegmented: Could not send segment. Aborting.\n");
- break; // loop
- }
- offset += len;
- }while(ptr < data->payload + data->payload_len);
+ do {
+ uint16_t len = 0;
+
+ if (offset + DLT_MAX_TRACE_SEGMENT_SIZE > data->payload_len)
+ len = data->payload_len - offset;
+ else
+ len = DLT_MAX_TRACE_SEGMENT_SIZE;
+
+ /* If payload size aligns perfectly with segment size, avoid sending empty segment */
+ if (len == 0)
+ break;
+
+ ptr = data->payload + offset;
+ DltReturnValue err = dlt_user_trace_network_segmented_segment(data->id,
+ data->handle,
+ data->nw_trace_type,
+ sequence++,
+ len,
+ ptr);
+
+ if ((err == DLT_RETURN_BUFFER_FULL) || (err == DLT_RETURN_ERROR)) {
+ dlt_log(LOG_ERR, "NWTSegmented: Could not send segment. Aborting.\n");
+ break; /* loop */
+ }
+
+ offset += len;
+ } while (ptr < data->payload + data->payload_len);
}
-DltReturnValue dlt_user_trace_network_segmented(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload)
+DltReturnValue dlt_user_trace_network_segmented(DltContext *handle,
+ DltNetworkTraceType nw_trace_type,
+ uint16_t header_len,
+ void *header,
+ uint16_t payload_len,
+ void *payload)
{
- /* Send as normal trace if possible */
- if(header_len+payload_len+sizeof(uint16_t) < dlt_user.log_buf_len) {
- return dlt_user_trace_network(handle, nw_trace_type, header_len, header, payload_len, payload);
- }
-
- /* Allocate Memory */
- s_segmented_data *thread_data = malloc(sizeof(s_segmented_data));
- if(thread_data == NULL)
- {
- return DLT_RETURN_ERROR;
- }
- thread_data->header = malloc(header_len);
- if(thread_data->header == NULL)
- {
- free(thread_data);
- return DLT_RETURN_ERROR;
- }
- thread_data->payload = malloc(payload_len);
- if(thread_data->payload == NULL)
- {
- free(thread_data->header);
- free(thread_data);
- return DLT_RETURN_ERROR;
- }
-
- /* Copy data */
- thread_data->handle = handle;
- thread_data->nw_trace_type = nw_trace_type;
- thread_data->header_len = header_len;
- memcpy(thread_data->header, header, header_len);
- thread_data->payload_len = payload_len;
- memcpy(thread_data->payload, payload, payload_len);
-
- /* Send start message */
- DltReturnValue err = dlt_user_trace_network_segmented_start(&(thread_data->id),
- thread_data->handle, thread_data->nw_trace_type,
- thread_data->header_len, thread_data->header,
- thread_data->payload_len);
- if(err == DLT_RETURN_BUFFER_FULL || err == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_ERR,"NWTSegmented: Could not send start segment. Aborting.\n");
- free(thread_data->header);
- free(thread_data->payload);
- free(thread_data);
- return DLT_RETURN_ERROR;
- }
-
- /* Open queue if it is not open */
- if(dlt_init_message_queue() < 0)
- {
- dlt_log(LOG_ERR, "NWTSegmented: Could not open queue.\n");
- free(thread_data->header);
- free(thread_data->payload);
- free(thread_data);
-
- return DLT_RETURN_ERROR;
- }
-
- /* Add to queue */
- if(mq_send(dlt_user.dlt_segmented_queue_write_handle,
- (char *)&thread_data, sizeof(s_segmented_data *), 1) < 0)
- {
- if(errno == EAGAIN)
- {
- dlt_log(LOG_WARNING, "NWTSegmented: Queue full. Message discarded.\n");
- }
- free(thread_data->header);
- free(thread_data->payload);
- free(thread_data);
- dlt_vnlog(LOG_WARNING, 256,"NWTSegmented: Could not write into queue: %s \n",strerror(errno));
- return DLT_RETURN_ERROR;
- }
-
- //thread_data will be freed by the receiver function
- //coverity[leaked_storage]
- return DLT_RETURN_OK;
+ /* Send as normal trace if possible */
+ if (header_len + payload_len + sizeof(uint16_t) < dlt_user.log_buf_len)
+ return dlt_user_trace_network(handle, nw_trace_type, header_len, header, payload_len, payload);
+
+ /* Allocate Memory */
+ s_segmented_data *thread_data = malloc(sizeof(s_segmented_data));
+
+ if (thread_data == NULL)
+ return DLT_RETURN_ERROR;
+
+ thread_data->header = malloc(header_len);
+
+ if (thread_data->header == NULL) {
+ free(thread_data);
+ return DLT_RETURN_ERROR;
+ }
+
+ thread_data->payload = malloc(payload_len);
+
+ if (thread_data->payload == NULL) {
+ free(thread_data->header);
+ free(thread_data);
+ return DLT_RETURN_ERROR;
+ }
+
+ /* Copy data */
+ thread_data->handle = handle;
+ thread_data->nw_trace_type = nw_trace_type;
+ thread_data->header_len = header_len;
+ memcpy(thread_data->header, header, header_len);
+ thread_data->payload_len = payload_len;
+ memcpy(thread_data->payload, payload, payload_len);
+
+ /* Send start message */
+ DltReturnValue err = dlt_user_trace_network_segmented_start(&(thread_data->id),
+ thread_data->handle, thread_data->nw_trace_type,
+ thread_data->header_len, thread_data->header,
+ thread_data->payload_len);
+
+ if ((err == DLT_RETURN_BUFFER_FULL) || (err == DLT_RETURN_ERROR)) {
+ dlt_log(LOG_ERR, "NWTSegmented: Could not send start segment. Aborting.\n");
+ free(thread_data->header);
+ free(thread_data->payload);
+ free(thread_data);
+ return DLT_RETURN_ERROR;
+ }
+
+ /* Open queue if it is not open */
+ if (dlt_init_message_queue() < 0) {
+ dlt_log(LOG_ERR, "NWTSegmented: Could not open queue.\n");
+ free(thread_data->header);
+ free(thread_data->payload);
+ free(thread_data);
+
+ return DLT_RETURN_ERROR;
+ }
+
+ /* Add to queue */
+ if (mq_send(dlt_user.dlt_segmented_queue_write_handle,
+ (char *)&thread_data, sizeof(s_segmented_data *), 1) < 0) {
+ if (errno == EAGAIN)
+ dlt_log(LOG_WARNING, "NWTSegmented: Queue full. Message discarded.\n");
+
+ free(thread_data->header);
+ free(thread_data->payload);
+ free(thread_data);
+ dlt_vnlog(LOG_WARNING, 256, "NWTSegmented: Could not write into queue: %s \n", strerror(errno));
+ return DLT_RETURN_ERROR;
+ }
+
+ /*thread_data will be freed by the receiver function */
+ /*coverity[leaked_storage] */
+ return DLT_RETURN_OK;
}
-DltReturnValue dlt_user_trace_network(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload)
+DltReturnValue dlt_user_trace_network(DltContext *handle,
+ DltNetworkTraceType nw_trace_type,
+ uint16_t header_len,
+ void *header,
+ uint16_t payload_len,
+ void *payload)
{
return dlt_user_trace_network_truncated(handle, nw_trace_type, header_len, header, payload_len, payload, 1);
}
-DltReturnValue dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload, int allow_truncate)
+DltReturnValue dlt_user_trace_network_truncated(DltContext *handle,
+ DltNetworkTraceType nw_trace_type,
+ uint16_t header_len,
+ void *header,
+ uint16_t payload_len,
+ void *payload,
+ int allow_truncate)
{
int ret = DLT_RETURN_ERROR;
- if(payload == NULL && payload_len > 0)
+
+ if ((payload == NULL) && (payload_len > 0))
return DLT_RETURN_WRONG_PARAMETER;
DltContextData log;
- if (nw_trace_type < DLT_NW_TRACE_IPC || nw_trace_type >= DLT_NW_TRACE_MAX)
- {
+ if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
dlt_vlog(LOG_ERR, "Network trace type %d is outside valid range", nw_trace_type);
return DLT_RETURN_WRONG_PARAMETER;
}
- if (dlt_user.dlt_ll_ts==0)
- {
+ if (dlt_user.dlt_ll_ts == 0)
return DLT_RETURN_ERROR;
- }
- if (handle->trace_status_ptr && *(handle->trace_status_ptr)==DLT_TRACE_STATUS_ON)
- {
+ if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
if ((dlt_user_log_init(handle, &log) < DLT_RETURN_OK) || (dlt_user.dlt_ll_ts == NULL))
return DLT_RETURN_ERROR;
/* initialize values */
- if (log.buffer == NULL)
- {
+ if (log.buffer == NULL) {
log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
- if (log.buffer == NULL)
- {
+
+ if (log.buffer == NULL) {
dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
return DLT_RETURN_ERROR;
}
}
+
log.args_num = 0;
log.trace_status = nw_trace_type;
log.size = 0;
@@ -3269,32 +3106,25 @@ DltReturnValue dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTr
header_len = 0;
/* If truncation is allowed, check if we must do it */
- if(allow_truncate > 0 && (header_len+payload_len+sizeof(uint16_t))>dlt_user.log_buf_len)
- {
+ if ((allow_truncate > 0) && ((header_len + payload_len + sizeof(uint16_t)) > dlt_user.log_buf_len)) {
/* Identify as truncated */
- if(dlt_user_log_write_string(&log, "NWTR") < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_string(&log, "NWTR") < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Write header and its length */
- if (dlt_user_log_write_raw(&log, header, header_len) < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_raw(&log, header, header_len) < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/* Write original size of payload */
- if(dlt_user_log_write_uint32(&log, payload_len) < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_uint32(&log, payload_len) < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
/**
* Calculate maximum available space in sending buffer after headers.
*/
@@ -3302,34 +3132,29 @@ DltReturnValue dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTr
int truncated_payload_len = dlt_user.log_buf_len - log.size - sizeof(uint16_t) - sizeof(uint32_t);
/* Write truncated payload */
- if (dlt_user_log_write_raw(&log, payload, truncated_payload_len) < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_raw(&log, payload, truncated_payload_len) < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
}
- else /* Truncation not allowed or data short enough */
- {
+ else { /* Truncation not allowed or data short enough */
+
/* Write header and its length */
- if (dlt_user_log_write_raw(&log, header, header_len) < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_raw(&log, header, header_len) < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
if (payload == NULL)
payload_len = 0;
/* Write payload and its length */
- if (dlt_user_log_write_raw(&log, payload, payload_len) < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_raw(&log, payload, payload_len) < DLT_RETURN_OK) {
dlt_user_free_buffer(&(log.buffer));
return DLT_RETURN_ERROR;
}
-
}
+
ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE);
dlt_user_free_buffer(&(log.buffer));
@@ -3346,24 +3171,17 @@ DltReturnValue dlt_log_string(DltContext *handle, DltLogLevelType loglevel, cons
DltReturnValue ret = DLT_RETURN_OK;
DltContextData log;
- if (dlt_user.verbose_mode==0)
- {
+ if (dlt_user.verbose_mode == 0)
return DLT_RETURN_ERROR;
- }
if ((handle == NULL) || (text == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE)
- {
+ if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
ret = dlt_user_log_write_string(&log, text);
if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
- {
ret = DLT_RETURN_ERROR;
- }
}
return ret;
@@ -3374,25 +3192,18 @@ DltReturnValue dlt_log_string_int(DltContext *handle, DltLogLevelType loglevel,
DltReturnValue ret = DLT_RETURN_OK;
DltContextData log;
- if (dlt_user.verbose_mode==0)
- {
+ if (dlt_user.verbose_mode == 0)
return DLT_RETURN_ERROR;
- }
if ((handle == NULL) || (text == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE)
- {
+ if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
ret = dlt_user_log_write_string(&log, text);
dlt_user_log_write_int(&log, data);
if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
- {
ret = DLT_RETURN_ERROR;
- }
}
return ret;
@@ -3403,25 +3214,18 @@ DltReturnValue dlt_log_string_uint(DltContext *handle, DltLogLevelType loglevel,
DltReturnValue ret = DLT_RETURN_OK;
DltContextData log;
- if (dlt_user.verbose_mode==0)
- {
+ if (dlt_user.verbose_mode == 0)
return DLT_RETURN_ERROR;
- }
if ((handle == NULL) || (text == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE)
- {
+ if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
ret = dlt_user_log_write_string(&log, text);
dlt_user_log_write_uint(&log, data);
if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
- {
ret = DLT_RETURN_ERROR;
- }
}
return ret;
@@ -3431,24 +3235,17 @@ DltReturnValue dlt_log_int(DltContext *handle, DltLogLevelType loglevel, int dat
{
DltContextData log;
- if (dlt_user.verbose_mode==0)
- {
+ if (dlt_user.verbose_mode == 0)
return DLT_RETURN_ERROR;
- }
if (handle == NULL)
- {
return DLT_RETURN_ERROR;
- }
- if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE)
- {
+ if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
dlt_user_log_write_int(&log, data);
if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
}
return DLT_RETURN_OK;
@@ -3458,24 +3255,17 @@ DltReturnValue dlt_log_uint(DltContext *handle, DltLogLevelType loglevel, unsign
{
DltContextData log;
- if (dlt_user.verbose_mode==0)
- {
+ if (dlt_user.verbose_mode == 0)
return DLT_RETURN_ERROR;
- }
if (handle == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE)
- {
+ if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
dlt_user_log_write_uint(&log, data);
if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
}
return DLT_RETURN_OK;
@@ -3486,26 +3276,18 @@ DltReturnValue dlt_log_raw(DltContext *handle, DltLogLevelType loglevel, void *d
DltContextData log;
DltReturnValue ret = DLT_RETURN_OK;
- if (dlt_user.verbose_mode==0)
- {
+ if (dlt_user.verbose_mode == 0)
return DLT_RETURN_ERROR;
- }
if (handle == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (dlt_user_log_write_start(handle,&log,loglevel) > 0)
- {
- if ( (ret = dlt_user_log_write_raw(&log,data,length)) < DLT_RETURN_OK)
- {
+ if (dlt_user_log_write_start(handle, &log, loglevel) > 0) {
+ if ((ret = dlt_user_log_write_raw(&log, data, length)) < DLT_RETURN_OK)
return ret;
- }
+
if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
}
return DLT_RETURN_OK;
@@ -3513,10 +3295,8 @@ DltReturnValue dlt_log_raw(DltContext *handle, DltLogLevelType loglevel, void *d
DltReturnValue dlt_log_marker()
{
- if (!dlt_user_initialised)
- {
- if (dlt_init() < DLT_RETURN_OK)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -3527,10 +3307,8 @@ DltReturnValue dlt_log_marker()
DltReturnValue dlt_verbose_mode(void)
{
- if (!dlt_user_initialised)
- {
- if (dlt_init() < DLT_RETURN_OK)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -3544,10 +3322,8 @@ DltReturnValue dlt_verbose_mode(void)
DltReturnValue dlt_nonverbose_mode(void)
{
- if (!dlt_user_initialised)
- {
- if (dlt_init() < DLT_RETURN_OK)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -3561,10 +3337,8 @@ DltReturnValue dlt_nonverbose_mode(void)
DltReturnValue dlt_use_extended_header_for_non_verbose(int8_t use_extende_header_for_non_verbose)
{
- if (!dlt_user_initialised)
- {
- if (dlt_init() < DLT_RETURN_OK)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -3578,10 +3352,8 @@ DltReturnValue dlt_use_extended_header_for_non_verbose(int8_t use_extende_header
DltReturnValue dlt_with_session_id(int8_t with_session_id)
{
- if (!dlt_user_initialised)
- {
- if (dlt_init() < DLT_RETURN_OK)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -3595,10 +3367,8 @@ DltReturnValue dlt_with_session_id(int8_t with_session_id)
DltReturnValue dlt_with_timestamp(int8_t with_timestamp)
{
- if (!dlt_user_initialised)
- {
- if (dlt_init() < DLT_RETURN_OK)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -3612,10 +3382,8 @@ DltReturnValue dlt_with_timestamp(int8_t with_timestamp)
DltReturnValue dlt_with_ecu_id(int8_t with_ecu_id)
{
- if (!dlt_user_initialised)
- {
- if (dlt_init() < DLT_RETURN_OK)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -3629,10 +3397,8 @@ DltReturnValue dlt_with_ecu_id(int8_t with_ecu_id)
DltReturnValue dlt_enable_local_print(void)
{
- if (!dlt_user_initialised)
- {
- if (dlt_init() < DLT_RETURN_OK)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -3645,10 +3411,8 @@ DltReturnValue dlt_enable_local_print(void)
DltReturnValue dlt_disable_local_print(void)
{
- if (!dlt_user_initialised)
- {
- if (dlt_init() < DLT_RETURN_OK)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -3664,14 +3428,12 @@ void dlt_user_receiverthread_function(__attribute__((unused)) void *ptr)
#ifdef linux
prctl(PR_SET_NAME, "dlt_receiver", 0, 0, 0);
#endif
- while (1)
- {
+
+ while (1) {
/* Check for new messages from DLT daemon */
if (dlt_user_log_check_user_message() < DLT_RETURN_OK)
- {
/* Critical error */
- dlt_log(LOG_CRIT,"Receiver thread encountered error condition\n");
- }
+ dlt_log(LOG_CRIT, "Receiver thread encountered error condition\n");
usleep(DLT_USER_RECEIVE_DELAY); /* delay */
}
@@ -3681,13 +3443,11 @@ void dlt_user_receiverthread_function(__attribute__((unused)) void *ptr)
DltReturnValue dlt_user_log_init(DltContext *handle, DltContextData *log)
{
- if (handle == NULL || log == NULL)
+ if ((handle == NULL) || (log == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- if (!dlt_user_initialised)
- {
- if (dlt_init() < DLT_RETURN_OK)
- {
+ if (!dlt_user_initialised) {
+ if (dlt_init() < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
return DLT_RETURN_ERROR;
}
@@ -3703,11 +3463,10 @@ DltReturnValue dlt_user_queue_resend(void)
{
static unsigned char dlt_user_queue_resend_error_counter = 0;
- if(dlt_user.dlt_log_handle < 0)
- {
- // Fail silenty. FIFO is not open yet
+ if (dlt_user.dlt_log_handle < 0)
+ /* Fail silenty. FIFO is not open yet */
return DLT_RETURN_ERROR;
- }
+
/**
* Ask segmented thread to try emptying the buffer soon.
* This will be freed in dlt_user_trace_network_segmented_thread
@@ -3715,34 +3474,26 @@ DltReturnValue dlt_user_queue_resend(void)
s_segmented_data *resend_data = malloc(sizeof(s_segmented_data));
if (resend_data == NULL)
- {
return DLT_RETURN_ERROR;
- }
resend_data->payload_len = DLT_DELAYED_RESEND_INDICATOR_PATTERN;
-
-
/* Open queue if it is not open */
- if(dlt_init_message_queue() < DLT_RETURN_OK)
- {
- if(!dlt_user_queue_resend_error_counter)
- {
- // log error only when problem occurred first time
+ if (dlt_init_message_queue() < DLT_RETURN_OK) {
+ if (!dlt_user_queue_resend_error_counter)
+ /* log error only when problem occurred first time */
dlt_log(LOG_WARNING, "NWTSegmented: Could not open queue.\n");
- }
+
dlt_user_queue_resend_error_counter = 1;
free(resend_data);
return DLT_RETURN_ERROR;
}
- if(mq_send(dlt_user.dlt_segmented_queue_write_handle, (char *)&resend_data, sizeof(s_segmented_data *), 1) < 0)
- {
- if(!dlt_user_queue_resend_error_counter)
- {
- // log error only when problem occurred first time
- dlt_vnlog(LOG_DEBUG, 256,"Could not request resending.: %s \n",strerror(errno));
- }
+ if (mq_send(dlt_user.dlt_segmented_queue_write_handle, (char *)&resend_data, sizeof(s_segmented_data *), 1) < 0) {
+ if (!dlt_user_queue_resend_error_counter)
+ /* log error only when problem occurred first time */
+ dlt_vnlog(LOG_DEBUG, 256, "Could not request resending.: %s \n", strerror(errno));
+
dlt_user_queue_resend_error_counter = 1;
free(resend_data);
return DLT_RETURN_ERROR;
@@ -3750,8 +3501,8 @@ DltReturnValue dlt_user_queue_resend(void)
dlt_user_queue_resend_error_counter = 0;
- //thread_data will be freed by the receiver function
- //coverity[leaked_storage]
+ /*thread_data will be freed by the receiver function */
+ /*coverity[leaked_storage] */
return DLT_RETURN_OK;
}
@@ -3763,114 +3514,100 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype)
DltReturnValue ret = DLT_RETURN_OK;
- if (!dlt_user_initialised)
- {
+ if (!dlt_user_initialised) {
dlt_vlog(LOG_ERR, "%s dlt_user_initialised false\n", __FUNCTION__);
return DLT_RETURN_ERROR;
}
- if (log == NULL ||
- log->handle == NULL ||
- log->handle->contextID[0] == '\0' ||
+ if ((log == NULL) ||
+ (log->handle == NULL) ||
+ (log->handle->contextID[0] == '\0') ||
(mtype < DLT_TYPE_LOG) || (mtype > DLT_TYPE_CONTROL)
)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* also for Trace messages */
#ifdef DLT_SHM_ENABLE
+
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_SHM) < DLT_RETURN_OK)
#else
+
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG) < DLT_RETURN_OK)
#endif
- {
+
return DLT_RETURN_ERROR;
- }
if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
- {
return DLT_RETURN_ERROR;
- }
- msg.storageheader = (DltStorageHeader*)msg.headerbuffer;
+ msg.storageheader = (DltStorageHeader *)msg.headerbuffer;
- if (dlt_set_storageheader(msg.storageheader,dlt_user.ecuID) == DLT_RETURN_ERROR)
- {
+ if (dlt_set_storageheader(msg.storageheader, dlt_user.ecuID) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
- msg.standardheader = (DltStandardHeader*)(msg.headerbuffer + sizeof(DltStorageHeader));
- msg.standardheader->htyp = DLT_HTYP_PROTOCOL_VERSION1 ;
+ msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+ msg.standardheader->htyp = DLT_HTYP_PROTOCOL_VERSION1;
/* send ecu id */
- if(dlt_user.with_ecu_id)
- {
+ if (dlt_user.with_ecu_id)
msg.standardheader->htyp |= DLT_HTYP_WEID;
- }
/* send timestamp */
- if(dlt_user.with_timestamp)
- {
+ if (dlt_user.with_timestamp)
msg.standardheader->htyp |= DLT_HTYP_WTMS;
- }
/* send session id */
- if(dlt_user.with_session_id)
- {
+ if (dlt_user.with_session_id) {
msg.standardheader->htyp |= DLT_HTYP_WSID;
msg.headerextra.seid = getpid();
}
if (dlt_user.verbose_mode)
- {
/* In verbose mode, send extended header */
- msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_UEH );
- }
+ msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_UEH);
else
- {
/* In non-verbose, send extended header if desired */
- if(dlt_user.use_extende_header_for_non_verbose)
- msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_UEH );
- }
+ if (dlt_user.use_extende_header_for_non_verbose)
+ msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_UEH);
+
-#if (BYTE_ORDER==BIG_ENDIAN)
+#if (BYTE_ORDER == BIG_ENDIAN)
msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_MSBF);
#endif
msg.standardheader->mcnt = log->handle->mcnt++;
/* Set header extra parameters */
- dlt_set_id(msg.headerextra.ecu,dlt_user.ecuID);
- //msg.headerextra.seid = 0;
+ dlt_set_id(msg.headerextra.ecu, dlt_user.ecuID);
+ /*msg.headerextra.seid = 0; */
msg.headerextra.tmsp = dlt_uptime();
if (dlt_message_set_extraparameters(&msg, 0) == DLT_RETURN_ERROR)
- {
return DLT_RETURN_ERROR;
- }
/* Fill out extended header, if extended header should be provided */
- if (DLT_IS_HTYP_UEH(msg.standardheader->htyp))
- {
+ if (DLT_IS_HTYP_UEH(msg.standardheader->htyp)) {
/* with extended header */
- msg.extendedheader = (DltExtendedHeader*)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp) );
+ msg.extendedheader =
+ (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
- switch (mtype)
- {
+ switch (mtype) {
case DLT_TYPE_LOG:
{
- msg.extendedheader->msin = (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT) | ((log->log_level << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN) ; /* messsage info */
+ msg.extendedheader->msin = (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT) |
+ ((log->log_level << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN); /* messsage info */
break;
}
case DLT_TYPE_NW_TRACE:
{
- msg.extendedheader->msin = (DLT_TYPE_NW_TRACE << DLT_MSIN_MSTP_SHIFT) | ((log->trace_status << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN) ; /* messsage info */
+ msg.extendedheader->msin = (DLT_TYPE_NW_TRACE << DLT_MSIN_MSTP_SHIFT) |
+ ((log->trace_status << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN); /* messsage info */
break;
}
default:
{
- /* This case should not occur */
+ /* This case should not occur */
return DLT_RETURN_ERROR;
break;
}
@@ -3878,26 +3615,25 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype)
/* If in verbose mode, set flag in header for verbose mode */
if (dlt_user.verbose_mode)
- {
msg.extendedheader->msin |= DLT_MSIN_VERB;
- }
msg.extendedheader->noar = log->args_num; /* number of arguments */
- dlt_set_id(msg.extendedheader->apid,dlt_user.appID); /* application id */
- dlt_set_id(msg.extendedheader->ctid,log->handle->contextID); /* context id */
+ dlt_set_id(msg.extendedheader->apid, dlt_user.appID); /* application id */
+ dlt_set_id(msg.extendedheader->ctid, log->handle->contextID); /* context id */
- msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
+ msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
}
- else
- {
+ else {
/* without extended header */
- msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
+ msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(
+ msg.standardheader->htyp);
}
- len=msg.headersize - sizeof(DltStorageHeader) +log->size;
- if (len>UINT16_MAX)
- {
- dlt_log(LOG_WARNING,"Huge message discarded!\n");
+ len = msg.headersize - sizeof(DltStorageHeader) + log->size;
+
+ if (len > UINT16_MAX) {
+ dlt_log(LOG_WARNING, "Huge message discarded!\n");
return DLT_RETURN_ERROR;
}
@@ -3905,132 +3641,123 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype)
/* print to std out, if enabled */
if ((dlt_user.local_print_mode != DLT_PM_FORCE_OFF) &&
- (dlt_user.local_print_mode != DLT_PM_AUTOMATIC))
- {
- if ((dlt_user.enable_local_print) || (dlt_user.local_print_mode == DLT_PM_FORCE_ON))
- {
+ (dlt_user.local_print_mode != DLT_PM_AUTOMATIC)) {
+ if ((dlt_user.enable_local_print) || (dlt_user.local_print_mode == DLT_PM_FORCE_ON)) {
if (dlt_user_print_msg(&msg, log) == DLT_RETURN_ERROR)
- {
return DLT_RETURN_ERROR;
- }
}
}
- if (dlt_user.dlt_is_file)
- {
+ if (dlt_user.dlt_is_file) {
/* log to file */
- ret=dlt_user_log_out2(dlt_user.dlt_log_handle, msg.headerbuffer, msg.headersize, log->buffer, log->size);
+ ret = dlt_user_log_out2(dlt_user.dlt_log_handle, msg.headerbuffer, msg.headersize, log->buffer, log->size);
return ret;
}
- else
- {
+ else {
/* Reattach to daemon if neccesary */
dlt_user_log_reattach_to_daemon();
- if (dlt_user.overflow_counter)
- {
- if (dlt_user_log_send_overflow() == DLT_RETURN_OK)
- {
+ if (dlt_user.overflow_counter) {
+ if (dlt_user_log_send_overflow() == DLT_RETURN_OK) {
dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "%u messages discarded!\n", dlt_user.overflow_counter);
dlt_user.overflow_counter = 0;
}
}
- /* try to resent old data first */
- ret = DLT_RETURN_OK;
- if((dlt_user.dlt_log_handle!=-1) && (dlt_user.appID[0]!='\0'))
- {
- ret = dlt_user_log_resend_buffer();
- }
- if((ret == DLT_RETURN_OK) && (dlt_user.appID[0] != '\0'))
- {
- /* resend ok or nothing to resent */
+ /* try to resent old data first */
+ ret = DLT_RETURN_OK;
+
+ if ((dlt_user.dlt_log_handle != -1) && (dlt_user.appID[0] != '\0'))
+ ret = dlt_user_log_resend_buffer();
+
+ if ((ret == DLT_RETURN_OK) && (dlt_user.appID[0] != '\0')) {
+ /* resend ok or nothing to resent */
#ifdef DLT_SHM_ENABLE
- if(dlt_user.dlt_log_handle!=-1)
- dlt_shm_push(&dlt_user.dlt_shm,msg.headerbuffer+sizeof(DltStorageHeader), msg.headersize-sizeof(DltStorageHeader),
- log->buffer, log->size, 0, 0);
+
+ if (dlt_user.dlt_log_handle != -1)
+ dlt_shm_push(&dlt_user.dlt_shm, msg.headerbuffer + sizeof(DltStorageHeader),
+ msg.headersize - sizeof(DltStorageHeader),
+ log->buffer, log->size, 0, 0);
ret = dlt_user_log_out3(dlt_user.dlt_log_handle,
&(userheader), sizeof(DltUserHeader),
0, 0,
0, 0);
#else
-#ifdef DLT_TEST_ENABLE
- if(dlt_user.corrupt_user_header) {
- userheader.pattern[0]=0xff;
- userheader.pattern[1]=0xff;
- userheader.pattern[2]=0xff;
- userheader.pattern[3]=0xff;
+# ifdef DLT_TEST_ENABLE
+
+ if (dlt_user.corrupt_user_header) {
+ userheader.pattern[0] = 0xff;
+ userheader.pattern[1] = 0xff;
+ userheader.pattern[2] = 0xff;
+ userheader.pattern[3] = 0xff;
}
- if(dlt_user.corrupt_message_size) {
+
+ if (dlt_user.corrupt_message_size)
msg.standardheader->len = DLT_HTOBE_16(dlt_user.corrupt_message_size_size);
- }
-#endif
+
+# endif
ret = dlt_user_log_out3(dlt_user.dlt_log_handle,
&(userheader), sizeof(DltUserHeader),
- msg.headerbuffer+sizeof(DltStorageHeader), msg.headersize-sizeof(DltStorageHeader),
+ msg.headerbuffer + sizeof(DltStorageHeader),
+ msg.headersize - sizeof(DltStorageHeader),
log->buffer, log->size);
#endif
}
/* store message in ringbuffer, if an error has occured */
- if ((ret!=DLT_RETURN_OK) || (dlt_user.appID[0] == '\0'))
- {
+ if ((ret != DLT_RETURN_OK) || (dlt_user.appID[0] == '\0'))
ret = dlt_user_log_out_error_handling(&(userheader),
sizeof(DltUserHeader),
- msg.headerbuffer+sizeof(DltStorageHeader),
- msg.headersize-sizeof(DltStorageHeader),
+ msg.headerbuffer + sizeof(DltStorageHeader),
+ msg.headersize - sizeof(DltStorageHeader),
log->buffer,
log->size);
- }
- switch (ret)
+ switch (ret) {
+ case DLT_RETURN_BUFFER_FULL:
{
- case DLT_RETURN_BUFFER_FULL:
- {
- /* Buffer full */
- dlt_user.overflow_counter += 1;
- return DLT_RETURN_BUFFER_FULL;
- }
- case DLT_RETURN_PIPE_FULL:
- {
- /* data could not be written */
- return DLT_RETURN_PIPE_FULL;
- }
- case DLT_RETURN_PIPE_ERROR:
- {
- /* handle not open or pipe error */
- close(dlt_user.dlt_log_handle);
- dlt_user.dlt_log_handle = -1;
- dlt_user.connection_state = DLT_USER_RETRY_CONNECT;
+ /* Buffer full */
+ dlt_user.overflow_counter += 1;
+ return DLT_RETURN_BUFFER_FULL;
+ }
+ case DLT_RETURN_PIPE_FULL:
+ {
+ /* data could not be written */
+ return DLT_RETURN_PIPE_FULL;
+ }
+ case DLT_RETURN_PIPE_ERROR:
+ {
+ /* handle not open or pipe error */
+ close(dlt_user.dlt_log_handle);
+ dlt_user.dlt_log_handle = -1;
+ dlt_user.connection_state = DLT_USER_RETRY_CONNECT;
#ifdef DLT_SHM_ENABLE
- /* free shared memory */
- dlt_shm_free_client(&dlt_user.dlt_shm);
+ /* free shared memory */
+ dlt_shm_free_client(&dlt_user.dlt_shm);
#endif
- if (dlt_user.local_print_mode == DLT_PM_AUTOMATIC)
- {
- dlt_user_print_msg(&msg, log);
- }
+ if (dlt_user.local_print_mode == DLT_PM_AUTOMATIC)
+ dlt_user_print_msg(&msg, log);
- return DLT_RETURN_PIPE_ERROR;
- }
- case DLT_RETURN_ERROR:
- {
- /* other error condition */
- return DLT_RETURN_ERROR;
- }
- case DLT_RETURN_OK:
- {
- return DLT_RETURN_OK;
- }
- default:
- {
- /* This case should never occur. */
- return DLT_RETURN_ERROR;
- }
+ return DLT_RETURN_PIPE_ERROR;
+ }
+ case DLT_RETURN_ERROR:
+ {
+ /* other error condition */
+ return DLT_RETURN_ERROR;
+ }
+ case DLT_RETURN_OK:
+ {
+ return DLT_RETURN_OK;
+ }
+ default:
+ {
+ /* This case should never occur. */
+ return DLT_RETURN_ERROR;
+ }
}
}
@@ -4044,50 +3771,38 @@ DltReturnValue dlt_user_log_send_register_application(void)
DltReturnValue ret;
- if (dlt_user.appID[0]=='\0')
- {
+ if (dlt_user.appID[0] == '\0')
return DLT_RETURN_ERROR;
- }
/* set userheader */
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_REGISTER_APPLICATION) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
/* set usercontext */
- dlt_set_id(usercontext.apid,dlt_user.appID); /* application id */
+ dlt_set_id(usercontext.apid, dlt_user.appID); /* application id */
usercontext.pid = getpid();
if (dlt_user.application_description != NULL)
- {
usercontext.description_length = strlen(dlt_user.application_description);
- }
else
- {
usercontext.description_length = 0;
- }
if (dlt_user.dlt_is_file)
- {
return DLT_RETURN_OK;
- }
ret = dlt_user_log_out3(dlt_user.dlt_log_handle,
- &(userheader), sizeof(DltUserHeader),
- &(usercontext), sizeof(DltUserControlMsgRegisterApplication),
- dlt_user.application_description, usercontext.description_length);
+ &(userheader), sizeof(DltUserHeader),
+ &(usercontext), sizeof(DltUserControlMsgRegisterApplication),
+ dlt_user.application_description, usercontext.description_length);
/* store message in ringbuffer, if an error has occured */
if (ret < DLT_RETURN_OK)
- {
return dlt_user_log_out_error_handling(&(userheader),
sizeof(DltUserHeader),
&(usercontext),
sizeof(DltUserControlMsgRegisterApplication),
dlt_user.application_description,
usercontext.description_length);
- }
return DLT_RETURN_OK;
}
@@ -4098,25 +3813,19 @@ DltReturnValue dlt_user_log_send_unregister_application(void)
DltUserControlMsgUnregisterApplication usercontext;
DltReturnValue ret = DLT_RETURN_OK;
- if (dlt_user.appID[0]=='\0')
- {
+ if (dlt_user.appID[0] == '\0')
return DLT_RETURN_ERROR;
- }
/* set userheader */
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_UNREGISTER_APPLICATION) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
/* set usercontext */
- dlt_set_id(usercontext.apid,dlt_user.appID); /* application id */
+ dlt_set_id(usercontext.apid, dlt_user.appID); /* application id */
usercontext.pid = getpid();
if (dlt_user.dlt_is_file)
- {
return DLT_RETURN_OK;
- }
ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
&(userheader), sizeof(DltUserHeader),
@@ -4124,14 +3833,12 @@ DltReturnValue dlt_user_log_send_unregister_application(void)
/* store message in ringbuffer, if an error has occured */
if (ret < DLT_RETURN_OK)
- {
return dlt_user_log_out_error_handling(&(userheader),
sizeof(DltUserHeader),
&(usercontext),
sizeof(DltUserControlMsgUnregisterApplication),
NULL,
0);
- }
return DLT_RETURN_OK;
}
@@ -4143,29 +3850,21 @@ DltReturnValue dlt_user_log_send_register_context(DltContextData *log)
DltReturnValue ret = DLT_RETURN_ERROR;
if (log == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if (log->handle == NULL)
- {
return DLT_RETURN_ERROR;
- }
if (log->handle->contextID[0] == '\0')
- {
return DLT_RETURN_ERROR;
- }
/* set userheader */
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_REGISTER_CONTEXT) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
/* set usercontext */
- dlt_set_id(usercontext.apid,dlt_user.appID); /* application id */
- dlt_set_id(usercontext.ctid,log->handle->contextID); /* context id */
+ dlt_set_id(usercontext.apid, dlt_user.appID); /* application id */
+ dlt_set_id(usercontext.ctid, log->handle->contextID); /* context id */
usercontext.log_level_pos = log->handle->log_level_pos;
usercontext.pid = getpid();
@@ -4173,35 +3872,31 @@ DltReturnValue dlt_user_log_send_register_context(DltContextData *log)
usercontext.trace_status = (int8_t)log->trace_status;
if (log->context_description != NULL)
- {
usercontext.description_length = strlen(log->context_description);
- }
else
- {
usercontext.description_length = 0;
- }
if (dlt_user.dlt_is_file)
- {
return DLT_RETURN_OK;
- }
-
- if (dlt_user.appID[0]!='\0')
- {
- ret = dlt_user_log_out3(dlt_user.dlt_log_handle, &(userheader), sizeof(DltUserHeader), &(usercontext), sizeof(DltUserControlMsgRegisterContext),log->context_description,usercontext.description_length);
- }
+ if (dlt_user.appID[0] != '\0')
+ ret =
+ dlt_user_log_out3(dlt_user.dlt_log_handle,
+ &(userheader),
+ sizeof(DltUserHeader),
+ &(usercontext),
+ sizeof(DltUserControlMsgRegisterContext),
+ log->context_description,
+ usercontext.description_length);
/* store message in ringbuffer, if an error has occured */
if ((ret != DLT_RETURN_OK) || (dlt_user.appID[0] == '\0'))
- {
return dlt_user_log_out_error_handling(&(userheader),
sizeof(DltUserHeader),
&(usercontext),
sizeof(DltUserControlMsgRegisterContext),
log->context_description,
usercontext.description_length);
- }
return DLT_RETURN_OK;
@@ -4214,35 +3909,25 @@ DltReturnValue dlt_user_log_send_unregister_context(DltContextData *log)
DltReturnValue ret;
if (log == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if (log->handle == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if (log->handle->contextID[0] == '\0')
- {
- return DLT_RETURN_ERROR;
- }
+ return DLT_RETURN_ERROR;
/* set userheader */
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_UNREGISTER_CONTEXT) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
/* set usercontext */
- dlt_set_id(usercontext.apid,dlt_user.appID); /* application id */
- dlt_set_id(usercontext.ctid,log->handle->contextID); /* context id */
+ dlt_set_id(usercontext.apid, dlt_user.appID); /* application id */
+ dlt_set_id(usercontext.ctid, log->handle->contextID); /* context id */
usercontext.pid = getpid();
if (dlt_user.dlt_is_file)
- {
return DLT_RETURN_OK;
- }
ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
&(userheader),
@@ -4252,14 +3937,12 @@ DltReturnValue dlt_user_log_send_unregister_context(DltContextData *log)
/* store message in ringbuffer, if an error has occured */
if (ret < DLT_RETURN_OK)
- {
return dlt_user_log_out_error_handling(&(userheader),
sizeof(DltUserHeader),
&(usercontext),
sizeof(DltUserControlMsgUnregisterContext),
NULL,
0);
- }
return DLT_RETURN_OK;
}
@@ -4270,52 +3953,44 @@ DltReturnValue dlt_send_app_ll_ts_limit(const char *appid, DltLogLevelType logle
DltUserControlMsgAppLogLevelTraceStatus usercontext;
DltReturnValue ret;
- if (loglevel < DLT_USER_LOG_LEVEL_NOT_SET || loglevel >= DLT_LOG_MAX)
- {
+ if ((loglevel < DLT_USER_LOG_LEVEL_NOT_SET) || (loglevel >= DLT_LOG_MAX)) {
dlt_vlog(LOG_ERR, "Loglevel %d is outside valid range", loglevel);
return DLT_RETURN_ERROR;
}
- if (tracestatus < DLT_USER_TRACE_STATUS_NOT_SET || tracestatus >= DLT_TRACE_STATUS_MAX)
- {
+ if ((tracestatus < DLT_USER_TRACE_STATUS_NOT_SET) || (tracestatus >= DLT_TRACE_STATUS_MAX)) {
dlt_vlog(LOG_ERR, "Tracestatus %d is outside valid range", tracestatus);
return DLT_RETURN_ERROR;
}
- if ((appid == NULL) || (appid[0]=='\0'))
- {
+ if ((appid == NULL) || (appid[0] == '\0'))
return DLT_RETURN_ERROR;
- }
/* Removed because of DltLogLevelType and DltTraceStatusType
-
- if ((loglevel<DLT_LOG_DEFAULT) || (loglevel>DLT_LOG_VERBOSE))
- {
- return DLT_RETURN_ERROR;
- }
-
- if ((tracestatus<DLT_TRACE_STATUS_DEFAULT) || (tracestatus>DLT_TRACE_STATUS_ON))
- {
- return DLT_RETURN_ERROR;
- }
-
- */
+ *
+ * if ((loglevel<DLT_LOG_DEFAULT) || (loglevel>DLT_LOG_VERBOSE))
+ * {
+ * return DLT_RETURN_ERROR;
+ * }
+ *
+ * if ((tracestatus<DLT_TRACE_STATUS_DEFAULT) || (tracestatus>DLT_TRACE_STATUS_ON))
+ * {
+ * return DLT_RETURN_ERROR;
+ * }
+ *
+ */
/* set userheader */
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_APP_LL_TS) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
/* set usercontext */
- dlt_set_id(usercontext.apid,appid); /* application id */
+ dlt_set_id(usercontext.apid, appid); /* application id */
usercontext.log_level = loglevel;
usercontext.trace_status = tracestatus;
if (dlt_user.dlt_is_file)
- {
return DLT_RETURN_OK;
- }
ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
&(userheader), sizeof(DltUserHeader),
@@ -4323,14 +3998,12 @@ DltReturnValue dlt_send_app_ll_ts_limit(const char *appid, DltLogLevelType logle
/* store message in ringbuffer, if an error has occured */
if (ret < DLT_RETURN_OK)
- {
return dlt_user_log_out_error_handling(&(userheader),
sizeof(DltUserHeader),
&(usercontext),
sizeof(DltUserControlMsgAppLogLevelTraceStatus),
NULL,
0);
- }
return DLT_RETURN_OK;
}
@@ -4341,40 +4014,33 @@ DltReturnValue dlt_user_log_send_log_mode(DltUserLogMode mode)
DltUserControlMsgLogMode logmode;
DltReturnValue ret;
- if (mode < DLT_USER_MODE_UNDEFINED || mode >= DLT_USER_MODE_MAX)
- {
+ if ((mode < DLT_USER_MODE_UNDEFINED) || (mode >= DLT_USER_MODE_MAX)) {
dlt_vlog(LOG_ERR, "User log mode %d is outside valid range", mode);
return DLT_RETURN_WRONG_PARAMETER;
}
/* set userheader */
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_MODE) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
/* set data */
- logmode.log_mode = (unsigned char) mode;
+ logmode.log_mode = (unsigned char)mode;
if (dlt_user.dlt_is_file)
- {
return DLT_RETURN_OK;
- }
ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
- &(userheader), sizeof(DltUserHeader),
- &(logmode), sizeof(DltUserControlMsgLogMode));
+ &(userheader), sizeof(DltUserHeader),
+ &(logmode), sizeof(DltUserControlMsgLogMode));
/* store message in ringbuffer, if an error has occured */
if (ret < DLT_RETURN_OK)
- {
return dlt_user_log_out_error_handling(&(userheader),
sizeof(DltUserHeader),
&(logmode),
sizeof(DltUserControlMsgLogMode),
NULL,
0);
- }
return DLT_RETURN_OK;
}
@@ -4386,29 +4052,23 @@ DltReturnValue dlt_user_log_send_marker()
/* set userheader */
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_MARKER) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
if (dlt_user.dlt_is_file)
- {
return DLT_RETURN_OK;
- }
/* log to FIFO */
ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
- &(userheader), sizeof(DltUserHeader), 0, 0);
+ &(userheader), sizeof(DltUserHeader), 0, 0);
/* store message in ringbuffer, if an error has occured */
if (ret < DLT_RETURN_OK)
- {
return dlt_user_log_out_error_handling(&(userheader),
sizeof(DltUserHeader),
NULL,
0,
NULL,
0);
- }
return DLT_RETURN_OK;
}
@@ -4421,9 +4081,7 @@ DltReturnValue dlt_user_print_msg(DltMessage *msg, DltContextData *log)
static char text[DLT_USER_TEXT_LENGTH];
if ((msg == NULL) || (log == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* Save variables before print */
databuffer_tmp = msg->databuffer;
@@ -4439,15 +4097,13 @@ DltReturnValue dlt_user_print_msg(DltMessage *msg, DltContextData *log)
msg->databuffersize = log->size;
/* Print message as ASCII */
- if (dlt_message_print_ascii(msg,text,DLT_USER_TEXT_LENGTH, 0) == DLT_RETURN_ERROR)
- {
+ if (dlt_message_print_ascii(msg, text, DLT_USER_TEXT_LENGTH, 0) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
/* Restore variables and set len to BE*/
msg->databuffer = databuffer_tmp;
msg->databuffersize = databuffersize_tmp;
- msg->datasize = datasize_tmp;
+ msg->datasize = datasize_tmp;
msg->standardheader->len = DLT_HTOBE_16(msg->standardheader->len);
@@ -4456,8 +4112,8 @@ DltReturnValue dlt_user_print_msg(DltMessage *msg, DltContextData *log)
DltReturnValue dlt_user_log_check_user_message(void)
{
- int offset=0;
- int leave_while=0;
+ int offset = 0;
+ int leave_while = 0;
uint32_t i;
int fd;
@@ -4471,10 +4127,10 @@ DltReturnValue dlt_user_log_check_user_message(void)
unsigned char *userbuffer;
/* For delayed calling of injection callback, to avoid deadlock */
- DltUserInjectionCallback delayed_injection_callback;
+ DltUserInjectionCallback delayed_injection_callback;
DltUserLogLevelChangedCallback delayed_log_level_changed_callback;
- unsigned char *delayed_inject_buffer = 0;
- uint32_t delayed_inject_data_length = 0;
+ unsigned char *delayed_inject_buffer = 0;
+ uint32_t delayed_inject_data_length = 0;
/* Ensure that callback is null before searching for it */
delayed_injection_callback.injection_callback = 0;
@@ -4487,86 +4143,76 @@ DltReturnValue dlt_user_log_check_user_message(void)
fd = dlt_user.dlt_user_handle;
#endif
- if (fd != DLT_FD_INIT)
- {
- while (1)
- {
- if (dlt_receiver_receive(receiver, DLT_RECEIVE_FD)<=0)
- {
+ if (fd != DLT_FD_INIT) {
+ while (1) {
+ if (dlt_receiver_receive(receiver, DLT_RECEIVE_FD) <= 0)
/* No new message available */
return DLT_RETURN_OK;
- }
/* look through buffer as long as data is in there */
- while (1)
- {
+ while (1) {
if (receiver->bytesRcvd < (int32_t)sizeof(DltUserHeader))
- {
break;
- }
/* resync if necessary */
- offset=0;
- do
- {
- userheader = (DltUserHeader*) (receiver->buf+offset);
+ offset = 0;
+
+ do {
+ userheader = (DltUserHeader *)(receiver->buf + offset);
/* Check for user header pattern */
if (dlt_user_check_userheader(userheader))
- {
break;
- }
+
offset++;
- }
- while ((int32_t)(sizeof(DltUserHeader)+offset)<=receiver->bytesRcvd);
+ } while ((int32_t)(sizeof(DltUserHeader) + offset) <= receiver->bytesRcvd);
/* Check for user header pattern */
- if (dlt_user_check_userheader(userheader)<0 ||
- dlt_user_check_userheader(userheader)==0)
- {
+ if ((dlt_user_check_userheader(userheader) < 0) ||
+ (dlt_user_check_userheader(userheader) == 0))
break;
- }
/* Set new start offset */
- if (offset>0)
- {
- receiver->buf+=offset;
- receiver->bytesRcvd-=offset;
+ if (offset > 0) {
+ receiver->buf += offset;
+ receiver->bytesRcvd -= offset;
}
- switch (userheader->message)
- {
+ switch (userheader->message) {
case DLT_USER_MESSAGE_LOG_LEVEL:
{
- if (receiver->bytesRcvd < (int32_t)(sizeof(DltUserHeader)+sizeof(DltUserControlMsgLogLevel)))
- {
- leave_while=1;
+ if (receiver->bytesRcvd < (int32_t)(sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogLevel))) {
+ leave_while = 1;
break;
}
- usercontextll = (DltUserControlMsgLogLevel*) (receiver->buf+sizeof(DltUserHeader));
+ usercontextll = (DltUserControlMsgLogLevel *)(receiver->buf + sizeof(DltUserHeader));
/* Update log level and trace status */
- if (usercontextll != NULL)
- {
+ if (usercontextll != NULL) {
DLT_SEM_LOCK();
if ((usercontextll->log_level_pos >= 0) &&
- (usercontextll->log_level_pos < (int32_t)dlt_user.dlt_ll_ts_num_entries))
- {
- // printf("Store ll, ts\n");
- if (dlt_user.dlt_ll_ts)
- {
+ (usercontextll->log_level_pos < (int32_t)dlt_user.dlt_ll_ts_num_entries)) {
+ /* printf("Store ll, ts\n"); */
+ if (dlt_user.dlt_ll_ts) {
dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level = usercontextll->log_level;
- dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status = usercontextll->trace_status;
- if(dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_ptr)
- *(dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_ptr) = usercontextll->log_level;
- if(dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status_ptr)
- *(dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status_ptr) = usercontextll->trace_status;
-
- delayed_log_level_changed_callback.log_level_changed_callback = dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_changed_callback;
- memcpy(delayed_log_level_changed_callback.contextID,dlt_user.dlt_ll_ts[usercontextll->log_level_pos].contextID,DLT_ID_SIZE);
+ dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status =
+ usercontextll->trace_status;
+
+ if (dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_ptr)
+ *(dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_ptr) =
+ usercontextll->log_level;
+
+ if (dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status_ptr)
+ *(dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status_ptr) =
+ usercontextll->trace_status;
+
+ delayed_log_level_changed_callback.log_level_changed_callback =
+ dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_changed_callback;
+ memcpy(delayed_log_level_changed_callback.contextID,
+ dlt_user.dlt_ll_ts[usercontextll->log_level_pos].contextID, DLT_ID_SIZE);
delayed_log_level_changed_callback.log_level = usercontextll->log_level;
delayed_log_level_changed_callback.trace_status = usercontextll->trace_status;
}
@@ -4576,89 +4222,87 @@ DltReturnValue dlt_user_log_check_user_message(void)
}
/* call callback outside of semaphore */
- if(delayed_log_level_changed_callback.log_level_changed_callback!=0)
- {
- delayed_log_level_changed_callback.log_level_changed_callback(delayed_log_level_changed_callback.contextID,
- delayed_log_level_changed_callback.log_level,
- delayed_log_level_changed_callback.trace_status);
- }
+ if (delayed_log_level_changed_callback.log_level_changed_callback != 0)
+ delayed_log_level_changed_callback.log_level_changed_callback(
+ delayed_log_level_changed_callback.contextID,
+ delayed_log_level_changed_callback.log_level,
+ delayed_log_level_changed_callback.trace_status);
/* keep not read data in buffer */
- if (dlt_receiver_remove(receiver,sizeof(DltUserHeader)+sizeof(DltUserControlMsgLogLevel)) == DLT_RETURN_ERROR)
- {
+ if (dlt_receiver_remove(receiver,
+ sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogLevel)) ==
+ DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
}
- break;
+ break;
case DLT_USER_MESSAGE_INJECTION:
{
/* At least, user header, user context, and service id and data_length of injected message is available */
- if (receiver->bytesRcvd < (int32_t)(sizeof(DltUserHeader)+sizeof(DltUserControlMsgInjection)))
- {
+ if (receiver->bytesRcvd < (int32_t)(sizeof(DltUserHeader) + sizeof(DltUserControlMsgInjection))) {
leave_while = 1;
break;
}
- usercontextinj = (DltUserControlMsgInjection*) (receiver->buf+sizeof(DltUserHeader));
- userbuffer = (unsigned char*) (receiver->buf+sizeof(DltUserHeader)+sizeof(DltUserControlMsgInjection));
+ usercontextinj = (DltUserControlMsgInjection *)(receiver->buf + sizeof(DltUserHeader));
+ userbuffer =
+ (unsigned char *)(receiver->buf + sizeof(DltUserHeader) + sizeof(DltUserControlMsgInjection));
- if (userbuffer != NULL)
- {
+ if (userbuffer != NULL) {
- if (receiver->bytesRcvd < (int32_t)(sizeof(DltUserHeader)+sizeof(DltUserControlMsgInjection)+usercontextinj->data_length_inject))
- {
+ if (receiver->bytesRcvd <
+ (int32_t)(sizeof(DltUserHeader) + sizeof(DltUserControlMsgInjection) +
+ usercontextinj->data_length_inject)) {
leave_while = 1;
break;
}
DLT_SEM_LOCK();
- if ((usercontextinj->data_length_inject > 0) && (dlt_user.dlt_ll_ts))
- {
+ if ((usercontextinj->data_length_inject > 0) && (dlt_user.dlt_ll_ts)) {
/* Check if injection callback is registered for this context */
for (i = 0; i < dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].nrcallbacks; i++)
- {
if ((dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table) &&
- (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].service_id == usercontextinj->service_id))
- {
+ (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].service_id ==
+ usercontextinj->service_id)) {
/* Prepare delayed injection callback call */
- if (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].injection_callback != NULL)
- {
+ if (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+ injection_callback != NULL) {
delayed_injection_callback.injection_callback =
- dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].injection_callback;
+ dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+ injection_callback;
}
- else if (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].injection_callback_with_id != NULL)
+ else if (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+ injection_callback_with_id != NULL)
{
delayed_injection_callback.injection_callback_with_id =
- dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].injection_callback_with_id;
+ dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+ injection_callback_with_id;
delayed_injection_callback.data =
dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].data;
}
+
delayed_injection_callback.service_id = usercontextinj->service_id;
delayed_inject_data_length = usercontextinj->data_length_inject;
delayed_inject_buffer = malloc(delayed_inject_data_length);
- if (delayed_inject_buffer != NULL)
- {
+ if (delayed_inject_buffer != NULL) {
memcpy(delayed_inject_buffer, userbuffer, delayed_inject_data_length);
}
- else
- {
+ else {
DLT_SEM_FREE();
- dlt_log(LOG_WARNING,"malloc failed!\n");
+ dlt_log(LOG_WARNING, "malloc failed!\n");
return DLT_RETURN_ERROR;
}
+
break;
}
- }
}
DLT_SEM_FREE();
/* Delayed injection callback call */
if ((delayed_inject_buffer != NULL) &&
- (delayed_injection_callback.injection_callback != NULL))
- {
+ (delayed_injection_callback.injection_callback != NULL)) {
delayed_injection_callback.injection_callback(delayed_injection_callback.service_id,
delayed_inject_buffer,
delayed_inject_data_length);
@@ -4673,6 +4317,7 @@ DltReturnValue dlt_user_log_check_user_message(void)
delayed_injection_callback.data);
delayed_injection_callback.injection_callback_with_id = NULL;
}
+
free(delayed_inject_buffer);
delayed_inject_buffer = NULL;
@@ -4681,54 +4326,48 @@ DltReturnValue dlt_user_log_check_user_message(void)
(sizeof(DltUserHeader) +
sizeof(DltUserControlMsgInjection) +
usercontextinj->data_length_inject)) != DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
}
}
break;
case DLT_USER_MESSAGE_LOG_STATE:
{
/* At least, user header, user context, and service id and data_length of injected message is available */
- if (receiver->bytesRcvd < (int32_t)(sizeof(DltUserHeader)+sizeof(DltUserControlMsgLogState)))
- {
+ if (receiver->bytesRcvd < (int32_t)(sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogState))) {
leave_while = 1;
break;
}
- userlogstate = (DltUserControlMsgLogState*) (receiver->buf+sizeof(DltUserHeader));
+ userlogstate = (DltUserControlMsgLogState *)(receiver->buf + sizeof(DltUserHeader));
dlt_user.log_state = userlogstate->log_state;
/* keep not read data in buffer */
- if (dlt_receiver_remove(receiver,(sizeof(DltUserHeader)+sizeof(DltUserControlMsgLogState))) == DLT_RETURN_ERROR)
- {
+ if (dlt_receiver_remove(receiver,
+ (sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogState))) ==
+ DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- }
}
- break;
+ break;
default:
{
- dlt_log(LOG_WARNING,"Invalid user message type received!\n");
+ dlt_log(LOG_WARNING, "Invalid user message type received!\n");
/* Ignore result */
- dlt_receiver_remove(receiver,sizeof(DltUserHeader));
+ dlt_receiver_remove(receiver, sizeof(DltUserHeader));
/* In next invocation of while loop, a resync will be triggered if additional data was received */
}
break;
} /* switch() */
- if (leave_while==1)
- {
- leave_while=0;
+ if (leave_while == 1) {
+ leave_while = 0;
break;
}
-
} /* while buffer*/
if (dlt_receiver_move_to_begin(receiver) == DLT_RETURN_ERROR)
- {
return DLT_RETURN_ERROR;
- }
} /* while receive */
+
} /* if */
return DLT_RETURN_OK;
@@ -4736,13 +4375,13 @@ DltReturnValue dlt_user_log_check_user_message(void)
DltReturnValue dlt_user_log_resend_buffer(void)
{
- int num,count;
+ int num, count;
int size;
DltReturnValue ret;
DLT_SEM_LOCK();
- if (dlt_user.appID[0]=='\0')
- {
+
+ if (dlt_user.appID[0] == '\0') {
DLT_SEM_FREE();
return 0;
}
@@ -4751,72 +4390,77 @@ DltReturnValue dlt_user_log_resend_buffer(void)
count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
DLT_SEM_FREE();
- for (num=0;num<count;num++)
- {
+ for (num = 0; num < count; num++) {
DLT_SEM_LOCK();
- size = dlt_buffer_copy(&(dlt_user.startup_buffer),dlt_user.resend_buffer,dlt_user.log_buf_len);
-
- if (size>0)
- {
- DltUserHeader *userheader = (DltUserHeader*) (dlt_user.resend_buffer);
- /* Add application id to the messages of needed*/
- if (dlt_user_check_userheader(userheader))
- {
- switch (userheader->message)
+ size = dlt_buffer_copy(&(dlt_user.startup_buffer), dlt_user.resend_buffer, dlt_user.log_buf_len);
+
+ if (size > 0) {
+ DltUserHeader *userheader = (DltUserHeader *)(dlt_user.resend_buffer);
+
+ /* Add application id to the messages of needed*/
+ if (dlt_user_check_userheader(userheader)) {
+ switch (userheader->message) {
+ case DLT_USER_MESSAGE_REGISTER_CONTEXT:
{
- case DLT_USER_MESSAGE_REGISTER_CONTEXT:
- {
- DltUserControlMsgRegisterContext *usercontext = (DltUserControlMsgRegisterContext*) (dlt_user.resend_buffer+sizeof(DltUserHeader));
- if ((usercontext != 0) && (usercontext->apid[0]=='\0'))
- {
- dlt_set_id(usercontext->apid,dlt_user.appID);
- }
- break;
- }
- case DLT_USER_MESSAGE_LOG:
- {
- DltExtendedHeader * extendedHeader = (DltExtendedHeader *)(dlt_user.resend_buffer+sizeof(DltUserHeader)+
- sizeof(DltStandardHeader)+sizeof(DltStandardHeaderExtra));
- if ((extendedHeader) != 0 && (extendedHeader->apid[0]=='\0'))
- { // if application id is empty, add it
- dlt_set_id(extendedHeader->apid,dlt_user.appID);
- }
- break;
- }
- default:
- {
- break;
- }
+ DltUserControlMsgRegisterContext *usercontext =
+ (DltUserControlMsgRegisterContext *)(dlt_user.resend_buffer + sizeof(DltUserHeader));
+
+ if ((usercontext != 0) && (usercontext->apid[0] == '\0'))
+ dlt_set_id(usercontext->apid, dlt_user.appID);
+
+ break;
+ }
+ case DLT_USER_MESSAGE_LOG:
+ {
+ DltExtendedHeader *extendedHeader =
+ (DltExtendedHeader *)(dlt_user.resend_buffer + sizeof(DltUserHeader) +
+ sizeof(DltStandardHeader) +
+ sizeof(DltStandardHeaderExtra));
+
+ if (((extendedHeader) != 0) && (extendedHeader->apid[0] == '\0')) /* if application id is empty, add it */
+ dlt_set_id(extendedHeader->apid, dlt_user.appID);
+
+ break;
+ }
+ default:
+ {
+ break;
+ }
}
}
#ifdef DLT_SHM_ENABLE
- dlt_shm_push(&dlt_user.dlt_shm, dlt_user.resend_buffer+sizeof(DltUserHeader), size-sizeof(DltUserHeader), 0, 0, 0, 0);
-
- ret = dlt_user_log_out3(dlt_user.dlt_log_handle, dlt_user.resend_buffer,sizeof(DltUserHeader), 0, 0, 0, 0);
+ dlt_shm_push(&dlt_user.dlt_shm,
+ dlt_user.resend_buffer + sizeof(DltUserHeader),
+ size - sizeof(DltUserHeader),
+ 0,
+ 0,
+ 0,
+ 0);
+
+ ret = dlt_user_log_out3(dlt_user.dlt_log_handle, dlt_user.resend_buffer, sizeof(DltUserHeader), 0, 0, 0, 0);
#else
- ret = dlt_user_log_out3(dlt_user.dlt_log_handle, dlt_user.resend_buffer,size, 0, 0, 0, 0);
+ ret = dlt_user_log_out3(dlt_user.dlt_log_handle, dlt_user.resend_buffer, size, 0, 0, 0, 0);
#endif
/* in case of error, keep message in ringbuffer */
- if (ret == DLT_RETURN_OK)
- {
+ if (ret == DLT_RETURN_OK) {
dlt_buffer_remove(&(dlt_user.startup_buffer));
}
- else
- {
- if (ret == DLT_RETURN_PIPE_ERROR)
- {
+ else {
+ if (ret == DLT_RETURN_PIPE_ERROR) {
/* handle not open or pipe error */
close(dlt_user.dlt_log_handle);
dlt_user.dlt_log_handle = -1;
}
+
/* keep message in ringbuffer */
DLT_SEM_FREE();
return ret;
}
}
+
DLT_SEM_FREE();
}
@@ -4829,92 +4473,81 @@ void dlt_user_log_reattach_to_daemon(void)
DltContext handle;
DltContextData log_new;
- if (dlt_user.dlt_log_handle<0)
- {
- dlt_user.dlt_log_handle=-1;
+ if (dlt_user.dlt_log_handle < 0) {
+ dlt_user.dlt_log_handle = -1;
#ifdef DLT_USE_UNIX_SOCKET_IPC
/* try to open connection to dlt daemon */
dlt_initialize_socket_connection();
+
if (dlt_user.connection_state != DLT_USER_CONNECTED)
- {
/* return if not connected */
return;
- }
#else
/* try to open pipe to dlt daemon */
int fd = open(dlt_daemon_fifo, O_WRONLY | O_NONBLOCK);
if (fd < 0)
- {
return;
- }
dlt_user.dlt_log_handle = fd;
#endif
- if (dlt_user_log_init(&handle,&log_new) < DLT_RETURN_OK)
- {
+
+ if (dlt_user_log_init(&handle, &log_new) < DLT_RETURN_OK)
return;
- }
#ifdef DLT_SHM_ENABLE
+
/* init shared memory */
- if (dlt_shm_init_client(&dlt_user.dlt_shm,DLT_SHM_KEY) < 0)
- {
- dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Loging disabled, Shared memory %d cannot be created!\n", DLT_SHM_KEY);
- //return DLT_RETURN_OK;
- }
+ if (dlt_shm_init_client(&dlt_user.dlt_shm, DLT_SHM_KEY) < 0)
+ dlt_vnlog(LOG_WARNING,
+ DLT_USER_BUFFER_LENGTH,
+ "Loging disabled, Shared memory %d cannot be created!\n",
+ DLT_SHM_KEY);
+ /*return DLT_RETURN_OK; */
+
#endif
dlt_log(LOG_NOTICE, "Logging (re-)enabled!\n");
/* Re-register application */
if (dlt_user_log_send_register_application() < DLT_RETURN_ERROR)
- {
return;
- }
DLT_SEM_LOCK();
/* Re-register all stored contexts */
- for (num=0; num<dlt_user.dlt_ll_ts_num_entries; num++)
- {
+ for (num = 0; num < dlt_user.dlt_ll_ts_num_entries; num++)
/* Re-register stored context */
- if ((dlt_user.appID[0]!='\0') && (dlt_user.dlt_ll_ts) && (dlt_user.dlt_ll_ts[num].contextID[0]!='\0'))
- {
- //dlt_set_id(log_new.appID, dlt_user.appID);
+ if ((dlt_user.appID[0] != '\0') && (dlt_user.dlt_ll_ts) && (dlt_user.dlt_ll_ts[num].contextID[0] != '\0')) {
+ /*dlt_set_id(log_new.appID, dlt_user.appID); */
dlt_set_id(handle.contextID, dlt_user.dlt_ll_ts[num].contextID);
handle.log_level_pos = num;
log_new.context_description = dlt_user.dlt_ll_ts[num].context_description;
- // Release the mutex for sending context registration:
- // function dlt_user_log_send_register_context() can take the mutex to write to the DLT buffer. => dead lock
+ /* Release the mutex for sending context registration: */
+ /* function dlt_user_log_send_register_context() can take the mutex to write to the DLT buffer. => dead lock */
DLT_SEM_FREE();
log_new.log_level = DLT_USER_LOG_LEVEL_NOT_SET;
log_new.trace_status = DLT_USER_TRACE_STATUS_NOT_SET;
if (dlt_user_log_send_register_context(&log_new) < DLT_RETURN_ERROR)
- {
return;
- }
- reregistered=1;
+ reregistered = 1;
- // Lock again the mutex
- // it is necessary in the for(;;) test, in order to have coherent dlt_user data all over the critical section.
+ /* Lock again the mutex */
+ /* it is necessary in the for(;;) test, in order to have coherent dlt_user data all over the critical section. */
DLT_SEM_LOCK();
}
- }
DLT_SEM_FREE();
- if (reregistered==1)
- {
+ if (reregistered == 1)
dlt_user_log_resend_buffer();
- }
}
}
@@ -4925,27 +4558,23 @@ DltReturnValue dlt_user_log_send_overflow(void)
/* set userheader */
if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_OVERFLOW) < DLT_RETURN_OK)
- {
return DLT_RETURN_ERROR;
- }
if (dlt_user.dlt_is_file)
- {
return DLT_RETURN_OK;
- }
/* set user message parameters */
userpayload.overflow_counter = dlt_user.overflow_counter;
- dlt_set_id(userpayload.apid,dlt_user.appID);
+ dlt_set_id(userpayload.apid, dlt_user.appID);
return dlt_user_log_out2(dlt_user.dlt_log_handle,
- &(userheader), sizeof(DltUserHeader),
- &(userpayload), sizeof(DltUserControlMsgBufferOverflow));
+ &(userheader), sizeof(DltUserHeader),
+ &(userpayload), sizeof(DltUserControlMsgBufferOverflow));
}
DltReturnValue dlt_user_check_buffer(int *total_size, int *used_size)
{
- if(total_size == NULL || used_size == NULL)
+ if ((total_size == NULL) || (used_size == NULL))
return DLT_RETURN_WRONG_PARAMETER;
DLT_SEM_LOCK();
@@ -4967,7 +4596,7 @@ void dlt_user_test_corrupt_user_header(int enable)
{
dlt_user.corrupt_user_header = enable;
}
-void dlt_user_test_corrupt_message_size(int enable,int16_t size)
+void dlt_user_test_corrupt_message_size(int enable, int16_t size)
{
dlt_user.corrupt_message_size = enable;
dlt_user.corrupt_message_size_size = size;
@@ -4979,18 +4608,16 @@ int dlt_start_threads()
{
/* Start receiver thread */
if (pthread_create(&(dlt_receiverthread_handle),
- 0,
- (void *) &dlt_user_receiverthread_function,
- 0) != 0)
- {
+ 0,
+ (void *)&dlt_user_receiverthread_function,
+ 0) != 0) {
dlt_log(LOG_CRIT, "Can't create receiver thread!\n");
return -1;
}
/* Start the segmented thread */
if (pthread_create(&(dlt_user.dlt_segmented_nwt_handle), NULL,
- (void *) dlt_user_trace_network_segmented_thread, NULL))
- {
+ (void *)dlt_user_trace_network_segmented_thread, NULL)) {
dlt_log(LOG_CRIT, "Can't start segmented thread!\n");
return -1;
}
@@ -5002,55 +4629,54 @@ void dlt_stop_threads()
{
int dlt_receiverthread_result = 0;
int dlt_segmented_nwt_result = 0;
- if (dlt_receiverthread_handle)
- {
+
+ if (dlt_receiverthread_handle) {
/* do not ignore return value */
dlt_receiverthread_result = pthread_cancel(dlt_receiverthread_handle);
- if (dlt_receiverthread_result != 0)
- {
+
+ if (dlt_receiverthread_result != 0) {
snprintf(str, DLT_USER_BUFFER_LENGTH,
- "ERROR pthread_cancel(dlt_receiverthread_handle): %s\n",
- strerror(errno));
+ "ERROR pthread_cancel(dlt_receiverthread_handle): %s\n",
+ strerror(errno));
dlt_log(LOG_ERR, str);
}
}
- if (dlt_user.dlt_segmented_nwt_handle)
- {
+ if (dlt_user.dlt_segmented_nwt_handle) {
dlt_segmented_nwt_result = pthread_cancel(dlt_user.dlt_segmented_nwt_handle);
- if (dlt_segmented_nwt_result != 0)
- {
+
+ if (dlt_segmented_nwt_result != 0) {
snprintf(str, DLT_USER_BUFFER_LENGTH,
- "ERROR pthread_cancel(dlt_user.dlt_segmented_nwt_handle): %s\n",
- strerror(errno));
+ "ERROR pthread_cancel(dlt_user.dlt_segmented_nwt_handle): %s\n",
+ strerror(errno));
dlt_log(LOG_ERR, str);
}
}
/* make sure that the threads really finished working */
- if ((dlt_receiverthread_result == 0) && dlt_receiverthread_handle)
- {
+ if ((dlt_receiverthread_result == 0) && dlt_receiverthread_handle) {
int joined = pthread_join(dlt_receiverthread_handle, NULL);
- if (joined < 0)
- {
+
+ if (joined < 0) {
snprintf(str, DLT_USER_BUFFER_LENGTH,
- "ERROR pthread_join(dlt_receiverthread_handle, NULL): %s\n",
- strerror(errno));
+ "ERROR pthread_join(dlt_receiverthread_handle, NULL): %s\n",
+ strerror(errno));
dlt_log(LOG_ERR, str);
}
+
dlt_receiverthread_handle = 0; /* set to invalid */
}
- if ((dlt_segmented_nwt_result == 0) && dlt_user.dlt_segmented_nwt_handle)
- {
+ if ((dlt_segmented_nwt_result == 0) && dlt_user.dlt_segmented_nwt_handle) {
int joined = pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL);
- if (joined < 0)
- {
+
+ if (joined < 0) {
snprintf(str, DLT_USER_BUFFER_LENGTH,
- "ERROR pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL): %s\n",
- strerror(errno));
+ "ERROR pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL): %s\n",
+ strerror(errno));
dlt_log(LOG_ERR, str);
}
+
dlt_user.dlt_segmented_nwt_handle = 0; /* set to invalid */
}
}
@@ -5062,13 +4688,11 @@ static void dlt_fork_pre_fork_handler()
static void dlt_fork_parent_fork_handler()
{
- if (dlt_user_initialised)
- {
- if (dlt_start_threads() < 0)
- {
+ if (dlt_user_initialised) {
+ if (dlt_start_threads() < 0) {
snprintf(str, DLT_USER_BUFFER_LENGTH,
- "Logging disabled, failed re-start thread after fork(pid=%i)!\n",
- getpid());
+ "Logging disabled, failed re-start thread after fork(pid=%i)!\n",
+ getpid());
dlt_log(LOG_WARNING, str);
/* cleanup is the only thing we can do here */
dlt_log_free();
@@ -5079,17 +4703,17 @@ static void dlt_fork_parent_fork_handler()
static void dlt_fork_child_fork_handler()
{
- if (dlt_user_initialised)
- {
- /* don't start anything else but cleanup everything and avoid blow-out of buffers*/
- dlt_user.dlt_log_handle = -1;
- dlt_log_free();
- dlt_free();
- /* the only thing that remains is the atexit-handler */
- }
+ if (dlt_user_initialised) {
+ /* don't start anything else but cleanup everything and avoid blow-out of buffers*/
+ dlt_user.dlt_log_handle = -1;
+ dlt_log_free();
+ dlt_free();
+ /* the only thing that remains is the atexit-handler */
+ }
}
-DltReturnValue dlt_user_log_out_error_handling(void *ptr1, size_t len1, void* ptr2, size_t len2, void *ptr3, size_t len3)
+DltReturnValue dlt_user_log_out_error_handling(void *ptr1, size_t len1, void *ptr2, size_t len2, void *ptr3,
+ size_t len3)
{
int ret = DLT_RETURN_ERROR;
int msg_size = len1 + len2 + len3;
@@ -5099,17 +4723,17 @@ DltReturnValue dlt_user_log_out_error_handling(void *ptr1, size_t len1, void* pt
DLT_SEM_FREE();
DLT_SEM_LOCK();
+
if (dlt_buffer_push3(&(dlt_user.startup_buffer),
ptr1, len1,
ptr2, len2,
- ptr3, len3) == DLT_RETURN_ERROR)
- {
- if(dlt_user.overflow_counter == 0)
- {
- dlt_log(LOG_WARNING,"Buffer full! Messages will be discarded.\n");
- }
+ ptr3, len3) == DLT_RETURN_ERROR) {
+ if (dlt_user.overflow_counter == 0)
+ dlt_log(LOG_WARNING, "Buffer full! Messages will be discarded.\n");
+
ret = DLT_RETURN_BUFFER_FULL;
}
+
DLT_SEM_FREE();
return ret;
diff --git a/src/lib/dlt_user_cfg.h b/src/lib/dlt_user_cfg.h
index 83fa157..5e43ee0 100644
--- a/src/lib/dlt_user_cfg.h
+++ b/src/lib/dlt_user_cfg.h
@@ -89,7 +89,7 @@
#define DLT_USER_BUFFER_LENGTH 255
/* Number of context entries, which will be allocated,
- if no more context entries are available */
+ * if no more context entries are available */
#define DLT_USER_CONTEXT_ALLOC_SIZE 500
/* Maximu length of a filename string */
diff --git a/src/offlinelogstorage/dlt_offline_logstorage.c b/src/offlinelogstorage/dlt_offline_logstorage.c
index 42fcfcb..8571b7a 100644
--- a/src/offlinelogstorage/dlt_offline_logstorage.c
+++ b/src/offlinelogstorage/dlt_offline_logstorage.c
@@ -54,27 +54,22 @@ DLT_STATIC void dlt_logstorage_filter_config_free(DltLogStorageFilterConfig *dat
free(data->file_name);
data->file_name = NULL;
- if (data->ecuid != NULL)
- {
+ if (data->ecuid != NULL) {
free(data->ecuid);
data->ecuid = NULL;
}
if (data->log != NULL)
- {
fclose(data->log);
- }
- if (data->cache != NULL)
- {
+ if (data->cache != NULL) {
free(data->cache);
data->cache = NULL;
}
n = data->records;
- while (n)
- {
+ while (n) {
n1 = n;
n = n->next;
free(n1->name);
@@ -91,17 +86,16 @@ DLT_STATIC int dlt_logstorage_list_destroy(DltLogStorageFilterList **list,
DltLogStorageUserConfig *uconfig = NULL;
char *dev_path = NULL;
- while (*(list) != NULL)
- {
+ while (*(list) != NULL) {
tmp = *list;
*list = (*list)->next;
- if (tmp->key != NULL)
- {
+
+ if (tmp->key != NULL) {
free(tmp->key);
tmp->key = NULL;
}
- if (tmp->data != NULL)
- {
+
+ if (tmp->data != NULL) {
/* sync data if necessary */
/* ignore return value */
tmp->data->dlt_logstorage_sync(tmp->data,
@@ -114,6 +108,7 @@ DLT_STATIC int dlt_logstorage_list_destroy(DltLogStorageFilterList **list,
free(tmp->data);
tmp->data = NULL;
}
+
free(tmp);
tmp = NULL;
}
@@ -125,9 +120,7 @@ DLT_STATIC int dlt_logstorage_list_add_config(DltLogStorageFilterConfig *data,
DltLogStorageFilterConfig **listdata)
{
if (*(listdata) == NULL)
- {
return -1;
- }
(*listdata)->apids = NULL;
(*listdata)->ctids = NULL;
@@ -141,24 +134,16 @@ DLT_STATIC int dlt_logstorage_list_add_config(DltLogStorageFilterConfig *data,
memcpy(*listdata, data, sizeof(DltLogStorageFilterConfig));
if (data->apids != NULL)
- {
(*listdata)->apids = strdup(data->apids);
- }
if (data->ctids != NULL)
- {
(*listdata)->ctids = strdup(data->ctids);
- }
if (data->file_name != NULL)
- {
(*listdata)->file_name = strdup(data->file_name);
- }
if (data->ecuid != NULL)
- {
(*listdata)->ecuid = strdup(data->ecuid);
- }
return 0;
}
@@ -169,33 +154,28 @@ DLT_STATIC int dlt_logstorage_list_add(char *key,
{
DltLogStorageFilterList *tmp = NULL;
- while (*(list) != NULL)
- {
+ while (*(list) != NULL) {
/* if the key is already present then the data should be updated */
- if (strncmp((*list)->key, key, DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN) == 0)
- {
+ if (strncmp((*list)->key, key, DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN) == 0) {
if (dlt_logstorage_list_add_config(data, &((*list)->data)) != 0)
- {
return -1;
- }
+
return 0;
}
+
list = &(*list)->next;
}
tmp = calloc(1, sizeof(DltLogStorageFilterList));
if (tmp == NULL)
- {
return -1;
- }
tmp->key = strdup(key);
tmp->next = NULL;
tmp->data = calloc(1, sizeof(DltLogStorageFilterConfig));
- if (tmp->data == NULL)
- {
+ if (tmp->data == NULL) {
free(tmp->key);
free(tmp);
tmp->key = NULL;
@@ -203,8 +183,7 @@ DLT_STATIC int dlt_logstorage_list_add(char *key,
return -1;
}
- if (dlt_logstorage_list_add_config(data, &(tmp->data)) != 0)
- {
+ if (dlt_logstorage_list_add_config(data, &(tmp->data)) != 0) {
free(tmp->key);
free(tmp->data);
free(tmp);
@@ -222,16 +201,11 @@ DLT_STATIC int dlt_logstorage_list_add(char *key,
DLT_STATIC void *dlt_logstorage_list_find(char *key,
DltLogStorageFilterList **list)
{
- while (*(list) != NULL)
- {
+ while (*(list) != NULL) {
if (strncmp((*list)->key, key, DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN) == 0)
- {
return (*list)->data;
- }
else
- {
list = &(*list)->next;
- }
}
return NULL;
@@ -243,21 +217,16 @@ DLT_STATIC int dlt_logstorage_count_ids(const char *str)
{
if (str == NULL)
- {
return -1;
- }
- // delimiter is: ","
+ /* delimiter is: "," */
const char *p = str;
int i = 0;
int num = 1;
- while (p[i] != 0)
- {
+ while (p[i] != 0) {
if (p[i] == ',')
- {
num++;
- }
i++;
}
@@ -276,8 +245,7 @@ DLT_STATIC int dlt_logstorage_count_ids(const char *str)
*/
void dlt_logstorage_free(DltLogStorage *handle, int reason)
{
- if (handle == NULL)
- {
+ if (handle == NULL) {
dlt_vlog(LOG_ERR, "%s failed: handle is NULL\n", __func__);
return;
}
@@ -310,13 +278,10 @@ DLT_STATIC int dlt_logstorage_read_list_of_names(char **names, char *value)
int num = 1;
if ((names == NULL) || (value == NULL))
- {
return -1;
- }
/* free, alloce'd memory to store new apid/ctid */
- if (*names != NULL)
- {
+ if (*names != NULL) {
free(*names);
*names = NULL;
}
@@ -324,35 +289,29 @@ DLT_STATIC int dlt_logstorage_read_list_of_names(char **names, char *value)
len = strlen(value);
if (len == 0)
- {
return -1;
- }
/* count number of delimiters to get actual number off names */
num = dlt_logstorage_count_ids(value);
/* need to alloc space for 5 chars, 4 for the name and "," and "\0" */
*names = (char *)calloc(num * 5, sizeof(char));
+
if (*names == NULL)
- {
return -1;
- }
tok = strtok(value, ",");
i = 1;
- while (tok != NULL)
- {
+ while (tok != NULL) {
len = strlen(tok);
len = DLT_OFFLINE_LOGSTORAGE_MIN(len, 4);
strncpy((*names + y), tok, len);
if ((num > 1) && (i < num))
- {
strncpy((*names + y + len), ",", 1);
- }
y += len + 1;
@@ -383,32 +342,26 @@ DLT_STATIC int dlt_logstorage_read_number(unsigned int *number, char *value)
unsigned long size = 0;
if (value == NULL)
- {
return -1;
- }
*number = 0;
len = strlen(value);
/* check if string consists of digits only */
- for (i = 0 ; i < len ; i++)
- {
- if (isdigit(value[i] == 0))
- {
+ for (i = 0; i < len; i++)
+ if (isdigit(value[i] == 0)) {
dlt_log(LOG_ERR, "Invalid, is not a number \n");
return -1;
}
- }
size = strtoul(value, NULL, 10);
- if ((size == 0) || (size > UINT_MAX))
- {
+ if ((size == 0) || (size > UINT_MAX)) {
dlt_log(LOG_ERR, "Invalid, is not a number \n");
return -1;
}
- *number = (unsigned int) size;
+ *number = (unsigned int)size;
return 0;
}
@@ -426,7 +379,7 @@ DLT_STATIC int dlt_logstorage_read_number(unsigned int *number, char *value)
* @return: 0 on success, error on failure*
*/
DLT_STATIC int dlt_logstorage_get_keys_list(char *ids, char *sep, char **list,
- int *numids)
+ int *numids)
{
char *token = NULL;
char *tmp_token = NULL;
@@ -436,38 +389,38 @@ DLT_STATIC int dlt_logstorage_get_keys_list(char *ids, char *sep, char **list,
/* Duplicate the ids passed for using in strtok_r() */
ids_local = strdup(ids);
+
if (ids_local == NULL)
- {
return -1;
- }
token = strtok_r(ids_local, sep, &tmp_token);
- if (token == NULL)
- {
+
+ if (token == NULL) {
free(ids_local);
return -1;
}
- *list = (char *) calloc(DLT_OFFLINE_LOGSTORAGE_MAXIDS * (DLT_ID_SIZE + 1),
- sizeof(char));
- if (*(list) == NULL)
- {
+
+ *list = (char *)calloc(DLT_OFFLINE_LOGSTORAGE_MAXIDS * (DLT_ID_SIZE + 1),
+ sizeof(char));
+
+ if (*(list) == NULL) {
free(ids_local);
return -1;
}
- while (token != NULL )
- {
+ while (token != NULL) {
/* If it reached the max then other ids are ignored */
- if (*numids >= DLT_OFFLINE_LOGSTORAGE_MAXIDS)
- {
+ if (*numids >= DLT_OFFLINE_LOGSTORAGE_MAXIDS) {
free(ids_local);
return 0;
}
+
strncpy(((*list) + ((*numids) * (DLT_ID_SIZE + 1))), token,
DLT_ID_SIZE);
*numids = *numids + 1;
token = strtok_r(NULL, sep, &tmp_token);
}
+
free(ids_local);
return 0;
@@ -485,20 +438,19 @@ DLT_STATIC int dlt_logstorage_get_keys_list(char *ids, char *sep, char **list,
* @return None
*/
DLT_STATIC void dlt_logstorage_create_keys_only_ctid(char *ecuid, char *ctid,
- char *key)
+ char *key)
{
char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 };
int curr_len = 0;
- if (ecuid != NULL)
- {
+ if (ecuid != NULL) {
strncpy(curr_str, ecuid, strlen(ecuid));
strncat(curr_str, "::", 2);
}
- else
- {
+ else {
strncpy(curr_str, "::", 2);
}
+
curr_len = strlen(ctid);
strncat(curr_str, ctid, curr_len);
curr_len = strlen(curr_str);
@@ -518,20 +470,19 @@ DLT_STATIC void dlt_logstorage_create_keys_only_ctid(char *ecuid, char *ctid,
* @return None
*/
DLT_STATIC void dlt_logstorage_create_keys_only_apid(char *ecuid, char *apid,
- char *key)
+ char *key)
{
char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 };
int curr_len = 0;
- if (ecuid != NULL)
- {
+ if (ecuid != NULL) {
strncpy(curr_str, ecuid, strlen(ecuid));
strncat(curr_str, ":", 1);
}
- else
- {
+ else {
strncpy(curr_str, ":", 1);
}
+
curr_len = strlen(apid);
strncat(curr_str, apid, curr_len);
strncat(curr_str, ":", 1);
@@ -553,20 +504,19 @@ DLT_STATIC void dlt_logstorage_create_keys_only_apid(char *ecuid, char *apid,
* @return None
*/
DLT_STATIC void dlt_logstorage_create_keys_multi(char *ecuid, char *apid,
- char *ctid, char *key)
+ char *ctid, char *key)
{
char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 };
int curr_len = 0;
- if (ecuid != NULL)
- {
+ if (ecuid != NULL) {
strncpy(curr_str, ecuid, strlen(ecuid));
strncat(curr_str, ":", 1);
}
- else
- {
+ else {
strncpy(curr_str, ":", 1);
}
+
curr_len = strlen(apid);
strncat(curr_str, apid, curr_len);
strncat(curr_str, ":", 1);
@@ -625,10 +575,10 @@ DLT_STATIC void dlt_logstorage_create_keys_only_ecu(char *ecuid, char *key)
* @return: 0 on success, error on failure*
*/
DLT_STATIC int dlt_logstorage_create_keys(char *apids,
- char *ctids,
- char *ecuid,
- char **keys,
- int *num_keys)
+ char *ctids,
+ char *ecuid,
+ char **keys,
+ int *num_keys)
{
int i, j;
int num_apids = 0;
@@ -641,35 +591,32 @@ DLT_STATIC int dlt_logstorage_create_keys(char *apids,
int num_currkey = 0;
/* Handle ecuid alone case here */
- if ((apids == NULL) && (ctids == NULL) && (ecuid != NULL))
- {
+ if ((apids == NULL) && (ctids == NULL) && (ecuid != NULL)) {
dlt_logstorage_create_keys_only_ecu(ecuid, curr_key);
*(num_keys) = 1;
- *(keys) = (char *) calloc(*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN,
- sizeof(char));
+ *(keys) = (char *)calloc(*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN,
+ sizeof(char));
+
if (*(keys) == NULL)
- {
return -1;
- }
+
strncpy(*keys, curr_key, strlen(curr_key));
return 0;
}
- if ((apids == NULL) || (ctids == NULL))
- {
- dlt_log(LOG_ERR,"Required inputs (apid and ctid) are NULL\n");
+ if ((apids == NULL) || (ctids == NULL)) {
+ dlt_log(LOG_ERR, "Required inputs (apid and ctid) are NULL\n");
return -1;
}
/* obtain key list and number of keys for application ids */
- if (dlt_logstorage_get_keys_list(apids, ",", &apid_list, &num_apids) != 0)
- {
+ if (dlt_logstorage_get_keys_list(apids, ",", &apid_list, &num_apids) != 0) {
dlt_log(LOG_ERR, "Failed to obtain appid, check configuration file \n");
return -1;
}
+
/* obtain key list and number of keys for context ids */
- if (dlt_logstorage_get_keys_list(ctids, ",", &ctid_list, &num_ctids) != 0)
- {
+ if (dlt_logstorage_get_keys_list(ctids, ",", &ctid_list, &num_ctids) != 0) {
dlt_log(LOG_ERR, "Failed to obtain ctid, check configuration file \n");
free(apid_list);
return -1;
@@ -678,40 +625,36 @@ DLT_STATIC int dlt_logstorage_create_keys(char *apids,
*(num_keys) = num_apids * num_ctids;
/* allocate memory for needed number of keys */
- *(keys) = (char *) calloc(*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN,
- sizeof(char));
- if (*(keys) == NULL)
- {
+ *(keys) = (char *)calloc(*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN,
+ sizeof(char));
+
+ if (*(keys) == NULL) {
free(apid_list);
free(ctid_list);
return -1;
}
/* store all combinations of apid ctid in keys */
- for (i = 0; i < num_apids; i++)
- {
+ for (i = 0; i < num_apids; i++) {
curr_apid = apid_list + (i * (DLT_ID_SIZE + 1));
- for (j = 0; j < num_ctids; j++)
- {
+
+ for (j = 0; j < num_ctids; j++) {
curr_ctid = ctid_list + (j * (DLT_ID_SIZE + 1));
+
if (strncmp(curr_apid, ".*", 2) == 0) /* only context id matters */
- {
dlt_logstorage_create_keys_only_ctid(ecuid, curr_ctid, curr_key);
- }
else if (strncmp(curr_ctid, ".*", 2) == 0) /* only app id matters*/
- {
dlt_logstorage_create_keys_only_apid(ecuid, curr_apid, curr_key);
- }
else /* key is combination of all */
- {
dlt_logstorage_create_keys_multi(ecuid, curr_apid, curr_ctid, curr_key);
- }
+
strncpy((*keys + (num_currkey * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)),
curr_key, strlen(curr_key));
num_currkey += 1;
memset(&curr_key[0], 0, sizeof(curr_key));
}
}
+
free(apid_list);
free(ctid_list);
@@ -728,15 +671,14 @@ DLT_STATIC int dlt_logstorage_create_keys(char *apids,
* @return 0 on success, -1 on error
*/
DLT_STATIC int dlt_logstorage_prepare_table(DltLogStorage *handle,
- DltLogStorageFilterConfig *data)
+ DltLogStorageFilterConfig *data)
{
int ret = 0;
int num_keys = 0;
char *keys = NULL;
int idx = 0;
- if ((handle == NULL) || (data == NULL))
- {
+ if ((handle == NULL) || (data == NULL)) {
dlt_vlog(LOG_ERR, "Invalid parameters in %s\n", __func__);
return -1;
}
@@ -747,19 +689,16 @@ DLT_STATIC int dlt_logstorage_prepare_table(DltLogStorage *handle,
&keys,
&num_keys);
- if (ret != 0)
- {
+ if (ret != 0) {
dlt_log(LOG_ERR, "Not able to create keys for hash table\n");
return -1;
}
/* hash_add */
- for (idx = 0 ; idx < num_keys ; idx++)
- {
+ for (idx = 0; idx < num_keys; idx++) {
if (dlt_logstorage_list_add(keys + (idx * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN),
data,
- &(handle->config_list)) != 0)
- {
+ &(handle->config_list)) != 0) {
dlt_log(LOG_ERR,
"Adding to hash table failed, returning failure\n");
@@ -795,78 +734,61 @@ DLT_STATIC int dlt_logstorage_validate_filter_name(char *name)
int control_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION);
if (name == NULL)
- {
return -1;
- }
len = strlen(name);
-
+
/* Check if section header is of format "FILTER" followed by a number */
if (strncmp(name,
DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION,
- config_sec_len) == 0)
- {
+ config_sec_len) == 0) {
for (idx = config_sec_len; idx < len - 1; idx++)
- {
if (!isdigit(name[idx]))
- {
return -1;
- }
- }
+
return 0;
}
/* Check if section header is of format "FILTER" followed by a number */
else if (strncmp(name,
- DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION,
- storage_sec_len) == 0)
+ DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION,
+ storage_sec_len) == 0)
{
for (idx = storage_sec_len; idx < len - 1; idx++)
- {
if (!isdigit(name[idx]))
- {
return -1;
- }
- }
+
return 0;
}
/* Check if section header is of format "FILTER" followed by a number */
else if (strncmp(name,
- DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION,
- control_sec_len) == 0)
+ DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION,
+ control_sec_len) == 0)
{
for (idx = control_sec_len; idx < len - 1; idx++)
- {
if (!isdigit(name[idx]))
- {
return -1;
- }
- }
+
return 0;
}
- else
- {
+ else {
return -1;
}
}
DLT_STATIC void dlt_logstorage_filter_set_strategy(DltLogStorageFilterConfig *config,
- int strategy)
+ int strategy)
{
if (config == NULL)
- {
return;
- }
/* file based */
if ((strategy == DLT_LOGSTORAGE_SYNC_ON_MSG) ||
- (strategy == DLT_LOGSTORAGE_SYNC_UNSET))
- {
+ (strategy == DLT_LOGSTORAGE_SYNC_UNSET)) {
config->dlt_logstorage_prepare = &dlt_logstorage_prepare_on_msg;
config->dlt_logstorage_write = &dlt_logstorage_write_on_msg;
config->dlt_logstorage_sync = &dlt_logstorage_sync_on_msg;
}
- else /* cache based */
- {
+ else { /* cache based */
config->dlt_logstorage_prepare = &dlt_logstorage_prepare_msg_cache;
config->dlt_logstorage_write = &dlt_logstorage_write_msg_cache;
config->dlt_logstorage_sync = &dlt_logstorage_sync_msg_cache;
@@ -874,10 +796,9 @@ DLT_STATIC void dlt_logstorage_filter_set_strategy(DltLogStorageFilterConfig *co
}
DLT_STATIC int dlt_logstorage_check_apids(DltLogStorageFilterConfig *config,
- char *value)
+ char *value)
{
- if ((config == NULL) || (value == NULL))
- {
+ if ((config == NULL) || (value == NULL)) {
dlt_log(LOG_ERR, "Not able to create keys for hash table\n");
return -1;
}
@@ -886,32 +807,26 @@ DLT_STATIC int dlt_logstorage_check_apids(DltLogStorageFilterConfig *config,
}
DLT_STATIC int dlt_logstorage_check_ctids(DltLogStorageFilterConfig *config,
- char *value)
+ char *value)
{
if ((config == NULL) || (value == NULL))
- {
return -1;
- }
return dlt_logstorage_read_list_of_names(&config->ctids, value);
}
DLT_STATIC int dlt_logstorage_check_loglevel(DltLogStorageFilterConfig *config,
- char *value)
+ char *value)
{
if ((config == NULL) || (value == NULL))
- {
return -1;
- }
- if (value == NULL)
- {
+ if (value == NULL) {
config->log_level = 0;
return -1;
}
- if (strcmp(value, "DLT_LOG_FATAL") == 0)
- {
+ if (strcmp(value, "DLT_LOG_FATAL") == 0) {
config->log_level = 1;
}
else if (strcmp(value, "DLT_LOG_ERROR") == 0)
@@ -934,8 +849,7 @@ DLT_STATIC int dlt_logstorage_check_loglevel(DltLogStorageFilterConfig *config,
{
config->log_level = 6;
}
- else
- {
+ else {
config->log_level = -1;
dlt_log(LOG_ERR, "Invalid log level \n");
return -1;
@@ -945,21 +859,17 @@ DLT_STATIC int dlt_logstorage_check_loglevel(DltLogStorageFilterConfig *config,
}
DLT_STATIC int dlt_logstorage_check_reset_loglevel(DltLogStorageFilterConfig *config,
- char *value)
+ char *value)
{
if (config == NULL)
- {
return -1;
- }
- if (value == NULL)
- {
+ if (value == NULL) {
config->reset_log_level = 0;
return -1;
}
- if (strcmp(value, "DLT_LOG_OFF") == 0)
- {
+ if (strcmp(value, "DLT_LOG_OFF") == 0) {
config->reset_log_level = DLT_LOG_OFF;
}
else if (strcmp(value, "DLT_LOG_FATAL") == 0)
@@ -986,8 +896,7 @@ DLT_STATIC int dlt_logstorage_check_reset_loglevel(DltLogStorageFilterConfig *co
{
config->reset_log_level = DLT_LOG_VERBOSE;
}
- else
- {
+ else {
config->reset_log_level = -1;
dlt_log(LOG_ERR, "Invalid log level \n");
return -1;
@@ -997,17 +906,14 @@ DLT_STATIC int dlt_logstorage_check_reset_loglevel(DltLogStorageFilterConfig *co
}
DLT_STATIC int dlt_logstorage_check_filename(DltLogStorageFilterConfig *config,
- char *value)
+ char *value)
{
int len;
if ((value == NULL) || (strcmp(value, "") == 0))
- {
return -1;
- }
- if (config->file_name != NULL)
- {
+ if (config->file_name != NULL) {
free(config->file_name);
config->file_name = NULL;
}
@@ -1015,19 +921,18 @@ DLT_STATIC int dlt_logstorage_check_filename(DltLogStorageFilterConfig *config,
len = strlen(value);
/* do not allow the user to change directory by adding a relative path */
- if (strstr(value, "..") == NULL)
- {
+ if (strstr(value, "..") == NULL) {
config->file_name = calloc((len + 1), sizeof(char));
- if (config->file_name == NULL)
- {
+
+ if (config->file_name == NULL) {
dlt_log(LOG_ERR,
"Cannot allocate memory for filename\n");
return -1;
}
+
strncpy(config->file_name, value, len);
}
- else
- {
+ else {
dlt_log(LOG_ERR,
"Invalid filename, paths not accepted due to security issues\n");
return -1;
@@ -1037,34 +942,29 @@ DLT_STATIC int dlt_logstorage_check_filename(DltLogStorageFilterConfig *config,
}
DLT_STATIC int dlt_logstorage_check_filesize(DltLogStorageFilterConfig *config,
- char *value)
+ char *value)
{
if ((config == NULL) || (value == NULL))
- {
return -1;
- }
return dlt_logstorage_read_number(&config->file_size, value);
}
DLT_STATIC int dlt_logstorage_check_nofiles(DltLogStorageFilterConfig *config,
- char *value)
+ char *value)
{
if ((config == NULL) || (value == NULL))
- {
return -1;
- }
return dlt_logstorage_read_number(&config->num_files, value);
}
DLT_STATIC int dlt_logstorage_check_specificsize(DltLogStorageFilterConfig *config,
- char *value)
+ char *value)
{
if ((config == NULL) || (value == NULL))
- {
return -1;
- }
+
return dlt_logstorage_read_number(&config->specific_size, value);
}
@@ -1081,47 +981,33 @@ DLT_STATIC int dlt_logstorage_check_specificsize(DltLogStorageFilterConfig *conf
* @return 0 on success, -1 on error
*/
DLT_STATIC int dlt_logstorage_check_sync_strategy(DltLogStorageFilterConfig *config,
- char *value)
+ char *value)
{
if ((config == NULL) || (value == NULL))
- {
return -1;
- }
- if (strcasestr(value, "ON_MSG") != NULL)
- {
+ if (strcasestr(value, "ON_MSG") != NULL) {
config->sync = DLT_LOGSTORAGE_SYNC_ON_MSG;
dlt_log(LOG_DEBUG, "ON_MSG found, ignore other if added\n");
}
- else /* ON_MSG not set, combination of cache based strategies possible */
- {
+ else { /* ON_MSG not set, combination of cache based strategies possible */
+
if (strcasestr(value, "ON_DAEMON_EXIT") != NULL)
- {
config->sync |= DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT;
- }
if (strcasestr(value, "ON_DEMAND") != NULL)
- {
config->sync |= DLT_LOGSTORAGE_SYNC_ON_DEMAND;
- }
if (strcasestr(value, "ON_DEVICE_DISCONNECT") != NULL)
- {
config->sync |= DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT;
- }
if (strcasestr(value, "ON_SPECIFIC_SIZE") != NULL)
- {
config->sync |= DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE;
- }
if (strcasestr(value, "ON_FILE_SIZE") != NULL)
- {
config->sync |= DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE;
- }
- if (config->sync == 0)
- {
+ if (config->sync == 0) {
dlt_log(LOG_WARNING,
"Unknown sync strategies. Set default ON_MSG\n");
config->sync = DLT_LOGSTORAGE_SYNC_ON_MSG;
@@ -1142,27 +1028,24 @@ DLT_STATIC int dlt_logstorage_check_sync_strategy(DltLogStorageFilterConfig *con
* @return 0 on success, -1 on error
*/
DLT_STATIC int dlt_logstorage_check_ecuid(DltLogStorageFilterConfig *config,
- char *value)
+ char *value)
{
int len;
if ((config == NULL) || (value == NULL) || (value[0] == '\0'))
- {
return -1;
- }
- if (config->ecuid != NULL)
- {
+ if (config->ecuid != NULL) {
free(config->ecuid);
config->ecuid = NULL;
}
len = strlen(value);
config->ecuid = calloc((len + 1), sizeof(char));
+
if (config->ecuid == NULL)
- {
return -1;
- }
+
strncpy(config->ecuid, value, len);
return 0;
@@ -1216,9 +1099,9 @@ DLT_STATIC DltLogstorageFilterConf
.is_opt = 1
},
[DLT_LOGSTORAGE_FILTER_CONF_SPECIFIC_SIZE] = {
- .key = "SpecificSize",
- .func = dlt_logstorage_check_specificsize,
- .is_opt = 1
+ .key = "SpecificSize",
+ .func = dlt_logstorage_check_specificsize,
+ .is_opt = 1
}
};
@@ -1271,14 +1154,14 @@ DLT_STATIC DltLogstorageFilterConf
.is_opt = 0
},
[DLT_LOGSTORAGE_FILTER_CONF_SPECIFIC_SIZE] = {
- .key = NULL,
- .func = dlt_logstorage_check_specificsize,
- .is_opt = 1
+ .key = NULL,
+ .func = dlt_logstorage_check_specificsize,
+ .is_opt = 1
}
};
DLT_STATIC DltLogstorageFilterConf
-filter_nonverbose_control_entries[DLT_LOGSTORAGE_FILTER_CONF_COUNT] = {
+ filter_nonverbose_control_entries[DLT_LOGSTORAGE_FILTER_CONF_COUNT] = {
[DLT_LOGSTORAGE_FILTER_CONF_LOGAPPNAME] = {
.key = "LogAppName",
.func = dlt_logstorage_check_apids,
@@ -1339,26 +1222,22 @@ filter_nonverbose_control_entries[DLT_LOGSTORAGE_FILTER_CONF_COUNT] = {
* @return 0 on success, -1 otherwise
*/
DLT_STATIC int dlt_logstorage_check_param(DltLogStorageFilterConfig *config,
- DltLogstorageFilterConfType ctype,
- char *value)
+ DltLogstorageFilterConfType ctype,
+ char *value)
{
if ((config == NULL) || (value == NULL))
- {
return -1;
- }
if (ctype < DLT_LOGSTORAGE_FILTER_CONF_COUNT)
- {
return filter_cfg_entries[ctype].func(config, value);
- }
return -1;
}
DLT_STATIC int dlt_logstorage_get_filter_value(DltConfigFile *config_file,
- char *sec_name,
- int index,
- char *value)
+ char *sec_name,
+ int index,
+ char *value)
{
int ret = 0;
int config_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION);
@@ -1366,38 +1245,31 @@ DLT_STATIC int dlt_logstorage_get_filter_value(DltConfigFile *config_file,
int control_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION);
if ((config_file == NULL) || (sec_name == NULL))
- {
return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
- }
/* Branch based on section name, no complete string compare needed */
if (strncmp(sec_name,
DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION,
- config_sec_len) == 0)
- {
- if (filter_cfg_entries[index].key != NULL)
- {
+ config_sec_len) == 0) {
+ if (filter_cfg_entries[index].key != NULL) {
ret = dlt_config_file_get_value(config_file, sec_name,
filter_cfg_entries[index].key,
value);
- if ((ret != 0) && (filter_cfg_entries[index].is_opt == 0))
- {
+ if ((ret != 0) && (filter_cfg_entries[index].is_opt == 0)) {
dlt_vlog(LOG_WARNING,
- "Invalid configuration in section: %s -> %s : %s\n",
- sec_name, filter_cfg_entries[index].key, value);
+ "Invalid configuration in section: %s -> %s : %s\n",
+ sec_name, filter_cfg_entries[index].key, value);
return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
}
- if ((ret != 0) && (filter_cfg_entries[index].is_opt == 1))
- {
+ if ((ret != 0) && (filter_cfg_entries[index].is_opt == 1)) {
dlt_vlog(LOG_DEBUG, "Optional parameter %s not specified\n",
- filter_cfg_entries[index].key);
+ filter_cfg_entries[index].key);
return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
}
}
- else
- {
+ else {
return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
}
}
@@ -1405,20 +1277,17 @@ DLT_STATIC int dlt_logstorage_get_filter_value(DltConfigFile *config_file,
DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION,
storage_sec_len) == 0)
{
- if (filter_nonverbose_storage_entries[index].key != NULL)
- {
+ if (filter_nonverbose_storage_entries[index].key != NULL) {
if (dlt_config_file_get_value(config_file, sec_name,
- filter_nonverbose_storage_entries[index].key, value) != 0)
- {
+ filter_nonverbose_storage_entries[index].key, value) != 0) {
dlt_vlog(LOG_WARNING,
- "Invalid configuration in section: %s -> %s : %s\n",
- sec_name, filter_nonverbose_storage_entries[index].key,
- value);
+ "Invalid configuration in section: %s -> %s : %s\n",
+ sec_name, filter_nonverbose_storage_entries[index].key,
+ value);
return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
}
}
- else
- {
+ else {
return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
}
}
@@ -1426,25 +1295,21 @@ DLT_STATIC int dlt_logstorage_get_filter_value(DltConfigFile *config_file,
DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION,
control_sec_len) == 0))
{
- if (filter_nonverbose_control_entries[index].key != NULL)
- {
+ if (filter_nonverbose_control_entries[index].key != NULL) {
if (dlt_config_file_get_value(config_file, sec_name,
- filter_nonverbose_control_entries[index].key, value) != 0)
- {
+ filter_nonverbose_control_entries[index].key, value) != 0) {
dlt_vlog(LOG_WARNING,
- "Invalid configuration in section: %s -> %s : %s\n",
- sec_name, filter_nonverbose_control_entries[index].key,
- value);
+ "Invalid configuration in section: %s -> %s : %s\n",
+ sec_name, filter_nonverbose_control_entries[index].key,
+ value);
return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
}
}
- else
- {
+ else {
return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
}
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Error: Section name not valid \n");
return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
}
@@ -1462,8 +1327,8 @@ DLT_STATIC int dlt_logstorage_setup_table(DltLogStorage *handle,
dlt_logstorage_filter_set_strategy(tmp_data, tmp_data->sync);
ret = dlt_logstorage_prepare_table(handle, tmp_data);
- if (ret != 0)
- {
+
+ if (ret != 0) {
dlt_vlog(LOG_ERR, "%s Error: Storing filter values failed\n",
__func__);
ret = DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR;
@@ -1472,23 +1337,21 @@ DLT_STATIC int dlt_logstorage_setup_table(DltLogStorage *handle,
return ret;
}
/*Return :
- DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR - On filter properties or value is not valid
- DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR - On error while storing in hash table
+ * DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR - On filter properties or value is not valid
+ * DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR - On error while storing in hash table
*/
DLT_STATIC int dlt_daemon_offline_setup_filter_properties(DltLogStorage *handle,
- DltConfigFile *config_file,
- char *sec_name)
+ DltConfigFile *config_file,
+ char *sec_name)
{
DltLogStorageFilterConfig tmp_data;
- char value[DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1] = {'\0'};
+ char value[DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1] = { '\0' };
int i = 0;
int ret = 0;
if ((handle == NULL) || (config_file == NULL) || (sec_name == NULL))
- {
return DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR;
- }
memset(&tmp_data, 0, sizeof(DltLogStorageFilterConfig));
tmp_data.apids = NULL;
@@ -1501,60 +1364,52 @@ DLT_STATIC int dlt_daemon_offline_setup_filter_properties(DltLogStorage *handle,
tmp_data.log = NULL;
tmp_data.cache = NULL;
- for (i = 0 ; i < DLT_LOGSTORAGE_FILTER_CONF_COUNT ; i++)
- {
+ for (i = 0; i < DLT_LOGSTORAGE_FILTER_CONF_COUNT; i++) {
ret = dlt_logstorage_get_filter_value(config_file, sec_name, i, value);
+
if (ret == DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR)
- {
return ret;
- }
if (ret == DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE)
- {
continue;
- }
/* check value and store temporary */
ret = dlt_logstorage_check_param(&tmp_data, i, value);
- if (ret != 0)
- {
- if (tmp_data.apids != NULL)
- {
+
+ if (ret != 0) {
+ if (tmp_data.apids != NULL) {
free(tmp_data.apids);
tmp_data.apids = NULL;
}
- if (tmp_data.ctids != NULL)
- {
+ if (tmp_data.ctids != NULL) {
free(tmp_data.ctids);
tmp_data.ctids = NULL;
}
- if (tmp_data.file_name != NULL)
- {
+ if (tmp_data.file_name != NULL) {
free(tmp_data.file_name);
tmp_data.file_name = NULL;
}
- if (tmp_data.ecuid != NULL)
- {
+ if (tmp_data.ecuid != NULL) {
free(tmp_data.ecuid);
tmp_data.ecuid = NULL;
}
-
+
return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
}
}
+
/* filter configuration is valid */
ret = dlt_logstorage_setup_table(handle, &tmp_data);
- if (ret != 0)
- {
+
+ if (ret != 0) {
dlt_vlog(LOG_ERR, "%s Error: Storing filter values failed\n",
__func__);
ret = DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR;
}
- else /* move to next free filter configuration, if no error occurred */
- {
+ else { /* move to next free filter configuration, if no error occurred */
handle->num_configs += 1;
/* free tmp_data */
@@ -1576,7 +1431,7 @@ DLT_STATIC int dlt_daemon_offline_setup_filter_properties(DltLogStorage *handle,
*
*/
DLT_STATIC int dlt_logstorage_store_filters(DltLogStorage *handle,
- char *config_file_name)
+ char *config_file_name)
{
DltConfigFile *config = NULL;
int sec = 0;
@@ -1586,43 +1441,38 @@ DLT_STATIC int dlt_logstorage_store_filters(DltLogStorage *handle,
* filter configuration is valid and stored */
int valid = -1;
- if (config_file_name == NULL)
- {
+ if (config_file_name == NULL) {
dlt_vlog(LOG_ERR, "%s unexpected parameter received\n", __func__);
return -1;
}
config = dlt_config_file_init(config_file_name);
- if (config == NULL)
- {
+ if (config == NULL) {
dlt_log(LOG_CRIT, "Failed to open filter configuration file\n");
return -1;
}
dlt_config_file_get_num_sections(config, &num_sec);
- for (sec = 0 ; sec < num_sec ; sec++)
- {
+ for (sec = 0; sec < num_sec; sec++) {
char sec_name[DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1];
- if (dlt_config_file_get_section_name(config, sec, sec_name) == -1)
- {
+ if (dlt_config_file_get_section_name(config, sec, sec_name) == -1) {
dlt_log(LOG_CRIT, "Failed to read section name\n");
dlt_config_file_release(config);
return -1;
}
- if (strstr(sec_name, GENERAL_BASE_NAME) != NULL)
- {
- dlt_log(LOG_CRIT, "General configuration not supported \n");
- continue;
+ if (strstr(sec_name, GENERAL_BASE_NAME) != NULL) {
+ dlt_log(LOG_CRIT, "General configuration not supported \n");
+ continue;
}
else if (dlt_logstorage_validate_filter_name(sec_name) == 0)
{
ret = dlt_daemon_offline_setup_filter_properties(handle, config, sec_name);
- if (ret == DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR)
- {
+
+ if (ret == DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR) {
break;
}
else if (ret == DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR)
@@ -1635,17 +1485,11 @@ DLT_STATIC int dlt_logstorage_store_filters(DltLogStorage *handle,
continue;
}
else
- {
- /* Filter properties read and stored successfuly */
- if (valid != 1)
- {
- valid = 0;
- }
-
- }
+ /* Filter properties read and stored successfuly */
+ if (valid != 1)
+ valid = 0;
}
- else /* unknown section */
- {
+ else { /* unknown section */
dlt_vlog(LOG_WARNING, "Unknown section: %s", sec_name);
}
}
@@ -1671,22 +1515,19 @@ DLT_STATIC int dlt_logstorage_store_filters(DltLogStorage *handle,
*/
DLT_STATIC int dlt_logstorage_load_config(DltLogStorage *handle)
{
- char config_file_name[PATH_MAX + 1] = {'\0'};
+ char config_file_name[PATH_MAX + 1] = { '\0' };
int ret = 0;
/* Check if handle is NULL or already initialized or already configured */
if ((handle == NULL) ||
(handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED))
- {
return -1;
- }
/* Check if this device config was already setup */
- if (handle->config_status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- {
+ if (handle->config_status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) {
dlt_vlog(LOG_ERR,
- "%s: Device already configured. Send disconnect first.\n",
- __func__);
+ "%s: Device already configured. Send disconnect first.\n",
+ __func__);
return -1;
}
@@ -1694,16 +1535,15 @@ DLT_STATIC int dlt_logstorage_load_config(DltLogStorage *handle)
PATH_MAX,
"%s/%s",
handle->device_mount_point,
- DLT_OFFLINE_LOGSTORAGE_CONFIG_FILE_NAME) < 0)
- {
+ DLT_OFFLINE_LOGSTORAGE_CONFIG_FILE_NAME) < 0) {
dlt_log(LOG_ERR,
"Creating configuration file path string failed\n");
return -1;
}
ret = dlt_logstorage_store_filters(handle, config_file_name);
- if (ret == 1)
- {
+
+ if (ret == 1) {
handle->config_status = DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE;
return 1;
}
@@ -1730,14 +1570,12 @@ DLT_STATIC int dlt_logstorage_load_config(DltLogStorage *handle)
*/
int dlt_logstorage_device_connected(DltLogStorage *handle, char *mount_point)
{
- if ((handle == NULL) || (mount_point == NULL))
- {
+ if ((handle == NULL) || (mount_point == NULL)) {
dlt_log(LOG_ERR, "Handle error \n");
return -1;
}
- if (handle->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
- {
+ if (handle->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) {
dlt_log(LOG_WARNING,
"Device already connected. Send disconnect, connect request\n");
@@ -1769,15 +1607,11 @@ int dlt_logstorage_device_connected(DltLogStorage *handle, char *mount_point)
int dlt_logstorage_device_disconnected(DltLogStorage *handle, int reason)
{
if (handle == NULL)
- {
return -1;
- }
/* If configuration loading was done, free it */
if (handle->config_status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- {
dlt_logstorage_free(handle, reason);
- }
/* Reset all device status */
memset(handle->device_mount_point, '\0', sizeof(char) * DLT_MOUNT_PATH_MAX);
@@ -1810,15 +1644,12 @@ int dlt_logstorage_get_loglevel_by_key(DltLogStorage *handle, char *key)
(key == NULL) ||
(handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
(handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
- {
return -1;
- }
config = (DltLogStorageFilterConfig *)
dlt_logstorage_list_find(key, &(handle->config_list));
- if (config == NULL)
- {
+ if (config == NULL) {
dlt_vlog(LOG_WARNING, "Configuration for key [%s] not found!\n", key);
return -1;
}
@@ -1847,7 +1678,8 @@ int dlt_logstorage_get_config(DltLogStorage *handle,
char *ecuid)
{
DltLogStorageFilterConfig *ptr_config = NULL;
- char key[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS][DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN] = {{'\0'}, {'\0'}, {'\0'}};
+ char key[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS][DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN] =
+ { { '\0' }, { '\0' }, { '\0' } };
int i = 0;
int apid_len = 0;
int ctid_len = 0;
@@ -1859,55 +1691,49 @@ int dlt_logstorage_get_config(DltLogStorage *handle,
(handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
(handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) ||
(ecuid == NULL))
- {
return 0;
- }
/* Prepare possible keys with
* Possible combinations are
* ecu::
- ecu:apid:ctid
- :apid:ctid
- ecu::ctid
- ecu:apid:
- ::ctid
- :apid: */
+ * ecu:apid:ctid
+ * :apid:ctid
+ * ecu::ctid
+ * ecu:apid:
+ * ::ctid
+ * :apid: */
ecuid_len = strlen(ecuid);
+
if (ecuid_len > DLT_ID_SIZE)
- {
ecuid_len = DLT_ID_SIZE;
- }
- if ((apid == NULL) && (ctid == NULL))
- {
+ if ((apid == NULL) && (ctid == NULL)) {
/* ecu:: */
strncpy(key[0], ecuid, ecuid_len);
strncat(key[0], ":", 1);
strncat(key[0], ":", 1);
- ptr_config = (DltLogStorageFilterConfig *) dlt_logstorage_list_find(
- key[0], &(handle->config_list));
+ ptr_config = (DltLogStorageFilterConfig *)dlt_logstorage_list_find(
+ key[0], &(handle->config_list));
- if (ptr_config != NULL)
- {
+ if (ptr_config != NULL) {
config[num] = ptr_config;
num += 1;
}
+
return num;
}
apid_len = strlen(apid);
+
if (apid_len > DLT_ID_SIZE)
- {
apid_len = DLT_ID_SIZE;
- }
ctid_len = strlen(ctid);
+
if (ctid_len > DLT_ID_SIZE)
- {
ctid_len = DLT_ID_SIZE;
- }
/* :apid: */
strncpy(key[0], ":", 1);
@@ -1950,13 +1776,11 @@ int dlt_logstorage_get_config(DltLogStorage *handle,
strncat(key[6], ":", 1);
/* Search the list three times with keys as -apid: , :ctid and apid:ctid */
- for (i = 0; i < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS; i++)
- {
+ for (i = 0; i < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS; i++) {
ptr_config = (DltLogStorageFilterConfig *)
dlt_logstorage_list_find(key[i], &(handle->config_list));
- if (ptr_config != NULL)
- {
+ if (ptr_config != NULL) {
config[num] = ptr_config;
num += 1;
}
@@ -1983,50 +1807,40 @@ int dlt_logstorage_get_config(DltLogStorage *handle,
* @return number of found configurations
*/
DLT_STATIC int dlt_logstorage_filter(DltLogStorage *handle,
- DltLogStorageFilterConfig **config,
- char *apid,
- char *ctid,
- char *ecuid,
- int log_level)
+ DltLogStorageFilterConfig **config,
+ char *apid,
+ char *ctid,
+ char *ecuid,
+ int log_level)
{
int i = 0;
int num = 0;
if ((handle == NULL) || (config == NULL) || (ecuid == NULL))
- {
return -1;
- }
/* filter on names: find DltLogStorageFilterConfig structures */
num = dlt_logstorage_get_config(handle, config, apid, ctid, ecuid);
- if (num == 0)
- {
+ if (num == 0) {
dlt_log(LOG_DEBUG, "No valid filter configuration found\n");
return 0;
}
- for (i = 0 ; i < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS ; i++)
- {
+ for (i = 0; i < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS; i++) {
if (config[i] == NULL)
- {
continue;
- }
/* filter on log level */
- if (log_level > config[i]->log_level)
- {
+ if (log_level > config[i]->log_level) {
config[i] = NULL;
continue;
}
/* filter on ECU id only if EcuID is set */
- if (config[i]->ecuid != NULL)
- {
+ if (config[i]->ecuid != NULL) {
if (strncmp(ecuid, config[i]->ecuid, DLT_ID_SIZE) != 0)
- {
config[i] = NULL;
- }
}
}
@@ -2056,7 +1870,7 @@ int dlt_logstorage_write(DltLogStorage *handle,
unsigned char *data3,
int size3)
{
- DltLogStorageFilterConfig *config[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS] = {0};
+ DltLogStorageFilterConfig *config[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS] = { 0 };
int i = 0;
int ret = 0;
int num = 0;
@@ -2075,63 +1889,52 @@ int dlt_logstorage_write(DltLogStorage *handle,
(data1 == NULL) || (data2 == NULL) || (data3 == NULL) ||
(handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
(handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
- {
return 0;
- }
/* Calculate real length of DltStandardHeaderExtra */
standardHeader = (DltStandardHeader *)data2;
if (!DLT_IS_HTYP_WEID(standardHeader->htyp))
- {
standardHeaderExtraLen -= DLT_ID_SIZE;
- }
if (!DLT_IS_HTYP_WSID(standardHeader->htyp))
- {
standardHeaderExtraLen -= DLT_SIZE_WSID;
- }
if (!DLT_IS_HTYP_WTMS(standardHeader->htyp))
- {
standardHeaderExtraLen -= DLT_SIZE_WTMS;
- }
- extraHeader = (DltStandardHeaderExtra *) (data2
- + sizeof(DltStandardHeader));
+ extraHeader = (DltStandardHeaderExtra *)(data2
+ + sizeof(DltStandardHeader));
- if (DLT_IS_HTYP_UEH(standardHeader->htyp))
- {
+ if (DLT_IS_HTYP_UEH(standardHeader->htyp)) {
header_len = sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) + standardHeaderExtraLen;
+
/* check if size2 is big enough to contain expected DLT message header */
- if ((unsigned int)size2 < header_len)
- {
+ if ((unsigned int)size2 < header_len) {
dlt_log(LOG_ERR, "DLT message header is too small\n");
return 0;
}
- extendedHeader = (DltExtendedHeader *) (data2
- + sizeof(DltStandardHeader) + standardHeaderExtraLen);
+ extendedHeader = (DltExtendedHeader *)(data2
+ + sizeof(DltStandardHeader) + standardHeaderExtraLen);
log_level = DLT_GET_MSIN_MTIN(extendedHeader->msin);
/* check if log message need to be stored in a certain device based on
* filter configuration */
num = dlt_logstorage_filter(handle, config, extendedHeader->apid,
- extendedHeader->ctid, extraHeader->ecu, log_level);
+ extendedHeader->ctid, extraHeader->ecu, log_level);
- if (num == 0 || num == -1)
- {
+ if ((num == 0) || (num == -1)) {
dlt_log(LOG_DEBUG, "No valid filter configuration found!\n");
return 0;
}
}
- else
- {
+ else {
header_len = sizeof(DltStandardHeader) + standardHeaderExtraLen;
+
/* check if size2 is big enough to contain expected DLT message header */
- if ((unsigned int)size2 < header_len)
- {
+ if ((unsigned int)size2 < header_len) {
dlt_log(LOG_ERR, "DLT message header is too small (without extended header)\n");
return 0;
}
@@ -2141,29 +1944,23 @@ int dlt_logstorage_write(DltLogStorage *handle,
/* check if log message need to be stored in a certain device based on
* filter configuration */
num = dlt_logstorage_filter(handle, config, NULL,
- NULL, extraHeader->ecu, log_level);
+ NULL, extraHeader->ecu, log_level);
- if (num == 0 || num == -1)
- {
+ if ((num == 0) || (num == -1)) {
dlt_log(LOG_DEBUG, "No valid filter configuration found!\n");
return 0;
}
}
/* store log message in every found filter */
- for (i = 0; i < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS; i++)
- {
+ for (i = 0; i < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS; i++) {
if (config[i] == NULL)
- {
continue;
- }
/* If file name is not present, the filter is non verbose control filter
* hence skip storing */
if (config[i]->file_name == NULL)
- {
continue;
- }
/* prepare log file (create and/or open)*/
ret = config[i]->dlt_logstorage_prepare(config[i],
@@ -2171,8 +1968,7 @@ int dlt_logstorage_write(DltLogStorage *handle,
handle->device_mount_point,
size1 + size2 + size3);
- if (ret == 0) /* log data (write) */
- {
+ if (ret == 0) { /* log data (write) */
ret = config[i]->dlt_logstorage_write(config[i],
data1,
size1,
@@ -2181,8 +1977,7 @@ int dlt_logstorage_write(DltLogStorage *handle,
data3,
size3);
- if (ret == 0)
- {
+ if (ret == 0) {
/* flush to be sure log is stored on device */
ret = config[i]->dlt_logstorage_sync(config[i],
uconfig,
@@ -2190,27 +1985,21 @@ int dlt_logstorage_write(DltLogStorage *handle,
DLT_LOGSTORAGE_SYNC_ON_MSG);
if (ret != 0)
- {
dlt_log(LOG_ERR,
"dlt_logstorage_write: Unable to sync.\n");
- }
}
- else
- {
+ else {
handle->write_errors += 1;
if (handle->write_errors >=
DLT_OFFLINE_LOGSTORAGE_MAX_WRITE_ERRORS)
- {
err = -1;
- }
dlt_log(LOG_ERR,
"dlt_logstorage_write: Unable to write.\n");
}
}
- else
- {
+ else {
dlt_log(LOG_ERR,
"dlt_logstorage_write: Unable to prepare.\n");
}
@@ -2232,26 +2021,21 @@ int dlt_logstorage_sync_caches(DltLogStorage *handle)
DltLogStorageFilterList **tmp = NULL;
if (handle == NULL)
- {
return -1;
- }
tmp = &(handle->config_list);
- while (*(tmp) != NULL)
- {
- if ((*tmp)->data != NULL)
- {
+ while (*(tmp) != NULL) {
+ if ((*tmp)->data != NULL) {
if ((*tmp)->data->dlt_logstorage_sync((*tmp)->data,
&handle->uconfig,
handle->device_mount_point,
DLT_LOGSTORAGE_SYNC_ON_DEMAND) != 0)
- {
dlt_vlog(LOG_ERR,
- "%s: Sync failed. Continue with next cache.\n",
- __func__);
- }
+ "%s: Sync failed. Continue with next cache.\n",
+ __func__);
}
+
tmp = &(*tmp)->next;
}
diff --git a/src/offlinelogstorage/dlt_offline_logstorage.h b/src/offlinelogstorage/dlt_offline_logstorage.h
index 5020042..c2160b5 100644
--- a/src/offlinelogstorage/dlt_offline_logstorage.h
+++ b/src/offlinelogstorage/dlt_offline_logstorage.h
@@ -113,7 +113,7 @@
#define DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE (1 << 4) /* sync on after specific size */
#define DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE (1 << 5) /* sync on file size reached */
-#define DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(S, s) ((S) &(s))
+#define DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(S, s) ((S)&(s))
/* logstorage max cache */
unsigned int g_logstorage_cache_max;
@@ -206,7 +206,7 @@ typedef struct
unsigned int connection_type; /* Type of connection */
unsigned int config_status; /* Status of configuration */
int write_errors; /* number of write errors */
-}DltLogStorage;
+} DltLogStorage;
typedef struct {
char *key; /* The configuration key */
@@ -250,7 +250,7 @@ typedef enum {
* @return 0 on success, -1 on error
*/
int dlt_logstorage_device_connected(DltLogStorage *handle,
- char *mount_point);
+ char *mount_point);
/**
* dlt_logstorage_device_disconnected
@@ -261,7 +261,7 @@ int dlt_logstorage_device_connected(DltLogStorage *handle,
* @return 0 on success, -1 on error
*/
int dlt_logstorage_device_disconnected(DltLogStorage *handle,
- int reason);
+ int reason);
/**
* dlt_logstorage_get_config
*
diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c
index 46f0f9e..1d31f46 100644
--- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c
+++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c
@@ -57,39 +57,33 @@ void dlt_logstorage_log_file_name(char *log_file_name,
int idx)
{
if ((log_file_name == NULL) || (file_config == NULL))
- {
return;
- }
- char file_index[10] = {'\0'};
+ char file_index[10] = { '\0' };
- // create log file name
+ /* create log file name */
memset(log_file_name, 0, DLT_MOUNT_PATH_MAX * sizeof(char));
strcat(log_file_name, name);
strncat(log_file_name, &file_config->logfile_delimiter, 1);
snprintf(file_index, 10, "%d", idx);
- if (file_config->logfile_maxcounter != UINT_MAX)
- {
+ if (file_config->logfile_maxcounter != UINT_MAX) {
/* Setup 0's to be appended in file index until max index len*/
unsigned int digit_idx = 0;
unsigned int i = 0;
snprintf(file_index, 10, "%d", idx);
digit_idx = strlen(file_index);
- for (i = 0 ; i < (file_config->logfile_counteridxlen - digit_idx) ; i++)
- {
+ for (i = 0; i < (file_config->logfile_counteridxlen - digit_idx); i++)
strcat(log_file_name, "0");
- }
}
strcat(log_file_name, file_index);
/* Add time stamp if user has configured */
- if (file_config->logfile_timestamp)
- {
- char stamp[DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN + 1] = {0};
+ if (file_config->logfile_timestamp) {
+ char stamp[DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN + 1] = { 0 };
time_t t = time(NULL);
struct tm *tm_info = localtime(&t);
sprintf(stamp,
@@ -120,12 +114,9 @@ void dlt_logstorage_sort_file_name(DltLogStorageFileList **head)
int done = 0;
if ((head == NULL) || (*head == NULL) || ((*head)->next == NULL))
- {
return;
- }
- while (!done)
- {
+ while (!done) {
/* "source" of the pointer to the current node in the list struct */
DltLogStorageFileList **pv = head;
DltLogStorageFileList *nd = *head; /* local iterator pointer */
@@ -133,10 +124,8 @@ void dlt_logstorage_sort_file_name(DltLogStorageFileList **head)
done = 1;
- while (nx)
- {
- if (nd->idx > nx->idx)
- {
+ while (nx) {
+ if (nd->idx > nx->idx) {
nd->next = nx->next;
nx->next = nd;
*pv = nx;
@@ -168,16 +157,11 @@ void dlt_logstorage_rearrange_file_name(DltLogStorageFileList **head)
DltLogStorageFileList *n = NULL;
if ((head == NULL) || (*head == NULL) || ((*head)->next == NULL))
- {
return;
- }
- for (n = *head ; n != NULL ; n = n->next)
- {
- if (n && n_prev)
- {
- if ((n->idx - n_prev->idx) != 1)
- {
+ for (n = *head; n != NULL; n = n->next) {
+ if (n && n_prev) {
+ if ((n->idx - n_prev->idx) != 1) {
wrap_post = n;
wrap_pre = n_prev;
}
@@ -188,8 +172,7 @@ void dlt_logstorage_rearrange_file_name(DltLogStorageFileList **head)
tail = n_prev;
- if (wrap_post && wrap_pre)
- {
+ if (wrap_post && wrap_pre) {
wrap_pre->next = NULL;
tail->next = *head;
*head = wrap_post;
@@ -215,15 +198,12 @@ unsigned int dlt_logstorage_get_idx_of_log_file(DltLogStorageUserConfig *file_co
unsigned int fileindex_len = 0;
if ((file_config == NULL) || (file == NULL))
- {
return -1;
- }
/* Calculate actual file name length */
filename = strchr(file, file_config->logfile_delimiter);
- if (filename == NULL)
- {
+ if (filename == NULL) {
dlt_vlog(LOG_ERR, "Cannot extract filename from %s\n", file);
return -1;
}
@@ -231,36 +211,32 @@ unsigned int dlt_logstorage_get_idx_of_log_file(DltLogStorageUserConfig *file_co
filename_len = strlen(file) - strlen(filename);
/* index is retrived from file name */
- if (file_config->logfile_timestamp)
- {
+ if (file_config->logfile_timestamp) {
fileindex_len = strlen(file) -
(DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN +
DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN +
filename_len + 1);
- idx = (int) strtol(&file[strlen(file) -
- (DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN +
- fileindex_len +
- DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN)],
- &endptr,
- 10);
+ idx = (int)strtol(&file[strlen(file) -
+ (DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN +
+ fileindex_len +
+ DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN)],
+ &endptr,
+ 10);
}
- else
- {
+ else {
fileindex_len = strlen(file) -
(DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN +
filename_len + 1);
- idx = (int) strtol(&file[strlen(file) -
- (DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN
- + fileindex_len)], &endptr, 10);
+ idx = (int)strtol(&file[strlen(file) -
+ (DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN
+ + fileindex_len)], &endptr, 10);
}
if ((endptr == file) || (idx == 0))
- {
dlt_log(LOG_ERR,
"Unable to calculate index from log file name. Reset to 001.\n");
- }
return idx;
}
@@ -283,46 +259,39 @@ int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config,
int i = 0;
int cnt = 0;
int ret = 0;
- struct dirent **files = {0};
+ struct dirent **files = { 0 };
unsigned int current_idx = 0;
if ((config == NULL) ||
(file_config == NULL) ||
(path == NULL) ||
(config->file_name == NULL))
- {
return -1;
- }
cnt = scandir(path, &files, 0, alphasort);
- if (cnt < 0)
- {
+ if (cnt < 0) {
dlt_log(LOG_ERR,
"dlt_logstorage_storage_dir_info: Failed to scan directory\n");
return -1;
}
- for (i = 0 ; i < cnt ; i++)
- {
+ for (i = 0; i < cnt; i++) {
int len = 0;
len = strlen(config->file_name);
if ((strncmp(files[i]->d_name,
config->file_name,
len) == 0) &&
- (files[i]->d_name[len] == file_config->logfile_delimiter))
- {
+ (files[i]->d_name[len] == file_config->logfile_delimiter)) {
DltLogStorageFileList **tmp = NULL;
current_idx = dlt_logstorage_get_idx_of_log_file(file_config,
files[i]->d_name);
- if (config->records == NULL)
- {
+ if (config->records == NULL) {
config->records = malloc(sizeof(DltLogStorageFileList));
- if (config->records == NULL)
- {
+ if (config->records == NULL) {
ret = -1;
dlt_log(LOG_ERR,
"Memory allocation failed\n");
@@ -331,19 +300,15 @@ int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config,
tmp = &config->records;
}
- else
- {
+ else {
tmp = &config->records;
while (*(tmp) != NULL)
- {
tmp = &(*tmp)->next;
- }
*tmp = malloc(sizeof(DltLogStorageFileList));
- if (*tmp == NULL)
- {
+ if (*tmp == NULL) {
ret = -1;
dlt_log(LOG_ERR,
"Memory allocation failed\n");
@@ -357,17 +322,14 @@ int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config,
}
}
- if (ret == 0)
- {
+ if (ret == 0) {
dlt_logstorage_sort_file_name(&config->records);
dlt_logstorage_rearrange_file_name(&config->records);
}
/* free scandir result */
- for (i = 0 ; i < cnt ; i++)
- {
+ for (i = 0; i < cnt; i++)
free(files[i]);
- }
free(files);
@@ -394,21 +356,18 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config,
int msg_size)
{
int ret = 0;
- char absolute_file_path[DLT_MOUNT_PATH_MAX + DLT_OFFLINE_LOGSTORAGE_CONFIG_DIR_PATH_LEN + 1] = {'\0'};
- char storage_path[DLT_OFFLINE_LOGSTORAGE_CONFIG_DIR_PATH_LEN + 1] = {'\0'};
+ char absolute_file_path[DLT_MOUNT_PATH_MAX + DLT_OFFLINE_LOGSTORAGE_CONFIG_DIR_PATH_LEN + 1] = { '\0' };
+ char storage_path[DLT_OFFLINE_LOGSTORAGE_CONFIG_DIR_PATH_LEN + 1] = { '\0' };
unsigned int num_log_files = 0;
struct stat s;
DltLogStorageFileList **tmp = NULL;
DltLogStorageFileList **newest = NULL;
- char file_name[DLT_MOUNT_PATH_MAX + 1] = {'\0'};
+ char file_name[DLT_MOUNT_PATH_MAX + 1] = { '\0' };
if (config == NULL)
- {
return -1;
- }
- if (strlen(dev_path) > DLT_OFFLINE_LOGSTORAGE_CONFIG_DIR_PATH_LEN)
- {
+ if (strlen(dev_path) > DLT_OFFLINE_LOGSTORAGE_CONFIG_DIR_PATH_LEN) {
dlt_vlog(LOG_ERR, "device path '%s' is too long to store\n", dev_path);
return -1;
}
@@ -416,33 +375,26 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config,
snprintf(storage_path, DLT_OFFLINE_LOGSTORAGE_CONFIG_DIR_PATH_LEN, "%s/", dev_path);
/* check if there are already files stored */
- if (config->records == NULL)
- {
+ if (config->records == NULL) {
if (dlt_logstorage_storage_dir_info(file_config, storage_path, config)
!= 0)
- {
return -1;
- }
}
/* obtain locations of newest, current file names, file count */
tmp = &config->records;
- while (*(tmp) != NULL)
- {
+ while (*(tmp) != NULL) {
num_log_files += 1;
if ((*tmp)->next == NULL)
- {
newest = tmp;
- }
tmp = &(*tmp)->next;
}
/* need new file*/
- if (num_log_files == 0)
- {
+ if (num_log_files == 0) {
dlt_logstorage_log_file_name(file_name,
file_config,
config->file_name,
@@ -456,8 +408,7 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config,
/* Add file to file list */
*tmp = malloc(sizeof(DltLogStorageFileList));
- if (*tmp == NULL)
- {
+ if (*tmp == NULL) {
dlt_log(LOG_ERR,
"Memory allocation for file name failed\n");
return -1;
@@ -467,20 +418,17 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config,
(*tmp)->idx = 1;
(*tmp)->next = NULL;
}
- else /* newest file available*/
- {
+ else { /* newest file available*/
strcat(absolute_file_path, storage_path);
strcat(absolute_file_path, (*newest)->name);
ret = stat(absolute_file_path, &s);
/* if size is enough, open it */
- if ((ret == 0) && (s.st_size + msg_size < (int)config->file_size))
- {
+ if ((ret == 0) && (s.st_size + msg_size < (int)config->file_size)) {
config->log = fopen(absolute_file_path, "a+");
}
- else /* no space in file or file stats cannot be read */
- {
+ else { /* no space in file or file stats cannot be read */
unsigned int idx = 0;
/* get index of newest log file */
@@ -491,9 +439,7 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config,
/* wrap around if max index is reached or an error occurred
* while calculating index from file name */
if ((idx > file_config->logfile_maxcounter) || (idx == 0))
- {
idx = 1;
- }
dlt_logstorage_log_file_name(file_name,
file_config,
@@ -511,8 +457,7 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config,
/* Add file to file list */
*tmp = malloc(sizeof(DltLogStorageFileList));
- if (*tmp == NULL)
- {
+ if (*tmp == NULL) {
dlt_log(LOG_ERR,
"Memory allocation for file name failed\n");
return -1;
@@ -525,8 +470,7 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config,
num_log_files += 1;
/* check if number of log files exceeds configured max value */
- if (num_log_files > config->num_files)
- {
+ if (num_log_files > config->num_files) {
/* delete oldest */
DltLogStorageFileList **head = &config->records;
DltLogStorageFileList *n = *head;
@@ -544,8 +488,7 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config,
}
}
- if (config->log == NULL)
- {
+ if (config->log == NULL) {
dlt_log(LOG_ERR,
"dlt_logstorage_create_log_file: Unable to open log file.\n");
return -1;
@@ -569,19 +512,18 @@ DLT_STATIC int dlt_logstorage_find_dlt_header(void *ptr,
unsigned int cnt)
{
int index = 0;
- char substring[] = {'D', 'L', 'T', 0x01};
- while(cnt > 0)
- {
- if (*((char *)(ptr + offset + index)) == 'D')
- {
- if (strncmp(ptr + offset + index , substring, 4) == 0)
- {
+ char substring[] = { 'D', 'L', 'T', 0x01 };
+
+ while (cnt > 0) {
+ if (*((char *)(ptr + offset + index)) == 'D') {
+ if (strncmp(ptr + offset + index, substring, 4) == 0)
return index;
- }
}
+
cnt--;
index++;
}
+
return -1;
}
@@ -597,27 +539,19 @@ DLT_STATIC void dlt_logstorage_check_write_ret(DltLogStorageFilterConfig *config
int ret)
{
if (config == NULL)
- {
dlt_vlog(LOG_ERR, "%s: cannot retrieve config information\n", __func__);
- }
- if (ret <= 0)
- {
+
+ if (ret <= 0) {
if (ferror(config->log) != 0)
- {
dlt_vlog(LOG_ERR, "%s: failed to write cache into log file\n", __func__);
- }
}
- else
- {
+ else {
/* force sync */
if (fflush(config->log) != 0)
- {
dlt_vlog(LOG_ERR, "%s: failed to flush log file\n", __func__);
- }
+
if (fsync(fileno(config->log)) != 0)
- {
dlt_vlog(LOG_ERR, "%s: failed to sync log file\n", __func__);
- }
}
}
@@ -633,10 +567,10 @@ DLT_STATIC void dlt_logstorage_check_write_ret(DltLogStorageFilterConfig *config
* @return 0 on success, -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_sync_create_new_file(
- DltLogStorageFilterConfig *config,
- DltLogStorageUserConfig *file_config,
- char *dev_path,
- unsigned int remain_file_size)
+ DltLogStorageFilterConfig *config,
+ DltLogStorageUserConfig *file_config,
+ char *dev_path,
+ unsigned int remain_file_size)
{
int index = 0;
int ret;
@@ -644,94 +578,88 @@ DLT_STATIC DltReturnValue dlt_logstorage_sync_create_new_file(
unsigned int count = 0;
DltLogStorageCacheFooter *footer = NULL;
- if (config == NULL || file_config == NULL || dev_path == NULL)
- {
+ if ((config == NULL) || (file_config == NULL) || (dev_path == NULL)) {
dlt_vlog(LOG_ERR, "%s: cannot retrieve config information\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
+
footer = (DltLogStorageCacheFooter *)(config->cache +
config->file_size);
- if (footer == NULL)
- {
+
+ if (footer == NULL) {
dlt_vlog(LOG_ERR, "%s: Cannot retrieve cache information\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
/* sync capable data to file */
- if (footer->offset >= footer->last_sync_offset)
- {
+ if (footer->offset >= footer->last_sync_offset) {
count = config->file_size - footer->offset;
+
if (count > remain_file_size)
- {
count = remain_file_size;
- }
- index = dlt_logstorage_find_dlt_header(config->cache,footer->offset,count);
+
+ index = dlt_logstorage_find_dlt_header(config->cache, footer->offset, count);
cache_offset = footer->offset;
}
- else
- {
+ else {
count = config->file_size - footer->last_sync_offset;
+
if (count > remain_file_size)
- {
count = remain_file_size;
- }
+
index = dlt_logstorage_find_dlt_header(config->cache,
footer->last_sync_offset,
count);
cache_offset = footer->last_sync_offset;
}
- if (index >= 0)
- {
+
+ if (index >= 0) {
ret = fwrite(config->cache + cache_offset + index, count - index, 1, config->log);
dlt_logstorage_check_write_ret(config, ret);
config->current_write_file_offset += count - index;
}
+
if (footer->last_sync_offset == 0)
- {
footer->last_sync_offset = footer->offset + count;
- }
else
- {
footer->last_sync_offset += count;
- }
+
config->total_write_count -= count;
/* sync data to current file in case of file is not full */
- if (config->current_write_file_offset < config->file_size)
- {
+ if (config->current_write_file_offset < config->file_size) {
count = config->file_size - config->current_write_file_offset;
- if (footer->last_sync_offset < config->file_size)
- {
+ if (footer->last_sync_offset < config->file_size) {
ret = fwrite(config->cache + footer->last_sync_offset, count, 1, config->log);
dlt_logstorage_check_write_ret(config, ret);
footer->last_sync_offset += count;
}
/* sync remaining amount of file from start of cache */
- else
- {
+ else {
config->sync_from_start = 1;
+
if (count > footer->offset)
- {
count = footer->offset;
- }
+
ret = fwrite(config->cache, count, 1, config->log);
dlt_logstorage_check_write_ret(config, ret);
footer->last_sync_offset = count;
}
+
config->total_write_count -= count;
}
config->current_write_file_offset = 0;
fclose(config->log);
config->log = NULL;
+
/* get always a new file */
if (dlt_logstorage_prepare_on_msg(config,
file_config,
dev_path,
- config->file_size) != 0)
- {
+ config->file_size) != 0) {
dlt_vlog(LOG_ERR,
"%s: failed to prepare log file for file_size\n", __func__);
return DLT_RETURN_ERROR;
@@ -751,33 +679,32 @@ DLT_STATIC DltReturnValue dlt_logstorage_sync_create_new_file(
* @return 0 on success, -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_sync_to_file(
- DltLogStorageFilterConfig *config,
- DltLogStorageUserConfig *file_config,
- char *dev_path)
+ DltLogStorageFilterConfig *config,
+ DltLogStorageUserConfig *file_config,
+ char *dev_path)
{
int ret = 0;
unsigned int remain_file_size = 0;
unsigned int count = 0;
DltLogStorageCacheFooter *footer = NULL;
- if (config == NULL || file_config == NULL || dev_path == NULL)
- {
+ if ((config == NULL) || (file_config == NULL) || (dev_path == NULL)) {
dlt_vlog(LOG_ERR, "%s: cannot retrieve config information\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
+
footer = (DltLogStorageCacheFooter *)(config->cache + config->file_size);
- if (footer == NULL)
- {
+ if (footer == NULL) {
dlt_vlog(LOG_ERR, "%s: Cannot retrieve cache information\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
- };
+ }
+
count = footer->offset - footer->last_sync_offset;
remain_file_size = config->file_size - config->current_write_file_offset;
/* sync data to file if required sync data exceeds remaining file size */
- if (count > remain_file_size)
- {
+ if (count > remain_file_size) {
ret = fwrite(config->cache + footer->last_sync_offset, remain_file_size, 1, config->log);
dlt_logstorage_check_write_ret(config, ret);
config->current_write_file_offset += remain_file_size;
@@ -787,17 +714,18 @@ DLT_STATIC DltReturnValue dlt_logstorage_sync_to_file(
config->current_write_file_offset = 0;
fclose(config->log);
config->log = NULL;
+
/* get always a new file */
if (dlt_logstorage_prepare_on_msg(config,
file_config,
dev_path,
- config->file_size) != 0)
- {
+ config->file_size) != 0) {
dlt_vlog(LOG_ERR,
"%s: failed to prepare log file for file_size\n", __func__);
return DLT_RETURN_ERROR;
}
}
+
ret = fwrite(config->cache + footer->last_sync_offset, count, 1, config->log);
dlt_logstorage_check_write_ret(config, ret);
config->current_write_file_offset += count;
@@ -817,35 +745,34 @@ DLT_STATIC DltReturnValue dlt_logstorage_sync_to_file(
* @return 0 on success, -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_sync_capable_data_to_file(
- DltLogStorageFilterConfig *config,
- int index_status)
+ DltLogStorageFilterConfig *config,
+ int index_status)
{
int ret = 0;
int index = 0;
unsigned int count = 0;
DltLogStorageCacheFooter *footer = NULL;
- if (config == NULL)
- {
+ if (config == NULL) {
dlt_vlog(LOG_ERR, "%s: cannot retrieve config information\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
footer = (DltLogStorageCacheFooter *)(config->cache + config->file_size);
- if (footer == NULL)
- {
+
+ if (footer == NULL) {
dlt_vlog(LOG_ERR, "%s: Cannot retrieve cache information\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
- };
+ }
+
count = config->file_size - footer->last_sync_offset;
+
if (index_status == 1)
- {
index = dlt_logstorage_find_dlt_header(config->cache,
footer->last_sync_offset,
count);
- }
- if (count > 0 && index >=0)
- {
+
+ if ((count > 0) && (index >= 0)) {
ret = fwrite(config->cache + footer->last_sync_offset + index,
count - index,
1,
@@ -853,6 +780,7 @@ DLT_STATIC DltReturnValue dlt_logstorage_sync_capable_data_to_file(
dlt_logstorage_check_write_ret(config, ret);
config->current_write_file_offset += count - index;
}
+
config->total_write_count -= count;
footer->last_sync_offset = 0;
@@ -880,26 +808,20 @@ int dlt_logstorage_prepare_on_msg(DltLogStorageFilterConfig *config,
struct stat s;
if ((config == NULL) || (file_config == NULL) || (dev_path == NULL))
- {
return -1;
- }
- if (config->log == NULL) /* open a new log file */
- {
+ if (config->log == NULL) { /* open a new log file */
ret = dlt_logstorage_open_log_file(config,
file_config,
dev_path,
log_msg_size);
}
- else /* already open, check size and create a new file if needed */
- {
+ else { /* already open, check size and create a new file if needed */
ret = fstat(fileno(config->log), &s);
- if (ret == 0)
- {
+ if (ret == 0) {
/* check if adding new data do not exceed max file size */
- if (s.st_size + log_msg_size >= (int)config->file_size)
- {
+ if (s.st_size + log_msg_size >= (int)config->file_size) {
fclose(config->log);
config->log = NULL;
ret = dlt_logstorage_open_log_file(config,
@@ -907,13 +829,11 @@ int dlt_logstorage_prepare_on_msg(DltLogStorageFilterConfig *config,
dev_path,
log_msg_size);
}
- else /*everything is prepared */
- {
+ else { /*everything is prepared */
ret = 0;
}
}
- else
- {
+ else {
dlt_log(LOG_ERR,
"dlt_logstorage_prepare_log_file: stat() failed.\n");
ret = -1;
@@ -948,30 +868,22 @@ int dlt_logstorage_write_on_msg(DltLogStorageFilterConfig *config,
int ret;
if ((config == NULL) || (data1 == NULL) || (data2 == NULL) || (data3 == NULL))
- {
return -1;
- }
ret = fwrite(data1, 1, size1, config->log);
if (ret != size1)
- {
dlt_log(LOG_WARNING, "Wrote less data than specified\n");
- }
ret = fwrite(data2, 1, size2, config->log);
if (ret != size2)
- {
dlt_log(LOG_WARNING, "Wrote less data than specified\n");
- }
ret = fwrite(data3, 1, size3, config->log);
if (ret != size3)
- {
dlt_log(LOG_WARNING, "Wrote less data than specified\n");
- }
return ferror(config->log);
}
@@ -998,18 +910,13 @@ int dlt_logstorage_sync_on_msg(DltLogStorageFilterConfig *config,
dev_path = dev_path;
if (config == NULL)
- {
return -1;
- }
- if (status == DLT_LOGSTORAGE_SYNC_ON_MSG) /* sync on every message */
- {
+ if (status == DLT_LOGSTORAGE_SYNC_ON_MSG) { /* sync on every message */
ret = fflush(config->log);
if (ret != 0)
- {
dlt_log(LOG_ERR, "fflush failed\n");
- }
}
return 0;
@@ -1034,9 +941,7 @@ int dlt_logstorage_prepare_msg_cache(DltLogStorageFilterConfig *config,
int log_msg_size)
{
if ((config == NULL) || (file_config == NULL) || (dev_path == NULL))
- {
return -1;
- }
/* Combinations allowed: on Daemon_Exit with on Demand,File_Size with Daemon_Exit
* File_Size with on Demand, Specific_Size with Daemon_Exit,Specific_Size with on Demand
@@ -1044,8 +949,7 @@ int dlt_logstorage_prepare_msg_cache(DltLogStorageFilterConfig *config,
*/
/* check for combinations of specific_size and file_size strategy */
if ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync, DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0) &&
- (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync, DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE)) > 0)
- {
+ ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync, DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE)) > 0)) {
dlt_log(LOG_WARNING, "wrong combination of sync strategies \n");
return -1;
}
@@ -1053,46 +957,37 @@ int dlt_logstorage_prepare_msg_cache(DltLogStorageFilterConfig *config,
log_msg_size = log_msg_size; /* satisfy compiler */
/* create file to sync cache into later */
- if (config->log == NULL)
- {
+ if (config->log == NULL) {
if ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
- DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0) &&
- (config->specific_size > config->file_size))
- {
+ DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0) &&
+ (config->specific_size > config->file_size)) {
dlt_log(LOG_ERR,
"Cannot prepare log file for ON_DAEMON_SPECIFIC_SIZE sync\n");
return -1;
}
else
- {
- /* get always a new file */
- if (dlt_logstorage_prepare_on_msg(config,
- file_config,
- dev_path,
- config->file_size) != 0)
- {
- dlt_log(LOG_ERR,
- "Cannot prepare log file for ON_DAEMON_EXIT sync\n");
- return -1;
- }
+ /* get always a new file */
+ if (dlt_logstorage_prepare_on_msg(config,
+ file_config,
+ dev_path,
+ config->file_size) != 0) {
+ dlt_log(LOG_ERR,
+ "Cannot prepare log file for ON_DAEMON_EXIT sync\n");
+ return -1;
}
}
-
- if (config->cache == NULL)
- {
+ if (config->cache == NULL) {
/* check for sync_specific_size strategy */
if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
- DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
- {
+ DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0) {
/* check total logstorage cache size */
if ((g_logstorage_cache_size +
config->specific_size +
sizeof(DltLogStorageCacheFooter)) >
- g_logstorage_cache_max)
- {
+ g_logstorage_cache_max) {
dlt_log(LOG_ERR, "Max size of Logstorage Cache already used.");
return -1;
}
@@ -1104,17 +999,15 @@ int dlt_logstorage_prepare_msg_cache(DltLogStorageFilterConfig *config,
/* update current used cache size */
g_logstorage_cache_size = config->specific_size +
- sizeof(DltLogStorageCacheFooter);
+ sizeof(DltLogStorageCacheFooter);
}
- else /* other cache strategies */
- {
+ else { /* other cache strategies */
/* check total logstorage cache size */
if ((g_logstorage_cache_size +
config->file_size +
sizeof(DltLogStorageCacheFooter)) >
- g_logstorage_cache_max)
- {
+ g_logstorage_cache_max) {
dlt_log(LOG_ERR, "Max size of Logstorage Cache already used.");
return -1;
}
@@ -1126,14 +1019,12 @@ int dlt_logstorage_prepare_msg_cache(DltLogStorageFilterConfig *config,
/* update current used cache size */
g_logstorage_cache_size = config->file_size +
- sizeof(DltLogStorageCacheFooter);
+ sizeof(DltLogStorageCacheFooter);
}
if (config->cache == NULL)
- {
dlt_log(LOG_CRIT,
"Cannot allocate memory for filter ring buffer\n");
- }
}
return 0;
@@ -1171,105 +1062,97 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config,
if ((config == NULL) || (data1 == NULL) || (size1 < 0) || (data2 == NULL) ||
(size2 < 0) || (data3 == NULL) || (size3 < 0) || (config->cache == NULL))
- {
return -1;
- }
if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
- DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
- {
+ DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0) {
footer = (DltLogStorageCacheFooter *)(config->cache +
config->specific_size);
- if (footer == NULL)
- {
+
+ if (footer == NULL) {
dlt_log(LOG_ERR, "Cannot retrieve cache footer. Address is NULL\n");
return -1;
}
+
msg_size = size1 + size2 + size3;
remain_cache_size = config->specific_size - footer->offset;
}
- else
- {
+ else {
footer = (DltLogStorageCacheFooter *)(config->cache +
config->file_size);
- if (footer == NULL)
- {
+
+ if (footer == NULL) {
dlt_log(LOG_ERR, "Cannot retrieve cache footer. Address is NULL\n");
return -1;
}
+
msg_size = size1 + size2 + size3;
remain_cache_size = config->file_size - footer->offset;
}
- if (msg_size < remain_cache_size) /* add at current position */
- {
+ if (msg_size < remain_cache_size) { /* add at current position */
curr_write_addr = (void *)(config->cache + footer->offset);
footer->offset += msg_size;
}
else if (msg_size > remain_cache_size)
{
if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
- DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
- {
+ DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0) {
/*check for message size exceeds cache size for specific_size strategy */
- if ((unsigned int) msg_size > config->specific_size)
- {
+ if ((unsigned int)msg_size > config->specific_size) {
dlt_log(LOG_WARNING, "Message is larger than cache. Discard.\n");
- return -1 ;
+ return -1;
}
}
- else if ((unsigned int) msg_size > config->file_size)
+ else if ((unsigned int)msg_size > config->file_size)
{
dlt_log(LOG_WARNING, "Message is larger than cache. Discard.\n");
return -1;
}
- /*sync to file for specific_size or file_size */
- if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
- DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE) > 0)
- {
- ret = config->dlt_logstorage_sync(config,
- uconfig,
- dev_path,
- DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE);
- if (ret != 0)
- {
- dlt_log(LOG_ERR,"dlt_logstorage_sync: Unable to sync.\n");
- return -1;
- }
- }
- else if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
- DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
- {
-
- ret = config->dlt_logstorage_sync(config,
- uconfig,
- dev_path,
- DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE);
- if (ret != 0)
- {
- dlt_log(LOG_ERR,"dlt_logstorage_sync: Unable to sync.\n");
- return -1;
- }
- }
- else if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
- DLT_LOGSTORAGE_SYNC_ON_DEMAND) > 0)
- {
- config->pre_cache_sync = config->cur_cache_sync;
- config->cur_cache_sync = 0;
- if (config->pre_cache_sync == 0)
- {
- footer->last_sync_offset = 0;
- }
- }
+ /*sync to file for specific_size or file_size */
+ if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+ DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE) > 0) {
+ ret = config->dlt_logstorage_sync(config,
+ uconfig,
+ dev_path,
+ DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE);
+
+ if (ret != 0) {
+ dlt_log(LOG_ERR, "dlt_logstorage_sync: Unable to sync.\n");
+ return -1;
+ }
+ }
+ else if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+ DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
+ {
+
+ ret = config->dlt_logstorage_sync(config,
+ uconfig,
+ dev_path,
+ DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE);
+
+ if (ret != 0) {
+ dlt_log(LOG_ERR, "dlt_logstorage_sync: Unable to sync.\n");
+ return -1;
+ }
+ }
+ else if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+ DLT_LOGSTORAGE_SYNC_ON_DEMAND) > 0)
+ {
+ config->pre_cache_sync = config->cur_cache_sync;
+ config->cur_cache_sync = 0;
+
+ if (config->pre_cache_sync == 0)
+ footer->last_sync_offset = 0;
+ }
/* start writing from beginning */
curr_write_addr = config->cache;
footer->offset = msg_size;
footer->wrap_around_cnt += 1;
}
- else /* message just fits into cache */
- {
+ else { /* message just fits into cache */
curr_write_addr = (void *)(config->cache + footer->offset);
footer->wrap_around_cnt += 1;
}
@@ -1307,15 +1190,11 @@ int dlt_logstorage_sync_msg_cache(DltLogStorageFilterConfig *config,
DltLogStorageCacheFooter *footer = NULL;
if (config == NULL)
- {
return -1;
- }
/* sync only, if given strategy is set */
- if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync, status) > 0)
- {
- if ((config->log == NULL) || (config->cache == NULL))
- {
+ if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync, status) > 0) {
+ if ((config->log == NULL) || (config->cache == NULL)) {
dlt_log(LOG_ERR,
"Cannot copy cache to file. One of both is NULL\n");
return -1;
@@ -1324,17 +1203,16 @@ int dlt_logstorage_sync_msg_cache(DltLogStorageFilterConfig *config,
/* sync cache data to file for specific_size strategies */
if ((status == DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE)
- || ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
- DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
- && (status == DLT_LOGSTORAGE_SYNC_ON_DEMAND))
- || ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
- DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
- && (status == DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT)))
- {
+ || ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+ DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
+ && (status == DLT_LOGSTORAGE_SYNC_ON_DEMAND))
+ || ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+ DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
+ && (status == DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT))) {
footer = (DltLogStorageCacheFooter *)(config->cache +
config->specific_size);
- if (footer == NULL)
- {
+
+ if (footer == NULL) {
dlt_log(LOG_ERR, "Cannot retrieve cache information\n");
return -1;
}
@@ -1347,16 +1225,11 @@ int dlt_logstorage_sync_msg_cache(DltLogStorageFilterConfig *config,
remain_file_size = config->file_size - config->current_write_file_offset;
if (status == DLT_LOGSTORAGE_SYNC_ON_DEMAND)
- {
footer->last_sync_offset = footer->offset;
- }
else
- {
footer->last_sync_offset = 0;
- }
- if (remain_file_size < config->specific_size)
- {
+ if (remain_file_size < config->specific_size) {
config->current_write_file_offset = 0;
/* clean ring buffer and reset footer information */
memset(config->cache,
@@ -1368,20 +1241,20 @@ int dlt_logstorage_sync_msg_cache(DltLogStorageFilterConfig *config,
fclose(config->log);
config->log = NULL;
- }
+ }
}
/* sync cache data to file for file size strategies*/
else if ((status == DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE) ||
(status == DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT) ||
((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
- DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE) > 0)
- && (status == DLT_LOGSTORAGE_SYNC_ON_DEMAND)))
+ DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE) > 0)
+ && (status == DLT_LOGSTORAGE_SYNC_ON_DEMAND)))
{
footer = (DltLogStorageCacheFooter *)(config->cache +
config->file_size);
- if (footer == NULL)
- {
+
+ if (footer == NULL) {
dlt_log(LOG_ERR, "Cannot retrieve cache information\n");
return -1;
}
@@ -1394,13 +1267,12 @@ int dlt_logstorage_sync_msg_cache(DltLogStorageFilterConfig *config,
footer->last_sync_offset = footer->offset;
if ((status != DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT)
- && (status != DLT_LOGSTORAGE_SYNC_ON_DEMAND))
- {
+ && (status != DLT_LOGSTORAGE_SYNC_ON_DEMAND)) {
config->current_write_file_offset = 0;
/* clean ring buffer and reset footer information */
memset(config->cache,
- 0,
- config->file_size + sizeof(DltLogStorageCacheFooter));
+ 0,
+ config->file_size + sizeof(DltLogStorageCacheFooter));
/* close the file, a new one will be created when prepare is
* called again */
@@ -1413,81 +1285,70 @@ int dlt_logstorage_sync_msg_cache(DltLogStorageFilterConfig *config,
else if (status == DLT_LOGSTORAGE_SYNC_ON_DEMAND)
{
config->sync_from_start = 0;
- if ((file_config == NULL) || (dev_path == NULL))
- {
+
+ if ((file_config == NULL) || (dev_path == NULL)) {
dlt_log(LOG_ERR, "Cannot retrieve user configuration or mount point\n");
return -1;
}
+
footer = (DltLogStorageCacheFooter *)(config->cache +
config->file_size);
- if (footer == NULL)
- {
+
+ if (footer == NULL) {
dlt_log(LOG_ERR, "Cannot retrieve cache information\n");
return -1;
}
+
/* check for wrap around is 0 or cache is synced at least once
* in every wrap around */
- if ((footer->wrap_around_cnt < 1) || (config->cur_cache_sync == 1))
- {
+ if ((footer->wrap_around_cnt < 1) || (config->cur_cache_sync == 1)) {
ret = dlt_logstorage_sync_to_file(config,
file_config,
dev_path);
+
if (ret != 0)
- {
dlt_vlog(LOG_ERR, "%s: failed to sync data to file \n", __func__);
- }
}
- else
- {
+ else {
remain_file_size = config->file_size - config->current_write_file_offset;
/* check for total bytes of data need to sync */
- if (footer->offset >= footer->last_sync_offset )
- {
+ if (footer->offset >= footer->last_sync_offset)
config->total_write_count = config->file_size;
- }
else
- {
config->total_write_count = config->file_size - footer->last_sync_offset + footer->offset;
- }
/* sync data to file if required sync data exceeds remaining file size */
- if (config->total_write_count >= remain_file_size)
- {
+ if (config->total_write_count >= remain_file_size) {
ret = dlt_logstorage_sync_create_new_file(config,
file_config,
dev_path,
remain_file_size);
+
if (ret != 0)
- {
dlt_vlog(LOG_ERR, "%s: failed to sync and open new file\n", __func__);
- }
/* sync remaining end of cache data to new file*/
- if (config->sync_from_start == 0)
- {
+ if (config->sync_from_start == 0) {
ret = dlt_logstorage_sync_capable_data_to_file(config, 0);
+
if (ret != 0)
- {
dlt_vlog(LOG_ERR, "%s: failed to sync capable data to file\n", __func__);
- }
}
}
/* sync data to file if required sync data less than remaining file size */
- else
- {
+ else {
ret = dlt_logstorage_sync_capable_data_to_file(config, 1);
+
if (ret != 0)
- {
dlt_vlog(LOG_ERR, "%s: failed to sync capable data\n", __func__);
- }
}
+
/* sync data to file from almost the begin of cache
* if still data needs to sync */
- if (config->total_write_count > 0)
- {
+ if (config->total_write_count > 0) {
count = footer->offset - footer->last_sync_offset;
ret = fwrite(config->cache + footer->last_sync_offset,
count,
@@ -1498,6 +1359,7 @@ int dlt_logstorage_sync_msg_cache(DltLogStorageFilterConfig *config,
footer->last_sync_offset += count;
}
+
config->cur_cache_sync = 1;
}
}
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index 192f5d8..0768880 100644
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -45,30 +45,30 @@
#include "dlt_version.h"
#if defined (__WIN32__) || defined (_MSC_VER)
-#include <winsock2.h> /* for socket(), connect(), send(), and recv() */
+# include <winsock2.h> /* for socket(), connect(), send(), and recv() */
#else
-#include <sys/socket.h> /* for socket(), connect(), send(), and recv() */
-#include <syslog.h>
-#include <time.h> /* for clock_gettime() */
+# include <sys/socket.h> /* for socket(), connect(), send(), and recv() */
+# include <syslog.h>
+# include <time.h> /* for clock_gettime() */
#endif
#if defined (_MSC_VER)
-#include <io.h>
+# include <io.h>
#else
-#include <unistd.h> /* for read(), close() */
-#include <sys/time.h> /* for gettimeofday() */
+# include <unistd.h> /* for read(), close() */
+# include <sys/time.h> /* for gettimeofday() */
#endif
#if defined (__MSDOS__) || defined (_MSC_VER)
-#pragma warning(disable : 4996) /* Switch off C4996 warnings */
-#include <windows.h>
-#include <winbase.h>
+# pragma warning(disable : 4996) /* Switch off C4996 warnings */
+# include <windows.h>
+# include <winbase.h>
#endif
static char str[DLT_COMMON_BUFFER_LENGTH];
-const char dltSerialHeader[DLT_ID_SIZE] = { 'D','L','S',1 };
-char dltSerialHeaderChar[DLT_ID_SIZE] = { 'D','L','S',1 };
+const char dltSerialHeader[DLT_ID_SIZE] = { 'D', 'L', 'S', 1 };
+char dltSerialHeaderChar[DLT_ID_SIZE] = { 'D', 'L', 'S', 1 };
char dltFifoBaseDir[PATH_MAX + 1] = "/tmp";
/* internal logging parameters */
@@ -77,43 +77,42 @@ static int logging_level = LOG_INFO;
static char logging_filename[NAME_MAX + 1] = "";
static FILE *logging_handle = NULL;
-char *message_type[] = {"log","app_trace","nw_trace","control","","","",""};
-char *log_info[] = {"","fatal","error","warn","info","debug","verbose","","","","","","","","",""};
-char *trace_type[] = {"","variable","func_in","func_out","state","vfb","","","","","","","","","",""};
-char *nw_trace_type[] = {"","ipc","can","flexray","most","vfb","","","","","","","","","",""};
-char *control_type[] = {"","request","response","time","","","","","","","","","","","",""};
-static char *service_id[] = {"","set_log_level","set_trace_status","get_log_info","get_default_log_level","store_config","reset_to_factory_default",
- "set_com_interface_status","set_com_interface_max_bandwidth","set_verbose_mode","set_message_filtering","set_timing_packets",
- "get_local_time","use_ecu_id","use_session_id","use_timestamp","use_extended_header","set_default_log_level","set_default_trace_status",
- "get_software_version","message_buffer_overflow"
- };
-static char *return_type[] = {"ok","not_supported","error","perm_denied","warning","","","","no_matching_context_id"};
+char *message_type[] = { "log", "app_trace", "nw_trace", "control", "", "", "", "" };
+char *log_info[] = { "", "fatal", "error", "warn", "info", "debug", "verbose", "", "", "", "", "", "", "", "", "" };
+char *trace_type[] = { "", "variable", "func_in", "func_out", "state", "vfb", "", "", "", "", "", "", "", "", "", "" };
+char *nw_trace_type[] = { "", "ipc", "can", "flexray", "most", "vfb", "", "", "", "", "", "", "", "", "", "" };
+char *control_type[] = { "", "request", "response", "time", "", "", "", "", "", "", "", "", "", "", "", "" };
+static char *service_id[] =
+{ "", "set_log_level", "set_trace_status", "get_log_info", "get_default_log_level", "store_config",
+ "reset_to_factory_default",
+ "set_com_interface_status", "set_com_interface_max_bandwidth", "set_verbose_mode",
+ "set_message_filtering", "set_timing_packets",
+ "get_local_time", "use_ecu_id", "use_session_id", "use_timestamp", "use_extended_header",
+ "set_default_log_level", "set_default_trace_status",
+ "get_software_version", "message_buffer_overflow" };
+static char *return_type[] =
+{ "ok", "not_supported", "error", "perm_denied", "warning", "", "", "", "no_matching_context_id" };
/* internal function definitions */
-int dlt_buffer_get(DltBuffer *buf,unsigned char *data, int max_size,int delete);
+int dlt_buffer_get(DltBuffer *buf, unsigned char *data, int max_size, int delete);
int dlt_buffer_reset(DltBuffer *buf);
int dlt_buffer_increase_size(DltBuffer *buf);
int dlt_buffer_minimize_size(DltBuffer *buf);
-void dlt_buffer_write_block(DltBuffer *buf,int *write, const unsigned char *data,unsigned int size);
-void dlt_buffer_read_block(DltBuffer *buf,int *read,unsigned char *data,unsigned int size);
+void dlt_buffer_write_block(DltBuffer *buf, int *write, const unsigned char *data, unsigned int size);
+void dlt_buffer_read_block(DltBuffer *buf, int *read, unsigned char *data, unsigned int size);
-void dlt_print_hex(uint8_t *ptr,int size)
+void dlt_print_hex(uint8_t *ptr, int size)
{
int num;
if (ptr == NULL)
- {
return;
- }
- for (num=0;num<size;num++)
- {
- if (num>0)
- {
+ for (num = 0; num < size; num++) {
+ if (num > 0)
printf(" ");
- }
- printf("%.2x",((uint8_t*)ptr)[num]);
+ printf("%.2x", ((uint8_t *)ptr)[num]);
}
}
@@ -122,136 +121,134 @@ DltReturnValue dlt_print_hex_string(char *text, int textlength, uint8_t *ptr, in
int num;
if ((ptr == NULL) || (text == NULL) || (textlength <= 0) || (size < 0))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* Length 3: AB_ , A is first digit of hex number, B is second digit of hex number, _ is space */
- if (textlength<(size*3))
- {
+ if (textlength < (size * 3)) {
char str[255];
- snprintf(str, 254, "String does not fit hex data (available=%d, required=%d) !\n", textlength, size*3);
+ snprintf(str, 254, "String does not fit hex data (available=%d, required=%d) !\n", textlength, size * 3);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
- for (num=0; num<size; num++)
- {
- if (num>0)
- {
- snprintf(text,2," ");
+ for (num = 0; num < size; num++) {
+ if (num > 0) {
+ snprintf(text, 2, " ");
text++;
}
- snprintf(text,3,"%.2x",((uint8_t*)ptr)[num]);
- text+=2; /* 2 chars */
+ snprintf(text, 3, "%.2x", ((uint8_t *)ptr)[num]);
+ text += 2; /* 2 chars */
}
return DLT_RETURN_OK;
}
-DltReturnValue dlt_print_mixed_string(char *text, int textlength ,uint8_t *ptr, int size, int html)
+DltReturnValue dlt_print_mixed_string(char *text, int textlength, uint8_t *ptr, int size, int html)
{
int required_size = 0;
int lines, rest, i;
if ((ptr == NULL) || (text == NULL) || (textlength <= 0) || (size < 0))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* Check maximum required size and do a length check */
if (html == 0)
- {
- required_size=(DLT_COMMON_HEX_LINELEN+(2*DLT_COMMON_HEX_CHARS+(DLT_COMMON_HEX_CHARS-1))+DLT_COMMON_CHARLEN+DLT_COMMON_HEX_CHARS+DLT_COMMON_CHARLEN) *
- ((size/DLT_COMMON_HEX_CHARS) + 1);
+ required_size =
+ (DLT_COMMON_HEX_LINELEN + (2 * DLT_COMMON_HEX_CHARS + (DLT_COMMON_HEX_CHARS - 1)) + DLT_COMMON_CHARLEN +
+ DLT_COMMON_HEX_CHARS + DLT_COMMON_CHARLEN) *
+ ((size / DLT_COMMON_HEX_CHARS) + 1);
/* Example: (8 chars line number + (2*16 chars + 15 spaces) + space + 16 ascii chars + CR) *
- ((size/16) lines + extra line for the rest) */
- }
+ * ((size/16) lines + extra line for the rest) */
else
- {
- required_size=(DLT_COMMON_HEX_LINELEN+(2*DLT_COMMON_HEX_CHARS+(DLT_COMMON_HEX_CHARS-1))+DLT_COMMON_CHARLEN+DLT_COMMON_HEX_CHARS+4*DLT_COMMON_CHARLEN) *
- ((size/DLT_COMMON_HEX_CHARS) + 1);
+ required_size =
+ (DLT_COMMON_HEX_LINELEN + (2 * DLT_COMMON_HEX_CHARS + (DLT_COMMON_HEX_CHARS - 1)) + DLT_COMMON_CHARLEN +
+ DLT_COMMON_HEX_CHARS + 4 * DLT_COMMON_CHARLEN) *
+ ((size / DLT_COMMON_HEX_CHARS) + 1);
/* Example: (8 chars line number + (2*16 chars + 15 spaces) + space + 16 ascii chars + 4 [HTML CR: <BR>]) *
- ((size/16) lines + extra line for the rest) */
- }
-
- if (textlength<required_size)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH, "String does not fit mixed data (available=%d, required=%d) !\n", textlength, required_size);
+ * ((size/16) lines + extra line for the rest) */
+
+ if (textlength < required_size) {
+ snprintf(str,
+ DLT_COMMON_BUFFER_LENGTH,
+ "String does not fit mixed data (available=%d, required=%d) !\n",
+ textlength,
+ required_size);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
/* print full lines */
- for (lines=0; lines< (size / DLT_COMMON_HEX_CHARS); lines++)
- {
+ for (lines = 0; lines < (size / DLT_COMMON_HEX_CHARS); lines++) {
int ret = 0;
/* Line number */
- ret = snprintf(text,DLT_COMMON_HEX_LINELEN+1,"%.6x: ",lines * DLT_COMMON_HEX_CHARS);
- if ((ret < 0 ) || (ret >= (DLT_COMMON_HEX_LINELEN + 1)))
+ ret = snprintf(text, DLT_COMMON_HEX_LINELEN + 1, "%.6x: ", lines * DLT_COMMON_HEX_CHARS);
+
+ if ((ret < 0) || (ret >= (DLT_COMMON_HEX_LINELEN + 1)))
dlt_log(LOG_WARNING, "line was truncated\n");
- text+=DLT_COMMON_HEX_LINELEN; /* 'XXXXXX: ' */
+
+ text += DLT_COMMON_HEX_LINELEN; /* 'XXXXXX: ' */
/* Hex-Output */
/* It is not required to decrement textlength, as it was already checked, that
- there is enough space for the complete output */
- dlt_print_hex_string(text,textlength,(uint8_t*)(ptr+(lines*DLT_COMMON_HEX_CHARS)),DLT_COMMON_HEX_CHARS);
- text+=((2*DLT_COMMON_HEX_CHARS)+(DLT_COMMON_HEX_CHARS-1)); /* 32 characters + 15 spaces */
+ * there is enough space for the complete output */
+ dlt_print_hex_string(text, textlength, (uint8_t *)(ptr + (lines * DLT_COMMON_HEX_CHARS)), DLT_COMMON_HEX_CHARS);
+ text += ((2 * DLT_COMMON_HEX_CHARS) + (DLT_COMMON_HEX_CHARS - 1)); /* 32 characters + 15 spaces */
- snprintf(text,2," ");
- text+=DLT_COMMON_CHARLEN;
+ snprintf(text, 2, " ");
+ text += DLT_COMMON_CHARLEN;
/* Char-Output */
/* It is not required to decrement textlength, as it was already checked, that
- there is enough space for the complete output */
- dlt_print_char_string(&text,textlength,(uint8_t*)(ptr+(lines*DLT_COMMON_HEX_CHARS)),DLT_COMMON_HEX_CHARS);
+ * there is enough space for the complete output */
+ dlt_print_char_string(&text, textlength, (uint8_t *)(ptr + (lines * DLT_COMMON_HEX_CHARS)),
+ DLT_COMMON_HEX_CHARS);
- if (html==0)
- {
- snprintf(text,2,"\n");
- text+=DLT_COMMON_CHARLEN;
+ if (html == 0) {
+ snprintf(text, 2, "\n");
+ text += DLT_COMMON_CHARLEN;
}
- else
- {
- snprintf(text,5,"<BR>");
- text+=(4*DLT_COMMON_CHARLEN);
+ else {
+ snprintf(text, 5, "<BR>");
+ text += (4 * DLT_COMMON_CHARLEN);
}
}
/* print partial line */
rest = size % DLT_COMMON_HEX_CHARS;
- if (rest>0)
- {
+ if (rest > 0) {
/* Line number */
int ret = 0;
- ret = snprintf(text,9,"%.6x: ", (size / DLT_COMMON_HEX_CHARS) * DLT_COMMON_HEX_CHARS);
+ ret = snprintf(text, 9, "%.6x: ", (size / DLT_COMMON_HEX_CHARS) * DLT_COMMON_HEX_CHARS);
+
if ((ret < 0) || (ret >= 9))
- {
dlt_log(LOG_WARNING, "line number was truncated");
- }
- text+=DLT_COMMON_HEX_LINELEN; /* 'XXXXXX: ' */
+
+ text += DLT_COMMON_HEX_LINELEN; /* 'XXXXXX: ' */
/* Hex-Output */
/* It is not required to decrement textlength, as it was already checked, that
- there is enough space for the complete output */
- dlt_print_hex_string(text,textlength,(uint8_t*)(ptr+ ((size / DLT_COMMON_HEX_CHARS) * DLT_COMMON_HEX_CHARS)),rest);
- text+=2*rest+(rest-1);
+ * there is enough space for the complete output */
+ dlt_print_hex_string(text,
+ textlength,
+ (uint8_t *)(ptr + ((size / DLT_COMMON_HEX_CHARS) * DLT_COMMON_HEX_CHARS)),
+ rest);
+ text += 2 * rest + (rest - 1);
- for (i=0;i<(DLT_COMMON_HEX_CHARS-rest);i++)
- {
- snprintf(text,4," xx");
- text+=(3*DLT_COMMON_CHARLEN);
+ for (i = 0; i < (DLT_COMMON_HEX_CHARS - rest); i++) {
+ snprintf(text, 4, " xx");
+ text += (3 * DLT_COMMON_CHARLEN);
}
- snprintf(text,2," ");
- text+=DLT_COMMON_CHARLEN;
+ snprintf(text, 2, " ");
+ text += DLT_COMMON_CHARLEN;
/* Char-Output */
/* It is not required to decrement textlength, as it was already checked, that
- there is enough space for the complete output */
- dlt_print_char_string(&text,textlength,(uint8_t*)(ptr+ ((size / DLT_COMMON_HEX_CHARS) * DLT_COMMON_HEX_CHARS)),rest);
+ * there is enough space for the complete output */
+ dlt_print_char_string(&text, textlength,
+ (uint8_t *)(ptr + ((size / DLT_COMMON_HEX_CHARS) * DLT_COMMON_HEX_CHARS)), rest);
}
return DLT_RETURN_OK;
@@ -262,36 +259,27 @@ DltReturnValue dlt_print_char_string(char **text, int textlength, uint8_t *ptr,
int num;
if ((text == NULL) || (ptr == NULL) || (*text == NULL) || (textlength <= 0) || (size < 0))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (textlength < size)
- {
+ if (textlength < size) {
char str[255];
snprintf(str, 254, "String does not fit character data (available=%d, required=%d) !\n", textlength, size);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_WRONG_PARAMETER;
}
- for (num=0; num<size; num++)
- {
- if ( (((char*)ptr)[num]<DLT_COMMON_ASCII_CHAR_SPACE) || (((char*)ptr)[num]>DLT_COMMON_ASCII_CHAR_TILDE) )
- {
- snprintf(*text,2,".");
+ for (num = 0; num < size; num++) {
+ if ((((char *)ptr)[num] < DLT_COMMON_ASCII_CHAR_SPACE) || (((char *)ptr)[num] > DLT_COMMON_ASCII_CHAR_TILDE)) {
+ snprintf(*text, 2, ".");
}
- else
- {
+ else {
/* replace < with . */
- if (((char*)ptr)[num]!=DLT_COMMON_ASCII_CHAR_LT)
- {
- snprintf(*text,2,"%c",((char *)ptr)[num]);
- }
+ if (((char *)ptr)[num] != DLT_COMMON_ASCII_CHAR_LT)
+ snprintf(*text, 2, "%c", ((char *)ptr)[num]);
else
- {
- snprintf(*text,2,".");
- }
+ snprintf(*text, 2, ".");
}
+
(*text)++;
}
@@ -300,31 +288,29 @@ DltReturnValue dlt_print_char_string(char **text, int textlength, uint8_t *ptr,
void dlt_print_id(char *text, const char *id)
{
- // check nullpointer
- if(text == NULL || id == NULL)
+ /* check nullpointer */
+ if ((text == NULL) || (id == NULL))
return;
int i, len;
/* Initialize text */
- for (i=0; i<DLT_ID_SIZE; i++)
- {
- text[i]='-';
- }
+ for (i = 0; i < DLT_ID_SIZE; i++)
+ text[i] = '-';
text[DLT_ID_SIZE] = 0;
- len = ((strlen(id)<=DLT_ID_SIZE)?strlen(id):DLT_ID_SIZE);
+ len = ((strlen(id) <= DLT_ID_SIZE) ? strlen(id) : DLT_ID_SIZE);
/* Check id*/
- for (i=0; i<len; i++)
+ for (i = 0; i < len; i++)
text[i] = id[i];
}
void dlt_set_id(char *id, const char *text)
{
- // check nullpointer
- if(id == NULL || text == NULL)
+ /* check nullpointer */
+ if ((id == NULL) || (text == NULL))
return;
id[0] = 0;
@@ -332,41 +318,25 @@ void dlt_set_id(char *id, const char *text)
id[2] = 0;
id[3] = 0;
- if (text[0]!=0)
- {
+ if (text[0] != 0)
id[0] = text[0];
- }
else
- {
return;
- }
- if (text[1]!=0)
- {
+ if (text[1] != 0)
id[1] = text[1];
- }
else
- {
return;
- }
- if (text[2]!=0)
- {
+ if (text[2] != 0)
id[2] = text[2];
- }
else
- {
return;
- }
- if (text[3]!=0)
- {
+ if (text[3] != 0)
id[3] = text[3];
- }
else
- {
return;
- }
}
void dlt_clean_string(char *text, int length)
@@ -374,17 +344,11 @@ void dlt_clean_string(char *text, int length)
int num;
if (text == NULL)
- {
return;
- }
- for (num=0;num<length;num++)
- {
- if (text[num]=='\r' || text[num]=='\n')
- {
+ for (num = 0; num < length; num++)
+ if ((text[num] == '\r') || (text[num] == '\n'))
text[num] = ' ';
- }
- }
}
DltReturnValue dlt_filter_init(DltFilter *filter, int verbose)
@@ -392,9 +356,7 @@ DltReturnValue dlt_filter_init(DltFilter *filter, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (filter == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
filter->counter = 0;
@@ -406,84 +368,72 @@ DltReturnValue dlt_filter_free(DltFilter *filter, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (filter == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
return DLT_RETURN_OK;
}
DltReturnValue dlt_filter_load(DltFilter *filter, const char *filename, int verbose)
{
- if (filter == NULL || filename == NULL)
- {
+ if ((filter == NULL) || (filename == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- }
FILE *handle;
char str1[DLT_COMMON_BUFFER_LENGTH];
- char apid[DLT_ID_SIZE],ctid[DLT_ID_SIZE];
+ char apid[DLT_ID_SIZE], ctid[DLT_ID_SIZE];
PRINT_FUNCTION_VERBOSE(verbose);
- handle = fopen(filename,"r");
- if (handle == NULL)
- {
+ handle = fopen(filename, "r");
+
+ if (handle == NULL) {
snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Filter file %s cannot be opened!\n", filename);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
/* Reset filters */
- filter->counter=0;
+ filter->counter = 0;
- while (!feof(handle))
- {
- str1[0]=0;
- if (fscanf(handle,"%s",str1)!=1)
- {
+ while (!feof(handle)) {
+ str1[0] = 0;
+
+ if (fscanf(handle, "%s", str1) != 1)
break;
- }
- if (str1[0]==0)
- {
+
+ if (str1[0] == 0)
break;
- }
- printf(" %s",str1);
- if (strcmp(str1,"----")==0)
- {
- dlt_set_id(apid,"");
- }
+
+ printf(" %s", str1);
+
+ if (strcmp(str1, "----") == 0)
+ dlt_set_id(apid, "");
else
- {
- dlt_set_id(apid,str1);
- }
+ dlt_set_id(apid, str1);
- str1[0]=0;
- if (fscanf(handle,"%s",str1)!=1)
- {
+ str1[0] = 0;
+
+ if (fscanf(handle, "%s", str1) != 1)
break;
- }
- if (str1[0]==0)
- {
+
+ if (str1[0] == 0)
break;
- }
- printf(" %s\r\n",str1);
- if (strcmp(str1,"----")==0)
- {
- dlt_set_id(ctid,"");
- }
+
+ printf(" %s\r\n", str1);
+
+ if (strcmp(str1, "----") == 0)
+ dlt_set_id(ctid, "");
else
- {
- dlt_set_id(ctid,str1);
- }
+ dlt_set_id(ctid, str1);
- if (filter->counter<DLT_FILTER_MAX)
- {
- dlt_filter_add(filter,apid,ctid,verbose);
+ if (filter->counter < DLT_FILTER_MAX) {
+ dlt_filter_add(filter, apid, ctid, verbose);
}
- else
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH, "Maximum number (%d) of allowed filters reached, ignoring rest of filters!\n", DLT_FILTER_MAX);
+ else {
+ snprintf(str,
+ DLT_COMMON_BUFFER_LENGTH,
+ "Maximum number (%d) of allowed filters reached, ignoring rest of filters!\n",
+ DLT_FILTER_MAX);
dlt_log(LOG_WARNING, str);
}
}
@@ -495,10 +445,8 @@ DltReturnValue dlt_filter_load(DltFilter *filter, const char *filename, int verb
DltReturnValue dlt_filter_save(DltFilter *filter, const char *filename, int verbose)
{
- if (filter == NULL || filename == NULL)
- {
+ if ((filter == NULL) || (filename == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- }
FILE *handle;
int num;
@@ -506,33 +454,29 @@ DltReturnValue dlt_filter_save(DltFilter *filter, const char *filename, int verb
PRINT_FUNCTION_VERBOSE(verbose);
- handle = fopen(filename,"w");
- if (handle == NULL)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Filter file %s cannot be opened!\n",filename);
+ handle = fopen(filename, "w");
+
+ if (handle == NULL) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Filter file %s cannot be opened!\n", filename);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
- for (num=0;num<filter->counter;num++)
- {
- if (filter->apid[num][0]==0)
- {
- fprintf(handle,"---- ");
+ for (num = 0; num < filter->counter; num++) {
+ if (filter->apid[num][0] == 0) {
+ fprintf(handle, "---- ");
}
- else
- {
- dlt_print_id(buf,filter->apid[num]);
- fprintf(handle,"%s ",buf);
+ else {
+ dlt_print_id(buf, filter->apid[num]);
+ fprintf(handle, "%s ", buf);
}
- if (filter->ctid[num][0]==0)
- {
- fprintf(handle,"---- ");
+
+ if (filter->ctid[num][0] == 0) {
+ fprintf(handle, "---- ");
}
- else
- {
- dlt_print_id(buf,filter->ctid[num]);
- fprintf(handle,"%s ",buf);
+ else {
+ dlt_print_id(buf, filter->ctid[num]);
+ fprintf(handle, "%s ", buf);
}
}
@@ -548,62 +492,45 @@ int dlt_filter_find(DltFilter *filter, const char *apid, const char *ctid, int v
PRINT_FUNCTION_VERBOSE(verbose);
if ((filter == NULL) || (apid == NULL))
- {
return -1;
- }
- for (num=0; num<filter->counter; num++)
- {
- if (memcmp(filter->apid[num],apid,DLT_ID_SIZE)==0)
- {
+ for (num = 0; num < filter->counter; num++)
+ if (memcmp(filter->apid[num], apid, DLT_ID_SIZE) == 0) {
/* apid matches, now check for ctid */
- if (ctid == NULL)
- {
+ if (ctid == NULL) {
/* check if empty ctid matches */
- //if (memcmp(filter->ctid[num],"",DLT_ID_SIZE)==0)//coverity complains here about Out-of-bounds access.
- char empty_ctid[DLT_ID_SIZE]="";
- if (memcmp(filter->ctid[num],empty_ctid,DLT_ID_SIZE)==0)
- {
- return num;
- }
- }
- else
- {
- if (memcmp(filter->ctid[num],ctid,DLT_ID_SIZE)==0)
- {
+ /*if (memcmp(filter->ctid[num],"",DLT_ID_SIZE)==0)//coverity complains here about Out-of-bounds access. */
+ char empty_ctid[DLT_ID_SIZE] = "";
+
+ if (memcmp(filter->ctid[num], empty_ctid, DLT_ID_SIZE) == 0)
return num;
- }
}
+ else if (memcmp(filter->ctid[num], ctid, DLT_ID_SIZE) == 0)
+ return num;
}
- }
return -1; /* Not found */
}
-DltReturnValue dlt_filter_add(DltFilter *filter,const char *apid, const char *ctid, int verbose)
+DltReturnValue dlt_filter_add(DltFilter *filter, const char *apid, const char *ctid, int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
if ((filter == NULL) || (apid == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (filter->counter >= DLT_FILTER_MAX)
- {
+ if (filter->counter >= DLT_FILTER_MAX) {
sprintf(str, "Maximum number (%d) of allowed filters reached, ignoring filter!\n", DLT_FILTER_MAX);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
/* add each filter (apid, ctid) only once to filter array */
- if (dlt_filter_find(filter,apid,ctid,verbose)<0)
- {
+ if (dlt_filter_find(filter, apid, ctid, verbose) < 0) {
/* filter not found, so add it to filter array */
- if (filter->counter<DLT_FILTER_MAX)
- {
- dlt_set_id(filter->apid[filter->counter],apid);
- dlt_set_id(filter->ctid[filter->counter],(ctid?ctid:""));
+ if (filter->counter < DLT_FILTER_MAX) {
+ dlt_set_id(filter->apid[filter->counter], apid);
+ dlt_set_id(filter->ctid[filter->counter], (ctid ? ctid : ""));
filter->counter++;
@@ -614,45 +541,38 @@ DltReturnValue dlt_filter_add(DltFilter *filter,const char *apid, const char *ct
return DLT_RETURN_ERROR;
}
-DltReturnValue dlt_filter_delete(DltFilter *filter,const char *apid,const char *ctid, int verbose)
+DltReturnValue dlt_filter_delete(DltFilter *filter, const char *apid, const char *ctid, int verbose)
{
- int j,k;
- int found=0;
+ int j, k;
+ int found = 0;
PRINT_FUNCTION_VERBOSE(verbose);
if ((filter == NULL) || (apid == NULL) || (ctid == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (filter->counter>0)
- {
+ if (filter->counter > 0) {
/* Get first occurence of apid and ctid in filter array */
- for (j=0; j<filter->counter; j++)
- {
- if ((memcmp(filter->apid[j],apid,DLT_ID_SIZE)==0) &&
- (memcmp(filter->ctid[j],ctid,DLT_ID_SIZE)==0)
- )
-
- {
- found=1;
+ for (j = 0; j < filter->counter; j++)
+ if ((memcmp(filter->apid[j], apid, DLT_ID_SIZE) == 0) &&
+ (memcmp(filter->ctid[j], ctid, DLT_ID_SIZE) == 0)
+ ) {
+ found = 1;
break;
}
- }
- if (found)
- {
+
+
+ if (found) {
/* j is index */
/* Copy from j+1 til end to j til end-1 */
- dlt_set_id(filter->apid[j],"");
- dlt_set_id(filter->ctid[j],"");
+ dlt_set_id(filter->apid[j], "");
+ dlt_set_id(filter->ctid[j], "");
- for (k=j; k<(filter->counter-1); k++)
- {
- dlt_set_id(filter->apid[k],filter->apid[k+1]);
- dlt_set_id(filter->ctid[k],filter->ctid[k+1]);
+ for (k = j; k < (filter->counter - 1); k++) {
+ dlt_set_id(filter->apid[k], filter->apid[k + 1]);
+ dlt_set_id(filter->ctid[k], filter->ctid[k + 1]);
}
filter->counter--;
@@ -668,9 +588,7 @@ DltReturnValue dlt_message_init(DltMessage *msg, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (msg == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* initalise structure parameters */
msg->headersize = 0;
@@ -693,12 +611,10 @@ DltReturnValue dlt_message_free(DltMessage *msg, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (msg == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
+
/* delete databuffer if exists */
- if (msg->databuffer)
- {
+ if (msg->databuffer) {
free(msg->databuffer);
msg->databuffer = NULL;
msg->databuffersize = 0;
@@ -714,175 +630,126 @@ DltReturnValue dlt_message_header(DltMessage *msg, char *text, int textlength, i
DltReturnValue dlt_message_header_flags(DltMessage *msg, char *text, int textlength, int flags, int verbose)
{
- struct tm * timeinfo;
+ struct tm *timeinfo;
char buffer [DLT_COMMON_BUFFER_LENGTH];
PRINT_FUNCTION_VERBOSE(verbose);
if ((msg == NULL) || (text == NULL) || (textlength <= 0))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if ((flags<DLT_HEADER_SHOW_NONE) || (flags>DLT_HEADER_SHOW_ALL))
- {
+ if ((flags < DLT_HEADER_SHOW_NONE) || (flags > DLT_HEADER_SHOW_ALL))
return DLT_RETURN_WRONG_PARAMETER;
- }
text[0] = 0;
- if ((flags & DLT_HEADER_SHOW_TIME) == DLT_HEADER_SHOW_TIME)
- {
+ if ((flags & DLT_HEADER_SHOW_TIME) == DLT_HEADER_SHOW_TIME) {
/* print received time */
time_t tt = msg->storageheader->seconds;
timeinfo = localtime (&tt);
- if (timeinfo != NULL)
- {
- strftime (buffer,sizeof(buffer),"%Y/%m/%d %H:%M:%S",timeinfo);
- snprintf(text,textlength,"%s.%.6d ",buffer,msg->storageheader->microseconds);
+ if (timeinfo != NULL) {
+ strftime (buffer, sizeof(buffer), "%Y/%m/%d %H:%M:%S", timeinfo);
+ snprintf(text, textlength, "%s.%.6d ", buffer, msg->storageheader->microseconds);
}
}
- if ((flags & DLT_HEADER_SHOW_TMSTP) == DLT_HEADER_SHOW_TMSTP)
- {
+ if ((flags & DLT_HEADER_SHOW_TMSTP) == DLT_HEADER_SHOW_TMSTP) {
/* print timestamp if available */
- if ( DLT_IS_HTYP_WTMS(msg->standardheader->htyp) )
- {
- snprintf(text+strlen(text),textlength-strlen(text),"%10u ",msg->headerextra.tmsp);
- }
+ if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp))
+ snprintf(text + strlen(text), textlength - strlen(text), "%10u ", msg->headerextra.tmsp);
else
- {
- snprintf(text+strlen(text),textlength-strlen(text),"---------- ");
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "---------- ");
}
if ((flags & DLT_HEADER_SHOW_MSGCNT) == DLT_HEADER_SHOW_MSGCNT)
- {
/* print message counter */
- snprintf(text+strlen(text),textlength-strlen(text),"%.3d ",msg->standardheader->mcnt);
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "%.3d ", msg->standardheader->mcnt);
- if ((flags & DLT_HEADER_SHOW_ECUID) == DLT_HEADER_SHOW_ECUID)
- {
+ if ((flags & DLT_HEADER_SHOW_ECUID) == DLT_HEADER_SHOW_ECUID) {
/* print ecu id, use header extra if available, else storage header value */
- if ( DLT_IS_HTYP_WEID(msg->standardheader->htyp) )
- {
- dlt_print_id(text+strlen(text),msg->headerextra.ecu);
- }
+ if (DLT_IS_HTYP_WEID(msg->standardheader->htyp))
+ dlt_print_id(text + strlen(text), msg->headerextra.ecu);
else
- {
- dlt_print_id(text+strlen(text),msg->storageheader->ecu);
- }
+ dlt_print_id(text + strlen(text), msg->storageheader->ecu);
}
- /* print app id and context id if extended header available, else '----' */#
- if ((flags & DLT_HEADER_SHOW_APID) == DLT_HEADER_SHOW_APID)
- {
- snprintf(text+strlen(text),textlength-strlen(text)," ");
- if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) && (msg->extendedheader->apid[0]!=0))
- {
- dlt_print_id(text+strlen(text),msg->extendedheader->apid);
- }
+ /* print app id and context id if extended header available, else '----' */ #
+
+ if ((flags & DLT_HEADER_SHOW_APID) == DLT_HEADER_SHOW_APID) {
+ snprintf(text + strlen(text), textlength - strlen(text), " ");
+
+ if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) && (msg->extendedheader->apid[0] != 0))
+ dlt_print_id(text + strlen(text), msg->extendedheader->apid);
else
- {
- snprintf(text+strlen(text),textlength-strlen(text),"----");
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "----");
- snprintf(text+strlen(text),textlength-strlen(text)," ");
+ snprintf(text + strlen(text), textlength - strlen(text), " ");
}
- if ((flags & DLT_HEADER_SHOW_CTID) == DLT_HEADER_SHOW_CTID)
- {
- if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) && (msg->extendedheader->ctid[0]!=0))
- {
- dlt_print_id(text+strlen(text),msg->extendedheader->ctid);
- }
+ if ((flags & DLT_HEADER_SHOW_CTID) == DLT_HEADER_SHOW_CTID) {
+ if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) && (msg->extendedheader->ctid[0] != 0))
+ dlt_print_id(text + strlen(text), msg->extendedheader->ctid);
else
- {
- snprintf(text+strlen(text),textlength-strlen(text),"----");
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "----");
- snprintf(text+strlen(text),textlength-strlen(text)," ");
+ snprintf(text + strlen(text), textlength - strlen(text), " ");
}
/* print info about message type and length */
- if (DLT_IS_HTYP_UEH(msg->standardheader->htyp))
- {
- if ((flags & DLT_HEADER_SHOW_MSGTYPE) == DLT_HEADER_SHOW_MSGTYPE)
- {
- snprintf(text+strlen(text),textlength-strlen(text),"%s",message_type[DLT_GET_MSIN_MSTP(msg->extendedheader->msin)]);
- snprintf(text+strlen(text),textlength-strlen(text)," ");
+ if (DLT_IS_HTYP_UEH(msg->standardheader->htyp)) {
+ if ((flags & DLT_HEADER_SHOW_MSGTYPE) == DLT_HEADER_SHOW_MSGTYPE) {
+ snprintf(text + strlen(text), textlength - strlen(text), "%s",
+ message_type[DLT_GET_MSIN_MSTP(msg->extendedheader->msin)]);
+ snprintf(text + strlen(text), textlength - strlen(text), " ");
}
- if ((flags & DLT_HEADER_SHOW_MSGSUBTYPE) == DLT_HEADER_SHOW_MSGSUBTYPE)
- {
- if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin))==DLT_TYPE_LOG)
- {
- snprintf(text+strlen(text),textlength-strlen(text),"%s",log_info[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
- }
+ if ((flags & DLT_HEADER_SHOW_MSGSUBTYPE) == DLT_HEADER_SHOW_MSGSUBTYPE) {
+ if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin)) == DLT_TYPE_LOG)
+ snprintf(text + strlen(text), textlength - strlen(text), "%s",
+ log_info[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
- if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin))==DLT_TYPE_APP_TRACE)
- {
- snprintf(text+strlen(text),textlength-strlen(text),"%s",trace_type[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
- }
+ if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin)) == DLT_TYPE_APP_TRACE)
+ snprintf(text + strlen(text), textlength - strlen(text), "%s",
+ trace_type[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
- if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin))==DLT_TYPE_NW_TRACE)
- {
- snprintf(text+strlen(text),textlength-strlen(text),"%s",nw_trace_type[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
- }
+ if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin)) == DLT_TYPE_NW_TRACE)
+ snprintf(text + strlen(text), textlength - strlen(text), "%s",
+ nw_trace_type[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
- if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin))==DLT_TYPE_CONTROL)
- {
- snprintf(text+strlen(text),textlength-strlen(text),"%s",control_type[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
- }
+ if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin)) == DLT_TYPE_CONTROL)
+ snprintf(text + strlen(text), textlength - strlen(text), "%s",
+ control_type[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
- snprintf(text+strlen(text),textlength-strlen(text)," ");
+ snprintf(text + strlen(text), textlength - strlen(text), " ");
}
- if ((flags & DLT_HEADER_SHOW_VNVSTATUS) == DLT_HEADER_SHOW_VNVSTATUS)
- {
+ if ((flags & DLT_HEADER_SHOW_VNVSTATUS) == DLT_HEADER_SHOW_VNVSTATUS) {
/* print verbose status pf message */
if (DLT_IS_MSIN_VERB(msg->extendedheader->msin))
- {
- snprintf(text+strlen(text),textlength-strlen(text),"V");
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "V");
else
- {
- snprintf(text+strlen(text),textlength-strlen(text),"N");
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "N");
- snprintf(text+strlen(text),textlength-strlen(text)," ");
+ snprintf(text + strlen(text), textlength - strlen(text), " ");
}
if ((flags & DLT_HEADER_SHOW_NOARG) == DLT_HEADER_SHOW_NOARG)
- {
/* print number of arguments */
- snprintf(text+strlen(text),textlength-strlen(text),"%d", msg->extendedheader->noar);
- }
-
+ snprintf(text + strlen(text), textlength - strlen(text), "%d", msg->extendedheader->noar);
}
- else
- {
+ else {
if ((flags & DLT_HEADER_SHOW_MSGTYPE) == DLT_HEADER_SHOW_MSGTYPE)
- {
- snprintf(text+strlen(text),textlength-strlen(text),"--- ");
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "--- ");
if ((flags & DLT_HEADER_SHOW_MSGSUBTYPE) == DLT_HEADER_SHOW_MSGSUBTYPE)
- {
- snprintf(text+strlen(text),textlength-strlen(text),"--- ");
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "--- ");
if ((flags & DLT_HEADER_SHOW_VNVSTATUS) == DLT_HEADER_SHOW_VNVSTATUS)
- {
- snprintf(text+strlen(text),textlength-strlen(text),"N ");
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "N ");
if ((flags & DLT_HEADER_SHOW_NOARG) == DLT_HEADER_SHOW_NOARG)
- {
- snprintf(text+strlen(text),textlength-strlen(text),"-");
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "-");
}
return DLT_RETURN_OK;
@@ -890,8 +757,8 @@ DltReturnValue dlt_message_header_flags(DltMessage *msg, char *text, int textlen
DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength, int type, int verbose)
{
- uint32_t id=0, id_tmp=0;
- uint8_t retval=0;
+ uint32_t id = 0, id_tmp = 0;
+ uint8_t retval = 0;
uint8_t *ptr;
int32_t datalength;
@@ -900,20 +767,17 @@ DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength,
uint8_t **pptr;
int32_t *pdatalength;
- int ret=0;
+ int ret = 0;
int num;
- uint32_t type_info=0,type_info_tmp=0;
+ uint32_t type_info = 0, type_info_tmp = 0;
PRINT_FUNCTION_VERBOSE(verbose);
if ((msg == NULL) || (text == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (textlength <= 0)
- {
+ if (textlength <= 0) {
dlt_log(LOG_WARNING, "String does not fit binary data!\n");
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -922,21 +786,15 @@ DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength,
text[0] = 0;
/* print payload only as hex */
- if (type==DLT_OUTPUT_HEX)
- {
+ if (type == DLT_OUTPUT_HEX)
return dlt_print_hex_string(text, textlength, msg->databuffer, msg->datasize);
- }
/* print payload as mixed */
- if (type==DLT_OUTPUT_MIXED_FOR_PLAIN)
- {
- return dlt_print_mixed_string(text, textlength, msg->databuffer, msg->datasize,0);
- }
+ if (type == DLT_OUTPUT_MIXED_FOR_PLAIN)
+ return dlt_print_mixed_string(text, textlength, msg->databuffer, msg->datasize, 0);
- if (type==DLT_OUTPUT_MIXED_FOR_HTML)
- {
- return dlt_print_mixed_string(text, textlength, msg->databuffer, msg->datasize,1);
- }
+ if (type == DLT_OUTPUT_MIXED_FOR_HTML)
+ return dlt_print_mixed_string(text, textlength, msg->databuffer, msg->datasize, 1);
ptr = msg->databuffer;
datalength = msg->datasize;
@@ -948,80 +806,63 @@ DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength,
/* non-verbose mode */
/* print payload as hex */
- if (DLT_MSG_IS_NONVERBOSE(msg))
- {
+ if (DLT_MSG_IS_NONVERBOSE(msg)) {
- DLT_MSG_READ_VALUE(id_tmp,ptr,datalength,uint32_t);
- id=DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+ DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t);
+ id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
- if (textlength<((datalength*3)+20))
- {
+ if (textlength < ((datalength * 3) + 20)) {
char str[255];
- snprintf(str, 254, "String does not fit binary data (available=%d, required=%d) !\n", textlength, (datalength*3)+20);
+ snprintf(str, 254, "String does not fit binary data (available=%d, required=%d) !\n", textlength,
+ (datalength * 3) + 20);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
/* process message id / service id */
- if (DLT_MSG_IS_CONTROL(msg))
- {
- if (id > 0 && id < DLT_SERVICE_ID_LAST_ENTRY)
- {
- snprintf(text+strlen(text),textlength-strlen(text),"%s",service_id[id]); /* service id */
- }
- else
- {
- if (!(DLT_MSG_IS_CONTROL_TIME(msg)))
- {
- snprintf(text+strlen(text),textlength-strlen(text),"service(%u)",id); /* service id */
- }
+ if (DLT_MSG_IS_CONTROL(msg)) {
+ if ((id > 0) && (id < DLT_SERVICE_ID_LAST_ENTRY)) {
+ snprintf(text + strlen(text), textlength - strlen(text), "%s", service_id[id]); /* service id */
}
+ else if (!(DLT_MSG_IS_CONTROL_TIME(msg)))
+ snprintf(text + strlen(text), textlength - strlen(text), "service(%u)", id); /* service id */
- if (datalength>0)
- {
- snprintf(text+strlen(text),textlength-strlen(text),", ");
- }
+ if (datalength > 0)
+ snprintf(text + strlen(text), textlength - strlen(text), ", ");
}
- else
- {
- snprintf(text+strlen(text),textlength-strlen(text),"%u, ",id); /* message id */
+ else {
+ snprintf(text + strlen(text), textlength - strlen(text), "%u, ", id); /* message id */
}
/* process return value */
- if (DLT_MSG_IS_CONTROL_RESPONSE(msg))
- {
- if (datalength>0)
- {
- DLT_MSG_READ_VALUE(retval,ptr,datalength,uint8_t); /* No endian conversion necessary */
- if ( (retval<3) || (retval==8))
- {
- snprintf(text+strlen(text),textlength-strlen(text),"%s",return_type[retval]);
- }
+ if (DLT_MSG_IS_CONTROL_RESPONSE(msg)) {
+ if (datalength > 0) {
+ DLT_MSG_READ_VALUE(retval, ptr, datalength, uint8_t); /* No endian conversion necessary */
+
+ if ((retval < 3) || (retval == 8))
+ snprintf(text + strlen(text), textlength - strlen(text), "%s", return_type[retval]);
else
- {
- snprintf(text+strlen(text),textlength-strlen(text),"%.2x",retval);
- }
+ snprintf(text + strlen(text), textlength - strlen(text), "%.2x", retval);
- if (datalength>=1)
- {
- snprintf(text+strlen(text),textlength-strlen(text),", ");
- }
+ if (datalength >= 1)
+ snprintf(text + strlen(text), textlength - strlen(text), ", ");
}
}
- if (type==DLT_OUTPUT_ASCII_LIMITED)
- {
- ret=dlt_print_hex_string(text+strlen(text),textlength-strlen(text),ptr,
- (datalength>DLT_COMMON_ASCII_LIMIT_MAX_CHARS?DLT_COMMON_ASCII_LIMIT_MAX_CHARS:datalength));
- if ((datalength>DLT_COMMON_ASCII_LIMIT_MAX_CHARS) &&
- ((textlength-strlen(text))>4))
- {
- snprintf(text+strlen(text),textlength-strlen(text)," ...");
- }
+ if (type == DLT_OUTPUT_ASCII_LIMITED) {
+ ret = dlt_print_hex_string(text + strlen(text),
+ textlength - strlen(
+ text),
+ ptr,
+ (datalength >
+ DLT_COMMON_ASCII_LIMIT_MAX_CHARS ? DLT_COMMON_ASCII_LIMIT_MAX_CHARS : datalength));
+
+ if ((datalength > DLT_COMMON_ASCII_LIMIT_MAX_CHARS) &&
+ ((textlength - strlen(text)) > 4))
+ snprintf(text + strlen(text), textlength - strlen(text), " ...");
}
- else
- {
- ret=dlt_print_hex_string(text+strlen(text),textlength-strlen(text),ptr,datalength);
+ else {
+ ret = dlt_print_hex_string(text + strlen(text), textlength - strlen(text), ptr, datalength);
}
return ret;
@@ -1030,25 +871,20 @@ DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength,
/* At this point, it is ensured that a extended header is available */
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
+ type_info = 0;
+ type_info_tmp = 0;
- for (num=0;num<(int)(msg->extendedheader->noar);num++)
- {
- if (num!=0)
- {
- snprintf(text+strlen(text),textlength-strlen(text)," ");
- }
+ for (num = 0; num < (int)(msg->extendedheader->noar); num++) {
+ if (num != 0)
+ snprintf(text + strlen(text), textlength - strlen(text), " ");
/* first read the type info of the argument */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(msg->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(msg->standardheader->htyp, type_info_tmp);
/* print out argument */
if (dlt_message_argument_print(msg, type_info, pptr, pdatalength, text, textlength, -1, 0) == DLT_RETURN_ERROR)
- {
return DLT_RETURN_ERROR;
- }
}
return DLT_RETURN_OK;
@@ -1063,27 +899,20 @@ DltReturnValue dlt_message_filter_check(DltMessage *msg, DltFilter *filter, int
PRINT_FUNCTION_VERBOSE(verbose);
if ((msg == NULL) || (filter == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if ((filter->counter==0) || (!(DLT_IS_HTYP_UEH(msg->standardheader->htyp))))
- {
+ if ((filter->counter == 0) || (!(DLT_IS_HTYP_UEH(msg->standardheader->htyp))))
/* no filter is set, or no extended header is available, so do as filter is matching */
return DLT_RETURN_TRUE;
- }
- for (num=0 ;num<filter->counter; num++)
- {
+ for (num = 0; num < filter->counter; num++)
/* check each filter if it matches */
if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) &&
- (filter->apid[num][0]==0 || memcmp(filter->apid[num],msg->extendedheader->apid,DLT_ID_SIZE)==0) &&
- (filter->ctid[num][0]==0 || memcmp(filter->ctid[num],msg->extendedheader->ctid,DLT_ID_SIZE)==0) )
- {
+ ((filter->apid[num][0] == 0) || (memcmp(filter->apid[num], msg->extendedheader->apid, DLT_ID_SIZE) == 0)) &&
+ ((filter->ctid[num][0] == 0) || (memcmp(filter->ctid[num], msg->extendedheader->ctid, DLT_ID_SIZE) == 0))) {
found = DLT_RETURN_TRUE;
break;
}
- }
return found;
}
@@ -1095,40 +924,32 @@ int dlt_message_read(DltMessage *msg, uint8_t *buffer, unsigned int length, int
PRINT_FUNCTION_VERBOSE(verbose);
if ((msg == NULL) || (buffer == NULL) || (length <= 0))
- {
return DLT_MESSAGE_ERROR_UNKNOWN;
- }
/* initialize resync_offset */
- msg->resync_offset=0;
+ msg->resync_offset = 0;
/* check if message contains serial header, smaller than standard header */
- if (length<sizeof(dltSerialHeader))
- {
+ if (length < sizeof(dltSerialHeader))
/* dlt_log(LOG_ERR, "Length smaller than serial header!\n"); */
return DLT_MESSAGE_ERROR_SIZE;
- }
- if (memcmp(buffer, dltSerialHeader, sizeof(dltSerialHeader)) == 0)
- {
+ if (memcmp(buffer, dltSerialHeader, sizeof(dltSerialHeader)) == 0) {
/* serial header found */
msg->found_serialheader = 1;
buffer += sizeof(dltSerialHeader);
length -= sizeof(dltSerialHeader);
}
- else
- {
+ else {
/* serial header not found */
msg->found_serialheader = 0;
- if (resync)
- {
+
+ if (resync) {
/* resync if necessary */
- msg->resync_offset=0;
+ msg->resync_offset = 0;
- do
- {
- if (memcmp(buffer+msg->resync_offset, dltSerialHeader, sizeof(dltSerialHeader)) == 0)
- {
+ do {
+ if (memcmp(buffer + msg->resync_offset, dltSerialHeader, sizeof(dltSerialHeader)) == 0) {
/* serial header found */
msg->found_serialheader = 1;
buffer += sizeof(dltSerialHeader);
@@ -1137,103 +958,101 @@ int dlt_message_read(DltMessage *msg, uint8_t *buffer, unsigned int length, int
}
msg->resync_offset++;
- }
- while ((sizeof(dltSerialHeader)+msg->resync_offset)<=length);
+ } while ((sizeof(dltSerialHeader) + msg->resync_offset) <= length);
/* Set new start offset */
- if (msg->resync_offset>0)
- {
+ if (msg->resync_offset > 0) {
/* Resyncing connection */
- buffer+=msg->resync_offset;
- length-=msg->resync_offset;
+ buffer += msg->resync_offset;
+ length -= msg->resync_offset;
}
}
}
/* check that standard header fits buffer */
- if (length<sizeof(DltStandardHeader))
- {
+ if (length < sizeof(DltStandardHeader))
/* dlt_log(LOG_ERR, "Length smaller than standard header!\n"); */
return DLT_MESSAGE_ERROR_SIZE;
- }
- memcpy(msg->headerbuffer+sizeof(DltStorageHeader), buffer, sizeof(DltStandardHeader));
+
+ memcpy(msg->headerbuffer + sizeof(DltStorageHeader), buffer, sizeof(DltStandardHeader));
/* set ptrs to structures */
- msg->storageheader = (DltStorageHeader*) msg->headerbuffer;
- msg->standardheader = (DltStandardHeader*) (msg->headerbuffer + sizeof(DltStorageHeader));
+ msg->storageheader = (DltStorageHeader *)msg->headerbuffer;
+ msg->standardheader = (DltStandardHeader *)(msg->headerbuffer + sizeof(DltStorageHeader));
/* calculate complete size of headers */
- extra_size = DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp)+(DLT_IS_HTYP_UEH(msg->standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
+ extra_size = DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp) +
+ (DLT_IS_HTYP_UEH(msg->standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
msg->headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + extra_size;
- msg->datasize = DLT_BETOH_16(msg->standardheader->len) - (msg->headersize - sizeof(DltStorageHeader));
-
- if (verbose)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH, "BufferLength=%d, HeaderSize=%d, DataSize=%d\n", length, msg->headersize, msg->datasize);
+ msg->datasize = DLT_BETOH_16(msg->standardheader->len) - (msg->headersize - sizeof(DltStorageHeader));
+
+ if (verbose) {
+ snprintf(str,
+ DLT_COMMON_BUFFER_LENGTH,
+ "BufferLength=%d, HeaderSize=%d, DataSize=%d\n",
+ length,
+ msg->headersize,
+ msg->datasize);
dlt_log(LOG_DEBUG, str);
}
/* check data size */
- if (msg->datasize < 0)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH, "Plausibility check failed. Complete message size too short (%d)!\n",msg->datasize);
+ if (msg->datasize < 0) {
+ snprintf(str,
+ DLT_COMMON_BUFFER_LENGTH,
+ "Plausibility check failed. Complete message size too short (%d)!\n",
+ msg->datasize);
dlt_log(LOG_WARNING, str);
return DLT_MESSAGE_ERROR_CONTENT;
}
/* load standard header extra parameters and Extended header if used */
- if (extra_size>0)
- {
- if (length < (msg->headersize - sizeof(DltStorageHeader)))
- {
+ if (extra_size > 0) {
+ if (length < (msg->headersize - sizeof(DltStorageHeader)))
return DLT_MESSAGE_ERROR_SIZE;
- }
- memcpy(msg->headerbuffer+sizeof(DltStorageHeader)+sizeof(DltStandardHeader),buffer+sizeof(DltStandardHeader),extra_size);
+ memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
+ buffer + sizeof(DltStandardHeader), extra_size);
/* set extended header ptr and get standard header extra parameters */
if (DLT_IS_HTYP_UEH(msg->standardheader->htyp))
- {
- msg->extendedheader = (DltExtendedHeader*) (msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
- DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
- }
+ msg->extendedheader =
+ (DltExtendedHeader *)(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
else
- {
msg->extendedheader = NULL;
- }
- dlt_message_get_extraparameters(msg,verbose);
+ dlt_message_get_extraparameters(msg, verbose);
}
/* check if payload fits length */
- if (length < (msg->headersize - sizeof(DltStorageHeader) + msg->datasize))
- {
+ if (length < (msg->headersize - sizeof(DltStorageHeader) + msg->datasize))
/* dlt_log(LOG_ERR,"length does not fit!\n"); */
return DLT_MESSAGE_ERROR_SIZE;
- }
/* free last used memory for buffer */
- if (msg->databuffer)
- {
- if (msg->datasize>msg->databuffersize){
+ if (msg->databuffer) {
+ if (msg->datasize > msg->databuffersize) {
free(msg->databuffer);
- msg->databuffer=(uint8_t *)malloc(msg->datasize);
+ msg->databuffer = (uint8_t *)malloc(msg->datasize);
msg->databuffersize = msg->datasize;
}
- }else{
+ }
+ else {
/* get new memory for buffer */
msg->databuffer = (uint8_t *)malloc(msg->datasize);
msg->databuffersize = msg->datasize;
}
- if (msg->databuffer == NULL)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Cannot allocate memory for payload buffer of size %d!\n",msg->datasize);
+
+ if (msg->databuffer == NULL) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Cannot allocate memory for payload buffer of size %d!\n",
+ msg->datasize);
dlt_log(LOG_WARNING, str);
return DLT_MESSAGE_ERROR_UNKNOWN;
}
/* load payload data from buffer */
- memcpy(msg->databuffer,buffer+(msg->headersize-sizeof(DltStorageHeader)),msg->datasize);
+ memcpy(msg->databuffer, buffer + (msg->headersize - sizeof(DltStorageHeader)), msg->datasize);
return DLT_MESSAGE_ERROR_OK;
}
@@ -1243,27 +1062,23 @@ DltReturnValue dlt_message_get_extraparameters(DltMessage *msg, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (msg == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if (DLT_IS_HTYP_WEID(msg->standardheader->htyp))
- {
- memcpy(msg->headerextra.ecu,msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),DLT_ID_SIZE);
- }
+ memcpy(msg->headerextra.ecu,
+ msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
+ DLT_ID_SIZE);
- if (DLT_IS_HTYP_WSID(msg->standardheader->htyp))
- {
- memcpy(&(msg->headerextra.seid),msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+ if (DLT_IS_HTYP_WSID(msg->standardheader->htyp)) {
+ memcpy(&(msg->headerextra.seid), msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+ (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0), DLT_SIZE_WSID);
msg->headerextra.seid = DLT_BETOH_32(msg->headerextra.seid);
}
- if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp))
- {
- memcpy(&(msg->headerextra.tmsp),msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+ if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp)) {
+ memcpy(&(msg->headerextra.tmsp), msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+ (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0)
- + (DLT_IS_HTYP_WSID(msg->standardheader->htyp) ? DLT_SIZE_WSID : 0),DLT_SIZE_WTMS);
+ + (DLT_IS_HTYP_WSID(msg->standardheader->htyp) ? DLT_SIZE_WSID : 0), DLT_SIZE_WTMS);
msg->headerextra.tmsp = DLT_BETOH_32(msg->headerextra.tmsp);
}
@@ -1275,28 +1090,28 @@ DltReturnValue dlt_message_set_extraparameters(DltMessage *msg, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (msg == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if (DLT_IS_HTYP_WEID(msg->standardheader->htyp))
- {
- memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),msg->headerextra.ecu,DLT_ID_SIZE);
- }
+ memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
+ msg->headerextra.ecu,
+ DLT_ID_SIZE);
- if (DLT_IS_HTYP_WSID(msg->standardheader->htyp))
- {
+ if (DLT_IS_HTYP_WSID(msg->standardheader->htyp)) {
msg->headerextra.seid = DLT_HTOBE_32(msg->headerextra.seid);
memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
- + (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0), &(msg->headerextra.seid),DLT_SIZE_WSID);
+ + (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0),
+ &(msg->headerextra.seid),
+ DLT_SIZE_WSID);
}
- if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp))
- {
+ if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp)) {
msg->headerextra.tmsp = DLT_HTOBE_32(msg->headerextra.tmsp);
memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+ (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0)
- + (DLT_IS_HTYP_WSID(msg->standardheader->htyp) ? DLT_SIZE_WSID : 0), &(msg->headerextra.tmsp),DLT_SIZE_WTMS);
+ + (DLT_IS_HTYP_WSID(msg->standardheader->htyp) ? DLT_SIZE_WSID : 0),
+ &(msg->headerextra.tmsp),
+ DLT_SIZE_WTMS);
}
return DLT_RETURN_OK;
@@ -1307,9 +1122,7 @@ DltReturnValue dlt_file_init(DltFile *file, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (file == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* initalise structure parameters */
file->handle = NULL;
@@ -1325,7 +1138,7 @@ DltReturnValue dlt_file_init(DltFile *file, int verbose)
file->error_messages = 0;
- return dlt_message_init(&(file->msg),verbose);
+ return dlt_message_init(&(file->msg), verbose);
}
DltReturnValue dlt_file_set_filter(DltFile *file, DltFilter *filter, int verbose)
@@ -1333,9 +1146,7 @@ DltReturnValue dlt_file_set_filter(DltFile *file, DltFilter *filter, int verbose
PRINT_FUNCTION_VERBOSE(verbose);
if (file == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* set filter */
file->filter = filter;
@@ -1348,45 +1159,44 @@ DltReturnValue dlt_file_read_header(DltFile *file, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (file == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* load header from file */
- if (fread(file->msg.headerbuffer, sizeof(DltStorageHeader)+sizeof(DltStandardHeader), 1, file->handle)!=1)
- {
+ if (fread(file->msg.headerbuffer, sizeof(DltStorageHeader) + sizeof(DltStandardHeader), 1, file->handle) != 1) {
if (!feof(file->handle))
- {
dlt_log(LOG_WARNING, "Cannot read header from file!\n");
- }
+
return DLT_RETURN_ERROR;
}
/* set ptrs to structures */
- file->msg.storageheader = (DltStorageHeader*) file->msg.headerbuffer;
- file->msg.standardheader = (DltStandardHeader*) (file->msg.headerbuffer + sizeof(DltStorageHeader));
+ file->msg.storageheader = (DltStorageHeader *)file->msg.headerbuffer;
+ file->msg.standardheader = (DltStandardHeader *)(file->msg.headerbuffer + sizeof(DltStorageHeader));
/* check id of storage header */
- if (dlt_check_storageheader(file->msg.storageheader) != DLT_RETURN_TRUE)
- {
+ if (dlt_check_storageheader(file->msg.storageheader) != DLT_RETURN_TRUE) {
dlt_log(LOG_WARNING, "DLT storage header pattern not found!\n");
return DLT_RETURN_ERROR;
}
/* calculate complete size of headers */
file->msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
- DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp) + (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
+ DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp) +
+ (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
file->msg.datasize = DLT_BETOH_16(file->msg.standardheader->len) + sizeof(DltStorageHeader) - file->msg.headersize;
- if (verbose)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"HeaderSize=%d, DataSize=%d\n",file->msg.headersize, file->msg.datasize);
+
+ if (verbose) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "HeaderSize=%d, DataSize=%d\n", file->msg.headersize,
+ file->msg.datasize);
dlt_log(LOG_DEBUG, str);
}
/* check data size */
- if (file->msg.datasize < 0)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Plausibility check failed. Complete message size too short! (%d)\n", file->msg.datasize);
+ if (file->msg.datasize < 0) {
+ snprintf(str,
+ DLT_COMMON_BUFFER_LENGTH,
+ "Plausibility check failed. Complete message size too short! (%d)\n",
+ file->msg.datasize);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
@@ -1401,94 +1211,85 @@ DltReturnValue dlt_file_read_header_raw(DltFile *file, int resync, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (file == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* check if serial header exists, ignore if found */
- if (fread(dltSerialHeaderBuffer,sizeof(dltSerialHeaderBuffer),1,file->handle)!=1)
- {
+ if (fread(dltSerialHeaderBuffer, sizeof(dltSerialHeaderBuffer), 1, file->handle) != 1) {
/* cannot read serial header, not enough data available in file */
if (!feof(file->handle))
- {
dlt_log(LOG_WARNING, "Cannot read header from file!\n");
- }
+
return DLT_RETURN_ERROR;
}
- if (memcmp(dltSerialHeaderBuffer,dltSerialHeader,sizeof(dltSerialHeader)) == 0)
- {
+
+ if (memcmp(dltSerialHeaderBuffer, dltSerialHeader, sizeof(dltSerialHeader)) == 0) {
/* serial header found */
/* nothing to do continue reading */
}
- else
- {
+ else {
/* serial header not found */
- if(resync)
- {
+ if (resync) {
/* increase error counter */
file->error_messages++;
/* resync to serial header */
- do
- {
- memmove(dltSerialHeaderBuffer,dltSerialHeaderBuffer+1,sizeof(dltSerialHeader)-1);
- if (fread(dltSerialHeaderBuffer+3,1,1,file->handle)!=1)
- {
+ do {
+ memmove(dltSerialHeaderBuffer, dltSerialHeaderBuffer + 1, sizeof(dltSerialHeader) - 1);
+
+ if (fread(dltSerialHeaderBuffer + 3, 1, 1, file->handle) != 1)
/* cannot read any data, perhaps end of file reached */
return DLT_RETURN_ERROR;
- }
- if (memcmp(dltSerialHeaderBuffer,dltSerialHeader,sizeof(dltSerialHeader)) == 0)
- {
+
+ if (memcmp(dltSerialHeaderBuffer, dltSerialHeader, sizeof(dltSerialHeader)) == 0)
/* serial header synchronised */
break;
- }
- } while(1);
+ } while (1);
}
else
- {
- /* go back to last file position */
- if (0 != fseek(file->handle,file->file_position,SEEK_SET))
- return DLT_RETURN_ERROR;
- }
+ /* go back to last file position */
+ if (0 != fseek(file->handle, file->file_position, SEEK_SET))
+ return DLT_RETURN_ERROR;
}
/* load header from file */
- if (fread(file->msg.headerbuffer+sizeof(DltStorageHeader),sizeof(DltStandardHeader),1,file->handle)!=1)
- {
+ if (fread(file->msg.headerbuffer + sizeof(DltStorageHeader), sizeof(DltStandardHeader), 1, file->handle) != 1) {
if (!feof(file->handle))
- {
dlt_log(LOG_WARNING, "Cannot read header from file!\n");
- }
+
return DLT_RETURN_ERROR;
}
/* set ptrs to structures */
- file->msg.storageheader = (DltStorageHeader*) file->msg.headerbuffer; // this points now to a empty storage header (filled with '0')
- file->msg.standardheader = (DltStandardHeader*) (file->msg.headerbuffer + sizeof(DltStorageHeader));
+ file->msg.storageheader = (DltStorageHeader *)file->msg.headerbuffer; /* this points now to a empty storage header (filled with '0') */
+ file->msg.standardheader = (DltStandardHeader *)(file->msg.headerbuffer + sizeof(DltStorageHeader));
/* Skip storage header field, fill this field with '0' */
memset(file->msg.storageheader, 0, sizeof(DltStorageHeader));
/* Set storage header */
- dlt_set_storageheader(file->msg.storageheader,DLT_COMMON_DUMMY_ECUID);
+ dlt_set_storageheader(file->msg.storageheader, DLT_COMMON_DUMMY_ECUID);
/* no check for storage header id*/
/* calculate complete size of headers */
file->msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
- DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp) + (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
+ DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp) +
+ (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
file->msg.datasize = DLT_BETOH_16(file->msg.standardheader->len) + sizeof(DltStorageHeader) - file->msg.headersize;
- if (verbose)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"HeaderSize=%d, DataSize=%d\n",file->msg.headersize, file->msg.datasize);
+
+ if (verbose) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "HeaderSize=%d, DataSize=%d\n", file->msg.headersize,
+ file->msg.datasize);
dlt_log(LOG_DEBUG, str);
}
/* check data size */
- if (file->msg.datasize < 0)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Plausibility check failed. Complete message size too short! (%d)\n", file->msg.datasize);
+ if (file->msg.datasize < 0) {
+ snprintf(str,
+ DLT_COMMON_BUFFER_LENGTH,
+ "Plausibility check failed. Complete message size too short! (%d)\n",
+ file->msg.datasize);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
@@ -1501,49 +1302,40 @@ DltReturnValue dlt_file_read_header_extended(DltFile *file, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (file == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* load standard header extra parameters if used */
- if (DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp))
- {
- if (fread(file->msg.headerbuffer+sizeof(DltStorageHeader)+sizeof(DltStandardHeader),
+ if (DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp)) {
+ if (fread(file->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp),
- 1,file->handle)!=1)
- {
+ 1, file->handle) != 1) {
dlt_log(LOG_WARNING, "Cannot read standard header extra parameters from file!\n");
return DLT_RETURN_ERROR;
}
- dlt_message_get_extraparameters(&(file->msg),verbose);
+ dlt_message_get_extraparameters(&(file->msg), verbose);
}
/* load Extended header if used */
- if (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp)==0)
- {
+ if (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) == 0)
/* there is nothing to be loaded */
return DLT_RETURN_OK;
- }
- if (fread(file->msg.headerbuffer+sizeof(DltStorageHeader)+sizeof(DltStandardHeader)+DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp),
+ if (fread(file->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp),
(DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0),
- 1,file->handle)!=1)
- {
+ 1, file->handle) != 1) {
dlt_log(LOG_WARNING, "Cannot read extended header from file!\n");
return DLT_RETURN_ERROR;
}
/* set extended header ptr */
if (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp))
- {
- file->msg.extendedheader = (DltExtendedHeader*) (file->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
- DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp));
- }
+ file->msg.extendedheader =
+ (DltExtendedHeader *)(file->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp));
else
- {
file->msg.extendedheader = NULL;
- }
return DLT_RETURN_OK;
}
@@ -1553,36 +1345,36 @@ DltReturnValue dlt_file_read_data(DltFile *file, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (file == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* free last used memory for buffer */
- if (file->msg.databuffer && (file->msg.databuffersize < file->msg.datasize))
- {
+ if (file->msg.databuffer && (file->msg.databuffersize < file->msg.datasize)) {
free(file->msg.databuffer);
file->msg.databuffer = NULL;
}
- if (file->msg.databuffer == NULL){
+ if (file->msg.databuffer == NULL) {
/* get new memory for buffer */
file->msg.databuffer = (uint8_t *)malloc(file->msg.datasize);
file->msg.databuffersize = file->msg.datasize;
}
- if (file->msg.databuffer == NULL)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Cannot allocate memory for payload buffer of size %d!\n",file->msg.datasize);
+ if (file->msg.databuffer == NULL) {
+ snprintf(str,
+ DLT_COMMON_BUFFER_LENGTH,
+ "Cannot allocate memory for payload buffer of size %d!\n",
+ file->msg.datasize);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
/* load payload data from file */
- if (fread(file->msg.databuffer,file->msg.datasize,1,file->handle)!=1)
- {
- if (file->msg.datasize!=0)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Cannot read payload data from file of size %d!\n",file->msg.datasize);
+ if (fread(file->msg.databuffer, file->msg.datasize, 1, file->handle) != 1) {
+ if (file->msg.datasize != 0) {
+ snprintf(str,
+ DLT_COMMON_BUFFER_LENGTH,
+ "Cannot read payload data from file of size %d!\n",
+ file->msg.datasize);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
@@ -1591,11 +1383,11 @@ DltReturnValue dlt_file_read_data(DltFile *file, int verbose)
return DLT_RETURN_OK;
}
-DltReturnValue dlt_file_open(DltFile *file,const char *filename,int verbose)
+DltReturnValue dlt_file_open(DltFile *file, const char *filename, int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
- if(file == NULL || filename == NULL)
+ if ((file == NULL) || (filename == NULL))
return DLT_RETURN_WRONG_PARAMETER;
/* reset counters */
@@ -1607,117 +1399,102 @@ DltReturnValue dlt_file_open(DltFile *file,const char *filename,int verbose)
file->error_messages = 0;
if (file->handle)
- {
fclose(file->handle);
- }
/* open dlt file */
- file->handle = fopen(filename,"rb");
- if (file->handle == NULL)
- {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH - 1 ,"File %s cannot be opened!\n", filename);
+ file->handle = fopen(filename, "rb");
+
+ if (file->handle == NULL) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH - 1, "File %s cannot be opened!\n", filename);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
- if (0 != fseek(file->handle, 0, SEEK_END))
- {
+ if (0 != fseek(file->handle, 0, SEEK_END)) {
snprintf(str, DLT_COMMON_BUFFER_LENGTH, "dlt_file_open: Seek failed to 0,SEEK_END");
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
+
file->file_length = ftell(file->handle);
- if (0 != fseek(file->handle,0,SEEK_SET))
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"dlt_file_open: Seek failed to 0,SEEK_SET");
+ if (0 != fseek(file->handle, 0, SEEK_SET)) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "dlt_file_open: Seek failed to 0,SEEK_SET");
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
- if (verbose)
- {
+ if (verbose) {
/* print file length */
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"File is %lu bytes long\n",file->file_length);
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "File is %lu bytes long\n", file->file_length);
dlt_log(LOG_DEBUG, str);
}
+
return DLT_RETURN_OK;
}
-DltReturnValue dlt_file_read(DltFile *file,int verbose)
+DltReturnValue dlt_file_read(DltFile *file, int verbose)
{
long *ptr;
int found = DLT_RETURN_OK;
- if (verbose)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"%s: Message %d:\n",__func__, file->counter_total);
+ if (verbose) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "%s: Message %d:\n", __func__, file->counter_total);
dlt_log(LOG_DEBUG, str);
}
if (file == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* allocate new memory for index if number of messages exceeds a multiple of DLT_COMMON_INDEX_ALLOC (e.g.: 1000) */
- if (file->counter % DLT_COMMON_INDEX_ALLOC == 0)
- {
- ptr = (long *) malloc(((file->counter/DLT_COMMON_INDEX_ALLOC) + 1) * DLT_COMMON_INDEX_ALLOC * sizeof(long));
+ if (file->counter % DLT_COMMON_INDEX_ALLOC == 0) {
+ ptr = (long *)malloc(((file->counter / DLT_COMMON_INDEX_ALLOC) + 1) * DLT_COMMON_INDEX_ALLOC * sizeof(long));
if (ptr == NULL)
- {
return DLT_RETURN_ERROR;
- }
- if (file->index)
- {
- memcpy(ptr,file->index,file->counter * sizeof(long));
+ if (file->index) {
+ memcpy(ptr, file->index, file->counter * sizeof(long));
free(file->index);
}
+
file->index = ptr;
}
/* set to end of last succesful read message, because of conflicting calls to dlt_file_read and dlt_file_message */
- if (0 != fseek(file->handle,file->file_position,SEEK_SET))
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Seek failed to file_position %ld \n",file->file_position);
+ if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek failed to file_position %ld \n", file->file_position);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
/* get file position at start of DLT message */
- if (verbose)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Position in file: %ld\n",file->file_position);
+ if (verbose) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Position in file: %ld\n", file->file_position);
dlt_log(LOG_INFO, str);
}
/* read header */
- if (dlt_file_read_header(file,verbose) < DLT_RETURN_OK)
- {
+ if (dlt_file_read_header(file, verbose) < DLT_RETURN_OK) {
/* go back to last position in file */
- fseek(file->handle,file->file_position,SEEK_SET);
+ fseek(file->handle, file->file_position, SEEK_SET);
return DLT_RETURN_ERROR;
}
- if (file->filter)
- {
+ if (file->filter) {
/* read the extended header if filter is enabled and extended header exists */
- if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK)
- {
+ if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK) {
/* go back to last position in file */
- if (0 != fseek(file->handle,file->file_position,SEEK_SET))
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Seek to last file pos failed!\n");
+ if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek to last file pos failed!\n");
dlt_log(LOG_WARNING, str);
}
+
return DLT_RETURN_ERROR;
}
/* check the filters if message is used */
- if (dlt_message_filter_check(&(file->msg),file->filter,verbose) == DLT_RETURN_TRUE)
- {
+ if (dlt_message_filter_check(&(file->msg), file->filter, verbose) == DLT_RETURN_TRUE) {
/* filter matched, consequently store current message */
/* store index pointer to message position in DLT file */
file->index[file->counter] = file->file_position;
@@ -1728,37 +1505,40 @@ DltReturnValue dlt_file_read(DltFile *file,int verbose)
}
/* skip payload data */
- if (fseek(file->handle,file->msg.datasize,SEEK_CUR)!=0)
- {
+ if (fseek(file->handle, file->msg.datasize, SEEK_CUR) != 0) {
/* go back to last position in file */
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Seek failed to skip payload data of size %d!\n",file->msg.datasize);
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek failed to skip payload data of size %d!\n",
+ file->msg.datasize);
dlt_log(LOG_WARNING, str);
- if (0 != fseek(file->handle,file->file_position,SEEK_SET))
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Seek back also failed!\n");
+ if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek back also failed!\n");
dlt_log(LOG_WARNING, str);
}
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
/* filter is disabled */
/* skip additional header parameters and payload data */
- if (fseek(file->handle,file->msg.headersize - sizeof(DltStorageHeader) - sizeof(DltStandardHeader) + file->msg.datasize,SEEK_CUR))
- {
-
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Seek failed to skip extra header and payload data from file of size %d!\n",
- file->msg.headersize - (int32_t)sizeof(DltStorageHeader) - (int32_t)sizeof(DltStandardHeader) + file->msg.datasize);
+ if (fseek(file->handle,
+ file->msg.headersize - sizeof(DltStorageHeader) - sizeof(DltStandardHeader) + file->msg.datasize,
+ SEEK_CUR)) {
+
+ snprintf(str,
+ DLT_COMMON_BUFFER_LENGTH,
+ "Seek failed to skip extra header and payload data from file of size %d!\n",
+ file->msg.headersize - (int32_t)sizeof(DltStorageHeader) - (int32_t)sizeof(DltStandardHeader) +
+ file->msg.datasize);
dlt_log(LOG_WARNING, str);
+
/* go back to last position in file */
- if (fseek(file->handle,file->file_position,SEEK_SET))
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Seek back also failed!\n");
+ if (fseek(file->handle, file->file_position, SEEK_SET)) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek back also failed!\n");
dlt_log(LOG_WARNING, str);
}
+
return DLT_RETURN_ERROR;
}
@@ -1784,8 +1564,7 @@ DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose)
int found = DLT_RETURN_OK;
long *ptr;
- if (verbose)
- {
+ if (verbose) {
snprintf(str, DLT_COMMON_BUFFER_LENGTH, "%s: Message %d:\n", __func__, file->counter_total);
dlt_log(LOG_DEBUG, str);
}
@@ -1794,66 +1573,59 @@ DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose)
return DLT_RETURN_WRONG_PARAMETER;
/* allocate new memory for index if number of messages exceeds a multiple of DLT_COMMON_INDEX_ALLOC (e.g.: 1000) */
- if (file->counter % DLT_COMMON_INDEX_ALLOC == 0)
- {
- ptr = (long *) malloc(((file->counter/DLT_COMMON_INDEX_ALLOC) + 1) * DLT_COMMON_INDEX_ALLOC * sizeof(long));
+ if (file->counter % DLT_COMMON_INDEX_ALLOC == 0) {
+ ptr = (long *)malloc(((file->counter / DLT_COMMON_INDEX_ALLOC) + 1) * DLT_COMMON_INDEX_ALLOC * sizeof(long));
if (ptr == NULL)
- {
return DLT_RETURN_ERROR;
- }
- if (file->index)
- {
- memcpy(ptr,file->index,file->counter * sizeof(long));
+ if (file->index) {
+ memcpy(ptr, file->index, file->counter * sizeof(long));
free(file->index);
}
+
file->index = ptr;
}
/* set to end of last successful read message, because of conflicting calls to dlt_file_read and dlt_file_message */
- if (0 != fseek(file->handle,file->file_position,SEEK_SET))
+ if (0 != fseek(file->handle, file->file_position, SEEK_SET))
return DLT_RETURN_ERROR;
/* get file position at start of DLT message */
- if (verbose)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Position in file: %ld\n",file->file_position);
+ if (verbose) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Position in file: %ld\n", file->file_position);
dlt_log(LOG_DEBUG, str);
}
/* read header */
- if (dlt_file_read_header_raw(file,resync,verbose) < DLT_RETURN_OK)
- {
+ if (dlt_file_read_header_raw(file, resync, verbose) < DLT_RETURN_OK) {
/* go back to last position in file */
- if (0!= fseek(file->handle,file->file_position,SEEK_SET))
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"dlt_file_read_raw, fseek failed 1\n");
+ if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "dlt_file_read_raw, fseek failed 1\n");
dlt_log(LOG_WARNING, str);
}
+
return DLT_RETURN_ERROR;
}
/* read the extended header if filter is enabled and extended header exists */
- if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK)
- {
+ if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK) {
/* go back to last position in file */
- if (0 != fseek(file->handle,file->file_position,SEEK_SET))
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"dlt_file_read_raw, fseek failed 2\n");
+ if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "dlt_file_read_raw, fseek failed 2\n");
dlt_log(LOG_WARNING, str);
}
+
return DLT_RETURN_ERROR;
}
- if (dlt_file_read_data(file,verbose) < DLT_RETURN_OK)
- {
+ if (dlt_file_read_data(file, verbose) < DLT_RETURN_OK) {
/* go back to last position in file */
- if (0 != fseek(file->handle,file->file_position,SEEK_SET))
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"dlt_file_read_raw, fseek failed 3\n");
+ if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "dlt_file_read_raw, fseek failed 3\n");
dlt_log(LOG_WARNING, str);
}
+
return DLT_RETURN_ERROR;
}
@@ -1878,14 +1650,10 @@ DltReturnValue dlt_file_close(DltFile *file, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (file == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if (file->handle)
- {
fclose(file->handle);
- }
file->handle = NULL;
@@ -1897,41 +1665,32 @@ DltReturnValue dlt_file_message(DltFile *file, int index, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (file == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* check if message is in range */
- if (index >= file->counter)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH, "Message %d out of range!\r\n", index);
+ if (index >= file->counter) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Message %d out of range!\r\n", index);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_WRONG_PARAMETER;
}
/* seek to position in file */
- if (fseek(file->handle,file->index[index],SEEK_SET)!=0)
- {
- snprintf(str,DLT_COMMON_BUFFER_LENGTH,"Seek to message %d to position %ld failed!\r\n",index,file->index[index]);
+ if (fseek(file->handle, file->index[index], SEEK_SET) != 0) {
+ snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek to message %d to position %ld failed!\r\n", index,
+ file->index[index]);
dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
/* read all header and payload */
- if (dlt_file_read_header(file,verbose) < DLT_RETURN_OK)
- {
+ if (dlt_file_read_header(file, verbose) < DLT_RETURN_OK)
return DLT_RETURN_ERROR;
- }
- if (dlt_file_read_header_extended(file,verbose) < DLT_RETURN_OK)
- {
+ if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK)
return DLT_RETURN_ERROR;
- }
- if (dlt_file_read_data(file,verbose) < DLT_RETURN_OK)
- {
+ if (dlt_file_read_data(file, verbose) < DLT_RETURN_OK)
return DLT_RETURN_ERROR;
- }
/* set current position in file */
file->position = index;
@@ -1944,54 +1703,49 @@ DltReturnValue dlt_file_free(DltFile *file, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if (file == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* delete index lost if exists */
if (file->index)
- {
free(file->index);
- }
+
file->index = NULL;
/* close file */
if (file->handle)
- {
fclose(file->handle);
- }
+
file->handle = NULL;
- return dlt_message_free(&(file->msg),verbose);
+ return dlt_message_free(&(file->msg), verbose);
}
void dlt_log_set_level(int level)
{
- if(level < 0 || level > LOG_DEBUG)
- {
- if(logging_level < LOG_WARNING)
+ if ((level < 0) || (level > LOG_DEBUG)) {
+ if (logging_level < LOG_WARNING)
logging_level = LOG_WARNING;
dlt_vlog(LOG_WARNING, "Wrong parameter for level: %d\n", level);
}
- else
+ else {
logging_level = level;
+ }
}
void dlt_log_set_filename(const char *filename)
{
- // check nullpointer
- if(filename == NULL)
- {
+ /* check nullpointer */
+ if (filename == NULL) {
dlt_log(LOG_WARNING, "Wrong parameter: filename is NULL\n");
return;
}
strncpy(logging_filename, filename, NAME_MAX);
- logging_filename[NAME_MAX]=0;
+ logging_filename[NAME_MAX] = 0;
}
-void dlt_log_set_fifo_basedir(const char * env_pipe_dir)
+void dlt_log_set_fifo_basedir(const char *env_pipe_dir)
{
strncpy(dltFifoBaseDir, env_pipe_dir, PATH_MAX);
dltFifoBaseDir[PATH_MAX] = 0;
@@ -1999,20 +1753,18 @@ void dlt_log_set_fifo_basedir(const char * env_pipe_dir)
void dlt_log_init(int mode)
{
- if(mode < DLT_LOG_TO_CONSOLE || mode > DLT_LOG_DROPPED)
- {
+ if ((mode < DLT_LOG_TO_CONSOLE) || (mode > DLT_LOG_DROPPED)) {
dlt_vlog(LOG_WARNING, "Wrong parameter for mode: %d\n", mode);
return;
}
logging_mode = mode;
- if(logging_mode == DLT_LOG_TO_FILE)
- {
+ if (logging_mode == DLT_LOG_TO_FILE) {
/* internal logging to file */
- logging_handle = fopen(logging_filename,"w");
- if (logging_handle == NULL)
- {
+ logging_handle = fopen(logging_filename, "w");
+
+ if (logging_handle == NULL) {
printf("Internal log file %s cannot be opened!\n", logging_filename);
return;
}
@@ -2021,56 +1773,68 @@ void dlt_log_init(int mode)
void dlt_log_free(void)
{
- if(logging_mode == DLT_LOG_TO_FILE) {
+ if (logging_mode == DLT_LOG_TO_FILE)
fclose(logging_handle);
- }
}
DltReturnValue dlt_log(int prio, char *s)
{
- static const char asSeverity[LOG_DEBUG+2][11] = {"EMERGENCY", "ALERT ", "CRITICAL ", "ERROR ", "WARNING ", "NOTICE ", "INFO ", "DEBUG ", " "};
+ static const char asSeverity[LOG_DEBUG +
+ 2][11] =
+ { "EMERGENCY", "ALERT ", "CRITICAL ", "ERROR ", "WARNING ", "NOTICE ", "INFO ", "DEBUG ",
+ " " };
static const char sFormatString[] = "[%5d.%06d]~DLT~%5d~%s~%s";
struct timespec sTimeSpec;
if (s == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if(logging_level<prio)
- {
+
+ if (logging_level < prio)
return DLT_RETURN_OK;
- }
+
if ((prio < 0) || (prio > LOG_DEBUG))
- {
prio = LOG_DEBUG + 1;
- }
clock_gettime(CLOCK_MONOTONIC, &sTimeSpec);
- switch(logging_mode)
- {
- case DLT_LOG_TO_CONSOLE:
- /* log to stdout */
- printf(sFormatString, (unsigned int)sTimeSpec.tv_sec, (unsigned int)(sTimeSpec.tv_nsec/1000), getpid(), asSeverity[prio], s);
- fflush(stdout);
- break;
- case DLT_LOG_TO_SYSLOG:
- /* log to syslog */
+
+ switch (logging_mode) {
+ case DLT_LOG_TO_CONSOLE:
+ /* log to stdout */
+ printf(sFormatString,
+ (unsigned int)sTimeSpec.tv_sec,
+ (unsigned int)(sTimeSpec.tv_nsec / 1000),
+ getpid(),
+ asSeverity[prio],
+ s);
+ fflush(stdout);
+ break;
+ case DLT_LOG_TO_SYSLOG:
+ /* log to syslog */
#if !defined (__WIN32__) && !defined(_MSC_VER)
- openlog("DLT",LOG_PID,LOG_DAEMON);
- syslog(prio, sFormatString, (unsigned int)sTimeSpec.tv_sec, (unsigned int)(sTimeSpec.tv_nsec/1000), getpid(), asSeverity[prio], s);
- closelog();
+ openlog("DLT", LOG_PID, LOG_DAEMON);
+ syslog(prio,
+ sFormatString,
+ (unsigned int)sTimeSpec.tv_sec,
+ (unsigned int)(sTimeSpec.tv_nsec / 1000),
+ getpid(),
+ asSeverity[prio],
+ s);
+ closelog();
#endif
- break;
- case DLT_LOG_TO_FILE:
- /* log to file */
- if(logging_handle) {
- fprintf(logging_handle,sFormatString, (unsigned int)sTimeSpec.tv_sec, (unsigned int)(sTimeSpec.tv_nsec/1000), getpid(), asSeverity[prio], s);
- fflush(logging_handle);
- }
- break;
- case DLT_LOG_DROPPED:
- default:
- break;
+ break;
+ case DLT_LOG_TO_FILE:
+
+ /* log to file */
+ if (logging_handle) {
+ fprintf(logging_handle, sFormatString, (unsigned int)sTimeSpec.tv_sec,
+ (unsigned int)(sTimeSpec.tv_nsec / 1000), getpid(), asSeverity[prio], s);
+ fflush(logging_handle);
+ }
+
+ break;
+ case DLT_LOG_DROPPED:
+ default:
+ break;
}
return DLT_RETURN_OK;
@@ -2106,10 +1870,10 @@ DltReturnValue dlt_vnlog(int prio, size_t size, const char *format, ...)
if (format == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (logging_level < prio || size == 0)
+ if ((logging_level < prio) || (size == 0))
return DLT_RETURN_OK;
- if ( (outputString = (char*) calloc(size + 1, sizeof(char))) == NULL )
+ if ((outputString = (char *)calloc(size + 1, sizeof(char))) == NULL)
return DLT_RETURN_ERROR;
va_start(args, format);
@@ -2127,9 +1891,7 @@ DltReturnValue dlt_vnlog(int prio, size_t size, const char *format, ...)
DltReturnValue dlt_receiver_init(DltReceiver *receiver, int fd, int buffersize)
{
if (receiver == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
receiver->lastBytesRcvd = 0;
receiver->bytesRcvd = 0;
@@ -2137,16 +1899,14 @@ DltReturnValue dlt_receiver_init(DltReceiver *receiver, int fd, int buffersize)
receiver->bytes_sent = 0;
receiver->buffersize = buffersize;
receiver->fd = fd;
- receiver->buffer = (char*)malloc(receiver->buffersize);
+ receiver->buffer = (char *)malloc(receiver->buffersize);
receiver->backup_buf = NULL;
- if (receiver->buffer == NULL)
- {
+ if (receiver->buffer == NULL) {
receiver->buf = NULL;
return DLT_RETURN_ERROR;
}
- else
- {
+ else {
receiver->buf = receiver->buffer;
}
@@ -2156,20 +1916,18 @@ DltReturnValue dlt_receiver_init(DltReceiver *receiver, int fd, int buffersize)
DltReturnValue dlt_receiver_init_unix_socket(DltReceiver *receiver, int fd, char **buffer)
{
if (receiver == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (*buffer == NULL)
- {
+
+ if (*buffer == NULL) {
/* allocating the buffer once and using it for all application receivers
* by keeping allocated buffer in app_recv_buffer global handle
*/
- *buffer = (char*)malloc(DLT_RECEIVE_BUFSIZE);
+ *buffer = (char *)malloc(DLT_RECEIVE_BUFSIZE);
+
if (*buffer == NULL)
- {
return DLT_RETURN_ERROR;
- }
}
+
receiver->lastBytesRcvd = 0;
receiver->bytesRcvd = 0;
receiver->totalBytesRcvd = 0;
@@ -2186,19 +1944,13 @@ DltReturnValue dlt_receiver_free(DltReceiver *receiver)
{
if (receiver == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if (receiver->buffer)
- {
free(receiver->buffer);
- }
if (receiver->backup_buf)
- {
free(receiver->backup_buf);
- }
receiver->buffer = NULL;
receiver->buf = NULL;
@@ -2211,14 +1963,10 @@ DltReturnValue dlt_receiver_free_unix_socket(DltReceiver *receiver)
{
if (receiver == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if (receiver->backup_buf)
- {
free(receiver->backup_buf);
- }
receiver->buffer = NULL;
receiver->buf = NULL;
@@ -2230,43 +1978,33 @@ DltReturnValue dlt_receiver_free_unix_socket(DltReceiver *receiver)
int dlt_receiver_receive(DltReceiver *receiver, DltReceiverType from_src)
{
if (receiver == NULL)
- {
return -1;
- }
if (receiver->buffer == NULL)
- {
return -1;
- }
receiver->buf = (char *)receiver->buffer;
receiver->lastBytesRcvd = receiver->bytesRcvd;
- if ((receiver->lastBytesRcvd) && (receiver->backup_buf != NULL))
- {
+ if ((receiver->lastBytesRcvd) && (receiver->backup_buf != NULL)) {
memcpy(receiver->buf, receiver->backup_buf, receiver->lastBytesRcvd);
free(receiver->backup_buf);
receiver->backup_buf = NULL;
}
if (from_src == DLT_RECEIVE_SOCKET)
- {
/* wait for data from socket */
receiver->bytesRcvd = recv(receiver->fd,
receiver->buf + receiver->lastBytesRcvd,
receiver->buffersize - receiver->lastBytesRcvd,
0);
- }
else
- {
/* wait for data from fd */
receiver->bytesRcvd = read(receiver->fd,
receiver->buf + receiver->lastBytesRcvd,
receiver->buffersize - receiver->lastBytesRcvd);
- }
- if (receiver->bytesRcvd <= 0)
- {
+ if (receiver->bytesRcvd <= 0) {
receiver->bytesRcvd = 0;
return receiver->bytesRcvd;
@@ -2281,17 +2019,12 @@ int dlt_receiver_receive(DltReceiver *receiver, DltReceiverType from_src)
DltReturnValue dlt_receiver_remove(DltReceiver *receiver, int size)
{
if (receiver == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if (receiver->buf == NULL)
- {
return DLT_RETURN_ERROR;
- }
- if (size > receiver->bytesRcvd || size <= 0)
- {
+ if ((size > receiver->bytesRcvd) || (size <= 0)) {
receiver->buf = receiver->buf + receiver->bytesRcvd;
receiver->bytesRcvd = 0;
return DLT_RETURN_WRONG_PARAMETER;
@@ -2306,29 +2039,20 @@ DltReturnValue dlt_receiver_remove(DltReceiver *receiver, int size)
DltReturnValue dlt_receiver_move_to_begin(DltReceiver *receiver)
{
if (receiver == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if ((receiver->buffer == NULL) || (receiver->buf == NULL))
- {
return DLT_RETURN_ERROR;
- }
- if ((receiver->buffer!=receiver->buf) && (receiver->bytesRcvd!=0))
- {
+ if ((receiver->buffer != receiver->buf) && (receiver->bytesRcvd != 0)) {
receiver->backup_buf = calloc(receiver->bytesRcvd + 1, sizeof(char));
if (receiver->backup_buf == NULL)
- {
dlt_vlog(LOG_WARNING,
"Can't allocate memory for backup buf, there will be atleast"
"one corrupted message for fd[%d] \n", receiver->fd);
- }
else
- {
memcpy(receiver->backup_buf, receiver->buf, receiver->bytesRcvd);
- }
}
return DLT_RETURN_OK;
@@ -2342,29 +2066,25 @@ int dlt_receiver_check_and_get(DltReceiver *receiver,
unsigned int min_size = to_get;
void *src = NULL;
- if (flags & DLT_RCV_SKIP_HEADER) {
+ if (flags & DLT_RCV_SKIP_HEADER)
min_size += sizeof(DltUserHeader);
- }
if (!receiver ||
(receiver->bytesRcvd < (int32_t)min_size) ||
!receiver->buf ||
- !dest) {
+ !dest)
return DLT_RETURN_WRONG_PARAMETER;
- }
src = (void *)receiver->buf;
- if (flags & DLT_RCV_SKIP_HEADER) {
+ if (flags & DLT_RCV_SKIP_HEADER)
src += sizeof(DltUserHeader);
- }
memcpy(dest, src, to_get);
if (flags & DLT_RCV_REMOVE) {
- if (dlt_receiver_remove(receiver, min_size) != DLT_RETURN_OK)
- {
- dlt_log(LOG_WARNING,"Can't remove bytes from receiver\n");
+ if (dlt_receiver_remove(receiver, min_size) != DLT_RETURN_OK) {
+ dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
return DLT_RETURN_ERROR;
}
}
@@ -2379,10 +2099,8 @@ DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char
struct timeval tv;
#endif
- if (storageheader == NULL || ecu == NULL)
- {
+ if ((storageheader == NULL) || (ecu == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- }
/* get time of day */
#if defined(_MSC_VER)
@@ -2397,7 +2115,7 @@ DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char
storageheader->pattern[2] = 'T';
storageheader->pattern[3] = 0x01;
- dlt_set_id(storageheader->ecu,ecu);
+ dlt_set_id(storageheader->ecu, ecu);
/* Set current time */
#if defined(_MSC_VER)
@@ -2415,11 +2133,11 @@ DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader)
if (storageheader == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- return ((storageheader->pattern[0] == 'D') &&
- (storageheader->pattern[1] == 'L') &&
- (storageheader->pattern[2] == 'T') &&
- (storageheader->pattern[3] == 1))
- ? DLT_RETURN_TRUE : DLT_RETURN_OK;
+ return ((storageheader->pattern[0] == 'D') &&
+ (storageheader->pattern[1] == 'L') &&
+ (storageheader->pattern[2] == 'T') &&
+ (storageheader->pattern[3] == 1))
+ ? DLT_RETURN_TRUE : DLT_RETURN_OK;
}
@@ -2435,26 +2153,26 @@ DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader)
DltReturnValue dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint32_t size)
{
- if(buf == NULL || ptr == NULL)
+ if ((buf == NULL) || (ptr == NULL))
return DLT_RETURN_WRONG_PARAMETER;
DltBufferHead *head;
- // Init parameters
+ /* Init parameters */
buf->shm = (unsigned char *)ptr;
buf->min_size = size;
buf->max_size = size;
buf->step_size = 0;
- // Init pointers
- head = (DltBufferHead*)buf->shm;
+ /* Init pointers */
+ head = (DltBufferHead *)buf->shm;
head->read = 0;
head->write = 0;
head->count = 0;
buf->mem = (unsigned char *)(buf->shm + sizeof(DltBufferHead));
buf->size = buf->min_size - sizeof(DltBufferHead);
- // clear memory
+ /* clear memory */
memset(buf->mem, 0, buf->size);
dlt_vlog(LOG_DEBUG,
@@ -2466,16 +2184,16 @@ DltReturnValue dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char
DltReturnValue dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint32_t size)
{
- if(buf == NULL || ptr == NULL)
+ if ((buf == NULL) || (ptr == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- // Init parameters
+ /* Init parameters */
buf->shm = (unsigned char *)ptr;
buf->min_size = size;
buf->max_size = size;
buf->step_size = 0;
- // Init pointers
+ /* Init pointers */
buf->mem = (unsigned char *)(buf->shm + sizeof(DltBufferHead));
buf->size = buf->min_size - sizeof(DltBufferHead);
@@ -2486,40 +2204,42 @@ DltReturnValue dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char
return DLT_RETURN_OK; /* OK */
}
-DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size,uint32_t step_size)
+DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size, uint32_t step_size)
{
- //Do not DLT_SEM_LOCK inside here!
+ /*Do not DLT_SEM_LOCK inside here! */
DltBufferHead *head;
- // catch null pointer
- if(buf == NULL)
+ /* catch null pointer */
+ if (buf == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- // catch 0 logical errors
- if(min_size == 0 || max_size == 0 || step_size == 0)
+
+ /* catch 0 logical errors */
+ if ((min_size == 0) || (max_size == 0) || (step_size == 0))
return DLT_RETURN_WRONG_PARAMETER;
- if(min_size > max_size)
+ if (min_size > max_size)
return DLT_RETURN_WRONG_PARAMETER;
- if(step_size > max_size)
+ if (step_size > max_size)
return DLT_RETURN_WRONG_PARAMETER;
- // Init parameters
+ /* Init parameters */
buf->min_size = min_size;
buf->max_size = max_size;
buf->step_size = step_size;
- // allocat memory
+ /* allocat memory */
buf->shm = malloc(buf->min_size);
- if(buf->shm == NULL) {
+
+ if (buf->shm == NULL) {
dlt_vlog(LOG_EMERG,
"%s: Buffer: Cannot allocate %d bytes\n",
__func__, buf->min_size);
return DLT_RETURN_ERROR;
}
- // Init pointers
- head = (DltBufferHead*)buf->shm;
+ /* Init pointers */
+ head = (DltBufferHead *)buf->shm;
head->read = 0;
head->write = 0;
head->count = 0;
@@ -2530,7 +2250,7 @@ DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32
"%s: Buffer: Size %d, Start address %lX\n",
__func__, buf->size, (unsigned long)buf->mem);
- // clear memory
+ /* clear memory */
memset(buf->mem, 0, buf->size);
return DLT_RETURN_OK; /* OK */
@@ -2538,12 +2258,12 @@ DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32
DltReturnValue dlt_buffer_free_static(DltBuffer *buf)
{
- // catch null pointer
- if(buf == NULL)
+ /* catch null pointer */
+ if (buf == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if(buf->mem == NULL) {
- // buffer not initialized
+ if (buf->mem == NULL) {
+ /* buffer not initialized */
dlt_vlog(LOG_WARNING, "%s: Buffer: Buffer not initialized\n", __func__);
return DLT_RETURN_ERROR; /* ERROR */
}
@@ -2553,12 +2273,12 @@ DltReturnValue dlt_buffer_free_static(DltBuffer *buf)
DltReturnValue dlt_buffer_free_dynamic(DltBuffer *buf)
{
- // catch null pointer
- if(buf == NULL)
+ /* catch null pointer */
+ if (buf == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if(buf->shm == NULL) {
- // buffer not initialized
+ if (buf->shm == NULL) {
+ /* buffer not initialized */
dlt_vlog(LOG_WARNING, "%s: Buffer: Buffer not initialized\n", __func__);
return DLT_RETURN_ERROR; /* ERROR */
}
@@ -2572,44 +2292,42 @@ DltReturnValue dlt_buffer_free_dynamic(DltBuffer *buf)
void dlt_buffer_write_block(DltBuffer *buf, int *write, const unsigned char *data, unsigned int size)
{
- // catch null pointer
- if(buf != NULL && write != NULL && data != NULL) {
- if((int)(*write+size) <= buf->size) {
- // write one block
- memcpy(buf->mem+*write,data,size);
+ /* catch null pointer */
+ if ((buf != NULL) && (write != NULL) && (data != NULL)) {
+ if ((int)(*write + size) <= buf->size) {
+ /* write one block */
+ memcpy(buf->mem + *write, data, size);
*write += size;
}
else {
- // write two blocks
- memcpy(buf->mem+*write, data, buf->size-*write);
- memcpy(buf->mem, data+buf->size-*write, size-buf->size+*write);
- *write += size-buf->size;
+ /* write two blocks */
+ memcpy(buf->mem + *write, data, buf->size - *write);
+ memcpy(buf->mem, data + buf->size - *write, size - buf->size + *write);
+ *write += size - buf->size;
}
}
- else
- {
+ else {
dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
}
}
void dlt_buffer_read_block(DltBuffer *buf, int *read, unsigned char *data, unsigned int size)
{
- // catch nullpointer
- if(buf != NULL && read != NULL && data != NULL) {
- if((int)(*read+size) <= buf->size) {
- // read one block
- memcpy(data,buf->mem+*read,size);
+ /* catch nullpointer */
+ if ((buf != NULL) && (read != NULL) && (data != NULL)) {
+ if ((int)(*read + size) <= buf->size) {
+ /* read one block */
+ memcpy(data, buf->mem + *read, size);
*read += size;
}
else {
- // read two blocks
- memcpy(data, buf->mem+*read, buf->size-*read);
- memcpy(data+buf->size-*read, buf->mem, size-buf->size+*read);
- *read += size-buf->size;
+ /* read two blocks */
+ memcpy(data, buf->mem + *read, buf->size - *read);
+ memcpy(data + buf->size - *read, buf->mem, size - buf->size + *read);
+ *read += size - buf->size;
}
}
- else
- {
+ else {
dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
}
}
@@ -2617,64 +2335,60 @@ void dlt_buffer_read_block(DltBuffer *buf, int *read, unsigned char *data, unsig
int dlt_buffer_check_size(DltBuffer *buf, int needed)
{
if (buf == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
if ((buf->size + sizeof(DltBufferHead) + needed) > buf->max_size)
- {
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
}
int dlt_buffer_increase_size(DltBuffer *buf)
{
- DltBufferHead *head,*new_head;
+ DltBufferHead *head, *new_head;
unsigned char *new_ptr;
- // catch null pointer
- if(buf == NULL) {
+ /* catch null pointer */
+ if (buf == NULL) {
dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
/* check size */
- if(buf->step_size==0) {
+ if (buf->step_size == 0)
/* cannot increase size */
return DLT_RETURN_ERROR;
- }
/* check size */
- if((buf->size + sizeof(DltBufferHead) + buf->step_size) > buf->max_size) {
+ if ((buf->size + sizeof(DltBufferHead) + buf->step_size) > buf->max_size)
/* max size reached, do not increase */
return DLT_RETURN_ERROR;
- }
/* allocate new buffer */
new_ptr = malloc(buf->size + sizeof(DltBufferHead) + buf->step_size);
- if(new_ptr == NULL) {
+
+ if (new_ptr == NULL) {
dlt_vlog(LOG_WARNING,
- "%s: Buffer: Cannot increase size because allocate %d bytes failed\n",
- __func__, buf->min_size);
+ "%s: Buffer: Cannot increase size because allocate %d bytes failed\n",
+ __func__, buf->min_size);
return DLT_RETURN_ERROR;
}
/* copy data */
- head = (DltBufferHead*)buf->shm;
- new_head = (DltBufferHead*)new_ptr;
- if(head->read < head->write) {
- memcpy(new_ptr+sizeof(DltBufferHead) , buf->mem+head->read , head->write-head->read);
+ head = (DltBufferHead *)buf->shm;
+ new_head = (DltBufferHead *)new_ptr;
+
+ if (head->read < head->write) {
+ memcpy(new_ptr + sizeof(DltBufferHead), buf->mem + head->read, head->write - head->read);
new_head->read = 0;
- new_head->write = head->write-head->read;
+ new_head->write = head->write - head->read;
new_head->count = head->count;
}
else {
- memcpy(new_ptr+sizeof(DltBufferHead) , buf->mem+head->read , buf->size-head->read);
- memcpy(new_ptr+sizeof(DltBufferHead)+buf->size-head->read , buf->mem , head->write);
+ memcpy(new_ptr + sizeof(DltBufferHead), buf->mem + head->read, buf->size - head->read);
+ memcpy(new_ptr + sizeof(DltBufferHead) + buf->size - head->read, buf->mem, head->write);
new_head->read = 0;
- new_head->write = buf->size-head->read+head->write;
+ new_head->write = buf->size - head->read + head->write;
new_head->count = head->count;
}
@@ -2683,38 +2397,36 @@ int dlt_buffer_increase_size(DltBuffer *buf)
/* update data */
buf->shm = new_ptr;
- buf->mem = new_ptr+sizeof(DltBufferHead);
+ buf->mem = new_ptr + sizeof(DltBufferHead);
buf->size += buf->step_size;
dlt_vlog(LOG_DEBUG,
"%s: Buffer: Size increased to %d bytes with start address %lX\n",
__func__,
- buf->size+(int32_t)sizeof(DltBufferHead),
+ buf->size + (int32_t)sizeof(DltBufferHead),
(unsigned long)buf->mem);
- return DLT_RETURN_OK; // OK
+ return DLT_RETURN_OK; /* OK */
}
int dlt_buffer_minimize_size(DltBuffer *buf)
{
unsigned char *new_ptr;
- // catch null pointer
- if(buf == NULL)
- {
+ /* catch null pointer */
+ if (buf == NULL) {
dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- if((buf->size + sizeof(DltBufferHead)) == buf->min_size)
- {
+ if ((buf->size + sizeof(DltBufferHead)) == buf->min_size)
/* already minimized */
return DLT_RETURN_OK;
- }
/* allocate new buffer */
new_ptr = malloc(buf->min_size);
- if(new_ptr == NULL) {
+
+ if (new_ptr == NULL) {
dlt_vlog(LOG_WARNING,
"%s: Buffer: Cannot set to min size of %d bytes\n",
__func__, buf->min_size);
@@ -2726,19 +2438,19 @@ int dlt_buffer_minimize_size(DltBuffer *buf)
/* update data */
buf->shm = new_ptr;
- buf->mem = new_ptr+sizeof(DltBufferHead);
+ buf->mem = new_ptr + sizeof(DltBufferHead);
buf->size = buf->min_size - sizeof(DltBufferHead);
/* reset pointers and counters */
- ((int*)(buf->shm))[0] = 0; // pointer to write memory
- ((int*)(buf->shm))[1] = 0; // pointer to read memory
- ((int*)(buf->shm))[2] = 0; // number of packets
+ ((int *)(buf->shm))[0] = 0; /* pointer to write memory */
+ ((int *)(buf->shm))[1] = 0; /* pointer to read memory */
+ ((int *)(buf->shm))[2] = 0; /* number of packets */
dlt_vlog(LOG_DEBUG,
"%s: Buffer: Buffer minimized to Size %d bytes with start address %lX\n",
__func__, buf->size, (unsigned long)buf->mem);
- // clear memory
+ /* clear memory */
memset(buf->mem, 0, buf->size);
return DLT_RETURN_OK; /* OK */
@@ -2746,9 +2458,8 @@ int dlt_buffer_minimize_size(DltBuffer *buf)
int dlt_buffer_reset(DltBuffer *buf)
{
- // catch null pointer
- if(buf == NULL)
- {
+ /* catch null pointer */
+ if (buf == NULL) {
dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -2758,54 +2469,58 @@ int dlt_buffer_reset(DltBuffer *buf)
__func__, buf->size, (unsigned long)buf->mem);
/* reset pointers and counters */
- ((int*)(buf->shm))[0] = 0; // pointer to write memory
- ((int*)(buf->shm))[1] = 0; // pointer to read memory
- ((int*)(buf->shm))[2] = 0; // number of packets
+ ((int *)(buf->shm))[0] = 0; /* pointer to write memory */
+ ((int *)(buf->shm))[1] = 0; /* pointer to read memory */
+ ((int *)(buf->shm))[2] = 0; /* number of packets */
- // clear memory
+ /* clear memory */
memset(buf->mem, 0, buf->size);
return DLT_RETURN_OK; /* OK */
}
-DltReturnValue dlt_buffer_push(DltBuffer *buf,const unsigned char *data,unsigned int size)
+DltReturnValue dlt_buffer_push(DltBuffer *buf, const unsigned char *data, unsigned int size)
{
return dlt_buffer_push3(buf, data, size, 0, 0, 0, 0);
}
-int dlt_buffer_push3(DltBuffer *buf, const unsigned char *data1, unsigned int size1, const unsigned char *data2, unsigned int size2, const unsigned char *data3, unsigned int size3)
+int dlt_buffer_push3(DltBuffer *buf,
+ const unsigned char *data1,
+ unsigned int size1,
+ const unsigned char *data2,
+ unsigned int size2,
+ const unsigned char *data3,
+ unsigned int size3)
{
int free_size;
int write, read, count;
DltBufferBlockHead head;
- // catch null pointer
+ /* catch null pointer */
if (buf == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if (buf->shm == NULL)
- {
- // buffer not initialised
+ if (buf->shm == NULL) {
+ /* buffer not initialised */
dlt_vlog(LOG_ERR, "%s: Buffer: Buffer not initialized\n", __func__);
return DLT_RETURN_ERROR; /* ERROR */
}
- // get current write pointer
- write = ((int*) (buf->shm))[0];
- read = ((int*) (buf->shm))[1];
- count = ((int*) (buf->shm))[2];
+ /* get current write pointer */
+ write = ((int *)(buf->shm))[0];
+ read = ((int *)(buf->shm))[1];
+ count = ((int *)(buf->shm))[2];
- // check pointers
- if ((read > buf->size) || (write > buf->size))
- {
+ /* check pointers */
+ if ((read > buf->size) || (write > buf->size)) {
dlt_vlog(LOG_ERR,
"%s: Buffer: Pointer out of range. Read: %d, Write: %d, Size: %d\n",
__func__, read, write, buf->size);
dlt_buffer_reset(buf);
- return DLT_RETURN_ERROR; // ERROR
+ return DLT_RETURN_ERROR; /* ERROR */
}
- // calculate free size
+ /* calculate free size */
if (read > write)
free_size = read - write;
else if (count && (write == read))
@@ -2813,42 +2528,42 @@ int dlt_buffer_push3(DltBuffer *buf, const unsigned char *data1, unsigned int si
else
free_size = buf->size - write + read;
- // check size
- if (free_size < (int) (sizeof(DltBufferBlockHead) + size1 + size2 + size3))
- {
- // try to increase size if possible
+ /* check size */
+ if (free_size < (int)(sizeof(DltBufferBlockHead) + size1 + size2 + size3)) {
+ /* try to increase size if possible */
if (dlt_buffer_increase_size(buf))
- {
/* increase size is not possible */
- //dlt_log(LOG_ERR, "Buffer: Buffer is full\n");
- return DLT_RETURN_ERROR; // ERROR
- }
+ /*dlt_log(LOG_ERR, "Buffer: Buffer is full\n"); */
+ return DLT_RETURN_ERROR; /* ERROR */
- // update pointers
- write = ((int*) (buf->shm))[0];
- read = ((int*) (buf->shm))[1];
+ /* update pointers */
+ write = ((int *)(buf->shm))[0];
+ read = ((int *)(buf->shm))[1];
}
- // set header
+ /* set header */
strncpy(head.head, DLT_BUFFER_HEAD, 3);
head.head[3] = 0;
head.status = 2;
head.size = size1 + size2 + size3;
- // write data
- dlt_buffer_write_block(buf, &write, (unsigned char*) &head, sizeof(DltBufferBlockHead));
+ /* write data */
+ dlt_buffer_write_block(buf, &write, (unsigned char *)&head, sizeof(DltBufferBlockHead));
+
if (size1)
dlt_buffer_write_block(buf, &write, data1, size1);
+
if (size2)
dlt_buffer_write_block(buf, &write, data2, size2);
+
if (size3)
dlt_buffer_write_block(buf, &write, data3, size3);
- // update global shm pointers
- ((int*) (buf->shm))[0] = write; // set new write pointer
- ((int*) (buf->shm))[2] += 1; // increase counter
+ /* update global shm pointers */
+ ((int *)(buf->shm))[0] = write; /* set new write pointer */
+ ((int *)(buf->shm))[2] += 1; /* increase counter */
- return DLT_RETURN_OK; // OK
+ return DLT_RETURN_OK; /* OK */
}
@@ -2859,145 +2574,136 @@ int dlt_buffer_get(DltBuffer *buf, unsigned char *data, int max_size, int delete
char head_compare[] = DLT_BUFFER_HEAD;
DltBufferBlockHead head;
- // catch null pointer
- if(buf == NULL)
+ /* catch null pointer */
+ if (buf == NULL)
return DLT_RETURN_WRONG_PARAMETER;
- if(buf->shm == NULL) {
- // shm not initialised
+ if (buf->shm == NULL) {
+ /* shm not initialised */
dlt_vlog(LOG_ERR, "%s: Buffer: SHM not initialized\n", __func__);
return DLT_RETURN_ERROR; /* ERROR */
}
- // get current write pointer
- write = ((int*)(buf->shm))[0];
- read = ((int*)(buf->shm))[1];
- count = ((int*)(buf->shm))[2];
+ /* get current write pointer */
+ write = ((int *)(buf->shm))[0];
+ read = ((int *)(buf->shm))[1];
+ count = ((int *)(buf->shm))[2];
- // check pointers
- if((read>buf->size) || (write>buf->size) || (count<0))
- {
+ /* check pointers */
+ if ((read > buf->size) || (write > buf->size) || (count < 0)) {
dlt_vlog(LOG_ERR,
"%s: Buffer: Pointer out of range. Read: %d, Write: %d, Count: %d, Size: %d\n",
__func__, read, write, count, buf->size);
dlt_buffer_reset(buf);
- return DLT_RETURN_ERROR; // ERROR
+ return DLT_RETURN_ERROR; /* ERROR */
}
- // check if data is in there
- if(count==0) {
- if(write!=read)
- {
+ /* check if data is in there */
+ if (count == 0) {
+ if (write != read) {
dlt_vlog(LOG_ERR,
"%s: Buffer: SHM should be empty, but is not. Read: %d, Write: %d\n",
__func__, read, write);
dlt_buffer_reset(buf);
}
- return DLT_RETURN_ERROR; // ERROR
+
+ return DLT_RETURN_ERROR; /* ERROR */
}
- // calculate used size
- if(write>read)
+ /* calculate used size */
+ if (write > read)
used_size = write - read;
else
used_size = buf->size - read + write;
- // first check size
- if(used_size < (int)(sizeof(DltBufferBlockHead))) {
+ /* first check size */
+ if (used_size < (int)(sizeof(DltBufferBlockHead))) {
dlt_vlog(LOG_ERR,
"%s: Buffer: Used size is smaller than buffer block header size. Used size: %d\n",
__func__, used_size);
dlt_buffer_reset(buf);
- return DLT_RETURN_ERROR; // ERROR
+ return DLT_RETURN_ERROR; /* ERROR */
}
- // read header
- dlt_buffer_read_block(buf,&read,(unsigned char*)&head,sizeof(DltBufferBlockHead));
+ /* read header */
+ dlt_buffer_read_block(buf, &read, (unsigned char *)&head, sizeof(DltBufferBlockHead));
- // check header
- if(memcmp((unsigned char*)(head.head),head_compare,sizeof(head_compare))!=0)
- {
+ /* check header */
+ if (memcmp((unsigned char *)(head.head), head_compare, sizeof(head_compare)) != 0) {
dlt_vlog(LOG_ERR, "%s: Buffer: Header head check failed\n", __func__);
dlt_buffer_reset(buf);
- return DLT_RETURN_ERROR; // ERROR
+ return DLT_RETURN_ERROR; /* ERROR */
}
- if(head.status != 2)
- {
+
+ if (head.status != 2) {
dlt_vlog(LOG_ERR, "%s: Buffer: Header status check failed\n", __func__);
dlt_buffer_reset(buf);
- return DLT_RETURN_ERROR; // ERROR
+ return DLT_RETURN_ERROR; /* ERROR */
}
- // second check size
- if(used_size < (int)(sizeof(DltBufferBlockHead)+head.size)) {
+ /* second check size */
+ if (used_size < (int)(sizeof(DltBufferBlockHead) + head.size)) {
dlt_vlog(LOG_ERR,
"%s: Buffer: Used size is smaller than buffer block header size And read header size. Used size: %d\n",
__func__, used_size);
dlt_buffer_reset(buf);
- return DLT_RETURN_ERROR; // ERROR
+ return DLT_RETURN_ERROR; /* ERROR */
}
- // third check size
- if(max_size && (head.size > max_size)) {
+ /* third check size */
+ if (max_size && (head.size > max_size))
dlt_vlog(LOG_WARNING,
"%s: Buffer: Max size is smaller than read header size. Max size: %d\n",
__func__, max_size);
- // nothing to do but data does not fit provided buffer
- }
+ /* nothing to do but data does not fit provided buffer */
- if(data != NULL && max_size)
- {
- // read data
- dlt_buffer_read_block(buf,&read,data,head.size);
- if(delete)
- {
- // update buffer pointers
- ((int*)(buf->shm))[1] = read; // set new read pointer
- }
+ if ((data != NULL) && max_size) {
+ /* read data */
+ dlt_buffer_read_block(buf, &read, data, head.size);
+
+ if (delete)
+ /* update buffer pointers */
+ ((int *)(buf->shm))[1] = read; /* set new read pointer */
}
- else
- {
- if(delete) {
- if( (read+head.size) <= buf->size)
- ((int*)(buf->shm))[1] = read+head.size; // set new read pointer
- else
- ((int*)(buf->shm))[1] = read+head.size-buf->size; // set new read pointer
- }
+ else if (delete) {
+ if ((read + head.size) <= buf->size)
+ ((int *)(buf->shm))[1] = read + head.size; /* set new read pointer */
+ else
+ ((int *)(buf->shm))[1] = read + head.size - buf->size; /* set new read pointer */
+
}
- if(delete) {
- ((int*)(buf->shm))[2] -= 1; // decrease counter
- if(((int*)(buf->shm))[2] == 0)
- {
- // try to minimize size
+ if (delete) {
+ ((int *)(buf->shm))[2] -= 1; /* decrease counter */
+
+ if (((int *)(buf->shm))[2] == 0)
+ /* try to minimize size */
dlt_buffer_minimize_size(buf);
- }
}
- return head.size; // OK
+ return head.size; /* OK */
}
-int dlt_buffer_pull(DltBuffer *buf,unsigned char *data, int max_size)
+int dlt_buffer_pull(DltBuffer *buf, unsigned char *data, int max_size)
{
- return dlt_buffer_get(buf,data,max_size,1);
+ return dlt_buffer_get(buf, data, max_size, 1);
}
-int dlt_buffer_copy(DltBuffer *buf,unsigned char *data, int max_size)
+int dlt_buffer_copy(DltBuffer *buf, unsigned char *data, int max_size)
{
- return dlt_buffer_get(buf,data,max_size,0);
+ return dlt_buffer_get(buf, data, max_size, 0);
}
int dlt_buffer_remove(DltBuffer *buf)
{
- return dlt_buffer_get(buf,0,0,1);
+ return dlt_buffer_get(buf, 0, 0, 1);
}
void dlt_buffer_info(DltBuffer *buf)
{
- // check nullpointer
- if (buf == NULL)
- {
+ /* check nullpointer */
+ if (buf == NULL) {
dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
return;
}
@@ -3011,20 +2717,19 @@ void dlt_buffer_status(DltBuffer *buf)
{
int write, read, count;
- // check nullpointer
- if (buf == NULL)
- {
+ /* check nullpointer */
+ if (buf == NULL) {
dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
return;
}
/* check if buffer available */
- if(buf->shm == NULL)
+ if (buf->shm == NULL)
return;
- write = ((int*)(buf->shm))[0];
- read = ((int*)(buf->shm))[1];
- count = ((int*)(buf->shm))[2];
+ write = ((int *)(buf->shm))[0];
+ read = ((int *)(buf->shm))[1];
+ count = ((int *)(buf->shm))[2];
dlt_vlog(LOG_DEBUG,
"Buffer: Write: %d, Read: %d, Count: %d\n",
@@ -3033,8 +2738,8 @@ void dlt_buffer_status(DltBuffer *buf)
uint32_t dlt_buffer_get_total_size(DltBuffer *buf)
{
- // catch null pointer
- if(buf == NULL)
+ /* catch null pointer */
+ if (buf == NULL)
return DLT_RETURN_WRONG_PARAMETER;
return buf->max_size;
@@ -3044,124 +2749,115 @@ int dlt_buffer_get_used_size(DltBuffer *buf)
{
int write, read, count;
- // catch null pointer
- if(buf == NULL)
+ /* catch null pointer */
+ if (buf == NULL)
return DLT_RETURN_WRONG_PARAMETER;
/* check if buffer available */
- if(buf->shm == NULL)
+ if (buf->shm == NULL)
return DLT_RETURN_OK;
- write = ((int*)(buf->shm))[0];
- read = ((int*)(buf->shm))[1];
- count = ((int*)(buf->shm))[2];
+ write = ((int *)(buf->shm))[0];
+ read = ((int *)(buf->shm))[1];
+ count = ((int *)(buf->shm))[2];
- if(count == 0)
+ if (count == 0)
return DLT_RETURN_OK;
- if(write>read)
- return (write - read);
+ if (write > read)
+ return write - read;
- return (buf->size - read + write);
+ return buf->size - read + write;
}
int dlt_buffer_get_message_count(DltBuffer *buf)
{
- // catch null pointer
- if(buf == NULL)
+ /* catch null pointer */
+ if (buf == NULL)
return DLT_RETURN_WRONG_PARAMETER;
/* check if buffer available */
- if(buf->shm == NULL)
+ if (buf->shm == NULL)
return DLT_RETURN_OK;
- return ((int*)(buf->shm))[2];
+ return ((int *)(buf->shm))[2];
}
#if !defined (__WIN32__)
DltReturnValue dlt_setup_serial(int fd, speed_t speed)
{
-#if !defined (__WIN32__) && !defined(_MSC_VER)
+# if !defined (__WIN32__) && !defined(_MSC_VER)
struct termios config;
- if (isatty(fd)==0)
- {
+ if (isatty(fd) == 0)
return DLT_RETURN_ERROR;
- }
if (tcgetattr(fd, &config) < 0)
- {
return DLT_RETURN_ERROR;
- }
/* Input flags - Turn off input processing
- convert break to null byte, no CR to NL translation,
- no NL to CR translation, don't mark parity errors or breaks
- no input parity check, don't strip high bit off,
- no XON/XOFF software flow control
- */
+ * convert break to null byte, no CR to NL translation,
+ * no NL to CR translation, don't mark parity errors or breaks
+ * no input parity check, don't strip high bit off,
+ * no XON/XOFF software flow control
+ */
config.c_iflag &= ~(IGNBRK | BRKINT | ICRNL |
INLCR | PARMRK | INPCK | ISTRIP | IXON);
/* Output flags - Turn off output processing
- no CR to NL translation, no NL to CR-NL translation,
- no NL to CR translation, no column 0 CR suppression,
- no Ctrl-D suppression, no fill characters, no case mapping,
- no local output processing
-
- config.c_oflag &= ~(OCRNL | ONLCR | ONLRET |
- ONOCR | ONOEOT| OFILL | OLCUC | OPOST);
- */
+ * no CR to NL translation, no NL to CR-NL translation,
+ * no NL to CR translation, no column 0 CR suppression,
+ * no Ctrl-D suppression, no fill characters, no case mapping,
+ * no local output processing
+ *
+ * config.c_oflag &= ~(OCRNL | ONLCR | ONLRET |
+ * ONOCR | ONOEOT| OFILL | OLCUC | OPOST);
+ */
config.c_oflag = 0;
/* No line processing:
- echo off, echo newline off, canonical mode off,
- extended input processing off, signal chars off
- */
+ * echo off, echo newline off, canonical mode off,
+ * extended input processing off, signal chars off
+ */
config.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG);
/* Turn off character processing
- clear current char size mask, no parity checking,
- no output processing, force 8 bit input
- */
+ * clear current char size mask, no parity checking,
+ * no output processing, force 8 bit input
+ */
config.c_cflag &= ~(CSIZE | PARENB);
config.c_cflag |= CS8;
/* One input byte is enough to return from read()
- Inter-character timer off
- */
- config.c_cc[VMIN] = 1;
+ * Inter-character timer off
+ */
+ config.c_cc[VMIN] = 1;
config.c_cc[VTIME] = 0;
/* Communication speed (simple version, using the predefined
- constants)
- */
- if (cfsetispeed(&config, speed) < 0 || cfsetospeed(&config, speed) < 0)
- {
+ * constants)
+ */
+ if ((cfsetispeed(&config, speed) < 0) || (cfsetospeed(&config, speed) < 0))
return DLT_RETURN_ERROR;
- }
/* Finally, apply the configuration
- */
+ */
if (tcsetattr(fd, TCSAFLUSH, &config) < 0)
- {
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
-#else
+# else
return DLT_RETURN_ERROR;
-#endif
+# endif
}
speed_t dlt_convert_serial_speed(int baudrate)
{
-#if !defined (__WIN32__) && !defined(_MSC_VER) && !defined(__CYGWIN__)
+# if !defined (__WIN32__) && !defined(_MSC_VER) && !defined(__CYGWIN__)
speed_t ret;
- switch (baudrate)
- {
+ switch (baudrate) {
case 50:
{
ret = B50;
@@ -3247,7 +2943,7 @@ speed_t dlt_convert_serial_speed(int baudrate)
ret = B115200;
break;
}
-#ifdef __linux__
+# ifdef __linux__
case 230400:
{
ret = B230400;
@@ -3313,7 +3009,7 @@ speed_t dlt_convert_serial_speed(int baudrate)
ret = B4000000;
break;
}
-#endif /* __linux__ */
+# endif /* __linux__ */
default:
{
ret = B115200;
@@ -3322,29 +3018,37 @@ speed_t dlt_convert_serial_speed(int baudrate)
}
return ret;
-#else
+# else
return 0;
-#endif
+# endif
}
#endif
void dlt_get_version(char *buf, size_t size)
{
- if(buf == NULL && size > 0)
- {
+ if ((buf == NULL) && (size > 0)) {
dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
return;
}
- snprintf(buf,size,"DLT Package Version: %s %s, Package Revision: %s, build on %s %s\n%s %s %s %s\n",
- _DLT_PACKAGE_VERSION, _DLT_PACKAGE_VERSION_STATE, _DLT_PACKAGE_REVISION, __DATE__ , __TIME__,_DLT_SYSTEMD_ENABLE,_DLT_SYSTEMD_WATCHDOG_ENABLE,_DLT_TEST_ENABLE,_DLT_SHM_ENABLE );
+ snprintf(buf,
+ size,
+ "DLT Package Version: %s %s, Package Revision: %s, build on %s %s\n%s %s %s %s\n",
+ _DLT_PACKAGE_VERSION,
+ _DLT_PACKAGE_VERSION_STATE,
+ _DLT_PACKAGE_REVISION,
+ __DATE__,
+ __TIME__,
+ _DLT_SYSTEMD_ENABLE,
+ _DLT_SYSTEMD_WATCHDOG_ENABLE,
+ _DLT_TEST_ENABLE,
+ _DLT_SHM_ENABLE);
}
void dlt_get_major_version(char *buf, size_t size)
{
- if (buf == NULL && size > 0)
- {
+ if ((buf == NULL) && (size > 0)) {
dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
return;
}
@@ -3354,8 +3058,7 @@ void dlt_get_major_version(char *buf, size_t size)
void dlt_get_minor_version(char *buf, size_t size)
{
- if (buf == NULL && size > 0)
- {
+ if ((buf == NULL) && (size > 0)) {
dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
return;
}
@@ -3369,19 +3072,15 @@ uint32_t dlt_uptime(void)
#if defined (__WIN32__) || defined(_MSC_VER)
- return (uint32_t)(GetTickCount()*10); /* GetTickCount() return DWORD */
+ return (uint32_t)(GetTickCount() * 10); /* GetTickCount() return DWORD */
#else
struct timespec ts;
- if (clock_gettime(CLOCK_MONOTONIC,&ts)==0)
- {
- return ( (uint32_t)ts.tv_sec*10000 + (uint32_t)ts.tv_nsec/100000 );// in 0.1 ms = 100 us
- }
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
+ return (uint32_t)ts.tv_sec * 10000 + (uint32_t)ts.tv_nsec / 100000;/* in 0.1 ms = 100 us */
else
- {
return 0;
- }
#endif
@@ -3390,12 +3089,10 @@ uint32_t dlt_uptime(void)
DltReturnValue dlt_message_print_header(DltMessage *message, char *text, uint32_t size, int verbose)
{
if ((message == NULL) || (text == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
dlt_message_header(message, text, size, verbose);
- printf("%s\n",text);
+ printf("%s\n", text);
return DLT_RETURN_OK;
}
@@ -3403,14 +3100,12 @@ DltReturnValue dlt_message_print_header(DltMessage *message, char *text, uint32_
DltReturnValue dlt_message_print_hex(DltMessage *message, char *text, uint32_t size, int verbose)
{
if ((message == NULL) || (text == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- dlt_message_header(message,text,size,verbose);
- printf("%s ",text);
- dlt_message_payload(message,text,size,DLT_OUTPUT_HEX,verbose);
- printf("[%s]\n",text);
+ dlt_message_header(message, text, size, verbose);
+ printf("%s ", text);
+ dlt_message_payload(message, text, size, DLT_OUTPUT_HEX, verbose);
+ printf("[%s]\n", text);
return DLT_RETURN_OK;
}
@@ -3418,14 +3113,12 @@ DltReturnValue dlt_message_print_hex(DltMessage *message, char *text, uint32_t s
DltReturnValue dlt_message_print_ascii(DltMessage *message, char *text, uint32_t size, int verbose)
{
if ((message == NULL) || (text == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- dlt_message_header(message,text,size,verbose);
- printf("%s ",text);
- dlt_message_payload(message,text,size,DLT_OUTPUT_ASCII,verbose);
- printf("[%s]\n",text);
+ dlt_message_header(message, text, size, verbose);
+ printf("%s ", text);
+ dlt_message_payload(message, text, size, DLT_OUTPUT_ASCII, verbose);
+ printf("[%s]\n", text);
return DLT_RETURN_OK;
}
@@ -3433,14 +3126,12 @@ DltReturnValue dlt_message_print_ascii(DltMessage *message, char *text, uint32_t
DltReturnValue dlt_message_print_mixed_plain(DltMessage *message, char *text, uint32_t size, int verbose)
{
if ((message == NULL) || (text == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- dlt_message_header(message,text,size,verbose);
- printf("%s \n",text);
- dlt_message_payload(message,text,size,DLT_OUTPUT_MIXED_FOR_PLAIN,verbose);
- printf("[%s]\n",text);
+ dlt_message_header(message, text, size, verbose);
+ printf("%s \n", text);
+ dlt_message_payload(message, text, size, DLT_OUTPUT_MIXED_FOR_PLAIN, verbose);
+ printf("[%s]\n", text);
return DLT_RETURN_OK;
}
@@ -3448,41 +3139,46 @@ DltReturnValue dlt_message_print_mixed_plain(DltMessage *message, char *text, ui
DltReturnValue dlt_message_print_mixed_html(DltMessage *message, char *text, uint32_t size, int verbose)
{
if ((message == NULL) || (text == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- dlt_message_header(message,text,size,verbose);
- printf("%s \n",text);
- dlt_message_payload(message,text,size,DLT_OUTPUT_MIXED_FOR_HTML,verbose);
- printf("[%s]\n",text);
+ dlt_message_header(message, text, size, verbose);
+ printf("%s \n", text);
+ dlt_message_payload(message, text, size, DLT_OUTPUT_MIXED_FOR_HTML, verbose);
+ printf("[%s]\n", text);
return DLT_RETURN_OK;
}
-DltReturnValue dlt_message_argument_print(DltMessage *msg,uint32_t type_info,uint8_t **ptr,int32_t *datalength,char *text,int textlength,int byteLength,int __attribute__((unused)) verbose)
+DltReturnValue dlt_message_argument_print(DltMessage *msg,
+ uint32_t type_info,
+ uint8_t **ptr,
+ int32_t *datalength,
+ char *text,
+ int textlength,
+ int byteLength,
+ int __attribute__((unused)) verbose)
{
- // check null pointers
- if(msg == NULL || ptr == NULL || datalength == NULL || text == NULL)
+ /* check null pointers */
+ if ((msg == NULL) || (ptr == NULL) || (datalength == NULL) || (text == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- int16_t length=0,length_tmp=0; /* the macro can set this variable to -1 */
- uint16_t length2=0,length2_tmp=0,length3=0,length3_tmp=0;
+ int16_t length = 0, length_tmp = 0; /* the macro can set this variable to -1 */
+ uint16_t length2 = 0, length2_tmp = 0, length3 = 0, length3_tmp = 0;
- uint8_t value8u=0;
- uint16_t value16u=0,value16u_tmp=0;
- uint32_t value32u=0,value32u_tmp=0;
- uint64_t value64u=0,value64u_tmp=0;
+ uint8_t value8u = 0;
+ uint16_t value16u = 0, value16u_tmp = 0;
+ uint32_t value32u = 0, value32u_tmp = 0;
+ uint64_t value64u = 0, value64u_tmp = 0;
- int8_t value8i=0;
- int16_t value16i=0,value16i_tmp=0;
- int32_t value32i=0,value32i_tmp=0;
- int64_t value64i=0,value64i_tmp=0;
+ int8_t value8i = 0;
+ int16_t value16i = 0, value16i_tmp = 0;
+ int32_t value32i = 0, value32i_tmp = 0;
+ int64_t value64i = 0, value64i_tmp = 0;
- float32_t value32f=0,value32f_tmp=0;
- int32_t value32f_tmp_int32i=0,value32f_tmp_int32i_swaped=0;
- float64_t value64f=0,value64f_tmp=0;
- int64_t value64f_tmp_int64i=0,value64f_tmp_int64i_swaped=0;
+ float32_t value32f = 0, value32f_tmp = 0;
+ int32_t value32f_tmp_int32i = 0, value32f_tmp_int32i_swaped = 0;
+ float64_t value64f = 0, value64f_tmp = 0;
+ int64_t value64f_tmp_int64i = 0, value64f_tmp_int64i_swaped = 0;
uint32_t quantisation_tmp = 0;
@@ -3491,465 +3187,536 @@ DltReturnValue dlt_message_argument_print(DltMessage *msg,uint32_t type_info,uin
* case but never read anywhere */
quantisation_tmp += quantisation_tmp;
- if ( (type_info & DLT_TYPE_INFO_STRG) && (((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_ASCII) || ((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_UTF8)) )
- {
+ if ((type_info & DLT_TYPE_INFO_STRG) &&
+ (((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_ASCII) || ((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_UTF8))) {
/* string type or utf8-encoded string type */
- if (byteLength<0)
- {
- DLT_MSG_READ_VALUE(length_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+ if (byteLength < 0) {
+ DLT_MSG_READ_VALUE(length_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- length=DLT_ENDIAN_GET_16(msg->standardheader->htyp, length_tmp);
+
+ length = DLT_ENDIAN_GET_16(msg->standardheader->htyp, length_tmp);
}
- else
- {
- length=(int16_t)byteLength;
+ else {
+ length = (int16_t)byteLength;
}
- if (type_info & DLT_TYPE_INFO_VARI)
- {
- DLT_MSG_READ_VALUE(length2_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+ if (type_info & DLT_TYPE_INFO_VARI) {
+ DLT_MSG_READ_VALUE(length2_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- length2=DLT_ENDIAN_GET_16(msg->standardheader->htyp, length2_tmp);
- if((*datalength)<length2)
+
+ length2 = DLT_ENDIAN_GET_16(msg->standardheader->htyp, length2_tmp);
+
+ if ((*datalength) < length2)
return DLT_RETURN_ERROR;
+
*ptr += length2;
- *datalength-=length2;
+ *datalength -= length2;
}
- DLT_MSG_READ_STRING((text+strlen(text)),*ptr,*datalength,length);
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
+ DLT_MSG_READ_STRING((text + strlen(text)), *ptr, *datalength, length);
+ if ((*datalength) < 0)
+ return DLT_RETURN_ERROR;
}
else if (type_info & DLT_TYPE_INFO_BOOL)
{
/* Boolean type */
- if (type_info & DLT_TYPE_INFO_VARI)
- {
- DLT_MSG_READ_VALUE(length2_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+ if (type_info & DLT_TYPE_INFO_VARI) {
+ DLT_MSG_READ_VALUE(length2_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- length2=DLT_ENDIAN_GET_16(msg->standardheader->htyp, length2_tmp);
- if((*datalength)<length2)
+
+ length2 = DLT_ENDIAN_GET_16(msg->standardheader->htyp, length2_tmp);
+
+ if ((*datalength) < length2)
return DLT_RETURN_ERROR;
+
*ptr += length2;
- *datalength-=length2;
+ *datalength -= length2;
}
- value8u=0;
- DLT_MSG_READ_VALUE(value8u,*ptr,*datalength,uint8_t); /* No endian conversion necessary */
- if((*datalength)<0)
+
+ value8u = 0;
+ DLT_MSG_READ_VALUE(value8u, *ptr, *datalength, uint8_t); /* No endian conversion necessary */
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- snprintf(text+strlen(text),textlength-strlen(text),"%d",value8u);
+
+ snprintf(text + strlen(text), textlength - strlen(text), "%d", value8u);
}
else if ((type_info & DLT_TYPE_INFO_UINT) && (DLT_SCOD_BIN == (type_info & DLT_TYPE_INFO_SCOD)))
{
- if (DLT_TYLE_8BIT == (type_info & DLT_TYPE_INFO_TYLE))
- {
- DLT_MSG_READ_VALUE(value8u,*ptr,*datalength,uint8_t); /* No endian conversion necessary */
- if((*datalength)<0)
+ if (DLT_TYLE_8BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+ DLT_MSG_READ_VALUE(value8u, *ptr, *datalength, uint8_t); /* No endian conversion necessary */
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- char binary[10] = {'\0'}; // e.g.: "0b1100 0010"
+
+ char binary[10] = { '\0' }; /* e.g.: "0b1100 0010" */
int i;
- for (i = (1 << 7); i > 0; i >>= 1)
- {
- if ((1<<3) == i)
+
+ for (i = (1 << 7); i > 0; i >>= 1) {
+ if ((1 << 3) == i)
strcat(binary, " ");
+
strcat(binary, (i == (value8u & i)) ? "1" : "0");
}
- snprintf(text+strlen(text),textlength-strlen(text),"0b%s",binary);
+ snprintf(text + strlen(text), textlength - strlen(text), "0b%s", binary);
}
- if (DLT_TYLE_16BIT == (type_info & DLT_TYPE_INFO_TYLE))
- {
- DLT_MSG_READ_VALUE(value16u,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+
+ if (DLT_TYLE_16BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+ DLT_MSG_READ_VALUE(value16u, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- char binary[20] = {'\0'}; // e.g.: "0b1100 0010 0011 0110"
+
+ char binary[20] = { '\0' }; /* e.g.: "0b1100 0010 0011 0110" */
int i;
- for (i = (1 << 15); i > 0; i >>= 1)
- {
- if (((1<<3) == i) || ((1<<7) == i) || ((1<<11) == i))
+
+ for (i = (1 << 15); i > 0; i >>= 1) {
+ if (((1 << 3) == i) || ((1 << 7) == i) || ((1 << 11) == i))
strcat(binary, " ");
+
strcat(binary, (i == (value16u & i)) ? "1" : "0");
}
- snprintf(text+strlen(text),textlength-strlen(text),"0b%s",binary);
+ snprintf(text + strlen(text), textlength - strlen(text), "0b%s", binary);
}
}
else if ((type_info & DLT_TYPE_INFO_UINT) && (DLT_SCOD_HEX == (type_info & DLT_TYPE_INFO_SCOD)))
{
- if (DLT_TYLE_8BIT == (type_info & DLT_TYPE_INFO_TYLE))
- {
- DLT_MSG_READ_VALUE(value8u,*ptr,*datalength,uint8_t); /* No endian conversion necessary */
- if((*datalength)<0)
+ if (DLT_TYLE_8BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+ DLT_MSG_READ_VALUE(value8u, *ptr, *datalength, uint8_t); /* No endian conversion necessary */
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- snprintf(text+strlen(text),textlength-strlen(text),"0x%02x",value8u);
+
+ snprintf(text + strlen(text), textlength - strlen(text), "0x%02x", value8u);
}
- if (DLT_TYLE_16BIT == (type_info & DLT_TYPE_INFO_TYLE))
- {
- DLT_MSG_READ_VALUE(value16u,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+
+ if (DLT_TYLE_16BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+ DLT_MSG_READ_VALUE(value16u, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- snprintf(text+strlen(text),textlength-strlen(text),"0x%04x",value16u);
+
+ snprintf(text + strlen(text), textlength - strlen(text), "0x%04x", value16u);
}
- if (DLT_TYLE_32BIT == (type_info & DLT_TYPE_INFO_TYLE))
- {
- DLT_MSG_READ_VALUE(value32u,*ptr,*datalength,uint32_t);
- if((*datalength)<0)
+
+ if (DLT_TYLE_32BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+ DLT_MSG_READ_VALUE(value32u, *ptr, *datalength, uint32_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- snprintf(text+strlen(text),textlength-strlen(text),"0x%08x",value32u);
+
+ snprintf(text + strlen(text), textlength - strlen(text), "0x%08x", value32u);
}
- if (DLT_TYLE_64BIT == (type_info & DLT_TYPE_INFO_TYLE))
- {
+
+ if (DLT_TYLE_64BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
*ptr += 4;
- DLT_MSG_READ_VALUE(value32u,*ptr,*datalength,uint32_t);
- if((*datalength)<0)
+ DLT_MSG_READ_VALUE(value32u, *ptr, *datalength, uint32_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- snprintf(text+strlen(text),textlength-strlen(text),"0x%08x",value32u);
+
+ snprintf(text + strlen(text), textlength - strlen(text), "0x%08x", value32u);
*ptr -= 8;
- DLT_MSG_READ_VALUE(value32u,*ptr,*datalength,uint32_t);
- if((*datalength)<0)
+ DLT_MSG_READ_VALUE(value32u, *ptr, *datalength, uint32_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- snprintf(text+strlen(text),textlength-strlen(text),"%08x",value32u);
+
+ snprintf(text + strlen(text), textlength - strlen(text), "%08x", value32u);
*ptr += 4;
}
}
else if ((type_info & DLT_TYPE_INFO_SINT) || (type_info & DLT_TYPE_INFO_UINT))
{
/* signed or unsigned argument received */
- if (type_info & DLT_TYPE_INFO_VARI)
- {
- DLT_MSG_READ_VALUE(length2_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+ if (type_info & DLT_TYPE_INFO_VARI) {
+ DLT_MSG_READ_VALUE(length2_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- length2=DLT_ENDIAN_GET_16(msg->standardheader->htyp, length2_tmp);
- DLT_MSG_READ_VALUE(length3_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+
+ length2 = DLT_ENDIAN_GET_16(msg->standardheader->htyp, length2_tmp);
+ DLT_MSG_READ_VALUE(length3_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- length3=DLT_ENDIAN_GET_16(msg->standardheader->htyp, length3_tmp);
- if((*datalength)<length2)
+
+ length3 = DLT_ENDIAN_GET_16(msg->standardheader->htyp, length3_tmp);
+
+ if ((*datalength) < length2)
return DLT_RETURN_ERROR;
+
*ptr += length2;
- *datalength-=length2;
- if((*datalength)<length3)
+ *datalength -= length2;
+
+ if ((*datalength) < length3)
return DLT_RETURN_ERROR;
+
*ptr += length3;
- *datalength-=length3;
+ *datalength -= length3;
}
- if (type_info & DLT_TYPE_INFO_FIXP)
- {
+
+ if (type_info & DLT_TYPE_INFO_FIXP) {
DLT_MSG_READ_VALUE(quantisation_tmp, *ptr, *datalength, uint32_t);
- if((*datalength)<0)
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- switch ( type_info & DLT_TYPE_INFO_TYLE)
- {
- case DLT_TYLE_8BIT:
- case DLT_TYLE_16BIT:
- case DLT_TYLE_32BIT:
- {
- if((*datalength)<4)
- return DLT_RETURN_ERROR;
- *ptr += 4;
- *datalength-=4;
- break;
- }
- case DLT_TYLE_64BIT:
- {
- if((*datalength)<8)
- return DLT_RETURN_ERROR;
- *ptr += 8;
- *datalength-=8;
- break;
- }
- case DLT_TYLE_128BIT:
- {
- if((*datalength)<16)
- return DLT_RETURN_ERROR;
- *ptr += 16;
- *datalength-=16;
- break;
- }
- default:
- {
- return DLT_RETURN_ERROR;
- }
- }
- }
- switch (type_info & DLT_TYPE_INFO_TYLE)
- {
+ switch (type_info & DLT_TYPE_INFO_TYLE) {
case DLT_TYLE_8BIT:
- {
- if (type_info & DLT_TYPE_INFO_SINT)
- {
- value8i=0;
- DLT_MSG_READ_VALUE(value8i,*ptr,*datalength,int8_t); /* No endian conversion necessary */
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
- snprintf(text+strlen(text),textlength-strlen(text),"%d",value8i);
- }
- else
- {
- value8u=0;
- DLT_MSG_READ_VALUE(value8u,*ptr,*datalength,uint8_t); /* No endian conversion necessary */
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
- snprintf(text+strlen(text),textlength-strlen(text),"%d",value8u);
- }
- break;
- }
case DLT_TYLE_16BIT:
- {
- if (type_info & DLT_TYPE_INFO_SINT)
- {
- value16i=0;
- value16i_tmp=0;
- DLT_MSG_READ_VALUE(value16i_tmp,*ptr,*datalength,int16_t);
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
- value16i=DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16i_tmp);
- snprintf(text+strlen(text),textlength-strlen(text),"%hd",value16i);
- }
- else
- {
- value16u=0;
- value16u_tmp=0;
- DLT_MSG_READ_VALUE(value16u_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
- value16u=DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
- snprintf(text+strlen(text),textlength-strlen(text),"%hu",value16u);
- }
- break;
- }
case DLT_TYLE_32BIT:
{
- if (type_info & DLT_TYPE_INFO_SINT)
- {
- value32i=0;
- value32i_tmp=0;
- DLT_MSG_READ_VALUE(value32i_tmp,*ptr,*datalength,int32_t);
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
- value32i=DLT_ENDIAN_GET_32(msg->standardheader->htyp, (uint32_t)value32i_tmp);
- snprintf(text+strlen(text),textlength-strlen(text),"%d",value32i);
- }
- else
- {
- value32u=0;
- value32u_tmp=0;
- DLT_MSG_READ_VALUE(value32u_tmp,*ptr,*datalength,uint32_t);
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
- value32u=DLT_ENDIAN_GET_32(msg->standardheader->htyp, value32u_tmp);
- snprintf(text+strlen(text),textlength-strlen(text),"%u",value32u);
- }
+ if ((*datalength) < 4)
+ return DLT_RETURN_ERROR;
+
+ *ptr += 4;
+ *datalength -= 4;
break;
}
case DLT_TYLE_64BIT:
{
- if (type_info & DLT_TYPE_INFO_SINT)
- {
- value64i=0;
- value64i_tmp=0;
- DLT_MSG_READ_VALUE(value64i_tmp,*ptr,*datalength,int64_t);
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
- value64i=DLT_ENDIAN_GET_64(msg->standardheader->htyp, (uint64_t)value64i_tmp);
- #if defined (__WIN32__) && !defined(_MSC_VER)
- snprintf(text+strlen(text),textlength-strlen(text),"%I64d",value64i);
- #else
- snprintf(text+strlen(text),textlength-strlen(text),"%"PRId64, value64i);
- #endif
- }
- else
- {
- value64u=0;
- value64u_tmp=0;
- DLT_MSG_READ_VALUE(value64u_tmp,*ptr,*datalength,uint64_t);
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
- value64u=DLT_ENDIAN_GET_64(msg->standardheader->htyp, value64u_tmp);
- #if defined (__WIN32__) && !defined(_MSC_VER)
- snprintf(text+strlen(text),textlength-strlen(text),"%I64u",value64u);
- #else
- snprintf(text+strlen(text),textlength-strlen(text),"%"PRId64,value64u);
- #endif
- }
+ if ((*datalength) < 8)
+ return DLT_RETURN_ERROR;
+
+ *ptr += 8;
+ *datalength -= 8;
break;
}
case DLT_TYLE_128BIT:
{
- if (*datalength>=16)
- dlt_print_hex_string(text+strlen(text),textlength,*ptr,16);
- if((*datalength)<16)
+ if ((*datalength) < 16)
return DLT_RETURN_ERROR;
+
*ptr += 16;
- *datalength-=16;
+ *datalength -= 16;
break;
}
default:
{
return DLT_RETURN_ERROR;
}
+ }
+ }
+
+ switch (type_info & DLT_TYPE_INFO_TYLE) {
+ case DLT_TYLE_8BIT:
+ {
+ if (type_info & DLT_TYPE_INFO_SINT) {
+ value8i = 0;
+ DLT_MSG_READ_VALUE(value8i, *ptr, *datalength, int8_t); /* No endian conversion necessary */
+
+ if ((*datalength) < 0)
+ return DLT_RETURN_ERROR;
+
+ snprintf(text + strlen(text), textlength - strlen(text), "%d", value8i);
+ }
+ else {
+ value8u = 0;
+ DLT_MSG_READ_VALUE(value8u, *ptr, *datalength, uint8_t); /* No endian conversion necessary */
+
+ if ((*datalength) < 0)
+ return DLT_RETURN_ERROR;
+
+ snprintf(text + strlen(text), textlength - strlen(text), "%d", value8u);
+ }
+
+ break;
+ }
+ case DLT_TYLE_16BIT:
+ {
+ if (type_info & DLT_TYPE_INFO_SINT) {
+ value16i = 0;
+ value16i_tmp = 0;
+ DLT_MSG_READ_VALUE(value16i_tmp, *ptr, *datalength, int16_t);
+
+ if ((*datalength) < 0)
+ return DLT_RETURN_ERROR;
+
+ value16i = DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16i_tmp);
+ snprintf(text + strlen(text), textlength - strlen(text), "%hd", value16i);
+ }
+ else {
+ value16u = 0;
+ value16u_tmp = 0;
+ DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
+ return DLT_RETURN_ERROR;
+
+ value16u = DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+ snprintf(text + strlen(text), textlength - strlen(text), "%hu", value16u);
+ }
+
+ break;
+ }
+ case DLT_TYLE_32BIT:
+ {
+ if (type_info & DLT_TYPE_INFO_SINT) {
+ value32i = 0;
+ value32i_tmp = 0;
+ DLT_MSG_READ_VALUE(value32i_tmp, *ptr, *datalength, int32_t);
+
+ if ((*datalength) < 0)
+ return DLT_RETURN_ERROR;
+
+ value32i = DLT_ENDIAN_GET_32(msg->standardheader->htyp, (uint32_t)value32i_tmp);
+ snprintf(text + strlen(text), textlength - strlen(text), "%d", value32i);
+ }
+ else {
+ value32u = 0;
+ value32u_tmp = 0;
+ DLT_MSG_READ_VALUE(value32u_tmp, *ptr, *datalength, uint32_t);
+
+ if ((*datalength) < 0)
+ return DLT_RETURN_ERROR;
+
+ value32u = DLT_ENDIAN_GET_32(msg->standardheader->htyp, value32u_tmp);
+ snprintf(text + strlen(text), textlength - strlen(text), "%u", value32u);
+ }
+
+ break;
+ }
+ case DLT_TYLE_64BIT:
+ {
+ if (type_info & DLT_TYPE_INFO_SINT) {
+ value64i = 0;
+ value64i_tmp = 0;
+ DLT_MSG_READ_VALUE(value64i_tmp, *ptr, *datalength, int64_t);
+
+ if ((*datalength) < 0)
+ return DLT_RETURN_ERROR;
+
+ value64i = DLT_ENDIAN_GET_64(msg->standardheader->htyp, (uint64_t)value64i_tmp);
+ #if defined (__WIN32__) && !defined(_MSC_VER)
+ snprintf(text + strlen(text), textlength - strlen(text), "%I64d", value64i);
+ #else
+ snprintf(text + strlen(text), textlength - strlen(text), "%" PRId64, value64i);
+ #endif
+ }
+ else {
+ value64u = 0;
+ value64u_tmp = 0;
+ DLT_MSG_READ_VALUE(value64u_tmp, *ptr, *datalength, uint64_t);
+
+ if ((*datalength) < 0)
+ return DLT_RETURN_ERROR;
+
+ value64u = DLT_ENDIAN_GET_64(msg->standardheader->htyp, value64u_tmp);
+ #if defined (__WIN32__) && !defined(_MSC_VER)
+ snprintf(text + strlen(text), textlength - strlen(text), "%I64u", value64u);
+ #else
+ snprintf(text + strlen(text), textlength - strlen(text), "%" PRId64, value64u);
+ #endif
+ }
+
+ break;
+ }
+ case DLT_TYLE_128BIT:
+ {
+ if (*datalength >= 16)
+ dlt_print_hex_string(text + strlen(text), textlength, *ptr, 16);
+
+ if ((*datalength) < 16)
+ return DLT_RETURN_ERROR;
+
+ *ptr += 16;
+ *datalength -= 16;
+ break;
+ }
+ default:
+ {
+ return DLT_RETURN_ERROR;
+ }
}
}
else if (type_info & DLT_TYPE_INFO_FLOA)
{
/* float data argument */
- if (type_info & DLT_TYPE_INFO_VARI)
- {
- DLT_MSG_READ_VALUE(length2_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+ if (type_info & DLT_TYPE_INFO_VARI) {
+ DLT_MSG_READ_VALUE(length2_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- length2=DLT_ENDIAN_GET_16(msg->standardheader->htyp, length2_tmp);
- DLT_MSG_READ_VALUE(length3_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+
+ length2 = DLT_ENDIAN_GET_16(msg->standardheader->htyp, length2_tmp);
+ DLT_MSG_READ_VALUE(length3_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- length3=DLT_ENDIAN_GET_16(msg->standardheader->htyp, length3_tmp);
- if((*datalength)<length2)
+
+ length3 = DLT_ENDIAN_GET_16(msg->standardheader->htyp, length3_tmp);
+
+ if ((*datalength) < length2)
return DLT_RETURN_ERROR;
+
*ptr += length2;
- *datalength-=length2;
- if((*datalength)<length3)
+ *datalength -= length2;
+
+ if ((*datalength) < length3)
return DLT_RETURN_ERROR;
+
*ptr += length3;
- *datalength-=length3;
+ *datalength -= length3;
}
- switch ( type_info & DLT_TYPE_INFO_TYLE)
+
+ switch (type_info & DLT_TYPE_INFO_TYLE) {
+ case DLT_TYLE_8BIT:
{
- case DLT_TYLE_8BIT:
- {
- if (*datalength>=1)
- dlt_print_hex_string(text+strlen(text),textlength,*ptr,1);
- if((*datalength)<1)
+ if (*datalength >= 1)
+ dlt_print_hex_string(text + strlen(text), textlength, *ptr, 1);
+
+ if ((*datalength) < 1)
+ return DLT_RETURN_ERROR;
+
+ *ptr += 1;
+ *datalength -= 1;
+ break;
+ }
+ case DLT_TYLE_16BIT:
+ {
+ if (*datalength >= 2)
+ dlt_print_hex_string(text + strlen(text), textlength, *ptr, 2);
+
+ if ((*datalength) < 2)
+ return DLT_RETURN_ERROR;
+
+ *ptr += 2;
+ *datalength -= 2;
+ break;
+ }
+ case DLT_TYLE_32BIT:
+ {
+ if (sizeof(float32_t) == 4) {
+ value32f = 0;
+ value32f_tmp = 0;
+ value32f_tmp_int32i = 0;
+ value32f_tmp_int32i_swaped = 0;
+ DLT_MSG_READ_VALUE(value32f_tmp, *ptr, *datalength, float32_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- *ptr += 1;
- *datalength-=1;
- break;
+
+ memcpy(&value32f_tmp_int32i, &value32f_tmp, sizeof(float32_t));
+ value32f_tmp_int32i_swaped =
+ DLT_ENDIAN_GET_32(msg->standardheader->htyp, (uint32_t)value32f_tmp_int32i);
+ memcpy(&value32f, &value32f_tmp_int32i_swaped, sizeof(float32_t));
+ snprintf(text + strlen(text), textlength - strlen(text), "%g", value32f);
}
- case DLT_TYLE_16BIT:
- {
- if (*datalength>=2)
- dlt_print_hex_string(text+strlen(text),textlength,*ptr,2);
- if((*datalength)<2)
- return DLT_RETURN_ERROR;
- *ptr += 2;
- *datalength-=2;
- break;
+ else {
+ dlt_log(LOG_ERR, "Invalid size of float32_t\n");
+ return DLT_RETURN_ERROR;
}
- case DLT_TYLE_32BIT:
- {
- if (sizeof(float32_t)==4)
- {
- value32f=0;
- value32f_tmp=0;
- value32f_tmp_int32i=0;
- value32f_tmp_int32i_swaped=0;
- DLT_MSG_READ_VALUE(value32f_tmp,*ptr,*datalength,float32_t);
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
- memcpy(&value32f_tmp_int32i,&value32f_tmp,sizeof(float32_t));
- value32f_tmp_int32i_swaped=DLT_ENDIAN_GET_32(msg->standardheader->htyp, (uint32_t)value32f_tmp_int32i);
- memcpy(&value32f,&value32f_tmp_int32i_swaped,sizeof(float32_t));
- snprintf(text+strlen(text),textlength-strlen(text),"%g",value32f);
- }
- else
- {
- dlt_log(LOG_ERR, "Invalid size of float32_t\n");
+
+ break;
+ }
+ case DLT_TYLE_64BIT:
+ {
+ if (sizeof(float64_t) == 8) {
+ value64f = 0;
+ value64f_tmp = 0;
+ value64f_tmp_int64i = 0;
+ value64f_tmp_int64i_swaped = 0;
+ DLT_MSG_READ_VALUE(value64f_tmp, *ptr, *datalength, float64_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- }
- break;
- }
- case DLT_TYLE_64BIT:
- {
- if (sizeof(float64_t)==8)
- {
- value64f=0;
- value64f_tmp=0;
- value64f_tmp_int64i=0;
- value64f_tmp_int64i_swaped=0;
- DLT_MSG_READ_VALUE(value64f_tmp,*ptr,*datalength,float64_t);
- if((*datalength)<0)
- return DLT_RETURN_ERROR;
- memcpy(&value64f_tmp_int64i,&value64f_tmp,sizeof(float64_t));
- value64f_tmp_int64i_swaped=DLT_ENDIAN_GET_64(msg->standardheader->htyp, (uint64_t)value64f_tmp_int64i);
- memcpy(&value64f,&value64f_tmp_int64i_swaped,sizeof(float64_t));
+
+ memcpy(&value64f_tmp_int64i, &value64f_tmp, sizeof(float64_t));
+ value64f_tmp_int64i_swaped =
+ DLT_ENDIAN_GET_64(msg->standardheader->htyp, (uint64_t)value64f_tmp_int64i);
+ memcpy(&value64f, &value64f_tmp_int64i_swaped, sizeof(float64_t));
#ifdef __arm__
- snprintf(text+strlen(text),textlength-strlen(text),"ILLEGAL");
+ snprintf(text + strlen(text), textlength - strlen(text), "ILLEGAL");
#else
- snprintf(text+strlen(text),textlength-strlen(text),"%g",value64f);
+ snprintf(text + strlen(text), textlength - strlen(text), "%g", value64f);
#endif
- }
- else
- {
- dlt_log(LOG_ERR, "Invalid size of float64_t\n");
- return DLT_RETURN_ERROR;
- }
- break;
}
- case DLT_TYLE_128BIT:
- {
- if (*datalength>=16)
- dlt_print_hex_string(text+strlen(text),textlength,*ptr,16);
- if((*datalength)<16)
- return DLT_RETURN_ERROR;
- *ptr += 16;
- *datalength-=16;
- break;
- }
- default:
- {
+ else {
+ dlt_log(LOG_ERR, "Invalid size of float64_t\n");
return DLT_RETURN_ERROR;
}
+
+ break;
}
+ case DLT_TYLE_128BIT:
+ {
+ if (*datalength >= 16)
+ dlt_print_hex_string(text + strlen(text), textlength, *ptr, 16);
+
+ if ((*datalength) < 16)
+ return DLT_RETURN_ERROR;
+ *ptr += 16;
+ *datalength -= 16;
+ break;
+ }
+ default:
+ {
+ return DLT_RETURN_ERROR;
+ }
+ }
}
else if (type_info & DLT_TYPE_INFO_RAWD)
{
/* raw data argument */
- DLT_MSG_READ_VALUE(length_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+ DLT_MSG_READ_VALUE(length_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- length=DLT_ENDIAN_GET_16(msg->standardheader->htyp, length_tmp);
- if (type_info & DLT_TYPE_INFO_VARI)
- {
- DLT_MSG_READ_VALUE(length2_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+
+ length = DLT_ENDIAN_GET_16(msg->standardheader->htyp, length_tmp);
+
+ if (type_info & DLT_TYPE_INFO_VARI) {
+ DLT_MSG_READ_VALUE(length2_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- length2=DLT_ENDIAN_GET_16(msg->standardheader->htyp, length2_tmp);
- if((*datalength)<length2)
+
+ length2 = DLT_ENDIAN_GET_16(msg->standardheader->htyp, length2_tmp);
+
+ if ((*datalength) < length2)
return DLT_RETURN_ERROR;
+
*ptr += length2;
- *datalength-=length2;
+ *datalength -= length2;
}
- if((*datalength)<length)
+
+ if ((*datalength) < length)
return DLT_RETURN_ERROR;
- dlt_print_hex_string(text+strlen(text),textlength,*ptr,length);
- *ptr+=length;
- *datalength-=length;
+
+ dlt_print_hex_string(text + strlen(text), textlength, *ptr, length);
+ *ptr += length;
+ *datalength -= length;
}
else if (type_info & DLT_TYPE_INFO_TRAI)
{
/* trace info argument */
- DLT_MSG_READ_VALUE(length_tmp,*ptr,*datalength,uint16_t);
- if((*datalength)<0)
+ DLT_MSG_READ_VALUE(length_tmp, *ptr, *datalength, uint16_t);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
- length=DLT_ENDIAN_GET_16(msg->standardheader->htyp, length_tmp);
- DLT_MSG_READ_STRING((text+strlen(text)),*ptr,*datalength,length);
- if((*datalength)<0)
+
+ length = DLT_ENDIAN_GET_16(msg->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_STRING((text + strlen(text)), *ptr, *datalength, length);
+
+ if ((*datalength) < 0)
return DLT_RETURN_ERROR;
}
- else
- {
+ else {
return DLT_RETURN_ERROR;
}
- if (*datalength<0)
- {
+ if (*datalength < 0) {
dlt_log(LOG_ERR, "Payload of DLT message corrupted\n");
return DLT_RETURN_ERROR;
}
@@ -3959,40 +3726,33 @@ DltReturnValue dlt_message_argument_print(DltMessage *msg,uint32_t type_info,uin
void dlt_check_envvar()
{
- char* env_log_filename = getenv("DLT_LOG_FILENAME");
+ char *env_log_filename = getenv("DLT_LOG_FILENAME");
- if( env_log_filename != NULL )
- {
+ if (env_log_filename != NULL)
dlt_log_set_filename(env_log_filename);
+
+ char *env_log_level_str = getenv("DLT_LOG_LEVEL");
+
+ if (env_log_level_str != NULL) {
+ int level = 0;
+
+ if (sscanf(env_log_level_str, "%d", &level))
+ dlt_log_set_level(level);
}
- char* env_log_level_str = getenv("DLT_LOG_LEVEL");
+ char *env_log_mode = getenv("DLT_LOG_MODE");
- if( env_log_level_str != NULL )
- {
- int level = 0;
- if( sscanf(env_log_level_str, "%d", &level) )
- {
- dlt_log_set_level(level);
- }
- }
+ if (env_log_mode != NULL) {
+ int mode = 0;
- char* env_log_mode = getenv("DLT_LOG_MODE");
+ if (sscanf(env_log_mode, "%d", &mode))
+ dlt_log_init(mode);
+ }
- if( env_log_mode != NULL )
- {
- int mode = 0;
- if( sscanf(env_log_mode, "%d", &mode) )
- {
- dlt_log_init(mode);
- }
- }
+ char *env_pipe_dir = getenv("DLT_PIPE_DIR");
- char* env_pipe_dir = getenv("DLT_PIPE_DIR");
- if( env_pipe_dir != NULL )
- {
+ if (env_pipe_dir != NULL)
dlt_log_set_fifo_basedir(env_pipe_dir);
- }
}
int dlt_set_loginfo_parse_service_id(char *resp_text,
@@ -4004,15 +3764,14 @@ int dlt_set_loginfo_parse_service_id(char *resp_text,
char service_opt_str[SERVICE_OPT_LENGTH];
if ((resp_text == NULL) || (service_id == NULL) || (service_opt == NULL))
- {
return DLT_RETURN_ERROR;
- }
+
/* ascii type, syntax is 'get_log_info, ..' */
/* check target id */
strncpy(get_log_info_tag, "get_log_info", strlen("get_log_info"));
- ret = memcmp((void *)resp_text, (void *)get_log_info_tag, sizeof(get_log_info_tag)-1);
- if (ret == 0)
- {
+ ret = memcmp((void *)resp_text, (void *)get_log_info_tag, sizeof(get_log_info_tag) - 1);
+
+ if (ret == 0) {
*service_id = DLT_SERVICE_ID_GET_LOG_INFO;
/* reading the response mode from the resp_text. eg. option 7*/
service_opt_str[0] = *(resp_text + GET_LOG_INFO_LENGTH + 1);
@@ -4026,16 +3785,15 @@ int dlt_set_loginfo_parse_service_id(char *resp_text,
int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count)
{
- char num_work[5] = {0};
+ char num_work[5] = { 0 };
char *endptr;
if ((rp == NULL) || (rp_count == NULL))
- {
return -1;
- }
+
/* ------------------------------------------------------
- from: [89 13 ] -> to: ['+0x'1389\0] -> to num
- ------------------------------------------------------ */
+ * from: [89 13 ] -> to: ['+0x'1389\0] -> to num
+ * ------------------------------------------------------ */
num_work[0] = *(rp + *rp_count + 3);
num_work[1] = *(rp + *rp_count + 4);
num_work[2] = *(rp + *rp_count + 0);
@@ -4048,16 +3806,15 @@ int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count)
int16_t dlt_getloginfo_conv_ascii_to_int16_t(char *rp, int *rp_count)
{
- char num_work[3] = {0};
+ char num_work[3] = { 0 };
char *endptr;
if ((rp == NULL) || (rp_count == NULL))
- {
return -1;
- }
+
/* ------------------------------------------------------
- from: [89 ] -> to: ['0x'89\0] -> to num
- ------------------------------------------------------ */
+ * from: [89 ] -> to: ['0x'89\0] -> to num
+ * ------------------------------------------------------ */
num_work[0] = *(rp + *rp_count + 0);
num_work[1] = *(rp + *rp_count + 1);
num_work[2] = 0;
@@ -4068,29 +3825,28 @@ int16_t dlt_getloginfo_conv_ascii_to_int16_t(char *rp, int *rp_count)
void dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len)
{
- char number16[2] = {0};
+ char number16[2] = { 0 };
char *endptr;
int count;
if ((rp == NULL) || (rp_count == NULL) || (wp == NULL))
- {
return;
+
+ /* ------------------------------------------------------
+ * from: [72 65 6d 6f ] -> to: [0x72,0x65,0x6d,0x6f,0x00]
+ * ------------------------------------------------------ */
+ for (count = 0; count < len; count++) {
+ number16[0] = *(rp + *rp_count + 0);
+ number16[1] = *(rp + *rp_count + 1);
+ *(wp + count) = strtol(number16, &endptr, 16);
+ *rp_count += 3;
}
- /* ------------------------------------------------------
- from: [72 65 6d 6f ] -> to: [0x72,0x65,0x6d,0x6f,0x00]
- ------------------------------------------------------ */
- for (count = 0; count < len; count++)
- {
- number16[0] = *(rp + *rp_count + 0);
- number16[1] = *(rp + *rp_count + 1);
- *(wp + count) = strtol(number16, &endptr, 16);
- *rp_count += 3;
- }
- *(wp + count) = 0;
+
+ *(wp + count) = 0;
return;
}
-void dlt_hex_ascii_to_binary(const char *ptr,uint8_t *binary,int *size)
+void dlt_hex_ascii_to_binary(const char *ptr, uint8_t *binary, int *size)
{
char ch = *ptr;
int pos = 0;
@@ -4098,41 +3854,41 @@ void dlt_hex_ascii_to_binary(const char *ptr,uint8_t *binary,int *size)
int first = 1;
int found;
- for(;;)
- {
- if(ch == 0)
- {
+ for (;;) {
+ if (ch == 0) {
*size = pos;
return;
}
found = 0;
- if (ch >= '0' && ch <= '9')
- {
+
+ if ((ch >= '0') && (ch <= '9')) {
binary[pos] = (binary[pos] << 4) + (ch - '0');
found = 1;
}
- else if (ch >= 'A' && ch <= 'F')
+ else if ((ch >= 'A') && (ch <= 'F'))
{
binary[pos] = (binary[pos] << 4) + (ch - 'A' + 10);
found = 1;
}
- else if (ch >= 'a' && ch <= 'f')
+ else if ((ch >= 'a') && (ch <= 'f'))
{
binary[pos] = (binary[pos] << 4) + (ch - 'a' + 10);
found = 1;
}
- if(found)
- {
- if(first)
+
+ if (found) {
+ if (first) {
first = 0;
- else
- {
+ }
+ else {
first = 1;
pos++;
- if(pos>=*size)
+
+ if (pos >= *size)
return;
- binary[pos]=0;
+
+ binary[pos] = 0;
}
}
@@ -4143,40 +3899,35 @@ void dlt_hex_ascii_to_binary(const char *ptr,uint8_t *binary,int *size)
#ifndef DLT_USE_UNIX_SOCKET_IPC
int dlt_mkdir_recursive(const char *dir)
{
- int ret = 0;
- char tmp[PATH_MAX+1];
- char *p = NULL;
- char *end = NULL;
- size_t len;
-
- strncpy(tmp, dir, PATH_MAX);
- len = strlen(tmp);
- if(tmp[len - 1] == '/')
- {
- tmp[len - 1] = 0;
- }
- end = tmp + len;
-
- for(p = tmp + 1; ((*p) && (ret == 0)) || ((ret == -1 && errno == EEXIST) && (p != end)); p++)
- {
- if(*p == '/')
- {
- *p = 0;
- ret = mkdir(tmp, S_IRWXU);
- *p = '/';
- }
- }
+ int ret = 0;
+ char tmp[PATH_MAX + 1];
+ char *p = NULL;
+ char *end = NULL;
+ size_t len;
+
+ strncpy(tmp, dir, PATH_MAX);
+ len = strlen(tmp);
- if (ret == 0 || (ret == -1 && errno == EEXIST))
- {
- ret = mkdir(tmp, S_IRWXU);
- }
+ if (tmp[len - 1] == '/')
+ tmp[len - 1] = 0;
- if (ret == -1 && errno == EEXIST)
- {
- ret = 0;
- }
+ end = tmp + len;
- return ret;
+ for (p = tmp + 1; ((*p) && (ret == 0)) || ((ret == -1 && errno == EEXIST) && (p != end)); p++)
+ if (*p == '/') {
+ *p = 0;
+ ret = mkdir(tmp, S_IRWXU);
+ *p = '/';
+ }
+
+
+
+ if ((ret == 0) || ((ret == -1) && (errno == EEXIST)))
+ ret = mkdir(tmp, S_IRWXU);
+
+ if ((ret == -1) && (errno == EEXIST))
+ ret = 0;
+
+ return ret;
}
#endif
diff --git a/src/shared/dlt_common_cfg.h b/src/shared/dlt_common_cfg.h
index 454f885..7170a98 100644
--- a/src/shared/dlt_common_cfg.h
+++ b/src/shared/dlt_common_cfg.h
@@ -89,11 +89,11 @@
#define DLT_COMMON_INDEX_ALLOC 1000
/* If limited output is called,
- this is the maximum number of characters to be printed out */
+ * this is the maximum number of characters to be printed out */
#define DLT_COMMON_ASCII_LIMIT_MAX_CHARS 20
/* This defines the dummy ECU ID set in storage header during import
- of a message from a DLT file in RAW format (without storage header) */
+ * of a message from a DLT file in RAW format (without storage header) */
#define DLT_COMMON_DUMMY_ECUID "ECU"
diff --git a/src/shared/dlt_config_file_parser.c b/src/shared/dlt_config_file_parser.c
index 802d3ed..8c882e2 100644
--- a/src/shared/dlt_config_file_parser.c
+++ b/src/shared/dlt_config_file_parser.c
@@ -58,12 +58,13 @@ static void dlt_config_file_trim_line(char *line)
char *i = line;
char *j = line;
- while(*j != '\0')
- {
+ while (*j != '\0') {
*i = *j++;
- if(!isspace(*i))
+
+ if (!isspace(*i))
i++;
}
+
*i = '\0';
}
@@ -80,12 +81,12 @@ static int dlt_config_file_ignore_line(char *line)
int i = 0;
int len = strlen(line);
- for (i = 0; i < len; i++)
- {
- if (line[i] == '#' || line[i] == ';' || line[i] == '\n' || line[i] == '\0')
+ for (i = 0; i < len; i++) {
+ if ((line[i] == '#') || (line[i] == ';') || (line[i] == '\n') || (line[i] == '\0'))
return 0; /* ignore */
else
return -1; /* do not ignore */
+
}
return -1;
@@ -104,11 +105,10 @@ static int dlt_config_file_is_section_name(DltConfigFile *file, char *name)
{
int i = 0;
- if (file == NULL || name == NULL)
+ if ((file == NULL) || (name == NULL))
return -1;
- for (i = 0; i < file->num_sections; i++)
- {
+ for (i = 0; i < file->num_sections; i++) {
DltConfigFileSection *s = &file->sections[i];
if (strncmp(s->name, name, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0)
@@ -130,16 +130,15 @@ static int dlt_config_file_is_section_name(DltConfigFile *file, char *name)
static int dlt_config_file_set_section(DltConfigFile *file, char *name)
{
int section = file->num_sections;
+
/* check if adding another section would exceed max number of sections */
- if (section+1 >= DLT_CONFIG_FILE_SECTIONS_MAX)
- {
+ if (section + 1 >= DLT_CONFIG_FILE_SECTIONS_MAX) {
dlt_log(LOG_WARNING, "Cannot store more sections\n");
return -1; /* reached max number of sections */
}
/* do not store section with same name again */
- if (dlt_config_file_is_section_name(file, name) != 0)
- {
+ if (dlt_config_file_is_section_name(file, name) != 0) {
dlt_log(LOG_WARNING, "Cannot store section name again\n");
return -1;
}
@@ -148,15 +147,15 @@ static int dlt_config_file_set_section(DltConfigFile *file, char *name)
/* alloc data for entries */
s->name = calloc(sizeof(char), DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1);
- if (s->name == NULL)
- {
+
+ if (s->name == NULL) {
dlt_log(LOG_ERR, "Cannot allocate memory for internal data structure\n");
return -1;
}
s->keys = calloc(sizeof(char), DLT_CONFIG_FILE_ENTRY_MAX_LEN * DLT_CONFIG_FILE_KEYS_MAX + 1);
- if (s->keys == NULL)
- {
+
+ if (s->keys == NULL) {
free(s->name);
dlt_log(LOG_ERR, "Cannot allocate memory for internal data structure\n");
return -1;
@@ -181,14 +180,13 @@ static int dlt_config_file_set_section_data(DltConfigFile *file, char *str1, cha
{
DltConfigKeyData **tmp = NULL;
- if (file == NULL || str1 == NULL || str2 == NULL)
+ if ((file == NULL) || (str1 == NULL) || (str2 == NULL))
return -1;
- DltConfigFileSection *s = &file->sections[file->num_sections-1];
+ DltConfigFileSection *s = &file->sections[file->num_sections - 1];
int key_number = s->num_entries;
- if (key_number+1 >= DLT_CONFIG_FILE_KEYS_MAX)
- {
+ if (key_number + 1 >= DLT_CONFIG_FILE_KEYS_MAX) {
dlt_log(LOG_WARNING, "Cannot store more keys in section\n");
return -1; /* reached max number of keys per section */
}
@@ -196,33 +194,32 @@ static int dlt_config_file_set_section_data(DltConfigFile *file, char *str1, cha
/* copy data into structure */
strncpy(&s->keys[key_number * DLT_CONFIG_FILE_ENTRY_MAX_LEN], str1, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
- if (s->list == NULL)
- {
+ if (s->list == NULL) {
/* creating a list if it doesnt exists */
s->list = malloc(sizeof(DltConfigKeyData));
- if (s->list == NULL)
- {
+
+ if (s->list == NULL) {
dlt_log(LOG_WARNING, "Could not allocate initial memory to list \n");
return -1;
}
+
tmp = &s->list;
}
- else
- {
+ else {
tmp = &s->list;
while (*(tmp) != NULL)
- {
tmp = &(*tmp)->next;
- }
+
/* Adding new entry to the list */
*tmp = malloc(sizeof(DltConfigKeyData));
- if (*tmp == NULL)
- {
+
+ if (*tmp == NULL) {
dlt_log(LOG_WARNING, "Could not allocate memory to list \n");
return -1;
}
}
+
(*tmp)->key = strdup(str1);
(*tmp)->data = strdup(str2);
(*tmp)->next = NULL;
@@ -243,7 +240,8 @@ static int dlt_config_file_set_section_data(DltConfigFile *file, char *str1, cha
static int dlt_config_file_line_has_section(char *line)
{
line = line; /* avoid compiler warnings */
- if(line[0] == '[') /* section found */
+
+ if (line[0] == '[') /* section found */
return 0;
else
return -1;
@@ -262,14 +260,13 @@ static int dlt_config_file_get_section_name_from_string(char *line, char *name)
int i = 0;
int j = 0;
- if (line == NULL || name == NULL)
+ if ((line == NULL) || (name == NULL))
return -1;
- for(i = 0; i < DLT_CONFIG_FILE_ENTRY_MAX_LEN; i++)
- {
- if(line[i] == '[' || isspace(line[i]))
+ for (i = 0; i < DLT_CONFIG_FILE_ENTRY_MAX_LEN; i++) {
+ if ((line[i] == '[') || isspace(line[i]))
continue;
- else if (line[i] == ']' || line[i] == '\n' || line[i] == '\0')
+ else if ((line[i] == ']') || (line[i] == '\n') || (line[i] == '\0'))
break;
else
name[j++] = line[i];
@@ -294,7 +291,7 @@ static int dlt_config_file_get_key_value(char *line, char *str1, char *str2)
char *ptr;
char *save_ptr;
- if (line == NULL || str1 == NULL || str2 == NULL)
+ if ((line == NULL) || (str1 == NULL) || (str2 == NULL))
return -1;
ptr = strtok_r(line, delimiter, &save_ptr);
@@ -326,7 +323,7 @@ static int dlt_config_file_get_key_value(char *line, char *str1, char *str2)
*/
static int dlt_config_file_read_line(char *line, char *str1, char *str2)
{
- if (line == NULL || str1 == NULL || str2 == NULL)
+ if ((line == NULL) || (str1 == NULL) || (str2 == NULL))
return -1;
/* reset values to zero */
@@ -334,8 +331,7 @@ static int dlt_config_file_read_line(char *line, char *str1, char *str2)
memset(str2, 0, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
/* check if line contains a section */
- if ((dlt_config_file_line_has_section(line)) == 0)
- {
+ if ((dlt_config_file_line_has_section(line)) == 0) {
/* retrieve section name */
if (dlt_config_file_get_section_name_from_string(line, str1) != 0)
return -1;
@@ -361,16 +357,15 @@ static int dlt_config_file_read_line(char *line, char *str1, char *str2)
static void dlt_config_file_read_file(DltConfigFile *file, FILE *hdl)
{
int ret = 0;
- char error_str[DLT_DAEMON_TEXTBUFSIZE] = {'\0'};
- char line[DLT_CONFIG_FILE_LINE_MAX_LEN] = {'\0'};
- char str1[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = {'\0'};
- char str2[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = {'\0'};
+ char error_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+ char line[DLT_CONFIG_FILE_LINE_MAX_LEN] = { '\0' };
+ char str1[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+ char str2[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
int line_number = 0;
int is_section_valid = -1; /* to check if section name is given twice or invalid */
/* read configuration file line by line */
- while (fgets(line, DLT_CONFIG_FILE_LINE_MAX_LEN, hdl) != NULL)
- {
+ while (fgets(line, DLT_CONFIG_FILE_LINE_MAX_LEN, hdl) != NULL) {
line_number++;
/* ignore empty and comment lines */
@@ -383,24 +378,23 @@ static void dlt_config_file_read_file(DltConfigFile *file, FILE *hdl)
/* parse content of line */
ret = dlt_config_file_read_line(line, str1, str2);
- switch(ret)
- {
- case DLT_CONFIG_FILE_NEW_SECTION: /* store str1 as new section */
- is_section_valid = -1;
- if ((ret = dlt_config_file_set_section(file, str1)) == 0)
- {
- is_section_valid = 0;
- }
- break;
- case DLT_CONFIG_FILE_NEW_DATA: /* store str1 and str2 as new data for section */
- if (is_section_valid == 0)
- {
- ret = dlt_config_file_set_section_data(file, str1, str2);
- }
- break;
- default: /* something is wrong with the line */
- snprintf(error_str, DLT_DAEMON_TEXTBUFSIZE, "Line (%d) \"%s\" is invalid\n", line_number, line);
- dlt_log(LOG_WARNING, error_str);
+ switch (ret) {
+ case DLT_CONFIG_FILE_NEW_SECTION: /* store str1 as new section */
+ is_section_valid = -1;
+
+ if ((ret = dlt_config_file_set_section(file, str1)) == 0)
+ is_section_valid = 0;
+
+ break;
+ case DLT_CONFIG_FILE_NEW_DATA: /* store str1 and str2 as new data for section */
+
+ if (is_section_valid == 0)
+ ret = dlt_config_file_set_section_data(file, str1, str2);
+
+ break;
+ default: /* something is wrong with the line */
+ snprintf(error_str, DLT_DAEMON_TEXTBUFSIZE, "Line (%d) \"%s\" is invalid\n", line_number, line);
+ dlt_log(LOG_WARNING, error_str);
}
}
}
@@ -419,15 +413,14 @@ static int dlt_config_file_find_section(const DltConfigFile *file,
{
int i = 0;
- if (file == NULL || section == NULL || file->num_sections <= 0)
- {
+ if ((file == NULL) || (section == NULL) || (file->num_sections <= 0)) {
dlt_log(LOG_WARNING, "Section cannot be found due to invalid parameters\n");
return -1;
}
- for (i = 0; i < file->num_sections; i++)
- {
+ for (i = 0; i < file->num_sections; i++) {
DltConfigFileSection *s = &file->sections[i];
+
if (strncmp(s->name, section, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0)
return i;
}
@@ -441,15 +434,14 @@ DltConfigFile *dlt_config_file_init(char *file_name)
DltConfigFile *file;
FILE *hdl = NULL;
- if (file_name == NULL || (strlen(file_name) >= DLT_CONFIG_FILE_PATH_MAX_LEN))
- {
+ if ((file_name == NULL) || (strlen(file_name) >= DLT_CONFIG_FILE_PATH_MAX_LEN)) {
dlt_log(LOG_ERR, "Given configuration file invalid\n");
return NULL;
}
file = calloc(sizeof(DltConfigFile), 1);
- if (file == NULL)
- {
+
+ if (file == NULL) {
dlt_log(LOG_ERR, "Setup internal data structure to parse config file failed\n");
return NULL;
}
@@ -457,8 +449,7 @@ DltConfigFile *dlt_config_file_init(char *file_name)
file->sections = calloc(sizeof(DltConfigFileSection), DLT_CONFIG_FILE_SECTIONS_MAX);
/* open file */
- if ((hdl = fopen(file_name, "r")) == NULL)
- {
+ if ((hdl = fopen(file_name, "r")) == NULL) {
dlt_log(LOG_ERR, "Cannot open configuration file\n");
free(file);
return NULL;
@@ -476,21 +467,18 @@ void dlt_config_file_release(DltConfigFile *file)
{
int i = 0;
- if(file != NULL)
- {
+ if (file != NULL) {
int max = file->num_sections;
- for (i = 0; i < max; i++)
- {
+
+ for (i = 0; i < max; i++) {
DltConfigFileSection *s = &file->sections[i];
DltConfigKeyData *node = file->sections[i].list;
free(s->name);
if (s->keys != NULL)
- {
free(s->keys);
- }
- while (node)
- {
+
+ while (node) {
DltConfigKeyData *tmp = node;
node = node->next;
free(tmp->key);
@@ -508,7 +496,7 @@ int dlt_config_file_get_section_name(const DltConfigFile *file,
int num,
char *name)
{
- if (file == NULL || name == NULL || num < 0 || num >= file->num_sections)
+ if ((file == NULL) || (name == NULL) || (num < 0) || (num >= file->num_sections))
return -1;
strncpy(name, (file->sections + num)->name, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
@@ -518,7 +506,7 @@ int dlt_config_file_get_section_name(const DltConfigFile *file,
int dlt_config_file_get_num_sections(const DltConfigFile *file, int *num)
{
- if(file == NULL || file->num_sections < 0)
+ if ((file == NULL) || (file->num_sections < 0))
return -1;
*num = file->num_sections;
@@ -534,13 +522,14 @@ int dlt_config_file_get_value(const DltConfigFile *file,
DltConfigKeyData **tmp = NULL;
int num_section = 0;
- if (file == NULL || section == NULL || key == NULL || value == NULL)
+ if ((file == NULL) || (section == NULL) || (key == NULL) || (value == NULL))
return -1;
/* clean value */
memset(value, 0, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
num_section = dlt_config_file_find_section(file, section);
+
if (num_section == -1)
return -1;
@@ -548,15 +537,12 @@ int dlt_config_file_get_value(const DltConfigFile *file,
tmp = &s->list;
- while (*(tmp) != NULL)
- {
- if (strncmp((*tmp)->key, key, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0)
- {
+ while (*(tmp) != NULL) {
+ if (strncmp((*tmp)->key, key, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0) {
strncpy(value, (*tmp)->data, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
return 0;
}
- else /* not found yet see list for more */
- {
+ else { /* not found yet see list for more */
tmp = &(*tmp)->next;
}
}
diff --git a/src/shared/dlt_offline_trace.c b/src/shared/dlt_offline_trace.c
index 6b7a10a..76de233 100644
--- a/src/shared/dlt_offline_trace.c
+++ b/src/shared/dlt_offline_trace.c
@@ -72,12 +72,11 @@ unsigned int dlt_offline_trace_storage_dir_info(char *path, char *file_name, cha
int i = 0;
unsigned int num = 0;
int cnt = 0;
- struct dirent **files = {0};
+ struct dirent **files = { 0 };
char *tmp_old = NULL;
char *tmp_new = NULL;
- if (path == NULL || file_name == NULL || newest == NULL || oldest == NULL)
- {
+ if ((path == NULL) || (file_name == NULL) || (newest == NULL) || (oldest == NULL)) {
printf("dlt_offline_trace_storage_dir_info: Invalid parameter(s)");
return 0;
}
@@ -85,40 +84,28 @@ unsigned int dlt_offline_trace_storage_dir_info(char *path, char *file_name, cha
cnt = scandir(path, &files, NULL, alphasort);
if (cnt < 0)
- {
return 0;
- }
- for (i = 0; i < cnt; i++)
- {
+ for (i = 0; i < cnt; i++) {
int len = 0;
len = strlen(file_name);
- if ((strncmp(files[i]->d_name, file_name, len) == 0) && (files[i]->d_name[len] == '.'))
- {
+
+ if ((strncmp(files[i]->d_name, file_name, len) == 0) && (files[i]->d_name[len] == '.')) {
num++;
- if (tmp_old == NULL || (strlen(tmp_old) >= strlen(files[i]->d_name)))
- {
+ if ((tmp_old == NULL) || (strlen(tmp_old) >= strlen(files[i]->d_name))) {
if (tmp_old == NULL)
- {
tmp_old = files[i]->d_name;
- }
/* when file name is smaller, it is older */
else if (strlen(tmp_old) > strlen(files[i]->d_name))
- {
tmp_old = files[i]->d_name;
- }
else /* filename is equal, do a string compare */
- {
if (strcmp(tmp_old, files[i]->d_name) > 0)
tmp_old = files[i]->d_name;
- }
}
- if (tmp_new == NULL || (strlen(tmp_new) <= strlen(files[i]->d_name)))
- {
- if (tmp_new == NULL)
- {
+ if ((tmp_new == NULL) || (strlen(tmp_new) <= strlen(files[i]->d_name))) {
+ if (tmp_new == NULL) {
tmp_new = files[i]->d_name;
}
/* when file name is longer, it is younger */
@@ -126,40 +113,28 @@ unsigned int dlt_offline_trace_storage_dir_info(char *path, char *file_name, cha
{
tmp_new = files[i]->d_name;
}
- else
- {
- if (strcmp(tmp_new, files[i]->d_name) < 0)
- {
- tmp_new = files[i]->d_name;
- }
- }
+ else if (strcmp(tmp_new, files[i]->d_name) < 0)
+ tmp_new = files[i]->d_name;
}
}
}
- if (num > 0)
- {
- if (tmp_old != NULL)
- {
+ if (num > 0) {
+ if (tmp_old != NULL) {
if (strlen(tmp_old) < DLT_OFFLINETRACE_FILENAME_MAX_SIZE)
- {
strncpy(oldest, tmp_old, DLT_OFFLINETRACE_FILENAME_MAX_SIZE);
- }
}
- if (tmp_new != NULL)
- {
+
+ if (tmp_new != NULL) {
if (strlen(tmp_old) < DLT_OFFLINETRACE_FILENAME_MAX_SIZE)
- {
strncpy(newest, tmp_new, DLT_OFFLINETRACE_FILENAME_MAX_SIZE);
- }
}
}
/* free scandir result */
for (i = 0; i < cnt; i++)
- {
free(files[i]);
- }
+
free(files);
return num;
@@ -167,15 +142,15 @@ unsigned int dlt_offline_trace_storage_dir_info(char *path, char *file_name, cha
void dlt_offline_trace_file_name(char *log_file_name, char *name, unsigned int idx)
{
- char file_index[11]; // UINT_MAX = 4294967295 -> 10 digits
+ char file_index[11]; /* UINT_MAX = 4294967295 -> 10 digits */
sprintf(file_index, "%010u", idx);
- // create log file name
+ /* create log file name */
memset(log_file_name, 0, DLT_OFFLINETRACE_FILENAME_MAX_SIZE * sizeof(char));
- strncat(log_file_name, name,sizeof(DLT_OFFLINETRACE_FILENAME_BASE));
- strncat(log_file_name, DLT_OFFLINETRACE_FILENAME_DELI,sizeof(DLT_OFFLINETRACE_FILENAME_DELI));
- strncat(log_file_name, file_index,sizeof(file_index));
- strncat(log_file_name, DLT_OFFLINETRACE_FILENAME_EXT,sizeof(DLT_OFFLINETRACE_FILENAME_EXT));
+ strncat(log_file_name, name, sizeof(DLT_OFFLINETRACE_FILENAME_BASE));
+ strncat(log_file_name, DLT_OFFLINETRACE_FILENAME_DELI, sizeof(DLT_OFFLINETRACE_FILENAME_DELI));
+ strncat(log_file_name, file_index, sizeof(file_index));
+ strncat(log_file_name, DLT_OFFLINETRACE_FILENAME_EXT, sizeof(DLT_OFFLINETRACE_FILENAME_EXT));
}
unsigned int dlt_offline_trace_get_idx_of_log_file(char *file)
@@ -185,55 +160,51 @@ unsigned int dlt_offline_trace_get_idx_of_log_file(char *file)
unsigned int idx = 0;
if (file[0] == '\0')
- {
return 0;
- }
token = strtok(file, d);
/* we are interested in 2. token because of log file name */
token = strtok(NULL, d);
if (token != NULL)
- {
idx = strtol(token, NULL, 10);
- }
else
- {
idx = 0;
- }
+
return idx;
}
-DltReturnValue dlt_offline_trace_create_new_file(DltOfflineTrace *trace) {
+DltReturnValue dlt_offline_trace_create_new_file(DltOfflineTrace *trace)
+{
time_t t;
struct tm *tmp;
char outstr[200];
- char newest[DLT_OFFLINETRACE_FILENAME_MAX_SIZE] = {0};
- char oldest[DLT_OFFLINETRACE_FILENAME_MAX_SIZE] = {0};
+ char newest[DLT_OFFLINETRACE_FILENAME_MAX_SIZE] = { 0 };
+ char oldest[DLT_OFFLINETRACE_FILENAME_MAX_SIZE] = { 0 };
unsigned int idx = 0;
/* set filename */
- if(trace->filenameTimestampBased)
- {
+ if (trace->filenameTimestampBased) {
int ret = 0;
t = time(NULL);
tmp = localtime(&t);
+
if (NULL == tmp) {
printf("dlt_offline_trace_create_new_file: pointer to tmp is NULL!");
return DLT_RETURN_ERROR;
}
- if (strftime(outstr, sizeof(outstr),"%Y%m%d_%H%M%S", tmp) == 0) {
- }
- ret = snprintf(trace->filename, NAME_MAX , "%s/dlt_offlinetrace_%s.dlt", trace->directory, outstr);
- if ((ret < 0) || (ret >= NAME_MAX))
- {
+
+ if (strftime(outstr, sizeof(outstr), "%Y%m%d_%H%M%S", tmp) == 0) {}
+
+ ret = snprintf(trace->filename, NAME_MAX, "%s/dlt_offlinetrace_%s.dlt", trace->directory, outstr);
+
+ if ((ret < 0) || (ret >= NAME_MAX)) {
printf("dlt_offlinetrace filename cannot be concatenated\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
int ret = 0;
/* targeting newest file, ignoring number of files in dir returned */
dlt_offline_trace_storage_dir_info(trace->directory, DLT_OFFLINETRACE_FILENAME_BASE, newest, oldest);
@@ -241,27 +212,27 @@ DltReturnValue dlt_offline_trace_create_new_file(DltOfflineTrace *trace) {
dlt_offline_trace_file_name(outstr, DLT_OFFLINETRACE_FILENAME_BASE, idx);
ret = snprintf(trace->filename, NAME_MAX, "%s/%s", trace->directory, outstr);
- if ((ret < 0) || (ret >= NAME_MAX))
- {
+
+ if ((ret < 0) || (ret >= NAME_MAX)) {
printf("filename cannot be concatenated\n");
return DLT_RETURN_ERROR;
}
}
-
/* open DLT output file */
- trace->ohandle = open(trace->filename,O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
- if (trace->ohandle == -1)
- {
+ trace->ohandle = open(trace->filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
+
+ if (trace->ohandle == -1) {
/* trace file cannot be opened */
- printf("Offline trace file %s cannot be created\n",trace->filename);
+ printf("Offline trace file %s cannot be created\n", trace->filename);
return DLT_RETURN_ERROR;
} /* if */
return DLT_RETURN_OK; /* OK */
}
-unsigned long dlt_offline_trace_get_total_size(DltOfflineTrace *trace) {
+unsigned long dlt_offline_trace_get_total_size(DltOfflineTrace *trace)
+{
struct dirent *dp;
char filename[256];
unsigned long size = 0;
@@ -269,28 +240,26 @@ unsigned long dlt_offline_trace_get_total_size(DltOfflineTrace *trace) {
/* go through all dlt files in directory */
DIR *dir = opendir(trace->directory);
- while ((dp=readdir(dir)) != NULL) {
- if(strstr(dp->d_name,DLT_OFFLINETRACE_FILENAME_BASE))
- {
- int res = snprintf(filename, sizeof(filename), "%s/%s",trace->directory,dp->d_name);
- // if the total length of the string is greater than the buffer, silently forget it.
- // snprintf: a return value of size or more means that the output was truncated
- // if an output error is encountered, a negative value is returned.
- if( (unsigned int)res<sizeof(filename) && res>0 )
- {
- if(0 == stat(filename,&status))
- {
+
+ while ((dp = readdir(dir)) != NULL)
+ if (strstr(dp->d_name, DLT_OFFLINETRACE_FILENAME_BASE)) {
+ int res = snprintf(filename, sizeof(filename), "%s/%s", trace->directory, dp->d_name);
+
+ /* if the total length of the string is greater than the buffer, silently forget it. */
+ /* snprintf: a return value of size or more means that the output was truncated */
+ /* if an output error is encountered, a negative value is returned. */
+ if (((unsigned int)res < sizeof(filename)) && (res > 0)) {
+ if (0 == stat(filename, &status))
size += status.st_size;
- }
else
- printf("Offline trace file %s cannot be stat-ed",filename);
+ printf("Offline trace file %s cannot be stat-ed", filename);
}
- //else
- //{
- // dlt_log(3, "dlt_offline_trace_get_total_size: long filename ignored");
- //}
+
+ /*else */
+ /*{ */
+ /* dlt_log(3, "dlt_offline_trace_get_total_size: long filename ignored"); */
+ /*} */
}
- }
closedir(dir);
@@ -298,10 +267,11 @@ unsigned long dlt_offline_trace_get_total_size(DltOfflineTrace *trace) {
return size;
}
-int dlt_offline_trace_delete_oldest_file(DltOfflineTrace *trace) {
+int dlt_offline_trace_delete_oldest_file(DltOfflineTrace *trace)
+{
struct dirent *dp;
- char filename[PATH_MAX+1];
- char filename_oldest[PATH_MAX+1];
+ char filename[PATH_MAX + 1];
+ char filename_oldest[PATH_MAX + 1];
unsigned long size_oldest = 0;
struct stat status;
time_t time_oldest = 0;
@@ -311,81 +281,84 @@ int dlt_offline_trace_delete_oldest_file(DltOfflineTrace *trace) {
/* go through all dlt files in directory */
DIR *dir = opendir(trace->directory);
- while ((dp=readdir(dir)) != NULL) {
- if(strstr(dp->d_name,DLT_OFFLINETRACE_FILENAME_TO_COMPARE)) {
- int res = snprintf(filename, sizeof(filename), "%s/%s",trace->directory,dp->d_name);
- // if the total length of the string is greater than the buffer, silently forget it.
- // snprintf: a return value of size or more means that the output was truncated
- // if an output error is encountered, a negative value is returned.
- if( (unsigned int)res<sizeof(filename) && res>0 )
- {
- if(0 == stat(filename,&status))
- {
- if(time_oldest == 0 || status.st_mtime < time_oldest) {
- time_oldest = status.st_mtime;
- size_oldest = status.st_size;
- strncpy(filename_oldest,filename,PATH_MAX);
- filename_oldest[PATH_MAX]=0;
- }
+
+ while ((dp = readdir(dir)) != NULL)
+ if (strstr(dp->d_name, DLT_OFFLINETRACE_FILENAME_TO_COMPARE)) {
+ int res = snprintf(filename, sizeof(filename), "%s/%s", trace->directory, dp->d_name);
+
+ /* if the total length of the string is greater than the buffer, silently forget it. */
+ /* snprintf: a return value of size or more means that the output was truncated */
+ /* if an output error is encountered, a negative value is returned. */
+ if (((unsigned int)res < sizeof(filename)) && (res > 0)) {
+ if (0 == stat(filename, &status)) {
+ if ((time_oldest == 0) || (status.st_mtime < time_oldest)) {
+ time_oldest = status.st_mtime;
+ size_oldest = status.st_size;
+ strncpy(filename_oldest, filename, PATH_MAX);
+ filename_oldest[PATH_MAX] = 0;
}
- else
- printf("Old offline trace file %s cannot be stat-ed",filename);
}
+ else {
+ printf("Old offline trace file %s cannot be stat-ed", filename);
+ }
+ }
}
- }
+
closedir(dir);
/* delete file */
- if(filename_oldest[0]) {
- if(remove(filename_oldest)) {
- printf("Remove file %s failed!\n",filename_oldest);
+ if (filename_oldest[0]) {
+ if (remove(filename_oldest)) {
+ printf("Remove file %s failed!\n", filename_oldest);
return -1; /* ERROR */
}
}
else {
- printf("No file to be removed!\n");
- return -1; /* ERROR */
+ printf("No file to be removed!\n");
+ return -1; /* ERROR */
}
/* return size of deleted file*/
return size_oldest;
}
-DltReturnValue dlt_offline_trace_check_size(DltOfflineTrace *trace) {
+DltReturnValue dlt_offline_trace_check_size(DltOfflineTrace *trace)
+{
struct stat status;
/* check for existence of offline trace directory */
- if (stat(trace->directory, &status) == -1)
- {
- dlt_vlog(LOG_ERR, "Offline trace directory: %s doesn't exist \n", trace->directory);
- return DLT_RETURN_ERROR;
+ if (stat(trace->directory, &status) == -1) {
+ dlt_vlog(LOG_ERR, "Offline trace directory: %s doesn't exist \n", trace->directory);
+ return DLT_RETURN_ERROR;
}
-
+
/* check for accesibilty of offline trace directory */
- else if(access(trace->directory, W_OK) != 0)
+ else if (access(trace->directory, W_OK) != 0)
{
- dlt_vlog(LOG_ERR, "Offline trace directory: %s doesn't have the write access \n", trace->directory);
- return DLT_RETURN_ERROR;
+ dlt_vlog(LOG_ERR, "Offline trace directory: %s doesn't have the write access \n", trace->directory);
+ return DLT_RETURN_ERROR;
}
-
+
/* check size of complete offline trace */
- while((int)dlt_offline_trace_get_total_size(trace) > (trace->maxSize-trace->fileSize))
- {
+ while ((int)dlt_offline_trace_get_total_size(trace) > (trace->maxSize - trace->fileSize))
/* remove oldest files as long as new file will not fit in completely into complete offline trace */
- if(dlt_offline_trace_delete_oldest_file(trace) < 0) {
+ if (dlt_offline_trace_delete_oldest_file(trace) < 0)
return DLT_RETURN_ERROR;
- }
- }
return DLT_RETURN_OK; /* OK */
}
-DltReturnValue dlt_offline_trace_init(DltOfflineTrace *trace,const char *directory,int fileSize,int maxSize,int filenameTimestampBased) {
+DltReturnValue dlt_offline_trace_init(DltOfflineTrace *trace,
+ const char *directory,
+ int fileSize,
+ int maxSize,
+ int filenameTimestampBased)
+{
/* init parameters */
- strncpy(trace->directory,directory,NAME_MAX);
- trace->directory[NAME_MAX]=0;
+ strncpy(trace->directory, directory, NAME_MAX);
+ trace->directory[NAME_MAX] = 0;
trace->fileSize = fileSize;
trace->maxSize = maxSize;
trace->filenameTimestampBased = filenameTimestampBased;
@@ -395,14 +368,20 @@ DltReturnValue dlt_offline_trace_init(DltOfflineTrace *trace,const char *directo
return dlt_offline_trace_create_new_file(trace);
}
-DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace,unsigned char *data1,int size1,unsigned char *data2,int size2,unsigned char *data3,int size3) {
+DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace,
+ unsigned char *data1,
+ int size1,
+ unsigned char *data2,
+ int size2,
+ unsigned char *data3,
+ int size3)
+{
- if(trace->ohandle <= 0)
+ if (trace->ohandle <= 0)
return DLT_RETURN_ERROR;
/* check file size here */
- if((lseek(trace->ohandle,0,SEEK_CUR)+size1+size2+size3)>=trace->fileSize)
- {
+ if ((lseek(trace->ohandle, 0, SEEK_CUR) + size1 + size2 + size3) >= trace->fileSize) {
/* close old file */
close(trace->ohandle);
trace->ohandle = -1;
@@ -415,20 +394,22 @@ DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace,unsigned char *dat
}
/* write data into log file */
- if(data1 && (trace->ohandle >= 0)) {
- if(write(trace->ohandle,data1,size1)!=size1) {
+ if (data1 && (trace->ohandle >= 0)) {
+ if (write(trace->ohandle, data1, size1) != size1) {
printf("Offline trace write failed!\n");
return DLT_RETURN_ERROR;
}
}
- if(data2 && (trace->ohandle >= 0)) {
- if(write(trace->ohandle,data2,size2)!=size2) {
+
+ if (data2 && (trace->ohandle >= 0)) {
+ if (write(trace->ohandle, data2, size2) != size2) {
printf("Offline trace write failed!\n");
return DLT_RETURN_ERROR;
}
}
- if(data3 && (trace->ohandle >= 0)) {
- if(write(trace->ohandle,data3,size3)!=size3) {
+
+ if (data3 && (trace->ohandle >= 0)) {
+ if (write(trace->ohandle, data3, size3) != size3) {
printf("Offline trace write failed!\n");
return DLT_RETURN_ERROR;
}
@@ -437,9 +418,10 @@ DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace,unsigned char *dat
return DLT_RETURN_OK; /* OK */
}
-DltReturnValue dlt_offline_trace_free(DltOfflineTrace *trace) {
+DltReturnValue dlt_offline_trace_free(DltOfflineTrace *trace)
+{
- if(trace->ohandle <= 0)
+ if (trace->ohandle <= 0)
return DLT_RETURN_ERROR;
/* close last used log file */
diff --git a/src/shared/dlt_protocol.c b/src/shared/dlt_protocol.c
index 78c335f..b893ec4 100644
--- a/src/shared/dlt_protocol.c
+++ b/src/shared/dlt_protocol.c
@@ -29,8 +29,7 @@
#include "dlt_protocol.h"
-const char *const dlt_service_names[] =
-{
+const char *const dlt_service_names[] = {
"DLT_SERVICE_ID",
"DLT_SERVICE_ID_SET_LOG_LEVEL",
"DLT_SERVICE_ID_SET_TRACE_STATUS",
@@ -53,8 +52,7 @@ const char *const dlt_service_names[] =
"DLT_SERVICE_ID_GET_SOFTWARE_VERSION",
"DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW"
};
-const char *const dlt_user_service_names[] =
-{
+const char *const dlt_user_service_names[] = {
"DLT_USER_SERVICE_ID",
"DLT_SERVICE_ID_UNREGISTER_CONTEXT",
"DLT_SERVICE_ID_CONNECTION_INFO",
@@ -71,20 +69,12 @@ const char *const dlt_user_service_names[] =
const char *dlt_get_service_name(unsigned int id)
{
if (id == DLT_SERVICE_ID_CALLSW_CINJECTION)
- {
return "DLT_SERVICE_ID_CALLSW_CINJECTION";
- }
else if ((id == DLT_SERVICE_ID) || (id >= DLT_USER_SERVICE_ID_LAST_ENTRY) ||
- (id >= DLT_SERVICE_ID_LAST_ENTRY && id <= DLT_USER_SERVICE_ID))
- {
+ ((id >= DLT_SERVICE_ID_LAST_ENTRY) && (id <= DLT_USER_SERVICE_ID)))
return "UNDEFINED";
- }
else if ((id > DLT_SERVICE_ID) && (id < DLT_SERVICE_ID_LAST_ENTRY))
- {
return dlt_service_names[id];
- }
else /* user services */
- {
- return dlt_user_service_names[id&0xFF];
- }
+ return dlt_user_service_names[id & 0xFF];
}
diff --git a/src/shared/dlt_shm.c b/src/shared/dlt_shm.c
index 78e5951..b45b3c0 100644
--- a/src/shared/dlt_shm.c
+++ b/src/shared/dlt_shm.c
@@ -63,119 +63,119 @@
#include <string.h>
#if !defined(_MSC_VER)
-#include <unistd.h>
-#include <syslog.h>
+# include <unistd.h>
+# include <syslog.h>
#endif
#include <dlt_shm.h>
#include <dlt_common.h>
-void dlt_shm_print_hex(char *ptr,int size)
+void dlt_shm_print_hex(char *ptr, int size)
{
int num;
- for (num=0;num<size;num++)
- {
- if((num%16)==15)
- printf("%.2x\n",((unsigned char*)ptr)[num]);
+ for (num = 0; num < size; num++) {
+ if ((num % 16) == 15)
+ printf("%.2x\n", ((unsigned char *)ptr)[num]);
else
- printf("%.2x ",((unsigned char*)ptr)[num]);
+ printf("%.2x ", ((unsigned char *)ptr)[num]);
}
+
printf("\n");
}
-void dlt_shm_pv(int id,int operation)
+void dlt_shm_pv(int id, int operation)
{
static struct sembuf semaphor;
semaphor.sem_op = operation;
semaphor.sem_flg = SEM_UNDO;
- if(semop(id, &semaphor,1) == -1) {
- dlt_log(LOG_WARNING,"SHM: semop() failed");
- }
+ if (semop(id, &semaphor, 1) == -1)
+ dlt_log(LOG_WARNING, "SHM: semop() failed");
}
-int dlt_shm_init_server(DltShm *buf,int key,int size) {
+int dlt_shm_init_server(DltShm *buf, int key, int size)
+{
struct shmid_ds shm_buf;
unsigned char *ptr;
- // Init parameters
+ /* Init parameters */
buf->shmid = 0;
buf->semid = 0;
- // Create the segment.
+ /* Create the segment. */
if ((buf->shmid = shmget(key, size, IPC_CREAT | 0666)) < 0) {
- dlt_log(LOG_WARNING,"SHM: shmget() failed");
+ dlt_log(LOG_WARNING, "SHM: shmget() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
- // get the size of shm
- if (shmctl(buf->shmid, IPC_STAT, &shm_buf))
- {
- dlt_log(LOG_WARNING,"SHM: shmctl() failed");
+ /* get the size of shm */
+ if (shmctl(buf->shmid, IPC_STAT, &shm_buf)) {
+ dlt_log(LOG_WARNING, "SHM: shmctl() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
- // Now we attach the segment to our data space.
- if ((ptr = shmat(buf->shmid, NULL, 0)) == (unsigned char *) -1) {
- dlt_log(LOG_WARNING,"SHM: shmat() failed");
+ /* Now we attach the segment to our data space. */
+ if ((ptr = shmat(buf->shmid, NULL, 0)) == (unsigned char *)-1) {
+ dlt_log(LOG_WARNING, "SHM: shmat() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
- // Init semaphore
- if( (buf->semid = semget(DLT_SHM_SEM,1,S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT|IPC_EXCL)) == -1 ) {
- if( (buf->semid = semget(DLT_SHM_SEM,1,S_IRWXU|S_IRWXG|S_IRWXO|IPC_EXCL)) == -1 ) {
- dlt_log(LOG_WARNING,"SHM: semget() failed");
+ /* Init semaphore */
+ if ((buf->semid = semget(DLT_SHM_SEM, 1, S_IRWXU | S_IRWXG | S_IRWXO | IPC_CREAT | IPC_EXCL)) == -1) {
+ if ((buf->semid = semget(DLT_SHM_SEM, 1, S_IRWXU | S_IRWXG | S_IRWXO | IPC_EXCL)) == -1) {
+ dlt_log(LOG_WARNING, "SHM: semget() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
}
- if( semctl(buf->semid,0,SETVAL,(int)1) == -1 ) {
- dlt_log(LOG_WARNING,"SHM: semctl() failed");
+
+ if (semctl(buf->semid, 0, SETVAL, (int)1) == -1) {
+ dlt_log(LOG_WARNING, "SHM: semctl() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
- // init buffer
- dlt_buffer_init_static_server(&(buf->buffer),ptr,shm_buf.shm_segsz);
+ /* init buffer */
+ dlt_buffer_init_static_server(&(buf->buffer), ptr, shm_buf.shm_segsz);
return DLT_RETURN_OK; /* OK */
}
-DltReturnValue dlt_shm_init_client(DltShm *buf,int key) {
+DltReturnValue dlt_shm_init_client(DltShm *buf, int key)
+{
struct shmid_ds shm_buf;
unsigned char *ptr;
- // init parameters
+ /* init parameters */
buf->shmid = 0;
buf->semid = 0;
- // Create the segment.
+ /* Create the segment. */
if ((buf->shmid = shmget(key, 0, 0666)) < 0) {
- dlt_log(LOG_WARNING,"SHM: shmget() failed");
+ dlt_log(LOG_WARNING, "SHM: shmget() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
- // get the size of shm
- if (shmctl(buf->shmid, IPC_STAT, &shm_buf))
- {
- dlt_log(LOG_WARNING,"SHM: shmctl() failed");
- return DLT_RETURN_ERROR; /* ERROR */
+ /* get the size of shm */
+ if (shmctl(buf->shmid, IPC_STAT, &shm_buf)) {
+ dlt_log(LOG_WARNING, "SHM: shmctl() failed");
+ return DLT_RETURN_ERROR; /* ERROR */
}
- // Now we attach the segment to our data space.
- if ((ptr = shmat(buf->shmid, NULL, 0)) == (unsigned char *) -1) {
- dlt_log(LOG_WARNING,"shmat() failed");
+ /* Now we attach the segment to our data space. */
+ if ((ptr = shmat(buf->shmid, NULL, 0)) == (unsigned char *)-1) {
+ dlt_log(LOG_WARNING, "shmat() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
- // Init semaphore
- if( (buf->semid = semget(DLT_SHM_SEM,0,0)) == -1 ) {
- dlt_log(LOG_WARNING,"SHM: semget() failed");
- return DLT_RETURN_ERROR; /* ERROR */
+ /* Init semaphore */
+ if ((buf->semid = semget(DLT_SHM_SEM, 0, 0)) == -1) {
+ dlt_log(LOG_WARNING, "SHM: semget() failed");
+ return DLT_RETURN_ERROR; /* ERROR */
}
- // init buffer
- dlt_buffer_init_static_client(&(buf->buffer),ptr,shm_buf.shm_segsz);
+ /* init buffer */
+ dlt_buffer_init_static_client(&(buf->buffer), ptr, shm_buf.shm_segsz);
return DLT_RETURN_OK; /* OK */
}
@@ -200,11 +200,11 @@ int dlt_shm_get_used_size(DltShm *buf)
int ret;
/* check if buffer available */
- if(!buf->buffer.mem)
+ if (!buf->buffer.mem)
return -1;
DLT_SHM_SEM_GET(buf->semid);
- ret = dlt_buffer_get_used_size(&(buf->buffer));
+ ret = dlt_buffer_get_used_size(&(buf->buffer));
DLT_SHM_SEM_FREE(buf->semid);
return ret;
@@ -215,46 +215,52 @@ int dlt_shm_get_message_count(DltShm *buf)
return dlt_buffer_get_message_count(&(buf->buffer));
}
-int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size1,const unsigned char *data2,unsigned int size2,const unsigned char *data3,unsigned int size3)
+int dlt_shm_push(DltShm *buf,
+ const unsigned char *data1,
+ unsigned int size1,
+ const unsigned char *data2,
+ unsigned int size2,
+ const unsigned char *data3,
+ unsigned int size3)
{
int ret;
/* check if buffer available */
- if(!buf->buffer.mem)
+ if (!buf->buffer.mem)
return -1;
DLT_SHM_SEM_GET(buf->semid);
- ret = dlt_buffer_push3(&(buf->buffer),data1,size1,data2,size2,data3,size3);
+ ret = dlt_buffer_push3(&(buf->buffer), data1, size1, data2, size2, data3, size3);
DLT_SHM_SEM_FREE(buf->semid);
return ret;
}
-int dlt_shm_pull(DltShm *buf,unsigned char *data, int max_size)
+int dlt_shm_pull(DltShm *buf, unsigned char *data, int max_size)
{
int ret;
/* check if buffer available */
- if(!buf->buffer.mem)
+ if (!buf->buffer.mem)
return -1;
DLT_SHM_SEM_GET(buf->semid);
- ret = dlt_buffer_pull(&(buf->buffer),data,max_size);
+ ret = dlt_buffer_pull(&(buf->buffer), data, max_size);
DLT_SHM_SEM_FREE(buf->semid);
return ret;
}
-int dlt_shm_copy(DltShm *buf,unsigned char *data, int max_size)
+int dlt_shm_copy(DltShm *buf, unsigned char *data, int max_size)
{
int ret;
/* check if buffer available */
- if(!buf->buffer.mem)
+ if (!buf->buffer.mem)
return -1;
DLT_SHM_SEM_GET(buf->semid);
- ret = dlt_buffer_copy(&(buf->buffer),data,max_size);
+ ret = dlt_buffer_copy(&(buf->buffer), data, max_size);
DLT_SHM_SEM_FREE(buf->semid);
return ret;
@@ -265,34 +271,35 @@ int dlt_shm_remove(DltShm *buf)
int ret;
/* check if buffer available */
- if(!buf->buffer.mem)
+ if (!buf->buffer.mem)
return -1;
DLT_SHM_SEM_GET(buf->semid);
- ret = dlt_buffer_remove(&(buf->buffer));
+ ret = dlt_buffer_remove(&(buf->buffer));
DLT_SHM_SEM_FREE(buf->semid);
return ret;
}
-DltReturnValue dlt_shm_free_server(DltShm *buf) {
+DltReturnValue dlt_shm_free_server(DltShm *buf)
+{
- if(shmdt(buf->buffer.shm)) {
- dlt_log(LOG_WARNING,"SHM: shmdt() failed");
+ if (shmdt(buf->buffer.shm)) {
+ dlt_log(LOG_WARNING, "SHM: shmdt() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
- if(shmctl(buf->shmid,IPC_RMID,NULL) == -1) {
- dlt_log(LOG_WARNING,"SHM: shmdt() failed");
+ if (shmctl(buf->shmid, IPC_RMID, NULL) == -1) {
+ dlt_log(LOG_WARNING, "SHM: shmdt() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
- if(semctl(buf->semid,0,IPC_RMID,(int)0) == -1) {
- dlt_log(LOG_WARNING,"SHM: shmdt() failed");
+ if (semctl(buf->semid, 0, IPC_RMID, (int)0) == -1) {
+ dlt_log(LOG_WARNING, "SHM: shmdt() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
- // Reset parameters
+ /* Reset parameters */
buf->shmid = 0;
buf->semid = 0;
@@ -300,14 +307,15 @@ DltReturnValue dlt_shm_free_server(DltShm *buf) {
}
-DltReturnValue dlt_shm_free_client(DltShm *buf) {
+DltReturnValue dlt_shm_free_client(DltShm *buf)
+{
- if(shmdt(buf->buffer.shm)) {
- dlt_log(LOG_WARNING,"SHM: shmdt() failed");
+ if (shmdt(buf->buffer.shm)) {
+ dlt_log(LOG_WARNING, "SHM: shmdt() failed");
return DLT_RETURN_ERROR; /* ERROR */
}
- // Reset parameters
+ /* Reset parameters */
buf->shmid = 0;
buf->semid = 0;
diff --git a/src/shared/dlt_user_shared.c b/src/shared/dlt_user_shared.c
index 60418b4..7b5ebd2 100644
--- a/src/shared/dlt_user_shared.c
+++ b/src/shared/dlt_user_shared.c
@@ -64,8 +64,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <sys/stat.h>
@@ -96,27 +96,23 @@ DltReturnValue dlt_user_set_userheader(DltUserHeader *userheader, uint32_t mtype
int dlt_user_check_userheader(DltUserHeader *userheader)
{
- if (userheader==0)
- {
+ if (userheader == 0)
return -1;
- }
- return ((userheader->pattern[0] == 'D') &&
- (userheader->pattern[1] == 'U') &&
- (userheader->pattern[2] == 'H') &&
- (userheader->pattern[3] == 1));
+ return (userheader->pattern[0] == 'D') &&
+ (userheader->pattern[1] == 'U') &&
+ (userheader->pattern[2] == 'H') &&
+ (userheader->pattern[3] == 1);
}
-DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void* ptr2, size_t len2)
+DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void *ptr2, size_t len2)
{
struct iovec iov[2];
uint32_t bytes_written;
- if (handle<=0)
- {
+ if (handle <= 0)
/* Invalid handle */
return DLT_RETURN_ERROR;
- }
iov[0].iov_base = ptr1;
iov[0].iov_len = len1;
@@ -125,24 +121,20 @@ DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void* ptr2
bytes_written = writev(handle, iov, 2);
- if (bytes_written!=(len1+len2))
- {
+ if (bytes_written != (len1 + len2))
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
}
-DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void* ptr2, size_t len2, void *ptr3, size_t len3)
+DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void *ptr2, size_t len2, void *ptr3, size_t len3)
{
struct iovec iov[3];
uint32_t bytes_written;
- if (handle<=0)
- {
+ if (handle <= 0)
/* Invalid handle */
return DLT_RETURN_ERROR;
- }
iov[0].iov_base = ptr1;
iov[0].iov_len = len1;
@@ -153,30 +145,29 @@ DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void* ptr2
bytes_written = writev(handle, iov, 3);
- if (bytes_written!=(len1+len2+len3))
- {
- switch(errno)
+ if (bytes_written != (len1 + len2 + len3)) {
+ switch (errno) {
+ case EBADF:
+ {
+ return DLT_RETURN_PIPE_ERROR; /* EBADF - handle not open */
+ break;
+ }
+ case EPIPE:
{
- case EBADF:
- {
- return DLT_RETURN_PIPE_ERROR; /* EBADF - handle not open */
- break;
- }
- case EPIPE:
- {
- return DLT_RETURN_PIPE_ERROR; /* EPIPE - pipe error */
- break;
- }
- case EAGAIN:
- {
- return DLT_RETURN_PIPE_FULL; /* EAGAIN - data could not be written */
- break;
- }
- default:
- {
- break;
- }
+ return DLT_RETURN_PIPE_ERROR; /* EPIPE - pipe error */
+ break;
}
+ case EAGAIN:
+ {
+ return DLT_RETURN_PIPE_FULL; /* EAGAIN - data could not be written */
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
return DLT_RETURN_ERROR;
}
diff --git a/src/shared/dlt_user_shared.h b/src/shared/dlt_user_shared.h
index 795928e..cc9b070 100644
--- a/src/shared/dlt_user_shared.h
+++ b/src/shared/dlt_user_shared.h
@@ -211,7 +211,7 @@ int dlt_user_check_userheader(DltUserHeader *userheader);
* @param len2 length of second segment of data to be written
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void* ptr2, size_t len2);
+DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void *ptr2, size_t len2);
/**
* Atomic write to file descriptor, using vector of 3 elements
@@ -224,6 +224,6 @@ DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void* ptr2
* @param len3 length of third segment of data to be written
* @return Value from DltReturnValue enum
*/
-DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void* ptr2, size_t len2, void *ptr3, size_t len3);
+DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void *ptr2, size_t len2, void *ptr3, size_t len3);
#endif /* DLT_USER_SHARED_H */
diff --git a/src/system/dlt-system-filetransfer.c b/src/system/dlt-system-filetransfer.c
index 819b6de..9bb1d56 100644
--- a/src/system/dlt-system-filetransfer.c
+++ b/src/system/dlt-system-filetransfer.c
@@ -54,7 +54,7 @@
#include <pthread.h>
#include <unistd.h>
#ifdef linux
-#include <sys/inotify.h>
+# include <sys/inotify.h>
#endif
#include <libgen.h>
#include <dirent.h>
@@ -69,10 +69,10 @@
#include "dlt_filetransfer.h"
#ifdef linux
-#define INOTIFY_SZ (sizeof(struct inotify_event))
-#define INOTIFY_LEN (INOTIFY_SZ + NAME_MAX + 1)
+# define INOTIFY_SZ (sizeof(struct inotify_event))
+# define INOTIFY_LEN (INOTIFY_SZ + NAME_MAX + 1)
#endif
-#define Z_CHUNK_SZ 1024*128
+#define Z_CHUNK_SZ 1024 * 128
#define COMPRESS_EXTENSION ".gz"
#define SUBDIR_COMPRESS ".tocompress"
#define SUBDIR_TOSEND ".tosend"
@@ -80,8 +80,8 @@
extern DltSystemThreads threads;
-// From dlt_filetransfer
-extern uint32_t getFileSerialNumber(const char* file, int *ok);
+/* From dlt_filetransfer */
+extern uint32_t getFileSerialNumber(const char *file, int *ok);
DLT_IMPORT_CONTEXT(dltsystem)
DLT_DECLARE_CONTEXT(filetransferContext)
@@ -96,11 +96,12 @@ s_ft_inotify ino;
#endif
-char *origin_name(char *src){
- if (strlen( (char*) basename(src)) > 10 ){
- return (char*)(basename(src)+10);
+char *origin_name(char *src)
+{
+ if (strlen((char *)basename(src)) > 10) {
+ return (char *)(basename(src) + 10);
}
- else{
+ else {
DLT_LOG(dltsystem, DLT_LOG_ERROR,
DLT_STRING("dlt-system-filetransfer, error in recreating origin name!"));
return NULL;
@@ -114,68 +115,73 @@ char *unique_name(char *src)
time_t t = time(NULL);
int ok;
uint32_t l = getFileSerialNumber(src, &ok) ^ t;
- if (!ok){
- return (char*) NULL;
- }
+
+ if (!ok)
+ return (char *)NULL;
char *basename_f = basename(src);
- // Length of ULONG_MAX + 1
- int len = 11+strlen(basename_f);
- if (len > NAME_MAX){
+ /* Length of ULONG_MAX + 1 */
+ int len = 11 + strlen(basename_f);
+
+ if (len > NAME_MAX) {
DLT_LOG(dltsystem, DLT_LOG_WARN,
- DLT_STRING("dlt-system-filetransfer, unique name creation needs to shorten the filename:"),DLT_STRING(basename_f));
+ DLT_STRING("dlt-system-filetransfer, unique name creation needs to shorten the filename:"),
+ DLT_STRING(basename_f));
len = NAME_MAX;
}
char *ret = malloc(len);
MALLOC_ASSERT(ret);
- snprintf(ret, len, "%010" PRIu32 "%s", l,basename_f);
+ snprintf(ret, len, "%010" PRIu32 "%s", l, basename_f);
return ret;
}
/**
- * Function which only calls the relevant part to transfer the payload
- */
+ * Function which only calls the relevant part to transfer the payload
+ */
-void send_dumped_file(FiletransferOptions const *opts,char *dst_tosend)
+void send_dumped_file(FiletransferOptions const *opts, char *dst_tosend)
{
- // check if a client is connected to the deamon. If not, try again in a second
- while(dlt_get_log_state() != 1)
+ /* check if a client is connected to the deamon. If not, try again in a second */
+ while (dlt_get_log_state() != 1)
sleep(1);
char *fn = origin_name(dst_tosend);
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-filetransfer, sending dumped file:"),DLT_STRING(fn));
- if(dlt_user_log_file_header_alias(&filetransferContext, dst_tosend, fn) == 0)
- {
+ DLT_STRING("dlt-system-filetransfer, sending dumped file:"), DLT_STRING(fn));
+
+ if (dlt_user_log_file_header_alias(&filetransferContext, dst_tosend, fn) == 0) {
int pkgcount = dlt_user_log_file_packagesCount(&filetransferContext, dst_tosend);
int lastpkg = 0;
int success = 1;
- while(lastpkg < pkgcount)
- {
+
+ while (lastpkg < pkgcount) {
int total = 2;
int used = 2;
dlt_user_check_buffer(&total, &used);
- while((total-used) < (total/2))
- {
+
+ while ((total - used) < (total / 2)) {
struct timespec t;
t.tv_sec = 0;
- t.tv_nsec = 1000000ul*opts->TimeoutBetweenLogs;
+ t.tv_nsec = 1000000ul * opts->TimeoutBetweenLogs;
nanosleep(&t, NULL);
dlt_user_log_resend_buffer();
dlt_user_check_buffer(&total, &used);
}
+
lastpkg++;
- if(dlt_user_log_file_data(&filetransferContext, dst_tosend, lastpkg, opts->TimeoutBetweenLogs) < 0)
- {
+
+ if (dlt_user_log_file_data(&filetransferContext, dst_tosend, lastpkg, opts->TimeoutBetweenLogs) < 0) {
success = 0;
break;
}
}
+
if (success)
dlt_user_log_file_end(&filetransferContext, dst_tosend, 1);
}
+
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
DLT_STRING("dlt-system-filetransfer, sent dumped file"));
}
@@ -187,31 +193,33 @@ void send_dumped_file(FiletransferOptions const *opts,char *dst_tosend)
* @param src File to be sent
* @param dst destination where to compress the file
* @param level of compression
-**/
+ **/
int compress_file_to(char *src, char *dst, int level)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-filetransfer, compressing file from:"),DLT_STRING(src),DLT_STRING("to:"),DLT_STRING(dst));
+ DLT_LOG(dltsystem,
+ DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-filetransfer, compressing file from:"),
+ DLT_STRING(src),
+ DLT_STRING("to:"),
+ DLT_STRING(dst));
char *buf;
char dst_mode[8];
- snprintf(dst_mode,8, "wb%d", level);
+ snprintf(dst_mode, 8, "wb%d", level);
gzFile dst_file;
FILE *src_file;
dst_file = gzopen(dst, dst_mode);
- if(dst_file == Z_NULL)
- {
+
+ if (dst_file == Z_NULL)
return -1;
- }
src_file = fopen(src, "r");
- if(src_file == NULL)
- {
+ if (src_file == NULL) {
gzclose(dst_file);
return -1;
@@ -220,22 +228,23 @@ int compress_file_to(char *src, char *dst, int level)
buf = malloc(Z_CHUNK_SZ);
MALLOC_ASSERT(buf);
- while(!feof(src_file))
- {
+ while (!feof(src_file)) {
int read = fread(buf, 1, Z_CHUNK_SZ, src_file);
- if(ferror(src_file))
- {
+
+ if (ferror(src_file)) {
free(buf);
gzclose(dst_file);
fclose(src_file);
return -1;
}
+
gzwrite(dst_file, buf, read);
}
- if(remove(src) < 0)
+ if (remove(src) < 0)
DLT_LOG(dltsystem, DLT_LOG_WARN, DLT_STRING("Could not remove file"), DLT_STRING(src));
+
free(buf);
fclose(src_file);
gzclose(dst_file);
@@ -243,7 +252,7 @@ int compress_file_to(char *src, char *dst, int level)
return 0;
}
-//!Sends one file over DLT.
+/*!Sends one file over DLT. */
/**
* If configured in opts, compresses it, then sends it.
* uses subdirecties for compressing and before sending, to avoid that those files get changed in the meanwhile
@@ -255,49 +264,46 @@ int send_one(char *src, FiletransferOptions const *opts, int which)
DLT_STRING("dlt-system-filetransfer, sending a file."));
sleep(opts->TimeDelay);
- // Prepare all needed file names
+ /* Prepare all needed file names */
char *fn = basename(src);
- if (fn == NULL)
- {
+
+ if (fn == NULL) {
DLT_LOG(dltsystem,
DLT_LOG_ERROR,
DLT_STRING("basename not valid"));
return -1;
}
- char *fdir = strndup(src,PATH_MAX);
+ char *fdir = strndup(src, PATH_MAX);
MALLOC_ASSERT(fdir);
- fdir = dirname(fdir);//dirname overwrites its argument anyway
- char *dst_tosend;//file which is going to be sent
+ fdir = dirname(fdir);/*dirname overwrites its argument anyway */
+ char *dst_tosend;/*file which is going to be sent */
- char *rn = unique_name(src);//new unique filename based on inode
+ char *rn = unique_name(src);/*new unique filename based on inode */
- if (rn == NULL)
- {
+ if (rn == NULL) {
DLT_LOG(dltsystem,
DLT_LOG_ERROR,
DLT_STRING("file information not available, may be file got overwritten"));
return -1;
}
- // Compress if needed
- if(opts->Compression[which] > 0)
- {
+ /* Compress if needed */
+ if (opts->Compression[which] > 0) {
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
DLT_STRING("dlt-system-filetransfer, Moving file to tmp directory for compressing it."));
- char *dst_tocompress;//file which is going to be compressed, the compressed one is named dst_tosend
+ char *dst_tocompress;/*file which is going to be compressed, the compressed one is named dst_tosend */
- int len = strlen(fdir)+strlen(SUBDIR_COMPRESS)+strlen(rn)+3;//the filename in .tocompress +2 for 2*"/", +1 for \0
+ int len = strlen(fdir) + strlen(SUBDIR_COMPRESS) + strlen(rn) + 3;/*the filename in .tocompress +2 for 2*"/", +1 for \0 */
dst_tocompress = malloc(len);
MALLOC_ASSERT(dst_tocompress);
- snprintf(dst_tocompress,len,"%s/%s/%s",fdir,SUBDIR_COMPRESS,rn);
+ snprintf(dst_tocompress, len, "%s/%s/%s", fdir, SUBDIR_COMPRESS, rn);
- //moving in subdir, from where it can be compressed
- if(rename(src, dst_tocompress) < 0)
- {
+ /*moving in subdir, from where it can be compressed */
+ if (rename(src, dst_tocompress) < 0) {
DLT_LOG(dltsystem, DLT_LOG_ERROR,
DLT_STRING("Could not move file"),
DLT_STRING(src),
@@ -307,35 +313,38 @@ int send_one(char *src, FiletransferOptions const *opts, int which)
free(fdir);
return -1;
}
- len = strlen(fdir)+strlen(SUBDIR_TOSEND)+strlen(rn)+strlen(COMPRESS_EXTENSION)+3;//the resulting filename in .tosend +2 for 2*"/", +1 for \0
+
+ len = strlen(fdir) + strlen(SUBDIR_TOSEND) + strlen(rn) + strlen(COMPRESS_EXTENSION) + 3;/*the resulting filename in .tosend +2 for 2*"/", +1 for \0 */
dst_tosend = malloc(len);
MALLOC_ASSERT(dst_tosend);
- snprintf(dst_tosend,len,"%s/%s/%s%s",fdir,SUBDIR_TOSEND,rn,COMPRESS_EXTENSION);
+ snprintf(dst_tosend, len, "%s/%s/%s%s", fdir, SUBDIR_TOSEND, rn, COMPRESS_EXTENSION);
- if (compress_file_to(dst_tocompress,dst_tosend, opts->CompressionLevel[which]) != 0){
+ if (compress_file_to(dst_tocompress, dst_tosend, opts->CompressionLevel[which]) != 0) {
free(rn);
free(dst_tosend);
free(dst_tocompress);
free(fdir);
return -1;
}
+
free(dst_tocompress);
}
- else{
- //move it directly into "tosend"
+ else {
+ /*move it directly into "tosend" */
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
DLT_STRING("dlt-system-filetransfer, Moving file to tmp directory."));
- int len = strlen(fdir)+strlen(SUBDIR_TOSEND)+strlen(rn)+3;
- dst_tosend = malloc(len);//the resulting filename in .tosend +2 for 2*"/", +1 for \0
+ int len = strlen(fdir) + strlen(SUBDIR_TOSEND) + strlen(rn) + 3;
+ dst_tosend = malloc(len);/*the resulting filename in .tosend +2 for 2*"/", +1 for \0 */
- snprintf(dst_tosend,len,"%s/%s/%s",fdir,SUBDIR_TOSEND,rn);
+ snprintf(dst_tosend, len, "%s/%s/%s", fdir, SUBDIR_TOSEND, rn);
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-filetransfer, Rename:"),DLT_STRING(src),DLT_STRING("to: "),DLT_STRING(dst_tosend));
- //moving in subdir, from where it can be compressed
- if(rename(src, dst_tosend) < 0)
- {
+ DLT_STRING("dlt-system-filetransfer, Rename:"), DLT_STRING(src), DLT_STRING("to: "),
+ DLT_STRING(dst_tosend));
+
+ /*moving in subdir, from where it can be compressed */
+ if (rename(src, dst_tosend) < 0) {
DLT_LOG(dltsystem, DLT_LOG_ERROR,
DLT_STRING("Could not move file"),
DLT_STRING(src),
@@ -345,13 +354,12 @@ int send_one(char *src, FiletransferOptions const *opts, int which)
free(fdir);
return -1;
}
-
}
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
DLT_STRING("dlt-system-filetransfer, File ready to send"));
- send_dumped_file(opts,dst_tosend);
+ send_dumped_file(opts, dst_tosend);
free(rn);
@@ -362,192 +370,195 @@ int send_one(char *src, FiletransferOptions const *opts, int which)
}
-int flush_dir_send(FiletransferOptions const *opts, const char *compress_dir, const char *send_dir){
+int flush_dir_send(FiletransferOptions const *opts, const char *compress_dir, const char *send_dir)
+{
struct dirent *dp;
DIR *dir;
dir = opendir(send_dir);
- if(dir != NULL)
- {
- while((dp = readdir(dir)) != NULL)
- {
- if(dp->d_type != DT_REG)
+ if (dir != NULL) {
+ while ((dp = readdir(dir)) != NULL) {
+ if (dp->d_type != DT_REG)
continue;
+
char *fn;
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-filetransfer, old compressed file found in send directory:"),DLT_STRING(dp->d_name));
- int len = strlen(send_dir)+strlen(dp->d_name)+2;
+ DLT_STRING("dlt-system-filetransfer, old compressed file found in send directory:"),
+ DLT_STRING(dp->d_name));
+ int len = strlen(send_dir) + strlen(dp->d_name) + 2;
fn = malloc(len);
MALLOC_ASSERT(fn);
- snprintf(fn,len, "%s/%s", send_dir, dp->d_name);
-
+ snprintf(fn, len, "%s/%s", send_dir, dp->d_name);
- //if we have a file here and in the to_compress dir, we delete the to_send file: we can not be sure, that it has been properly compressed!
- if (!strncmp( dp->d_name+strlen(dp->d_name)-strlen(COMPRESS_EXTENSION),COMPRESS_EXTENSION,strlen(COMPRESS_EXTENSION)))
- {
+ /*if we have a file here and in the to_compress dir, we delete the to_send file: we can not be sure, that it has been properly compressed! */
+ if (!strncmp(dp->d_name + strlen(dp->d_name) - strlen(COMPRESS_EXTENSION), COMPRESS_EXTENSION,
+ strlen(COMPRESS_EXTENSION))) {
- //ends with ".gz"
- //old file name (not: path) would have been:
- char tmp[strlen(dp->d_name)-strlen(COMPRESS_EXTENSION)+1];
- strncpy(tmp,dp->d_name,strlen(dp->d_name)-strlen(COMPRESS_EXTENSION));
- tmp[strlen(dp->d_name)-strlen(COMPRESS_EXTENSION)]='\0';
+ /*ends with ".gz" */
+ /*old file name (not: path) would have been: */
+ char tmp[strlen(dp->d_name) - strlen(COMPRESS_EXTENSION) + 1];
+ strncpy(tmp, dp->d_name, strlen(dp->d_name) - strlen(COMPRESS_EXTENSION));
+ tmp[strlen(dp->d_name) - strlen(COMPRESS_EXTENSION)] = '\0';
- int len = strlen(tmp)+strlen(compress_dir)+1+1;//2 sizes + 1*"/" + \0
+ int len = strlen(tmp) + strlen(compress_dir) + 1 + 1;/*2 sizes + 1*"/" + \0 */
char *path_uncompressed = malloc(len);
MALLOC_ASSERT(path_uncompressed);
- snprintf(path_uncompressed,len,"%s/%s",compress_dir,tmp);
+ snprintf(path_uncompressed, len, "%s/%s", compress_dir, tmp);
struct stat sb;
- if (stat(path_uncompressed,&sb)==-1)
- {
- //uncompressed equivalent does not exist. We can send it out.
+
+ if (stat(path_uncompressed, &sb) == -1) {
+ /*uncompressed equivalent does not exist. We can send it out. */
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
DLT_STRING("dlt-system-filetransfer, sending file."));
- send_dumped_file(opts,fn);
+ send_dumped_file(opts, fn);
}
- else
- {
- //There is an uncompressed file. Compression seems to have been interrupted -> delete the compressed file instead of sending it!
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-filetransfer, uncompressed version exists. Deleting partially compressed version."));
- if (sb.st_mode & S_IFREG)
- {
+ else {
+ /*There is an uncompressed file. Compression seems to have been interrupted -> delete the compressed file instead of sending it! */
+ DLT_LOG(dltsystem,
+ DLT_LOG_DEBUG,
+ DLT_STRING(
+ "dlt-system-filetransfer, uncompressed version exists. Deleting partially compressed version."));
+ if (sb.st_mode & S_IFREG) {
- if( remove(fn ) != 0 )
- {
- //"Error deleting file". Continue? If we would cancel, maybe the dump is never sent! Deletion would again be tried in next LC.
+ if (remove(fn) != 0)
+ /*"Error deleting file". Continue? If we would cancel, maybe the dump is never sent! Deletion would again be tried in next LC. */
DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("Error deleting file:"),DLT_STRING(fn));
- }
+ DLT_STRING("Error deleting file:"), DLT_STRING(fn));
}
- else
- {
- //"Oldfile is a not reg file. Is this possible? Can we compress a directory?: %s\n",path_uncompressed);
+ else {
+ /*"Oldfile is a not reg file. Is this possible? Can we compress a directory?: %s\n",path_uncompressed); */
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-filetransfer, Oldfile is a not regular file! Do we have a problem?"),DLT_STRING(fn));
+ DLT_STRING(
+ "dlt-system-filetransfer, Oldfile is a not regular file! Do we have a problem?"),
+ DLT_STRING(fn));
}
-
}
- free(path_uncompressed);//it is no more used. It would be transferred in next step.
- }//it is a .gz file
- else{
- //uncompressed file. We can just resend it, the action to put it here was a move action.
+
+ free(path_uncompressed);/*it is no more used. It would be transferred in next step. */
+ }/*it is a .gz file */
+ else {
+ /*uncompressed file. We can just resend it, the action to put it here was a move action. */
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-filetransfer, Sending uncompressed file from previous LC."),DLT_STRING(fn));
- send_dumped_file(opts,fn);
+ DLT_STRING("dlt-system-filetransfer, Sending uncompressed file from previous LC."),
+ DLT_STRING(fn));
+ send_dumped_file(opts, fn);
}
+
free(fn);
}
}
- else
- {
+ else {
DLT_LOG(dltsystem, DLT_LOG_ERROR,
DLT_STRING("Could not open directory"),
DLT_STRING(send_dir));
return -1;
}
- closedir(dir);//end: send_dir
+
+ closedir(dir);/*end: send_dir */
return 0;
}
-int flush_dir_compress(FiletransferOptions const *opts, int which, const char *compress_dir, const char *send_dir){
+int flush_dir_compress(FiletransferOptions const *opts, int which, const char *compress_dir, const char *send_dir)
+{
- //check for files in compress_dir. Assumption: a file which lies here, should have been compressed, but that action was interrupted.
- //As it can arrive here only by a rename, it is most likely to be a complete file
+ /*check for files in compress_dir. Assumption: a file which lies here, should have been compressed, but that action was interrupted. */
+ /*As it can arrive here only by a rename, it is most likely to be a complete file */
struct dirent *dp;
DIR *dir;
dir = opendir(compress_dir);
- if(dir != NULL)
- {
- while((dp = readdir(dir)) != NULL)
- {
- if(dp->d_type != DT_REG)
+
+ if (dir != NULL) {
+ while ((dp = readdir(dir)) != NULL) {
+ if (dp->d_type != DT_REG)
continue;
+
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
DLT_STRING("dlt-system-filetransfer, old file found in compress-directory."));
- //compress file into to_send dir
- int len = strlen(compress_dir)+strlen(dp->d_name)+2;
+ /*compress file into to_send dir */
+ int len = strlen(compress_dir) + strlen(dp->d_name) + 2;
char *cd_filename = malloc(len);
MALLOC_ASSERT(cd_filename);
- snprintf(cd_filename,len,"%s/%s",compress_dir,dp->d_name);
+ snprintf(cd_filename, len, "%s/%s", compress_dir, dp->d_name);
- len = strlen(send_dir)+strlen(dp->d_name)+strlen(COMPRESS_EXTENSION)+2;
- char *dst_tosend = malloc(len);//the resulting filename in .tosend +2 for 1*"/", +1 for \0 + .gz
+ len = strlen(send_dir) + strlen(dp->d_name) + strlen(COMPRESS_EXTENSION) + 2;
+ char *dst_tosend = malloc(len);/*the resulting filename in .tosend +2 for 1*"/", +1 for \0 + .gz */
MALLOC_ASSERT(dst_tosend);
- snprintf(dst_tosend,len,"%s/%s%s",send_dir,dp->d_name,COMPRESS_EXTENSION);
+ snprintf(dst_tosend, len, "%s/%s%s", send_dir, dp->d_name, COMPRESS_EXTENSION);
- if (compress_file_to(cd_filename,dst_tosend, opts->CompressionLevel[which]) != 0){
+ if (compress_file_to(cd_filename, dst_tosend, opts->CompressionLevel[which]) != 0) {
free(dst_tosend);
free(cd_filename);
closedir(dir);
return -1;
}
- //send file
- send_dumped_file(opts,dst_tosend);
+ /*send file */
+ send_dumped_file(opts, dst_tosend);
free(dst_tosend);
free(cd_filename);
}
}
- else
- {
+ else {
DLT_LOG(dltsystem, DLT_LOG_ERROR,
DLT_STRING("Could not open directory"),
DLT_STRING(compress_dir));
return -1;
}
- closedir(dir);//end: compress_dir
+
+ closedir(dir);/*end: compress_dir */
return 0;
}
-int flush_dir_original(FiletransferOptions const *opts, int which){
+int flush_dir_original(FiletransferOptions const *opts, int which)
+{
struct dirent *dp;
DIR *dir;
const char *sdir = opts->Directory[which];
dir = opendir(sdir);
- if(dir != NULL)
- {
- while((dp = readdir(dir)) != NULL)
- {
- if(dp->d_type != DT_REG){
- //we don't send directories
+
+ if (dir != NULL) {
+ while ((dp = readdir(dir)) != NULL) {
+ if (dp->d_type != DT_REG)
+ /*we don't send directories */
continue;
- }
+
DLT_LOG(dltsystem, DLT_LOG_DEBUG,
DLT_STRING("dlt-system-filetransfer, old file found in directory."));
- int len = strlen(sdir)+strlen(dp->d_name)+2;
+ int len = strlen(sdir) + strlen(dp->d_name) + 2;
char *fn = malloc(len);
MALLOC_ASSERT(fn);
- snprintf(fn,len, "%s/%s", sdir, dp->d_name);
- if(send_one(fn, opts, which) < 0)
- {
+ snprintf(fn, len, "%s/%s", sdir, dp->d_name);
+
+ if (send_one(fn, opts, which) < 0) {
closedir(dir);
free(fn);
return -1;
}
+
free(fn);
}
}
- else
- {
+ else {
DLT_LOG(dltsystem, DLT_LOG_ERROR,
DLT_STRING("Could not open directory"),
DLT_STRING(sdir));
return -1;
}
+
closedir(dir);
return 0;
}
-//!Cleans the surveyed directories and subdirectories. Sends residing files into trace
+/*!Cleans the surveyed directories and subdirectories. Sends residing files into trace */
/**
* @param opts FiletransferOptions
* @param which which directory is affected -> position in list of opts->Directory
@@ -562,42 +573,41 @@ int flush_dir(FiletransferOptions const *opts, int which)
char *compress_dir;
char *send_dir;
- int len = strlen(opts->Directory[which])+strlen(SUBDIR_COMPRESS)+2;
+ int len = strlen(opts->Directory[which]) + strlen(SUBDIR_COMPRESS) + 2;
compress_dir = malloc (len);
MALLOC_ASSERT(compress_dir);
- snprintf(compress_dir,len,"%s/%s",opts->Directory[which],SUBDIR_COMPRESS);
+ snprintf(compress_dir, len, "%s/%s", opts->Directory[which], SUBDIR_COMPRESS);
- len = strlen(opts->Directory[which])+strlen(SUBDIR_TOSEND)+2;
+ len = strlen(opts->Directory[which]) + strlen(SUBDIR_TOSEND) + 2;
send_dir = malloc (len);
MALLOC_ASSERT(send_dir);
- snprintf(send_dir,len,"%s/%s",opts->Directory[which],SUBDIR_TOSEND);
+ snprintf(send_dir, len, "%s/%s", opts->Directory[which], SUBDIR_TOSEND);
- //1st: scan the tosend directory.
- if ( 0 != flush_dir_send(opts, compress_dir, send_dir) ){
+ /*1st: scan the tosend directory. */
+ if (0 != flush_dir_send(opts, compress_dir, send_dir)) {
free(send_dir);
free(compress_dir);
return -1;
}
- //1nd: scan the tocompress directory.
- if (0 != flush_dir_compress(opts, which, compress_dir, send_dir)){
+ /*1nd: scan the tocompress directory. */
+ if (0 != flush_dir_compress(opts, which, compress_dir, send_dir)) {
free(send_dir);
free(compress_dir);
return -1;
}
- free(send_dir);//no more used
+ free(send_dir);/*no more used */
free(compress_dir);
- //last step: scan the original directory - we can reuse the send_one function
- if ( 0 != flush_dir_original(opts,which)){
+ /*last step: scan the original directory - we can reuse the send_one function */
+ if (0 != flush_dir_original(opts, which))
return -1;
- }
return 0;
}
-//!Initializes the surveyed directories
+/*!Initializes the surveyed directories */
/**On startup, the inotifiy handlers are created, and existing files shall be sent into DLT stream
* @param opts FiletransferOptions
* @return Returns 0 if everything was okay. If there was a failure a value < 0 will be returned.
@@ -610,51 +620,61 @@ int init_filetransfer_dirs(FiletransferOptions const *opts)
#ifdef linux
ino.handle = inotify_init();
- if(ino.handle < 0)
- {
+ if (ino.handle < 0) {
DLT_LOG(filetransferContext, DLT_LOG_FATAL,
DLT_STRING("Failed to initialize inotify in dlt-system file transfer."));
return -1;
}
+
#endif
- for(i = 0;i < opts->Count;i++)
- {
- //create subdirectories for processing the files
+ for (i = 0; i < opts->Count; i++) {
+ /*create subdirectories for processing the files */
char *subdirpath;
- int len = strlen(opts->Directory[i])+strlen(SUBDIR_COMPRESS)+2;
- subdirpath= malloc (len);
+ int len = strlen(opts->Directory[i]) + strlen(SUBDIR_COMPRESS) + 2;
+ subdirpath = malloc (len);
MALLOC_ASSERT(subdirpath);
- snprintf(subdirpath,len,"%s/%s",opts->Directory[i],SUBDIR_COMPRESS);
- int ret = mkdir(subdirpath,0777);
-
- if (0 != ret && EEXIST != errno){
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-filetransfer, error creating subdirectory: "),DLT_STRING(subdirpath),DLT_STRING(" Errorcode: "),DLT_INT(errno));
+ snprintf(subdirpath, len, "%s/%s", opts->Directory[i], SUBDIR_COMPRESS);
+ int ret = mkdir(subdirpath, 0777);
+
+ if ((0 != ret) && (EEXIST != errno)) {
+ DLT_LOG(dltsystem,
+ DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-filetransfer, error creating subdirectory: "),
+ DLT_STRING(subdirpath),
+ DLT_STRING(" Errorcode: "),
+ DLT_INT(errno));
free (subdirpath);
return -1;
}
+
free(subdirpath);
- len = strlen(opts->Directory[i])+strlen(SUBDIR_TOSEND)+2;
- subdirpath= malloc (len);
+ len = strlen(opts->Directory[i]) + strlen(SUBDIR_TOSEND) + 2;
+ subdirpath = malloc (len);
MALLOC_ASSERT(subdirpath);
- snprintf(subdirpath,len,"%s/%s",opts->Directory[i],SUBDIR_TOSEND);
- ret = mkdir(subdirpath,0777);
- if (0 != ret && EEXIST != errno){
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-filetransfer, error creating subdirectory: "),DLT_STRING(subdirpath),DLT_STRING(" Errorcode: "),DLT_INT(errno));
+ snprintf(subdirpath, len, "%s/%s", opts->Directory[i], SUBDIR_TOSEND);
+ ret = mkdir(subdirpath, 0777);
+
+ if ((0 != ret) && (EEXIST != errno)) {
+ DLT_LOG(dltsystem,
+ DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-filetransfer, error creating subdirectory: "),
+ DLT_STRING(subdirpath),
+ DLT_STRING(" Errorcode: "),
+ DLT_INT(errno));
free (subdirpath);
return -1;
}
+
free(subdirpath);
#ifdef linux
ino.fd[i] = inotify_add_watch(ino.handle, opts->Directory[i],
- IN_CLOSE_WRITE|IN_MOVED_TO);
- if(ino.fd[i] < 0)
- {
+ IN_CLOSE_WRITE | IN_MOVED_TO);
+
+ if (ino.fd[i] < 0) {
char buf[1024];
snprintf(buf, 1024, "Failed to add inotify watch to directory %s in dlt-system file transfer.",
opts->Directory[i]);
@@ -662,11 +682,13 @@ int init_filetransfer_dirs(FiletransferOptions const *opts)
DLT_STRING(buf));
return -1;
}
+
#endif
flush_dir(opts, i);
}
+
return 0;
}
@@ -676,44 +698,50 @@ int wait_for_files(FiletransferOptions const *opts)
DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system-filetransfer, waiting for files."));
static char buf[INOTIFY_LEN];
ssize_t len = read(ino.handle, buf, INOTIFY_LEN);
- if(len < 0)
- {
+
+ if (len < 0) {
DLT_LOG(filetransferContext, DLT_LOG_ERROR,
DLT_STRING("Error while waiting for files in dlt-system file transfer."));
return -1;
}
unsigned int i = 0;
- while(i < (len-INOTIFY_SZ))
- {
+
+ while (i < (len - INOTIFY_SZ)) {
struct inotify_event *ie = (struct inotify_event *)&buf[i];
- if(ie->len > 0)
- {
- if((ie->mask & IN_CLOSE_WRITE) || (ie->mask & IN_MOVED_TO))
- {
+
+ if (ie->len > 0) {
+ if ((ie->mask & IN_CLOSE_WRITE) || (ie->mask & IN_MOVED_TO)) {
int j;
- for(j = 0;j < opts->Count;j++)
- {
- if(ie->wd == ino.fd[j])
- {
- DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system-filetransfer, found new file."), DLT_STRING(ie->name));
- int length = strlen(opts->Directory[j])+ie->len+1;
- if (length > PATH_MAX)
- {
- DLT_LOG(filetransferContext, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-filetransfer: Very long path for file transfer. Cancelling transfer! Length is: "),DLT_INT(length));
+
+ for (j = 0; j < opts->Count; j++)
+ if (ie->wd == ino.fd[j]) {
+ DLT_LOG(dltsystem,
+ DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-filetransfer, found new file."),
+ DLT_STRING(ie->name));
+ int length = strlen(opts->Directory[j]) + ie->len + 1;
+
+ if (length > PATH_MAX) {
+ DLT_LOG(filetransferContext,
+ DLT_LOG_ERROR,
+ DLT_STRING(
+ "dlt-system-filetransfer: Very long path for file transfer. Cancelling transfer! Length is: "),
+ DLT_INT(length));
return -1;
}
+
char *tosend = malloc(length);
- snprintf(tosend,length, "%s/%s", opts->Directory[j], ie->name);
+ snprintf(tosend, length, "%s/%s", opts->Directory[j], ie->name);
send_one(tosend, opts, j);
free(tosend);
}
- }
}
}
+
i += INOTIFY_SZ + ie->len;
}
+
#endif
return 0;
}
@@ -721,22 +749,21 @@ int wait_for_files(FiletransferOptions const *opts)
void filetransfer_thread(void *v_conf)
{
DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system-filetransfer, in thread."));
- DltSystemConfiguration *conf = (DltSystemConfiguration *) v_conf;
+ DltSystemConfiguration *conf = (DltSystemConfiguration *)v_conf;
DLT_REGISTER_CONTEXT(filetransferContext, conf->Filetransfer.ContextId,
"File transfer manager.");
sleep(conf->Filetransfer.TimeStartup);
- if(init_filetransfer_dirs(&(conf->Filetransfer)) < 0)
+ if (init_filetransfer_dirs(&(conf->Filetransfer)) < 0)
return;
- while(!threads.shutdown)
- {
- if(wait_for_files(&(conf->Filetransfer)) < 0)
- {
+ while (!threads.shutdown) {
+ if (wait_for_files(&(conf->Filetransfer)) < 0) {
DLT_LOG(dltsystem, DLT_LOG_ERROR, DLT_STRING("Error while waiting files. File transfer shutdown."));
return;
}
+
sleep(conf->Filetransfer.TimeDelay);
}
}
diff --git a/src/system/dlt-system-journal.c b/src/system/dlt-system-journal.c
index 5d9d7ef..32c6e13 100644
--- a/src/system/dlt-system-journal.c
+++ b/src/system/dlt-system-journal.c
@@ -65,12 +65,12 @@ extern DltSystemThreads threads;
#define DLT_SYSTEM_JOURNAL_BUFFER_SIZE_BIG 2048
#define DLT_SYSTEM_JOURNAL_ASCII_FIRST_VISIBLE_CHARACTER 31
-#define DLT_SYSTEM_JOURNAL_BOOT_ID_MAX_LENGTH 9+32+1
+#define DLT_SYSTEM_JOURNAL_BOOT_ID_MAX_LENGTH 9 + 32 + 1
typedef struct
{
- char real[DLT_SYSTEM_JOURNAL_BUFFER_SIZE];
- char monotonic[DLT_SYSTEM_JOURNAL_BUFFER_SIZE];
+ char real[DLT_SYSTEM_JOURNAL_BUFFER_SIZE];
+ char monotonic[DLT_SYSTEM_JOURNAL_BUFFER_SIZE];
} MessageTimestamp;
DLT_IMPORT_CONTEXT(dltsystem)
@@ -78,327 +78,321 @@ DLT_DECLARE_CONTEXT(journalContext)
int journal_checkUserBufferForFreeSpace()
{
- int total_size, used_size;
+ int total_size, used_size;
- dlt_user_check_buffer(&total_size, &used_size);
+ dlt_user_check_buffer(&total_size, &used_size);
- if((total_size - used_size) < (total_size/2))
- {
- return -1;
- }
- return 1;
+ if ((total_size - used_size) < (total_size / 2))
+ return -1;
+
+ return 1;
}
-int dlt_system_journal_get(sd_journal* j,char *target,const char *field,size_t max_size)
+int dlt_system_journal_get(sd_journal *j, char *target, const char *field, size_t max_size)
{
- char *data;
- size_t length;
- int error_code;
- size_t field_size;
-
- // pre check parameters
- if(max_size<1 || target == 0 || field == 0 || j == 0)
- return -1;
-
- // intialise empty target
- target[0]=0;
-
- // get data from journal
- error_code = sd_journal_get_data(j, field,(const void **) &data, &length);
-
- // check if an error
- if(error_code)
- return error_code;
-
- // calculate field size
- field_size = strlen(field)+1;
-
- //check length
- if(length<field_size)
- return -1;
-
- // copy string
- if(max_size<=(length-field_size))
- {
- // truncate
- strncpy(target,data+field_size,max_size-1);
- target[max_size-1]=0;
- }
- else
- {
- // full copy
- strncpy(target,data+field_size,length-field_size);
- target[length-field_size]=0;
-
- }
-
- // debug messages
- //printf("%s = %s\n",field,target);
-
- // Success
- return 0;
+ char *data;
+ size_t length;
+ int error_code;
+ size_t field_size;
+
+ /* pre check parameters */
+ if ((max_size < 1) || (target == 0) || (field == 0) || (j == 0))
+ return -1;
+
+ /* intialise empty target */
+ target[0] = 0;
+
+ /* get data from journal */
+ error_code = sd_journal_get_data(j, field, (const void **)&data, &length);
+
+ /* check if an error */
+ if (error_code)
+ return error_code;
+
+ /* calculate field size */
+ field_size = strlen(field) + 1;
+
+ /*check length */
+ if (length < field_size)
+ return -1;
+
+ /* copy string */
+ if (max_size <= (length - field_size)) {
+ /* truncate */
+ strncpy(target, data + field_size, max_size - 1);
+ target[max_size - 1] = 0;
+ }
+ else {
+ /* full copy */
+ strncpy(target, data + field_size, length - field_size);
+ target[length - field_size] = 0;
+
+ }
+
+ /* debug messages */
+ /*printf("%s = %s\n",field,target); */
+
+ /* Success */
+ return 0;
}
void dlt_system_journal_get_timestamp(sd_journal *journal, MessageTimestamp *timestamp)
{
- int ret = 0;
- uint64_t time_secs = 0;
- uint64_t time_usecs = 0;
- struct tm * timeinfo = NULL;
-
- char buffer_realtime[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 };
- char buffer_realtime_formatted[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 };
- char buffer_monotime[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 };
-
- /* Try to get realtime from message source and if not successful try to get realtime from journal entry */
- ret = dlt_system_journal_get(journal, buffer_realtime, "_SOURCE_REALTIME_TIMESTAMP", sizeof(buffer_realtime));
- if (ret == 0 && strlen(buffer_realtime) > 0)
- {
- errno = 0;
- time_usecs = strtoull(buffer_realtime, NULL, 10);
- if (errno != 0)
- time_usecs = 0;
- }
- else
- {
- if ((ret = sd_journal_get_realtime_usec(journal, &time_usecs)) < 0)
- {
- DLT_LOG(dltsystem, DLT_LOG_WARN,
- DLT_STRING("dlt-system-journal failed to get realtime: "),
- DLT_STRING(strerror(-ret)));
-
- /* just to be sure to have a defined value */
- time_usecs = 0;
- }
- }
-
- time_secs = time_usecs / 1000000;
- timeinfo = localtime((const time_t*) (&time_secs));
- strftime(buffer_realtime_formatted, sizeof(buffer_realtime_formatted), "%Y/%m/%d %H:%M:%S", timeinfo);
-
- snprintf(timestamp->real, sizeof(timestamp->real), "%s.%06"PRIu64, buffer_realtime_formatted, time_usecs % 1000000);
-
- /* Try to get monotonic time from message source and if not successful try to get monotonic time from journal entry */
- ret = dlt_system_journal_get(journal, buffer_monotime, "_SOURCE_MONOTONIC_TIMESTAMP", sizeof(buffer_monotime));
- if (ret == 0 && strlen(buffer_monotime) > 0)
- {
- errno = 0;
- time_usecs = strtoull(buffer_monotime, NULL, 10);
- if (errno != 0)
- time_usecs = 0;
- }
- else
- {
- if ((ret = sd_journal_get_monotonic_usec(journal, &time_usecs, NULL)) < 0)
- {
- DLT_LOG(dltsystem, DLT_LOG_WARN,
- DLT_STRING("dlt-system-journal failed to get monotonic time: "),
- DLT_STRING(strerror(-ret)));
-
- /* just to be sure to have a defined value */
- time_usecs = 0;
- }
- }
-
- snprintf(timestamp->monotonic, sizeof(timestamp->monotonic), "%"PRId64".%06"PRIu64, time_usecs / 1000000, time_usecs % 1000000);
+ int ret = 0;
+ uint64_t time_secs = 0;
+ uint64_t time_usecs = 0;
+ struct tm *timeinfo = NULL;
+
+ char buffer_realtime[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 };
+ char buffer_realtime_formatted[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 };
+ char buffer_monotime[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 };
+
+ /* Try to get realtime from message source and if not successful try to get realtime from journal entry */
+ ret = dlt_system_journal_get(journal, buffer_realtime, "_SOURCE_REALTIME_TIMESTAMP", sizeof(buffer_realtime));
+
+ if ((ret == 0) && (strlen(buffer_realtime) > 0)) {
+ errno = 0;
+ time_usecs = strtoull(buffer_realtime, NULL, 10);
+
+ if (errno != 0)
+ time_usecs = 0;
+ }
+ else if ((ret = sd_journal_get_realtime_usec(journal, &time_usecs)) < 0) {
+ DLT_LOG(dltsystem, DLT_LOG_WARN,
+ DLT_STRING("dlt-system-journal failed to get realtime: "),
+ DLT_STRING(strerror(-ret)));
+
+ /* just to be sure to have a defined value */
+ time_usecs = 0;
+ }
+
+ time_secs = time_usecs / 1000000;
+ timeinfo = localtime((const time_t *)(&time_secs));
+ strftime(buffer_realtime_formatted, sizeof(buffer_realtime_formatted), "%Y/%m/%d %H:%M:%S", timeinfo);
+
+ snprintf(timestamp->real, sizeof(timestamp->real), "%s.%06" PRIu64, buffer_realtime_formatted,
+ time_usecs % 1000000);
+
+ /* Try to get monotonic time from message source and if not successful try to get monotonic time from journal entry */
+ ret = dlt_system_journal_get(journal, buffer_monotime, "_SOURCE_MONOTONIC_TIMESTAMP", sizeof(buffer_monotime));
+
+ if ((ret == 0) && (strlen(buffer_monotime) > 0)) {
+ errno = 0;
+ time_usecs = strtoull(buffer_monotime, NULL, 10);
+
+ if (errno != 0)
+ time_usecs = 0;
+ }
+ else if ((ret = sd_journal_get_monotonic_usec(journal, &time_usecs, NULL)) < 0) {
+ DLT_LOG(dltsystem, DLT_LOG_WARN,
+ DLT_STRING("dlt-system-journal failed to get monotonic time: "),
+ DLT_STRING(strerror(-ret)));
+
+ /* just to be sure to have a defined value */
+ time_usecs = 0;
+ }
+
+ snprintf(timestamp->monotonic,
+ sizeof(timestamp->monotonic),
+ "%" PRId64 ".%06" PRIu64,
+ time_usecs / 1000000,
+ time_usecs % 1000000);
}
void journal_thread(void *v_conf)
{
- int r;
- sd_journal *j;
- char match[DLT_SYSTEM_JOURNAL_BOOT_ID_MAX_LENGTH] = "_BOOT_ID=";
- sd_id128_t boot_id;
-
- char buffer_process[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 },
- buffer_priority[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 },
- buffer_pid[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 },
- buffer_comm[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 },
+ int r;
+ sd_journal *j;
+ char match[DLT_SYSTEM_JOURNAL_BOOT_ID_MAX_LENGTH] = "_BOOT_ID=";
+ sd_id128_t boot_id;
+
+ char buffer_process[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 },
+ buffer_priority[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 },
+ buffer_pid[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 },
+ buffer_comm[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 },
buffer_message[DLT_SYSTEM_JOURNAL_BUFFER_SIZE_BIG] = { 0 },
- buffer_transport[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 };
+ buffer_transport[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 };
MessageTimestamp timestamp;
- int loglevel,systemd_loglevel;
- char* systemd_log_levels[] = { "Emergency","Alert","Critical","Error","Warning","Notice","Informational","Debug" };
-
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-journal, in thread."));
-
- DltSystemConfiguration *conf = (DltSystemConfiguration *) v_conf;
- DLT_REGISTER_CONTEXT(journalContext, conf->Journal.ContextId, "Journal Adapter");
-
- r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY/*SD_JOURNAL_LOCAL_ONLY|SD_JOURNAL_RUNTIME_ONLY*/);
- printf("journal open return %d\n", r);
- if (r < 0) {
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-journal, cannot open journal:"),DLT_STRING(strerror(-r)));
- printf("journal open failed: %s\n", strerror(-r));
- return;
- }
-
- if(conf->Journal.CurrentBoot)
- {
- /* show only current boot entries */
- r = sd_id128_get_boot(&boot_id);
- if(r<0)
- {
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-journal failed to get boot id:"),DLT_STRING(strerror(-r)));
- sd_journal_close(j);
- return;
-
- }
- sd_id128_to_string(boot_id, match + 9);
- r = sd_journal_add_match(j,match,strlen(match));
- if(r<0)
- {
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-journal failed to get match:"),DLT_STRING(strerror(-r)));
- sd_journal_close(j);
- return;
-
- }
- }
-
- if(conf->Journal.Follow)
- {
- /* show only last 10 entries and follow */
+ int loglevel, systemd_loglevel;
+ char *systemd_log_levels[] =
+ { "Emergency", "Alert", "Critical", "Error", "Warning", "Notice", "Informational", "Debug" };
+
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-journal, in thread."));
+
+ DltSystemConfiguration *conf = (DltSystemConfiguration *)v_conf;
+ DLT_REGISTER_CONTEXT(journalContext, conf->Journal.ContextId, "Journal Adapter");
+
+ r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY /*SD_JOURNAL_LOCAL_ONLY|SD_JOURNAL_RUNTIME_ONLY*/);
+ printf("journal open return %d\n", r);
+
+ if (r < 0) {
+ DLT_LOG(dltsystem, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-journal, cannot open journal:"), DLT_STRING(strerror(-r)));
+ printf("journal open failed: %s\n", strerror(-r));
+ return;
+ }
+
+ if (conf->Journal.CurrentBoot) {
+ /* show only current boot entries */
+ r = sd_id128_get_boot(&boot_id);
+
+ if (r < 0) {
+ DLT_LOG(dltsystem, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-journal failed to get boot id:"), DLT_STRING(strerror(-r)));
+ sd_journal_close(j);
+ return;
+
+ }
+
+ sd_id128_to_string(boot_id, match + 9);
+ r = sd_journal_add_match(j, match, strlen(match));
+
+ if (r < 0) {
+ DLT_LOG(dltsystem, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-journal failed to get match:"), DLT_STRING(strerror(-r)));
+ sd_journal_close(j);
+ return;
+
+ }
+ }
+
+ if (conf->Journal.Follow) {
+ /* show only last 10 entries and follow */
r = sd_journal_seek_tail(j);
- if(r<0)
- {
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-journal failed to seek to tail:"),DLT_STRING(strerror(-r)));
- sd_journal_close(j);
- return;
-
- }
+
+ if (r < 0) {
+ DLT_LOG(dltsystem, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-journal failed to seek to tail:"), DLT_STRING(strerror(-r)));
+ sd_journal_close(j);
+ return;
+
+ }
+
r = sd_journal_previous_skip(j, 10);
- if(r<0)
- {
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-journal failed to seek back 10 entries:"),DLT_STRING(strerror(-r)));
- sd_journal_close(j);
- return;
-
- }
-
- }
-
- while(!threads.shutdown)
- {
-
- r = sd_journal_next(j);
- if(r<0)
- {
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-journal failed to get next entry:"),DLT_STRING(strerror(-r)));
- sd_journal_close(j);
- return;
-
- }
- else if(r>0)
- {
- /* get all data from current journal entry */
- dlt_system_journal_get_timestamp(j, &timestamp);
-
- /* get data from journal entry, empty string if invalid fields */
- dlt_system_journal_get(j,buffer_comm,"_COMM",sizeof(buffer_comm));
- dlt_system_journal_get(j,buffer_pid,"_PID",sizeof(buffer_pid));
- dlt_system_journal_get(j,buffer_priority,"PRIORITY",sizeof(buffer_priority));
- dlt_system_journal_get(j,buffer_message,"MESSAGE",sizeof(buffer_message));
- dlt_system_journal_get(j,buffer_transport,"_TRANSPORT",sizeof(buffer_transport));
-
- /* prepare process string */
- if(strcmp(buffer_transport,"kernel")==0)
- snprintf(buffer_process,DLT_SYSTEM_JOURNAL_BUFFER_SIZE,"kernel:");
- else
- snprintf(buffer_process,DLT_SYSTEM_JOURNAL_BUFFER_SIZE,"%s[%s]:",buffer_comm,buffer_pid);
-
- /* map log level on demand */
- loglevel = DLT_LOG_INFO;
- systemd_loglevel = atoi(buffer_priority);
- if(conf->Journal.MapLogLevels)
- {
- /* Map log levels from journal to DLT */
- switch(systemd_loglevel)
- {
- case 0: /* Emergency */
- case 1: /* Alert */
- case 2: /* Critical */
- loglevel = DLT_LOG_FATAL;
- break;
- case 3: /* Error */
- loglevel = DLT_LOG_ERROR;
- break;
- case 4: /* Warning */
- loglevel = DLT_LOG_WARN;
- break;
- case 5: /* Notice */
- case 6: /* Informational */
- loglevel = DLT_LOG_INFO;
- break;
- case 7: /* Debug */
- loglevel = DLT_LOG_DEBUG;
- break;
- default:
- loglevel = DLT_LOG_INFO;
- break;
- }
- }
- if(systemd_loglevel>=0 && systemd_loglevel<=7)
- snprintf(buffer_priority,DLT_SYSTEM_JOURNAL_BUFFER_SIZE,"%s:",systemd_log_levels[systemd_loglevel]);
- else
- snprintf(buffer_priority,DLT_SYSTEM_JOURNAL_BUFFER_SIZE,"prio_unknown:");
-
- /* write log entry */
+
+ if (r < 0) {
+ DLT_LOG(dltsystem, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-journal failed to seek back 10 entries:"), DLT_STRING(strerror(-r)));
+ sd_journal_close(j);
+ return;
+
+ }
+ }
+
+ while (!threads.shutdown) {
+
+ r = sd_journal_next(j);
+
+ if (r < 0) {
+ DLT_LOG(dltsystem, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-journal failed to get next entry:"), DLT_STRING(strerror(-r)));
+ sd_journal_close(j);
+ return;
+
+ }
+ else if (r > 0)
+ {
+ /* get all data from current journal entry */
+ dlt_system_journal_get_timestamp(j, &timestamp);
+
+ /* get data from journal entry, empty string if invalid fields */
+ dlt_system_journal_get(j, buffer_comm, "_COMM", sizeof(buffer_comm));
+ dlt_system_journal_get(j, buffer_pid, "_PID", sizeof(buffer_pid));
+ dlt_system_journal_get(j, buffer_priority, "PRIORITY", sizeof(buffer_priority));
+ dlt_system_journal_get(j, buffer_message, "MESSAGE", sizeof(buffer_message));
+ dlt_system_journal_get(j, buffer_transport, "_TRANSPORT", sizeof(buffer_transport));
+
+ /* prepare process string */
+ if (strcmp(buffer_transport, "kernel") == 0)
+ snprintf(buffer_process, DLT_SYSTEM_JOURNAL_BUFFER_SIZE, "kernel:");
+ else
+ snprintf(buffer_process, DLT_SYSTEM_JOURNAL_BUFFER_SIZE, "%s[%s]:", buffer_comm, buffer_pid);
+
+ /* map log level on demand */
+ loglevel = DLT_LOG_INFO;
+ systemd_loglevel = atoi(buffer_priority);
+
+ if (conf->Journal.MapLogLevels) {
+ /* Map log levels from journal to DLT */
+ switch (systemd_loglevel) {
+ case 0: /* Emergency */
+ case 1: /* Alert */
+ case 2: /* Critical */
+ loglevel = DLT_LOG_FATAL;
+ break;
+ case 3: /* Error */
+ loglevel = DLT_LOG_ERROR;
+ break;
+ case 4: /* Warning */
+ loglevel = DLT_LOG_WARN;
+ break;
+ case 5: /* Notice */
+ case 6: /* Informational */
+ loglevel = DLT_LOG_INFO;
+ break;
+ case 7: /* Debug */
+ loglevel = DLT_LOG_DEBUG;
+ break;
+ default:
+ loglevel = DLT_LOG_INFO;
+ break;
+ }
+ }
+
+ if ((systemd_loglevel >= 0) && (systemd_loglevel <= 7))
+ snprintf(buffer_priority, DLT_SYSTEM_JOURNAL_BUFFER_SIZE, "%s:", systemd_log_levels[systemd_loglevel]);
+ else
+ snprintf(buffer_priority, DLT_SYSTEM_JOURNAL_BUFFER_SIZE, "prio_unknown:");
+
+ /* write log entry */
DLT_LOG(journalContext, loglevel,
- DLT_STRING(timestamp.real),
- DLT_STRING(timestamp.monotonic),
- DLT_STRING(buffer_process),
- DLT_STRING(buffer_priority),
- DLT_STRING(buffer_message)
- );
- }
- else
- {
- r = sd_journal_wait(j,1000000);
- if(r<0)
- {
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-journal failed to call sd_journal_get_realtime_usec(): "),DLT_STRING(strerror(-r)));
- sd_journal_close(j);
- return;
-
- }
- }
-
- if(journal_checkUserBufferForFreeSpace()==-1)
- {
- // buffer is nearly full
- // wait 500ms for writing next entry
- struct timespec t;
- t.tv_sec = 0;
- t.tv_nsec = 1000000ul*500;
- nanosleep(&t, NULL);
- }
-
- }
+ DLT_STRING(timestamp.real),
+ DLT_STRING(timestamp.monotonic),
+ DLT_STRING(buffer_process),
+ DLT_STRING(buffer_priority),
+ DLT_STRING(buffer_message)
+ );
+ }
+ else {
+ r = sd_journal_wait(j, 1000000);
+
+ if (r < 0) {
+ DLT_LOG(dltsystem, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-journal failed to call sd_journal_get_realtime_usec(): "),
+ DLT_STRING(strerror(-r)));
+ sd_journal_close(j);
+ return;
+
+ }
+ }
+
+ if (journal_checkUserBufferForFreeSpace() == -1) {
+ /* buffer is nearly full */
+ /* wait 500ms for writing next entry */
+ struct timespec t;
+ t.tv_sec = 0;
+ t.tv_nsec = 1000000ul * 500;
+ nanosleep(&t, NULL);
+ }
+ }
sd_journal_close(j);
- DLT_UNREGISTER_CONTEXT(journalContext);
+ DLT_UNREGISTER_CONTEXT(journalContext);
}
void start_systemd_journal(DltSystemConfiguration *conf)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-journal, start journal"));
- static pthread_attr_t t_attr;
- static pthread_t pt;
- pthread_create(&pt, &t_attr, (void *)journal_thread, conf);
- threads.threads[threads.count++] = pt;
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-journal, start journal"));
+ static pthread_attr_t t_attr;
+ static pthread_t pt;
+ pthread_create(&pt, &t_attr, (void *)journal_thread, conf);
+ threads.threads[threads.count++] = pt;
}
#endif /* DLT_SYSTEMD_JOURNAL_ENABLE */
diff --git a/src/system/dlt-system-logfile.c b/src/system/dlt-system-logfile.c
index 687d739..dae557f 100644
--- a/src/system/dlt-system-logfile.c
+++ b/src/system/dlt-system-logfile.c
@@ -50,7 +50,7 @@
#include <unistd.h>
#include "dlt-system.h"
-// Modes of sending
+/* Modes of sending */
#define SEND_MODE_OFF 0
#define SEND_MODE_ONCE 1
#define SEND_MODE_ON 2
@@ -62,98 +62,96 @@ DltContext logfileContext[DLT_SYSTEM_LOG_FILE_MAX];
void send_file(LogFileOptions const *fileopt, int n)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-logfile, sending file."));
- FILE * pFile;
- DltContext context = logfileContext[n];
- char buffer[1024];
- int bytes;
- int seq = 1;
-
- pFile = fopen((*fileopt).Filename[n],"r");
-
- if(pFile != NULL)
- {
- while (!feof(pFile)) {
- bytes = fread(buffer,1,sizeof(buffer)-1,pFile);
- if(bytes>=0)
- buffer[bytes] = 0;
- else
- buffer[0] = 0;
-
- if(feof(pFile)) {
- DLT_LOG(context, DLT_LOG_INFO, DLT_INT(seq*-1), DLT_STRING(buffer));
- break;
- }
- else {
- DLT_LOG(context, DLT_LOG_INFO, DLT_INT(seq++), DLT_STRING(buffer));
- }
- }
- fclose(pFile);
- }
- else
- {
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-logfile, failed to open file."),
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-logfile, sending file."));
+ FILE *pFile;
+ DltContext context = logfileContext[n];
+ char buffer[1024];
+ int bytes;
+ int seq = 1;
+
+ pFile = fopen((*fileopt).Filename[n], "r");
+
+ if (pFile != NULL) {
+ while (!feof(pFile)) {
+ bytes = fread(buffer, 1, sizeof(buffer) - 1, pFile);
+
+ if (bytes >= 0)
+ buffer[bytes] = 0;
+ else
+ buffer[0] = 0;
+
+ if (feof(pFile)) {
+ DLT_LOG(context, DLT_LOG_INFO, DLT_INT(seq * -1), DLT_STRING(buffer));
+ break;
+ }
+ else {
+ DLT_LOG(context, DLT_LOG_INFO, DLT_INT(seq++), DLT_STRING(buffer));
+ }
+ }
+
+ fclose(pFile);
+ }
+ else {
+ DLT_LOG(dltsystem, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-logfile, failed to open file."),
DLT_STRING((*fileopt).Filename[n]));
- }
+ }
}
void register_contexts(LogFileOptions const *fileopts)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-logfile, registering file contexts."));
- int i;
- for(i = 0;i < (*fileopts).Count;i++)
- {
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-logfile, registering file contexts."));
+ int i;
+
+ for (i = 0; i < (*fileopts).Count; i++)
DLT_REGISTER_CONTEXT(logfileContext[i], (*fileopts).ContextId[i],
- (*fileopts).Filename[i]);
- }
+ (*fileopts).Filename[i]);
}
void logfile_thread(void *v_conf)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-logfile, in thread."));
- DltSystemConfiguration *conf = (DltSystemConfiguration *) v_conf;
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-logfile, in thread."));
+ DltSystemConfiguration *conf = (DltSystemConfiguration *)v_conf;
register_contexts(&(conf->LogFile));
- int logfile_delays[DLT_SYSTEM_LOG_FILE_MAX];
- int i;
- for(i = 0;i < conf->LogFile.Count;i++)
- logfile_delays[i] = conf->LogFile.TimeDelay[i];
-
- while(!threads.shutdown)
- {
- sleep(1);
- for(i = 0;i < conf->LogFile.Count;i++)
- {
- if(conf->LogFile.Mode[i] == SEND_MODE_OFF)
- continue;
-
- if(logfile_delays[i] <= 0)
- {
+ int logfile_delays[DLT_SYSTEM_LOG_FILE_MAX];
+ int i;
+
+ for (i = 0; i < conf->LogFile.Count; i++)
+ logfile_delays[i] = conf->LogFile.TimeDelay[i];
+
+ while (!threads.shutdown) {
+ sleep(1);
+
+ for (i = 0; i < conf->LogFile.Count; i++) {
+ if (conf->LogFile.Mode[i] == SEND_MODE_OFF)
+ continue;
+
+ if (logfile_delays[i] <= 0) {
send_file(&(conf->LogFile), i);
- logfile_delays[i] = conf->LogFile.TimeDelay[i];
- if(conf->LogFile.Mode[i] == SEND_MODE_ONCE)
- conf->LogFile.Mode[i] = SEND_MODE_OFF;
- }
- else
- {
- logfile_delays[i]--;
- }
- }
- }
+ logfile_delays[i] = conf->LogFile.TimeDelay[i];
+
+ if (conf->LogFile.Mode[i] == SEND_MODE_ONCE)
+ conf->LogFile.Mode[i] = SEND_MODE_OFF;
+ }
+ else {
+ logfile_delays[i]--;
+ }
+ }
+ }
}
void start_logfile(DltSystemConfiguration *conf)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-logfile, starting."));
- DLT_LOG(dltsystem,DLT_LOG_DEBUG,DLT_STRING("Starting thread for logfile"));
- static pthread_attr_t t_attr;
- static pthread_t pt;
- pthread_create(&pt, &t_attr, (void *)logfile_thread, conf);
- threads.threads[threads.count++] = pt;
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-logfile, starting."));
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("Starting thread for logfile"));
+ static pthread_attr_t t_attr;
+ static pthread_t pt;
+ pthread_create(&pt, &t_attr, (void *)logfile_thread, conf);
+ threads.threads[threads.count++] = pt;
}
diff --git a/src/system/dlt-system-options.c b/src/system/dlt-system-options.c
index 01f2d65..63f2e37 100644
--- a/src/system/dlt-system-options.c
+++ b/src/system/dlt-system-options.c
@@ -65,17 +65,17 @@
*/
void usage(char *prog_name)
{
- char version[255];
- dlt_get_version(version,255);
-
- printf("Usage: %s [options]\n", prog_name);
- printf("Application to forward syslog messages to DLT, transfer system information, logs and files.\n");
- printf("%s\n", version);
- printf("Options:\n");
- printf(" -d Daemonize. Detach from terminal and run in background.\n");
- printf(" -c filename Use configuration file. \n");
- printf(" Default: %s\n", DEFAULT_CONF_FILE);
- printf(" -h This help message.\n");
+ char version[255];
+ dlt_get_version(version, 255);
+
+ printf("Usage: %s [options]\n", prog_name);
+ printf("Application to forward syslog messages to DLT, transfer system information, logs and files.\n");
+ printf("%s\n", version);
+ printf("Options:\n");
+ printf(" -d Daemonize. Detach from terminal and run in background.\n");
+ printf(" -c filename Use configuration file. \n");
+ printf(" Default: %s\n", DEFAULT_CONF_FILE);
+ printf(" -h This help message.\n");
}
/**
@@ -83,8 +83,8 @@ void usage(char *prog_name)
*/
void init_cli_options(DltSystemCliOptions *options)
{
- options->ConfigurationFileName = DEFAULT_CONF_FILE;
- options->Daemonize = 0;
+ options->ConfigurationFileName = DEFAULT_CONF_FILE;
+ options->Daemonize = 0;
}
/**
@@ -92,39 +92,38 @@ void init_cli_options(DltSystemCliOptions *options)
*/
int read_command_line(DltSystemCliOptions *options, int argc, char *argv[])
{
- init_cli_options(options);
- int opt;
-
- while((opt = getopt(argc, argv, "c:hd")) != -1)
- {
- switch(opt) {
- case 'd':
- {
- options->Daemonize = 1;
- break;
- }
- case 'c':
- {
- options->ConfigurationFileName = malloc(strlen(optarg)+1);
- MALLOC_ASSERT(options->ConfigurationFileName);
- strcpy(options->ConfigurationFileName, optarg); /* strcpy unritical here, because size matches exactly the size to be copied */
- break;
- }
- case 'h':
- {
- usage(argv[0]);
- exit(0);
- return -1;//for parasoft
- }
- default:
- {
- fprintf(stderr, "Unknown option '%c'\n", optopt);
- usage(argv[0]);
- return -1;
- }
- }
- }
- return 0;
+ init_cli_options(options);
+ int opt;
+
+ while ((opt = getopt(argc, argv, "c:hd")) != -1)
+ switch (opt) {
+ case 'd':
+ {
+ options->Daemonize = 1;
+ break;
+ }
+ case 'c':
+ {
+ options->ConfigurationFileName = malloc(strlen(optarg) + 1);
+ MALLOC_ASSERT(options->ConfigurationFileName);
+ strcpy(options->ConfigurationFileName, optarg); /* strcpy unritical here, because size matches exactly the size to be copied */
+ break;
+ }
+ case 'h':
+ {
+ usage(argv[0]);
+ exit(0);
+ return -1; /*for parasoft */
+ }
+ default:
+ {
+ fprintf(stderr, "Unknown option '%c'\n", optopt);
+ usage(argv[0]);
+ return -1;
+ }
+ }
+
+ return 0;
}
/**
@@ -132,62 +131,62 @@ int read_command_line(DltSystemCliOptions *options, int argc, char *argv[])
*/
void init_configuration(DltSystemConfiguration *config)
{
- int i = 0;
-
- // Common
- config->ApplicationId = "SYS";
-
- // Shell
- config->Shell.Enable = 0;
-
- // Syslog
- config->Syslog.Enable = 0;
- config->Syslog.ContextId = "SYSL";
- config->Syslog.Port = 47111;
-
- // Journal
- config->Journal.Enable = 0;
- config->Journal.ContextId = "JOUR";
- config->Journal.CurrentBoot = 1;
- config->Journal.Follow = 0;
- config->Journal.MapLogLevels = 1;
-
- // File transfer
- config->Filetransfer.Enable = 0;
- config->Filetransfer.ContextId = "FILE";
- config->Filetransfer.TimeDelay = 10;
- config->Filetransfer.TimeStartup = 30;
- config->Filetransfer.TimeoutBetweenLogs = 10;
- config->Filetransfer.Count = 0;
- for(i = 0;i < DLT_SYSTEM_LOG_DIRS_MAX;i++)
- {
- config->Filetransfer.Directory[i] = NULL;
- config->Filetransfer.Compression[i] = 0;
- config->Filetransfer.CompressionLevel[i] = 5;
- }
-
- // Log file
- config->LogFile.Enable = 0;
- config->LogFile.Count = 0;
- for(i = 0;i < DLT_SYSTEM_LOG_FILE_MAX;i++)
- {
- config->LogFile.ContextId[i] = NULL;
- config->LogFile.Filename[i] = NULL;
- config->LogFile.Mode[i] = 0;
- config->LogFile.TimeDelay[i] = 0;
- }
-
- // Log process
- config->LogProcesses.Enable = 0;
- config->LogProcesses.ContextId = "PROC";
- config->LogProcesses.Count = 0;
- for(i = 0;i < DLT_SYSTEM_LOG_PROCESSES_MAX;i++)
- {
- config->LogProcesses.Name[i] = NULL;
- config->LogProcesses.Filename[i] = NULL;
- config->LogProcesses.Mode[i] = 0;
- config->LogProcesses.TimeDelay[i] = 0;
- }
+ int i = 0;
+
+ /* Common */
+ config->ApplicationId = "SYS";
+
+ /* Shell */
+ config->Shell.Enable = 0;
+
+ /* Syslog */
+ config->Syslog.Enable = 0;
+ config->Syslog.ContextId = "SYSL";
+ config->Syslog.Port = 47111;
+
+ /* Journal */
+ config->Journal.Enable = 0;
+ config->Journal.ContextId = "JOUR";
+ config->Journal.CurrentBoot = 1;
+ config->Journal.Follow = 0;
+ config->Journal.MapLogLevels = 1;
+
+ /* File transfer */
+ config->Filetransfer.Enable = 0;
+ config->Filetransfer.ContextId = "FILE";
+ config->Filetransfer.TimeDelay = 10;
+ config->Filetransfer.TimeStartup = 30;
+ config->Filetransfer.TimeoutBetweenLogs = 10;
+ config->Filetransfer.Count = 0;
+
+ for (i = 0; i < DLT_SYSTEM_LOG_DIRS_MAX; i++) {
+ config->Filetransfer.Directory[i] = NULL;
+ config->Filetransfer.Compression[i] = 0;
+ config->Filetransfer.CompressionLevel[i] = 5;
+ }
+
+ /* Log file */
+ config->LogFile.Enable = 0;
+ config->LogFile.Count = 0;
+
+ for (i = 0; i < DLT_SYSTEM_LOG_FILE_MAX; i++) {
+ config->LogFile.ContextId[i] = NULL;
+ config->LogFile.Filename[i] = NULL;
+ config->LogFile.Mode[i] = 0;
+ config->LogFile.TimeDelay[i] = 0;
+ }
+
+ /* Log process */
+ config->LogProcesses.Enable = 0;
+ config->LogProcesses.ContextId = "PROC";
+ config->LogProcesses.Count = 0;
+
+ for (i = 0; i < DLT_SYSTEM_LOG_PROCESSES_MAX; i++) {
+ config->LogProcesses.Name[i] = NULL;
+ config->LogProcesses.Filename[i] = NULL;
+ config->LogProcesses.Mode[i] = 0;
+ config->LogProcesses.TimeDelay[i] = 0;
+ }
}
/**
@@ -195,254 +194,244 @@ void init_configuration(DltSystemConfiguration *config)
*/
int read_configuration_file(DltSystemConfiguration *config, char *file_name)
{
- FILE *file;
- char *line, *token, *value, *pch;
- int ret = 0;
-
- init_configuration(config);
-
- file = fopen(file_name, "r");
-
- if(file == NULL)
- {
- fprintf(stderr, "dlt-system-options, could not open configuration file.\n");
- return -1;
- }
-
- line = malloc(MAX_LINE);
- token = malloc(MAX_LINE);
- value = malloc(MAX_LINE);
-
- MALLOC_ASSERT(line);
- MALLOC_ASSERT(token);
- MALLOC_ASSERT(value);
-
- while(fgets(line, MAX_LINE, file) != NULL)
- {
- token[0] = 0;
- value[0] = 0;
-
- pch = strtok (line, " =\r\n");
- while(pch != NULL)
- {
- if(pch[0] == '#')
- break;
-
- if(token[0] == 0)
- {
- strncpy(token, pch, MAX_LINE-1);
- token[MAX_LINE-1]=0;
- }
- else
- {
- strncpy(value, pch, MAX_LINE);
- value[MAX_LINE-1]=0;
- break;
- }
-
- pch = strtok (NULL, " =\r\n");
- }
-
- if(token[0] && value[0])
- {
- // Common
- if(strcmp(token, "ApplicationId") == 0)
- {
- config->ApplicationId = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->ApplicationId);
- strcpy(config->ApplicationId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
- }
-
- // Shell
- else if(strcmp(token, "ShellEnable") == 0)
- {
- config->Shell.Enable = atoi(value);
- }
-
- // Syslog
- else if(strcmp(token, "SyslogEnable") == 0)
- {
- config->Syslog.Enable = atoi(value);
- }
- else if(strcmp(token, "SyslogContextId") == 0)
- {
- config->Syslog.ContextId = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->Syslog.ContextId);
- strcpy(config->Syslog.ContextId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
- }
- else if(strcmp(token, "SyslogPort") == 0)
- {
- config->Syslog.Port = atoi(value);
- }
-
- // Journal
- else if(strcmp(token, "JournalEnable") == 0)
- {
- config->Journal.Enable = atoi(value);
- }
- else if(strcmp(token, "JournalContextId") == 0)
- {
- config->Journal.ContextId = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->Journal.ContextId);
- strcpy(config->Journal.ContextId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
- }
- else if(strcmp(token, "JournalCurrentBoot") == 0)
- {
- config->Journal.CurrentBoot = atoi(value);
- }
- else if(strcmp(token, "JournalFollow") == 0)
- {
- config->Journal.Follow = atoi(value);
- }
- else if(strcmp(token, "JournalMapLogLevels") == 0)
- {
- config->Journal.MapLogLevels = atoi(value);
- }
-
- // File transfer
- else if(strcmp(token, "FiletransferEnable") == 0)
- {
- config->Filetransfer.Enable = atoi(value);
- }
- else if(strcmp(token, "FiletransferContextId") == 0)
- {
- config->Filetransfer.ContextId = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->Filetransfer.ContextId);
- strcpy(config->Filetransfer.ContextId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
- }
- else if(strcmp(token, "FiletransferTimeStartup") == 0)
- {
- config->Filetransfer.TimeStartup = atoi(value);
- }
- else if(strcmp(token, "FiletransferTimeDelay") == 0)
- {
- config->Filetransfer.TimeDelay = atoi(value);
- }
- else if(strcmp(token, "FiletransferTimeoutBetweenLogs") == 0)
- {
- config->Filetransfer.TimeoutBetweenLogs = atoi(value);
- }
- else if(strcmp(token, "FiletransferTempDir") == 0)
- {
- config->Filetransfer.TempDir = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->Filetransfer.TempDir);
- strcpy(config->Filetransfer.TempDir, value); /* strcpy unritical here, because size matches exactly the size to be copied */
- }
- else if(strcmp(token, "FiletransferDirectory") == 0)
- {
- config->Filetransfer.Directory[config->Filetransfer.Count] = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->Filetransfer.Directory[config->Filetransfer.Count]);
- strcpy(config->Filetransfer.Directory[config->Filetransfer.Count], value); /* strcpy unritical here, because size matches exactly the size to be copied */
- }
- else if(strcmp(token, "FiletransferCompression") == 0)
- {
- config->Filetransfer.Compression[config->Filetransfer.Count] = atoi(value);
- }
- else if(strcmp(token, "FiletransferCompressionLevel") == 0)
- {
- config->Filetransfer.CompressionLevel[config->Filetransfer.Count] = atoi(value);
- if(config->Filetransfer.Count < (DLT_SYSTEM_LOG_DIRS_MAX - 1))
- {
- config->Filetransfer.Count++;
- }
- else
- {
- fprintf(stderr,
- "Too many file transfer directories configured. Maximum: %d\n",
- DLT_SYSTEM_LOG_DIRS_MAX);
- ret = -1;
- break;
- }
- }
-
- // Log files
- else if(strcmp(token, "LogFileEnable") == 0)
- {
- config->LogFile.Enable = atoi(value);
- }
- else if(strcmp(token, "LogFileFilename") == 0)
- {
- config->LogFile.Filename[config->LogFile.Count] = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->LogFile.Filename[config->LogFile.Count]);
- strcpy(config->LogFile.Filename[config->LogFile.Count], value); /* strcpy unritical here, because size matches exactly the size to be copied */
- }
- else if(strcmp(token, "LogFileMode") == 0)
- {
- config->LogFile.Mode[config->LogFile.Count] = atoi(value);
- }
- else if(strcmp(token, "LogFileTimeDelay") == 0)
- {
- config->LogFile.TimeDelay[config->LogFile.Count] = atoi(value);
- }
- else if(strcmp(token, "LogFileContextId") == 0)
- {
- config->LogFile.ContextId[config->LogFile.Count] = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->LogFile.ContextId[config->LogFile.Count]);
- strcpy(config->LogFile.ContextId[config->LogFile.Count], value); /* strcpy unritical here, because size matches exactly the size to be copied */
- if(config->LogFile.Count < (DLT_SYSTEM_LOG_FILE_MAX - 1))
- {
- config->LogFile.Count++;
- }
- else
- {
- fprintf(stderr,
- "Too many log files configured. Maximum: %d\n",
- DLT_SYSTEM_LOG_FILE_MAX);
- ret = -1;
- break;
- }
-
- }
-
- // Log Processes
- else if(strcmp(token, "LogProcessesEnable") == 0)
- {
- config->LogProcesses.Enable = atoi(value);
- }
- else if(strcmp(token, "LogProcessesContextId") == 0)
- {
- config->LogProcesses.ContextId = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->LogProcesses.ContextId);
- strcpy(config->LogProcesses.ContextId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
- }
- else if(strcmp(token, "LogProcessName") == 0)
- {
- config->LogProcesses.Name[config->LogProcesses.Count] = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->LogProcesses.Name[config->LogProcesses.Count]);
- strcpy(config->LogProcesses.Name[config->LogProcesses.Count], value); /* strcpy unritical here, because size matches exactly the size to be copied */
- }
- else if(strcmp(token, "LogProcessFilename") == 0)
- {
- config->LogProcesses.Filename[config->LogProcesses.Count] = malloc(strlen(value)+1);
- MALLOC_ASSERT(config->LogProcesses.Filename[config->LogProcesses.Count]);
- strcpy(config->LogProcesses.Filename[config->LogProcesses.Count], value); /* strcpy unritical here, because size matches exactly the size to be copied */
- }
- else if(strcmp(token, "LogProcessMode") == 0)
- {
- config->LogProcesses.Mode[config->LogProcesses.Count] = atoi(value);
- }
- else if(strcmp(token, "LogProcessTimeDelay") == 0)
- {
- config->LogProcesses.TimeDelay[config->LogProcesses.Count] = atoi(value);
- if(config->LogProcesses.Count < (DLT_SYSTEM_LOG_PROCESSES_MAX - 1))
- {
- config->LogProcesses.Count++;
- }
- else
- {
- fprintf(stderr,
- "Too many processes to log configured. Maximum: %d\n",
- DLT_SYSTEM_LOG_PROCESSES_MAX);
- ret = -1;
- break;
- }
-
- }
- }
- }
- fclose(file);
- free(value);
- free(token);
- free(line);
- return ret;
+ FILE *file;
+ char *line, *token, *value, *pch;
+ int ret = 0;
+
+ init_configuration(config);
+
+ file = fopen(file_name, "r");
+
+ if (file == NULL) {
+ fprintf(stderr, "dlt-system-options, could not open configuration file.\n");
+ return -1;
+ }
+
+ line = malloc(MAX_LINE);
+ token = malloc(MAX_LINE);
+ value = malloc(MAX_LINE);
+
+ MALLOC_ASSERT(line);
+ MALLOC_ASSERT(token);
+ MALLOC_ASSERT(value);
+
+ while (fgets(line, MAX_LINE, file) != NULL) {
+ token[0] = 0;
+ value[0] = 0;
+
+ pch = strtok (line, " =\r\n");
+
+ while (pch != NULL) {
+ if (pch[0] == '#')
+ break;
+
+ if (token[0] == 0) {
+ strncpy(token, pch, MAX_LINE - 1);
+ token[MAX_LINE - 1] = 0;
+ }
+ else {
+ strncpy(value, pch, MAX_LINE);
+ value[MAX_LINE - 1] = 0;
+ break;
+ }
+
+ pch = strtok (NULL, " =\r\n");
+ }
+
+ if (token[0] && value[0]) {
+ /* Common */
+ if (strcmp(token, "ApplicationId") == 0) {
+ config->ApplicationId = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->ApplicationId);
+ strcpy(config->ApplicationId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
+ }
+
+ /* Shell */
+ else if (strcmp(token, "ShellEnable") == 0)
+ {
+ config->Shell.Enable = atoi(value);
+ }
+
+ /* Syslog */
+ else if (strcmp(token, "SyslogEnable") == 0)
+ {
+ config->Syslog.Enable = atoi(value);
+ }
+ else if (strcmp(token, "SyslogContextId") == 0)
+ {
+ config->Syslog.ContextId = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->Syslog.ContextId);
+ strcpy(config->Syslog.ContextId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
+ }
+ else if (strcmp(token, "SyslogPort") == 0)
+ {
+ config->Syslog.Port = atoi(value);
+ }
+
+ /* Journal */
+ else if (strcmp(token, "JournalEnable") == 0)
+ {
+ config->Journal.Enable = atoi(value);
+ }
+ else if (strcmp(token, "JournalContextId") == 0)
+ {
+ config->Journal.ContextId = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->Journal.ContextId);
+ strcpy(config->Journal.ContextId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
+ }
+ else if (strcmp(token, "JournalCurrentBoot") == 0)
+ {
+ config->Journal.CurrentBoot = atoi(value);
+ }
+ else if (strcmp(token, "JournalFollow") == 0)
+ {
+ config->Journal.Follow = atoi(value);
+ }
+ else if (strcmp(token, "JournalMapLogLevels") == 0)
+ {
+ config->Journal.MapLogLevels = atoi(value);
+ }
+
+ /* File transfer */
+ else if (strcmp(token, "FiletransferEnable") == 0)
+ {
+ config->Filetransfer.Enable = atoi(value);
+ }
+ else if (strcmp(token, "FiletransferContextId") == 0)
+ {
+ config->Filetransfer.ContextId = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->Filetransfer.ContextId);
+ strcpy(config->Filetransfer.ContextId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
+ }
+ else if (strcmp(token, "FiletransferTimeStartup") == 0)
+ {
+ config->Filetransfer.TimeStartup = atoi(value);
+ }
+ else if (strcmp(token, "FiletransferTimeDelay") == 0)
+ {
+ config->Filetransfer.TimeDelay = atoi(value);
+ }
+ else if (strcmp(token, "FiletransferTimeoutBetweenLogs") == 0)
+ {
+ config->Filetransfer.TimeoutBetweenLogs = atoi(value);
+ }
+ else if (strcmp(token, "FiletransferTempDir") == 0)
+ {
+ config->Filetransfer.TempDir = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->Filetransfer.TempDir);
+ strcpy(config->Filetransfer.TempDir, value); /* strcpy unritical here, because size matches exactly the size to be copied */
+ }
+ else if (strcmp(token, "FiletransferDirectory") == 0)
+ {
+ config->Filetransfer.Directory[config->Filetransfer.Count] = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->Filetransfer.Directory[config->Filetransfer.Count]);
+ strcpy(config->Filetransfer.Directory[config->Filetransfer.Count], value); /* strcpy unritical here, because size matches exactly the size to be copied */
+ }
+ else if (strcmp(token, "FiletransferCompression") == 0)
+ {
+ config->Filetransfer.Compression[config->Filetransfer.Count] = atoi(value);
+ }
+ else if (strcmp(token, "FiletransferCompressionLevel") == 0)
+ {
+ config->Filetransfer.CompressionLevel[config->Filetransfer.Count] = atoi(value);
+
+ if (config->Filetransfer.Count < (DLT_SYSTEM_LOG_DIRS_MAX - 1)) {
+ config->Filetransfer.Count++;
+ }
+ else {
+ fprintf(stderr,
+ "Too many file transfer directories configured. Maximum: %d\n",
+ DLT_SYSTEM_LOG_DIRS_MAX);
+ ret = -1;
+ break;
+ }
+ }
+
+ /* Log files */
+ else if (strcmp(token, "LogFileEnable") == 0)
+ {
+ config->LogFile.Enable = atoi(value);
+ }
+ else if (strcmp(token, "LogFileFilename") == 0)
+ {
+ config->LogFile.Filename[config->LogFile.Count] = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->LogFile.Filename[config->LogFile.Count]);
+ strcpy(config->LogFile.Filename[config->LogFile.Count], value); /* strcpy unritical here, because size matches exactly the size to be copied */
+ }
+ else if (strcmp(token, "LogFileMode") == 0)
+ {
+ config->LogFile.Mode[config->LogFile.Count] = atoi(value);
+ }
+ else if (strcmp(token, "LogFileTimeDelay") == 0)
+ {
+ config->LogFile.TimeDelay[config->LogFile.Count] = atoi(value);
+ }
+ else if (strcmp(token, "LogFileContextId") == 0)
+ {
+ config->LogFile.ContextId[config->LogFile.Count] = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->LogFile.ContextId[config->LogFile.Count]);
+ strcpy(config->LogFile.ContextId[config->LogFile.Count], value); /* strcpy unritical here, because size matches exactly the size to be copied */
+
+ if (config->LogFile.Count < (DLT_SYSTEM_LOG_FILE_MAX - 1)) {
+ config->LogFile.Count++;
+ }
+ else {
+ fprintf(stderr,
+ "Too many log files configured. Maximum: %d\n",
+ DLT_SYSTEM_LOG_FILE_MAX);
+ ret = -1;
+ break;
+ }
+ }
+
+ /* Log Processes */
+ else if (strcmp(token, "LogProcessesEnable") == 0)
+ {
+ config->LogProcesses.Enable = atoi(value);
+ }
+ else if (strcmp(token, "LogProcessesContextId") == 0)
+ {
+ config->LogProcesses.ContextId = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->LogProcesses.ContextId);
+ strcpy(config->LogProcesses.ContextId, value); /* strcpy unritical here, because size matches exactly the size to be copied */
+ }
+ else if (strcmp(token, "LogProcessName") == 0)
+ {
+ config->LogProcesses.Name[config->LogProcesses.Count] = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->LogProcesses.Name[config->LogProcesses.Count]);
+ strcpy(config->LogProcesses.Name[config->LogProcesses.Count], value); /* strcpy unritical here, because size matches exactly the size to be copied */
+ }
+ else if (strcmp(token, "LogProcessFilename") == 0)
+ {
+ config->LogProcesses.Filename[config->LogProcesses.Count] = malloc(strlen(value) + 1);
+ MALLOC_ASSERT(config->LogProcesses.Filename[config->LogProcesses.Count]);
+ strcpy(config->LogProcesses.Filename[config->LogProcesses.Count], value); /* strcpy unritical here, because size matches exactly the size to be copied */
+ }
+ else if (strcmp(token, "LogProcessMode") == 0)
+ {
+ config->LogProcesses.Mode[config->LogProcesses.Count] = atoi(value);
+ }
+ else if (strcmp(token, "LogProcessTimeDelay") == 0)
+ {
+ config->LogProcesses.TimeDelay[config->LogProcesses.Count] = atoi(value);
+
+ if (config->LogProcesses.Count < (DLT_SYSTEM_LOG_PROCESSES_MAX - 1)) {
+ config->LogProcesses.Count++;
+ }
+ else {
+ fprintf(stderr,
+ "Too many processes to log configured. Maximum: %d\n",
+ DLT_SYSTEM_LOG_PROCESSES_MAX);
+ ret = -1;
+ break;
+ }
+ }
+ }
+ }
+
+ fclose(file);
+ free(value);
+ free(token);
+ free(line);
+ return ret;
}
diff --git a/src/system/dlt-system-process-handling.c b/src/system/dlt-system-process-handling.c
index 21e2987..51c2547 100644
--- a/src/system/dlt-system-process-handling.c
+++ b/src/system/dlt-system-process-handling.c
@@ -61,88 +61,89 @@ DLT_IMPORT_CONTEXT(dltsystem)
int daemonize()
{
- DLT_LOG(dltsystem,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-process-handling, daemonize"));
-
- // Fork new process
- int f = fork();
-
- if(f < 0)
- return f;
- if(f > 0)
- exit(0);
-
- // Create a new process group
- if(setsid() < 0)
- return -1;
-
- /**
- * Close all file descriptors and point
- * stdin, stdout and stderr to /dev/null
- */
- int i;
- for(i = getdtablesize(); i >= 0; i--)
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-process-handling, daemonize"));
+
+ /* Fork new process */
+ int f = fork();
+
+ if (f < 0)
+ return f;
+
+ if (f > 0)
+ exit(0);
+
+ /* Create a new process group */
+ if (setsid() < 0)
+ return -1;
+
+ /**
+ * Close all file descriptors and point
+ * stdin, stdout and stderr to /dev/null
+ */
+ int i;
+
+ for (i = getdtablesize(); i >= 0; i--)
close(i);
- int fd = open("/dev/null",O_RDWR);
- if(fd < 0)
- {
+ int fd = open("/dev/null", O_RDWR);
+
+ if (fd < 0)
return -1;
- }
- if(dup(fd) < 0 || dup(fd) < 0)
- {
+ if ((dup(fd) < 0) || (dup(fd) < 0)) {
close(fd);
- return -1;
+ return -1;
}
- /**
- * Ignore signals related to child processes and
- * terminal handling.
- */
+ /**
+ * Ignore signals related to child processes and
+ * terminal handling.
+ */
signal(SIGCHLD, SIG_IGN);
signal(SIGTSTP, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
signal(SIGTTIN, SIG_IGN);
- //no close(fd); - we just intentionally pointed stdx to null! tbd: set ignore for coverity
- return 0;
+ /*no close(fd); - we just intentionally pointed stdx to null! tbd: set ignore for coverity */
+ return 0;
}
void start_threads(DltSystemConfiguration *config)
{
- DLT_LOG(dltsystem,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-process-handling, start threads"));
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-process-handling, start threads"));
- int i;
- threads.count = 0;
- threads.shutdown = 0;
- for(i = 0;i < MAX_THREADS; i++)
- {
- threads.threads[i] = 0;
- }
+ int i;
+ threads.count = 0;
+ threads.shutdown = 0;
+
+ for (i = 0; i < MAX_THREADS; i++)
+ threads.threads[i] = 0;
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
- start_systemd_watchdog(config);
+ start_systemd_watchdog(config);
#endif
- if(config->Shell.Enable)
- init_shell();
+ if (config->Shell.Enable)
+ init_shell();
- if(config->LogFile.Enable)
- start_logfile(config);
+ if (config->LogFile.Enable)
+ start_logfile(config);
- if(config->Filetransfer.Enable)
- start_filetransfer(config);
+ if (config->Filetransfer.Enable)
+ start_filetransfer(config);
- if(config->LogProcesses.Enable)
- start_logprocess(config);
+ if (config->LogProcesses.Enable)
+ start_logprocess(config);
- if(config->Syslog.Enable)
- start_syslog(config);
+ if (config->Syslog.Enable)
+ start_syslog(config);
#if defined(DLT_SYSTEMD_JOURNAL_ENABLE)
- if(config->Journal.Enable)
- start_systemd_journal(config);
+
+ if (config->Journal.Enable)
+ start_systemd_journal(config);
+
#endif
}
@@ -153,52 +154,48 @@ void start_threads(DltSystemConfiguration *config)
*/
void join_threads()
{
- int i;
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-process-handling, waiting for threads to exit."));
-
- if(threads.count < 1)
- {
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-process-handling, no threads, waiting for signal."));
- sleep(UINT_MAX);
- }
- else
- {
- DLT_LOG(dltsystem,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-process-handling, thread count: "),
- DLT_INT(threads.count));
-
- for (i = 0; i < threads.count; i++)
- {
- pthread_join(threads.threads[i], NULL);
- DLT_LOG(dltsystem,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-process-handling, thread exit: "),
- DLT_INT(threads.threads[i]));
- }
- }
+ int i;
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-process-handling, waiting for threads to exit."));
+
+ if (threads.count < 1) {
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-process-handling, no threads, waiting for signal."));
+ sleep(UINT_MAX);
+ }
+ else {
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-process-handling, thread count: "),
+ DLT_INT(threads.count));
+
+ for (i = 0; i < threads.count; i++) {
+ pthread_join(threads.threads[i], NULL);
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-process-handling, thread exit: "),
+ DLT_INT(threads.threads[i]));
+ }
+ }
}
void dlt_system_signal_handler(int sig)
{
- DLT_LOG(dltsystem,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-process-handling, signal handler"));
-
- switch (sig)
- {
- case SIGHUP:
- case SIGTERM:
- case SIGINT:
- case SIGQUIT:
- DLT_LOG(dltsystem,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-process-handling, exit, signal: "),
- DLT_INT(sig));
- exit(0);
- break;
- default:
- DLT_LOG(dltsystem,DLT_LOG_WARN,
- DLT_STRING("dlt-system-process-handling, unknown signal!"));
- break;
- }
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-process-handling, signal handler"));
+
+ switch (sig) {
+ case SIGHUP:
+ case SIGTERM:
+ case SIGINT:
+ case SIGQUIT:
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-process-handling, exit, signal: "),
+ DLT_INT(sig));
+ exit(0);
+ break;
+ default:
+ DLT_LOG(dltsystem, DLT_LOG_WARN,
+ DLT_STRING("dlt-system-process-handling, unknown signal!"));
+ break;
+ }
}
diff --git a/src/system/dlt-system-processes.c b/src/system/dlt-system-processes.c
index b92ff55..e9b8577 100644
--- a/src/system/dlt-system-processes.c
+++ b/src/system/dlt-system-processes.c
@@ -57,7 +57,7 @@
#include "dlt-system.h"
-// Modes of sending
+/* Modes of sending */
#define SEND_MODE_OFF 0
#define SEND_MODE_ONCE 1
#define SEND_MODE_ON 2
@@ -69,108 +69,105 @@ DLT_DECLARE_CONTEXT(procContext)
void send_process(LogProcessOptions const *popts, int n)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-processes, send process info."));
- FILE * pFile;
- struct dirent *dp;
- char filename[PATH_MAX];
- char buffer[1024];
- int bytes;
- int found = 0;
-
- /* go through all process files in directory */
- DIR *dir = opendir("/proc");
- if(dir != NULL)
- {
- while ((dp=readdir(dir)) != NULL)
- {
- if(isdigit(dp->d_name[0]))
- {
- buffer[0] = 0;
- snprintf(filename,PATH_MAX, "/proc/%s/cmdline",dp->d_name);
- pFile = fopen(filename, "r");
- if(pFile != NULL)
- {
- bytes = fread(buffer, 1, sizeof(buffer)-1, pFile);
- fclose(pFile);
- }
- if((strcmp((*popts).Name[n], "*")==0) ||
- (strcmp(buffer, (*popts).Name[n])==0))
- {
- found = 1;
- snprintf(filename,PATH_MAX, "/proc/%s/%s", dp->d_name,(*popts).Filename[n]);
- pFile = fopen(filename, "r");
- if(pFile != NULL)
- {
- bytes = fread(buffer, 1, sizeof(buffer)-1, pFile);
- fclose(pFile);
-
- if(bytes>0)
- {
- buffer[bytes] = 0;
- DLT_LOG(procContext, DLT_LOG_INFO, DLT_INT(atoi(dp->d_name)), DLT_STRING((*popts).Filename[n]), DLT_STRING(buffer));
- }
- }
- if(strcmp((*popts).Name[n], "*") !=0)
- break;
- }
- }
- }
- closedir(dir);
- }
- else
- {
- DLT_LOG(dltsystem, DLT_LOG_ERROR,
- DLT_STRING("dlt-system-processes, failed to open /proc."));
- }
-
- if(!found) {
- DLT_LOG(procContext, DLT_LOG_INFO, DLT_STRING("Process"), DLT_STRING((*popts).Name[n]),DLT_STRING("not running!"));
- }
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-processes, send process info."));
+ FILE *pFile;
+ struct dirent *dp;
+ char filename[PATH_MAX];
+ char buffer[1024];
+ int bytes;
+ int found = 0;
+
+ /* go through all process files in directory */
+ DIR *dir = opendir("/proc");
+
+ if (dir != NULL) {
+ while ((dp = readdir(dir)) != NULL)
+ if (isdigit(dp->d_name[0])) {
+ buffer[0] = 0;
+ snprintf(filename, PATH_MAX, "/proc/%s/cmdline", dp->d_name);
+ pFile = fopen(filename, "r");
+
+ if (pFile != NULL) {
+ bytes = fread(buffer, 1, sizeof(buffer) - 1, pFile);
+ fclose(pFile);
+ }
+
+ if ((strcmp((*popts).Name[n], "*") == 0) ||
+ (strcmp(buffer, (*popts).Name[n]) == 0)) {
+ found = 1;
+ snprintf(filename, PATH_MAX, "/proc/%s/%s", dp->d_name, (*popts).Filename[n]);
+ pFile = fopen(filename, "r");
+
+ if (pFile != NULL) {
+ bytes = fread(buffer, 1, sizeof(buffer) - 1, pFile);
+ fclose(pFile);
+
+ if (bytes > 0) {
+ buffer[bytes] = 0;
+ DLT_LOG(procContext, DLT_LOG_INFO, DLT_INT(atoi(dp->d_name)),
+ DLT_STRING((*popts).Filename[n]), DLT_STRING(buffer));
+ }
+ }
+
+ if (strcmp((*popts).Name[n], "*") != 0)
+ break;
+ }
+ }
+
+ closedir(dir);
+ }
+ else {
+ DLT_LOG(dltsystem, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-processes, failed to open /proc."));
+ }
+
+ if (!found)
+ DLT_LOG(procContext, DLT_LOG_INFO, DLT_STRING("Process"), DLT_STRING((*popts).Name[n]),
+ DLT_STRING("not running!"));
}
void logprocess_thread(void *v_conf)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-processes, in thread."));
-
- DltSystemConfiguration *conf = (DltSystemConfiguration *) v_conf;
- DLT_REGISTER_CONTEXT(procContext, conf->LogProcesses.ContextId, "Log Processes");
-
- int process_delays[DLT_SYSTEM_LOG_PROCESSES_MAX];
- int i;
- for(i = 0;i < conf->LogProcesses.Count;i++)
- process_delays[i] = conf->LogProcesses.TimeDelay[i];
-
- while(!threads.shutdown)
- {
- sleep(1);
- for(i = 0;i < conf->LogProcesses.Count;i++)
- {
- if(conf->LogProcesses.Mode[i] == SEND_MODE_OFF)
- continue;
-
- if(process_delays[i] <= 0)
- {
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-processes, in thread."));
+
+ DltSystemConfiguration *conf = (DltSystemConfiguration *)v_conf;
+ DLT_REGISTER_CONTEXT(procContext, conf->LogProcesses.ContextId, "Log Processes");
+
+ int process_delays[DLT_SYSTEM_LOG_PROCESSES_MAX];
+ int i;
+
+ for (i = 0; i < conf->LogProcesses.Count; i++)
+ process_delays[i] = conf->LogProcesses.TimeDelay[i];
+
+ while (!threads.shutdown) {
+ sleep(1);
+
+ for (i = 0; i < conf->LogProcesses.Count; i++) {
+ if (conf->LogProcesses.Mode[i] == SEND_MODE_OFF)
+ continue;
+
+ if (process_delays[i] <= 0) {
send_process(&(conf->LogProcesses), i);
- process_delays[i] = conf->LogProcesses.TimeDelay[i];
- if(conf->LogProcesses.Mode[i] == SEND_MODE_ONCE)
- conf->LogProcesses.Mode[i] = SEND_MODE_OFF;
- }
- else
- {
- process_delays[i]--;
- }
- }
- }
+ process_delays[i] = conf->LogProcesses.TimeDelay[i];
+
+ if (conf->LogProcesses.Mode[i] == SEND_MODE_ONCE)
+ conf->LogProcesses.Mode[i] = SEND_MODE_OFF;
+ }
+ else {
+ process_delays[i]--;
+ }
+ }
+ }
}
void start_logprocess(DltSystemConfiguration *conf)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-processes, starting process log."));
- static pthread_attr_t t_attr;
- static pthread_t pt;
- pthread_create(&pt, &t_attr, (void *)logprocess_thread, conf);
- threads.threads[threads.count++] = pt;
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-processes, starting process log."));
+ static pthread_attr_t t_attr;
+ static pthread_t pt;
+ pthread_create(&pt, &t_attr, (void *)logprocess_thread, conf);
+ threads.threads[threads.count++] = pt;
}
diff --git a/src/system/dlt-system-shell.c b/src/system/dlt-system-shell.c
index 8dce12e..6e24f3b 100644
--- a/src/system/dlt-system-shell.c
+++ b/src/system/dlt-system-shell.c
@@ -66,62 +66,58 @@ DLT_DECLARE_CONTEXT(shellContext)
int dlt_shell_injection_callback(uint32_t service_id, void *data, uint32_t length)
{
- (void) length;
+ (void)length;
- DLT_LOG(shellContext,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-shell, injection callback"));
- char text[DLT_SHELL_COMMAND_MAX_LENGTH];
+ DLT_LOG(shellContext, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-shell, injection callback"));
+ char text[DLT_SHELL_COMMAND_MAX_LENGTH];
int syserr = 0;
- if(length<=DLT_SHELL_COMMAND_MAX_LENGTH-1)
- {
- strncpy(text,data,length);
- text[length] = 0;
- }
- else
- {
- strncpy(text,data,DLT_SHELL_COMMAND_MAX_LENGTH-1);
- text[DLT_SHELL_COMMAND_MAX_LENGTH-1] = 0;
- }
+ if (length <= DLT_SHELL_COMMAND_MAX_LENGTH - 1) {
+ strncpy(text, data, length);
+ text[length] = 0;
+ }
+ else {
+ strncpy(text, data, DLT_SHELL_COMMAND_MAX_LENGTH - 1);
+ text[DLT_SHELL_COMMAND_MAX_LENGTH - 1] = 0;
+ }
- DLT_LOG(shellContext,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-shell, injection injection id:"),
- DLT_UINT32(service_id));
- DLT_LOG(shellContext,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-shell, injection data:"),
- DLT_STRING(text));
+ DLT_LOG(shellContext, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-shell, injection injection id:"),
+ DLT_UINT32(service_id));
+ DLT_LOG(shellContext, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-shell, injection data:"),
+ DLT_STRING(text));
+
+ switch (service_id) {
+ case 0x1001:
+
+ if ((syserr = system(text)) != 0)
+ DLT_LOG(shellContext, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-shell, abnormal exit status."),
+ DLT_STRING(text),
+ DLT_INT(syserr));
+ else
+ DLT_LOG(shellContext, DLT_LOG_INFO,
+ DLT_STRING("Shell command executed:"),
+ DLT_STRING(text));
+
+ break;
+ default:
+ DLT_LOG(shellContext, DLT_LOG_ERROR,
+ DLT_STRING("dlt-system-shell, unknown command received."),
+ DLT_UINT32(service_id),
+ DLT_STRING(text));
+ break;
+ }
- switch(service_id)
- {
- case 0x1001:
- if((syserr = system(text)) != 0)
- {
- DLT_LOG(shellContext,DLT_LOG_ERROR,
- DLT_STRING("dlt-system-shell, abnormal exit status."),
- DLT_STRING(text),
- DLT_INT(syserr));
- }
- else
- {
- DLT_LOG(shellContext,DLT_LOG_INFO,
- DLT_STRING("Shell command executed:"),
- DLT_STRING(text));
- }
- break;
- default:
- DLT_LOG(shellContext,DLT_LOG_ERROR,
- DLT_STRING("dlt-system-shell, unknown command received."),
- DLT_UINT32(service_id),
- DLT_STRING(text));
- break;
- }
return 0;
}
void init_shell()
{
- DLT_LOG(dltsystem,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-shell, register callback"));
- DLT_REGISTER_CONTEXT(shellContext,"CMD","Execute Shell commands");
- DLT_REGISTER_INJECTION_CALLBACK(shellContext, 0x1001, dlt_shell_injection_callback);
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-shell, register callback"));
+ DLT_REGISTER_CONTEXT(shellContext, "CMD", "Execute Shell commands");
+ DLT_REGISTER_INJECTION_CALLBACK(shellContext, 0x1001, dlt_shell_injection_callback);
}
diff --git a/src/system/dlt-system-syslog.c b/src/system/dlt-system-syslog.c
index 0f498b9..8fe9802 100644
--- a/src/system/dlt-system-syslog.c
+++ b/src/system/dlt-system-syslog.c
@@ -63,108 +63,103 @@ DLT_DECLARE_CONTEXT(syslogContext)
int init_socket(SyslogOptions opts)
{
- DLT_LOG(dltsystem,DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-syslog, init socket, port: "),
- DLT_INT(opts.Port));
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-syslog, init socket, port: "),
+ DLT_INT(opts.Port));
- int sock = -1;
- struct sockaddr_in syslog_addr;
+ int sock = -1;
+ struct sockaddr_in syslog_addr;
#ifdef DLT_USE_IPv6
- sock = socket(AF_INET6, SOCK_DGRAM, 0);
+ sock = socket(AF_INET6, SOCK_DGRAM, 0);
#else
- sock = socket(AF_INET, SOCK_DGRAM, 0);
+ sock = socket(AF_INET, SOCK_DGRAM, 0);
#endif
- if(sock < 0)
- {
- DLT_LOG(syslogContext, DLT_LOG_FATAL,
- DLT_STRING("Unable to create socket for SYSLOG."));
- return -1;
- }
+
+ if (sock < 0) {
+ DLT_LOG(syslogContext, DLT_LOG_FATAL,
+ DLT_STRING("Unable to create socket for SYSLOG."));
+ return -1;
+ }
#ifdef DLT_USE_IPv6
- syslog_addr.sin_family = AF_INET6;
+ syslog_addr.sin_family = AF_INET6;
#else
- syslog_addr.sin_family = AF_INET;
+ syslog_addr.sin_family = AF_INET;
#endif
- syslog_addr.sin_port = htons(opts.Port);
- syslog_addr.sin_addr.s_addr = INADDR_ANY;
- bzero(&(syslog_addr.sin_zero), 8);
-
- if (bind(sock, (struct sockaddr *)&syslog_addr,
- sizeof(struct sockaddr)) == -1)
- {
- DLT_LOG(syslogContext, DLT_LOG_FATAL,
- DLT_STRING("Unable to bind socket for SYSLOG."));
- close(sock);
- return -1;
- }
-
- return sock;
+ syslog_addr.sin_port = htons(opts.Port);
+ syslog_addr.sin_addr.s_addr = INADDR_ANY;
+ bzero(&(syslog_addr.sin_zero), 8);
+
+ if (bind(sock, (struct sockaddr *)&syslog_addr,
+ sizeof(struct sockaddr)) == -1) {
+ DLT_LOG(syslogContext, DLT_LOG_FATAL,
+ DLT_STRING("Unable to bind socket for SYSLOG."));
+ close(sock);
+ return -1;
+ }
+
+ return sock;
}
int read_socket(int sock)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-syslog, read socket"));
- char recv_data[RECV_BUF_SZ];
- struct sockaddr_in client_addr;
- socklen_t addr_len = sizeof(struct sockaddr_in);
-
- int bytes_read = recvfrom(sock, recv_data, RECV_BUF_SZ, 0,
- (struct sockaddr *) &client_addr, &addr_len);
- if(bytes_read == -1)
- {
- if(errno == EINTR)
- {
- return 0;
- }
- else
- {
- DLT_LOG(syslogContext, DLT_LOG_FATAL,
- DLT_STRING("Read from socket failed in SYSLOG."));
- return -1;
- }
- }
-
- recv_data[bytes_read] = '\0';
-
- if(bytes_read != 0)
- {
- DLT_LOG(syslogContext, DLT_LOG_INFO, DLT_STRING(recv_data));
- }
- return bytes_read;
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-syslog, read socket"));
+ char recv_data[RECV_BUF_SZ];
+ struct sockaddr_in client_addr;
+ socklen_t addr_len = sizeof(struct sockaddr_in);
+
+ int bytes_read = recvfrom(sock, recv_data, RECV_BUF_SZ, 0,
+ (struct sockaddr *)&client_addr, &addr_len);
+
+ if (bytes_read == -1) {
+ if (errno == EINTR) {
+ return 0;
+ }
+ else {
+ DLT_LOG(syslogContext, DLT_LOG_FATAL,
+ DLT_STRING("Read from socket failed in SYSLOG."));
+ return -1;
+ }
+ }
+
+ recv_data[bytes_read] = '\0';
+
+ if (bytes_read != 0)
+ DLT_LOG(syslogContext, DLT_LOG_INFO, DLT_STRING(recv_data));
+
+ return bytes_read;
}
void syslog_thread(void *v_conf)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-syslog, in thread."));
-
- DltSystemConfiguration *conf = (DltSystemConfiguration *) v_conf;
- DLT_REGISTER_CONTEXT(syslogContext, conf->Syslog.ContextId, "SYSLOG Adapter");
-
- int sock = init_socket(conf->Syslog);
- if(sock < 0)
- return;
-
- while(!threads.shutdown)
- {
- if(read_socket(sock) < 0)
- {
- close(sock);
- return;
- }
- }
- close (sock);
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-syslog, in thread."));
+
+ DltSystemConfiguration *conf = (DltSystemConfiguration *)v_conf;
+ DLT_REGISTER_CONTEXT(syslogContext, conf->Syslog.ContextId, "SYSLOG Adapter");
+
+ int sock = init_socket(conf->Syslog);
+
+ if (sock < 0)
+ return;
+
+ while (!threads.shutdown)
+ if (read_socket(sock) < 0) {
+ close(sock);
+ return;
+ }
+
+ close (sock);
}
void start_syslog(DltSystemConfiguration *conf)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,
- DLT_STRING("dlt-system-syslog, start syslog"));
- static pthread_attr_t t_attr;
- static pthread_t pt;
- pthread_create(&pt, &t_attr, (void *)syslog_thread, conf);
- threads.threads[threads.count++] = pt;
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG,
+ DLT_STRING("dlt-system-syslog, start syslog"));
+ static pthread_attr_t t_attr;
+ static pthread_t pt;
+ pthread_create(&pt, &t_attr, (void *)syslog_thread, conf);
+ threads.threads[threads.count++] = pt;
}
diff --git a/src/system/dlt-system-watchdog.c b/src/system/dlt-system-watchdog.c
index 8dae122..3905564 100644
--- a/src/system/dlt-system-watchdog.c
+++ b/src/system/dlt-system-watchdog.c
@@ -54,16 +54,12 @@ void wait_period (PeriodicData *info)
{
unsigned long long missed;
- if(read (info->timer_fd, &missed, sizeof (missed)) < 0)
- {
+ if (read (info->timer_fd, &missed, sizeof (missed)) < 0)
DLT_LOG(watchdogContext, DLT_LOG_ERROR,
DLT_STRING("Could not read from timer file descriptor in watchdog.\n"));
- }
if (missed > 0)
- {
info->wakeups_missed += (missed - 1);
- }
}
int make_periodic(unsigned int period, PeriodicData *info)
@@ -73,10 +69,9 @@ int make_periodic(unsigned int period, PeriodicData *info)
int fd;
struct itimerspec itval;
- if (info==0)
- {
- DLT_LOG(watchdogContext, DLT_LOG_ERROR,
- DLT_STRING("Invalid function parameters used for function make_periodic.\n"));
+ if (info == 0) {
+ DLT_LOG(watchdogContext, DLT_LOG_ERROR,
+ DLT_STRING("Invalid function parameters used for function make_periodic.\n"));
return -1;
}
@@ -86,15 +81,14 @@ int make_periodic(unsigned int period, PeriodicData *info)
info->wakeups_missed = 0;
info->timer_fd = fd;
- if (fd == -1)
- {
- DLT_LOG(watchdogContext, DLT_LOG_ERROR,
- DLT_STRING("Can't create timer filedescriptor.\n"));
+ if (fd == -1) {
+ DLT_LOG(watchdogContext, DLT_LOG_ERROR,
+ DLT_STRING("Can't create timer filedescriptor.\n"));
return -1;
}
/* Make the timer periodic */
- sec = period/1000000;
+ sec = period / 1000000;
ns = (period - (sec * 1000000)) * 1000;
itval.it_interval.tv_sec = sec;
itval.it_interval.tv_nsec = ns;
@@ -107,88 +101,78 @@ int make_periodic(unsigned int period, PeriodicData *info)
void watchdog_thread(void *v_conf)
{
- char str[512];
- char *watchdogUSec;
- unsigned int watchdogTimeoutSeconds;
- unsigned int notifiyPeriodNSec;
- PeriodicData info;
-
- DLT_REGISTER_CONTEXT(watchdogContext, "DOG","dlt system watchdog context.");
-
- sleep(1);
+ char str[512];
+ char *watchdogUSec;
+ unsigned int watchdogTimeoutSeconds;
+ unsigned int notifiyPeriodNSec;
+ PeriodicData info;
- DLT_LOG(watchdogContext, DLT_LOG_INFO,DLT_STRING("Watchdog thread started.\n"));
+ DLT_REGISTER_CONTEXT(watchdogContext, "DOG", "dlt system watchdog context.");
- if (v_conf==0)
- {
- DLT_LOG(watchdogContext, DLT_LOG_ERROR,
- DLT_STRING("Invalid function parameters used for function watchdog_thread.\n"));
- return;
- }
+ sleep(1);
+ DLT_LOG(watchdogContext, DLT_LOG_INFO, DLT_STRING("Watchdog thread started.\n"));
- watchdogUSec = getenv("WATCHDOG_USEC");
+ if (v_conf == 0) {
+ DLT_LOG(watchdogContext, DLT_LOG_ERROR,
+ DLT_STRING("Invalid function parameters used for function watchdog_thread.\n"));
+ return;
+ }
- if(watchdogUSec)
- {
- DLT_LOG(watchdogContext, DLT_LOG_DEBUG,DLT_STRING("watchdogusec: "),DLT_STRING(watchdogUSec));
+ watchdogUSec = getenv("WATCHDOG_USEC");
- watchdogTimeoutSeconds = atoi(watchdogUSec);
+ if (watchdogUSec) {
+ DLT_LOG(watchdogContext, DLT_LOG_DEBUG, DLT_STRING("watchdogusec: "), DLT_STRING(watchdogUSec));
- if( watchdogTimeoutSeconds > 0 ){
+ watchdogTimeoutSeconds = atoi(watchdogUSec);
- // Calculate half of WATCHDOG_USEC in ns for timer tick
- notifiyPeriodNSec = watchdogTimeoutSeconds / 2 ;
+ if (watchdogTimeoutSeconds > 0) {
- snprintf(str,512,"systemd watchdog timeout: %u nsec - timer will be initialized: %u nsec\n", watchdogTimeoutSeconds, notifiyPeriodNSec );
- DLT_LOG(watchdogContext, DLT_LOG_DEBUG,DLT_STRING(str));
+ /* Calculate half of WATCHDOG_USEC in ns for timer tick */
+ notifiyPeriodNSec = watchdogTimeoutSeconds / 2;
- if (make_periodic (notifiyPeriodNSec, &info) < 0 )
- {
- DLT_LOG(watchdogContext, DLT_LOG_ERROR,DLT_STRING("Could not initialize systemd watchdog timer\n"));
- return;
- }
+ snprintf(str,
+ 512,
+ "systemd watchdog timeout: %u nsec - timer will be initialized: %u nsec\n",
+ watchdogTimeoutSeconds,
+ notifiyPeriodNSec);
+ DLT_LOG(watchdogContext, DLT_LOG_DEBUG, DLT_STRING(str));
- while (1)
- {
- if(sd_notify(0, "WATCHDOG=1") < 0)
- {
- DLT_LOG(watchdogContext, DLT_LOG_ERROR,DLT_STRING("Could not reset systemd watchdog\n"));
- }
+ if (make_periodic (notifiyPeriodNSec, &info) < 0) {
+ DLT_LOG(watchdogContext, DLT_LOG_ERROR, DLT_STRING("Could not initialize systemd watchdog timer\n"));
+ return;
+ }
- DLT_LOG(watchdogContext, DLT_LOG_DEBUG,DLT_STRING("systemd watchdog waited periodic\n"));
+ while (1) {
+ if (sd_notify(0, "WATCHDOG=1") < 0)
+ DLT_LOG(watchdogContext, DLT_LOG_ERROR, DLT_STRING("Could not reset systemd watchdog\n"));
- /* Wait for next period */
- wait_period(&info);
- }
- }
- else
- {
- snprintf(str,512,"systemd watchdog timeout incorrect: %u\n", watchdogTimeoutSeconds);
- DLT_LOG(watchdogContext, DLT_LOG_DEBUG,DLT_STRING(str));
- }
- }
- else
- {
- DLT_LOG(watchdogContext, DLT_LOG_ERROR,DLT_STRING("systemd watchdog timeout (WATCHDOG_USEC) is null\n"));
- }
+ DLT_LOG(watchdogContext, DLT_LOG_DEBUG, DLT_STRING("systemd watchdog waited periodic\n"));
+ /* Wait for next period */
+ wait_period(&info);
+ }
+ }
+ else {
+ snprintf(str, 512, "systemd watchdog timeout incorrect: %u\n", watchdogTimeoutSeconds);
+ DLT_LOG(watchdogContext, DLT_LOG_DEBUG, DLT_STRING(str));
+ }
+ }
+ else {
+ DLT_LOG(watchdogContext, DLT_LOG_ERROR, DLT_STRING("systemd watchdog timeout (WATCHDOG_USEC) is null\n"));
+ }
}
void start_systemd_watchdog(DltSystemConfiguration *conf)
{
- DLT_LOG(dltsystem, DLT_LOG_DEBUG,DLT_STRING("Creating thread for systemd watchdog\n"));
-
- static pthread_attr_t t_attr;
- static pthread_t pt;
-
- if (pthread_create(&pt, &t_attr, (void *)watchdog_thread, conf) == 0)
- {
- threads.threads[threads.count++] = pt;
- }
- else
- {
- DLT_LOG(dltsystem, DLT_LOG_ERROR,DLT_STRING("Could not create thread for systemd watchdog\n"));
- }
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("Creating thread for systemd watchdog\n"));
+
+ static pthread_attr_t t_attr;
+ static pthread_t pt;
+
+ if (pthread_create(&pt, &t_attr, (void *)watchdog_thread, conf) == 0)
+ threads.threads[threads.count++] = pt;
+ else
+ DLT_LOG(dltsystem, DLT_LOG_ERROR, DLT_STRING("Could not create thread for systemd watchdog\n"));
}
#endif
diff --git a/src/system/dlt-system.c b/src/system/dlt-system.c
index b826286..317337d 100644
--- a/src/system/dlt-system.c
+++ b/src/system/dlt-system.c
@@ -53,75 +53,73 @@
#include <signal.h>
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE)
-#include "sd-daemon.h"
+# include "sd-daemon.h"
#endif
DLT_DECLARE_CONTEXT(dltsystem)
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- DltSystemCliOptions options;
- DltSystemConfiguration config;
+ DltSystemCliOptions options;
+ DltSystemConfiguration config;
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE)
- int ret;
+ int ret;
#endif
- if(read_command_line(&options, argc, argv) < 0)
- {
- fprintf(stderr, "Failed to read command line!\n");
- return -1;
- }
+ if (read_command_line(&options, argc, argv) < 0) {
+ fprintf(stderr, "Failed to read command line!\n");
+ return -1;
+ }
+
+ if (read_configuration_file(&config, options.ConfigurationFileName) < 0) {
+ fprintf(stderr, "Failed to read configuration file!\n");
+ return -1;
+ }
- if(read_configuration_file(&config, options.ConfigurationFileName) < 0)
- {
- fprintf(stderr, "Failed to read configuration file!\n");
- return -1;
- }
- DLT_REGISTER_APP(config.ApplicationId, "DLT System Manager");
- DLT_REGISTER_CONTEXT(dltsystem,"MGR", "Context of main dlt system manager");
+ DLT_REGISTER_APP(config.ApplicationId, "DLT System Manager");
+ DLT_REGISTER_CONTEXT(dltsystem, "MGR", "Context of main dlt system manager");
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE)
ret = sd_booted();
- if(ret == 0){
- DLT_LOG(dltsystem, DLT_LOG_INFO, DLT_STRING("system not booted with systemd!\n"));
+ if (ret == 0) {
+ DLT_LOG(dltsystem, DLT_LOG_INFO, DLT_STRING("system not booted with systemd!\n"));
}
- else if(ret < 0)
+ else if (ret < 0)
{
- DLT_LOG(dltsystem, DLT_LOG_ERROR, DLT_STRING("sd_booted failed!\n"));
- return -1;
+ DLT_LOG(dltsystem, DLT_LOG_ERROR, DLT_STRING("sd_booted failed!\n"));
+ return -1;
}
- else
- {
- DLT_LOG(dltsystem, DLT_LOG_INFO, DLT_STRING("system booted with systemd\n"));
+ else {
+ DLT_LOG(dltsystem, DLT_LOG_INFO, DLT_STRING("system booted with systemd\n"));
}
+
#endif
- DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("Configuration loaded."));
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("Configuration loaded."));
+
+ if (options.Daemonize > 0) {
+ if (daemonize() < 0) {
+ DLT_LOG(dltsystem, DLT_LOG_FATAL, DLT_STRING("Daemonization failed!"));
+ return -1;
+ }
- if(options.Daemonize > 0)
- {
- if(daemonize() < 0)
- {
- DLT_LOG(dltsystem, DLT_LOG_FATAL, DLT_STRING("Daemonization failed!"));
- return -1;
- }
- DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system daemonized."));
- }
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system daemonized."));
+ }
- DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("Setting signal handlers for abnormal exit"));
- signal(SIGTERM, dlt_system_signal_handler);
- signal(SIGHUP, dlt_system_signal_handler);
- signal(SIGQUIT, dlt_system_signal_handler);
- signal(SIGINT, dlt_system_signal_handler);
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("Setting signal handlers for abnormal exit"));
+ signal(SIGTERM, dlt_system_signal_handler);
+ signal(SIGHUP, dlt_system_signal_handler);
+ signal(SIGQUIT, dlt_system_signal_handler);
+ signal(SIGINT, dlt_system_signal_handler);
- DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("Launching threads."));
+ DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("Launching threads."));
- start_threads(&config);
- join_threads();
- return 0;
+ start_threads(&config);
+ join_threads();
+ return 0;
}
diff --git a/src/system/dlt-system.h b/src/system/dlt-system.h
index c415ad7..6f068ec 100644
--- a/src/system/dlt-system.h
+++ b/src/system/dlt-system.h
@@ -56,12 +56,12 @@
#ifndef DLT_SYSTEM_H_
#define DLT_SYSTEM_H_
-// DLT related includes.
+/* DLT related includes. */
#include "dlt.h"
#include "dlt_common.h"
-// Constants
-#define DEFAULT_CONF_FILE ( CONFIGURATION_FILES_DIR "/dlt-system.conf")
+/* Constants */
+#define DEFAULT_CONF_FILE (CONFIGURATION_FILES_DIR "/dlt-system.conf")
#define DLT_SYSTEM_LOG_FILE_MAX 32
#define DLT_SYSTEM_LOG_DIRS_MAX 32
#define DLT_SYSTEM_LOG_PROCESSES_MAX 32
@@ -74,113 +74,113 @@
#define MAX_THREADS 8
-// Macros
-#define MALLOC_ASSERT(x) if(x == NULL) {\
- fprintf(stderr, "Out of memory\n");\
- abort();}
+/* Macros */
+#define MALLOC_ASSERT(x) if (x == NULL) { \
+ fprintf(stderr, "Out of memory\n"); \
+ abort(); }
/**
* Configuration structures.
* Please see dlt-system.conf for explanation of all the options.
*/
-// Command line options
+/* Command line options */
typedef struct {
- char *ConfigurationFileName;
- int Daemonize;
+ char *ConfigurationFileName;
+ int Daemonize;
} DltSystemCliOptions;
-// Configuration shell options
+/* Configuration shell options */
typedef struct {
- int Enable;
+ int Enable;
} ShellOptions;
-// Configuration syslog options
+/* Configuration syslog options */
typedef struct {
- int Enable;
- char *ContextId;
- int Port;
+ int Enable;
+ char *ContextId;
+ int Port;
} SyslogOptions;
-// Configuration journal options
+/* Configuration journal options */
typedef struct {
- int Enable;
- char *ContextId;
- int CurrentBoot;
- int Follow;
- int MapLogLevels;
+ int Enable;
+ char *ContextId;
+ int CurrentBoot;
+ int Follow;
+ int MapLogLevels;
} JournalOptions;
typedef struct {
- int Enable;
- char *ContextId;
- int TimeStartup;
- int TimeDelay;
- int TimeoutBetweenLogs;
- char *TempDir;
-
- // Variable number of file transfer dirs
- int Count;
- int Compression[DLT_SYSTEM_LOG_DIRS_MAX];
- int CompressionLevel[DLT_SYSTEM_LOG_DIRS_MAX];
- char *Directory[DLT_SYSTEM_LOG_DIRS_MAX];
+ int Enable;
+ char *ContextId;
+ int TimeStartup;
+ int TimeDelay;
+ int TimeoutBetweenLogs;
+ char *TempDir;
+
+ /* Variable number of file transfer dirs */
+ int Count;
+ int Compression[DLT_SYSTEM_LOG_DIRS_MAX];
+ int CompressionLevel[DLT_SYSTEM_LOG_DIRS_MAX];
+ char *Directory[DLT_SYSTEM_LOG_DIRS_MAX];
} FiletransferOptions;
typedef struct {
- int Enable;
-
- // Variable number of files to transfer
- int Count;
- char *ContextId[DLT_SYSTEM_LOG_FILE_MAX];
- char *Filename[DLT_SYSTEM_LOG_FILE_MAX];
- int Mode[DLT_SYSTEM_LOG_FILE_MAX];
- int TimeDelay[DLT_SYSTEM_LOG_FILE_MAX];
+ int Enable;
+
+ /* Variable number of files to transfer */
+ int Count;
+ char *ContextId[DLT_SYSTEM_LOG_FILE_MAX];
+ char *Filename[DLT_SYSTEM_LOG_FILE_MAX];
+ int Mode[DLT_SYSTEM_LOG_FILE_MAX];
+ int TimeDelay[DLT_SYSTEM_LOG_FILE_MAX];
} LogFileOptions;
typedef struct {
- int Enable;
- char *ContextId;
-
- // Variable number of processes
- int Count;
- char *Name[DLT_SYSTEM_LOG_PROCESSES_MAX];
- char *Filename[DLT_SYSTEM_LOG_PROCESSES_MAX];
- int Mode[DLT_SYSTEM_LOG_PROCESSES_MAX];
- int TimeDelay[DLT_SYSTEM_LOG_PROCESSES_MAX];
+ int Enable;
+ char *ContextId;
+
+ /* Variable number of processes */
+ int Count;
+ char *Name[DLT_SYSTEM_LOG_PROCESSES_MAX];
+ char *Filename[DLT_SYSTEM_LOG_PROCESSES_MAX];
+ int Mode[DLT_SYSTEM_LOG_PROCESSES_MAX];
+ int TimeDelay[DLT_SYSTEM_LOG_PROCESSES_MAX];
} LogProcessOptions;
typedef struct {
- char *ApplicationId;
- ShellOptions Shell;
- SyslogOptions Syslog;
- JournalOptions Journal;
- FiletransferOptions Filetransfer;
- LogFileOptions LogFile;
- LogProcessOptions LogProcesses;
+ char *ApplicationId;
+ ShellOptions Shell;
+ SyslogOptions Syslog;
+ JournalOptions Journal;
+ FiletransferOptions Filetransfer;
+ LogFileOptions LogFile;
+ LogProcessOptions LogProcesses;
} DltSystemConfiguration;
typedef struct {
- pthread_t threads[MAX_THREADS];
- int count;
- int shutdown;
+ pthread_t threads[MAX_THREADS];
+ int count;
+ int shutdown;
} DltSystemThreads;
/**
* Forward declarations for the whole application
*/
-// In dlt-system-options.c
+/* In dlt-system-options.c */
int read_command_line(DltSystemCliOptions *options, int argc, char *argv[]);
int read_configuration_file(DltSystemConfiguration *config, char *file_name);
-// In dlt-process-handling.c
+/* In dlt-process-handling.c */
int daemonize();
void start_threads(DltSystemConfiguration *config);
void join_threads();
void dlt_system_signal_handler(int sig);
void register_with_dlt(DltSystemConfiguration *config);
-// Thread initiators:
+/* Thread initiators: */
void init_shell();
void start_syslog();
void start_filetransfer(DltSystemConfiguration *conf);
diff --git a/src/tests/dlt-test-client.c b/src/tests/dlt-test-client.c
index cab327f..2cd39c5 100644
--- a/src/tests/dlt-test-client.c
+++ b/src/tests/dlt-test-client.c
@@ -64,8 +64,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <ctype.h> /* for isprint() */
@@ -85,7 +85,7 @@
#define DLT_TESTCLIENT_NUM_TESTS 9
static int g_testsFailed = 0;
-DltClient g_dltclient;
+DltClient g_dltclient;
/* Function prototypes */
int dlt_testclient_message_callback(DltMessage *message, void *data);
@@ -127,7 +127,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-test-client [options] hostname/serial_device_name\n");
printf("Test against received data from dlt-test-user.\n");
@@ -149,10 +149,10 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
DltTestclientData dltdata;
- int c,i;
+ int c, i;
int index;
/* Initialize dltdata */
@@ -166,14 +166,13 @@ int main(int argc, char* argv[])
dltdata.fvalue = 0;
dltdata.evalue = 0;
dltdata.bvalue = 0;
- dltdata.ohandle=-1;
+ dltdata.ohandle = -1;
dltdata.running_test = 0;
- for (i=0;i<DLT_TESTCLIENT_NUM_TESTS;i++)
- {
- dltdata.test_counter_macro[i]=0;
- dltdata.test_counter_function[i]=0;
+ for (i = 0; i < DLT_TESTCLIENT_NUM_TESTS; i++) {
+ dltdata.test_counter_macro[i] = 0;
+ dltdata.test_counter_function[i] = 0;
}
dltdata.tests_passed = 0;
@@ -185,9 +184,7 @@ int main(int argc, char* argv[])
opterr = 0;
while ((c = getopt (argc, argv, "vashyxmf:o:e:b:")) != -1)
- {
- switch (c)
- {
+ switch (c) {
case 'v':
{
dltdata.vflag = 1;
@@ -245,18 +242,13 @@ int main(int argc, char* argv[])
}
case '?':
{
- if (optopt == 'o' || optopt == 'f' || optopt == 't')
- {
+ if ((optopt == 'o') || (optopt == 'f') || (optopt == 't'))
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
/* unknown or wrong option used, show usage information and terminate */
usage();
return -1;
@@ -264,10 +256,9 @@ int main(int argc, char* argv[])
default:
{
abort ();
- return -1;//for parasoft
+ return -1;/*for parasoft */
}
}
- }
/* Initialize DLT Client */
dlt_client_init(&g_dltclient, dltdata.vflag);
@@ -278,108 +269,91 @@ int main(int argc, char* argv[])
/* Setup DLT Client structure */
g_dltclient.mode = dltdata.yflag;
- if (g_dltclient.mode==0)
- {
+ if (g_dltclient.mode == 0) {
for (index = optind; index < argc; index++)
- {
- if(dlt_client_set_server_ip(&g_dltclient, argv[index]) == -1)
- {
- fprintf(stderr,"set server ip didn't succeed\n");
+ if (dlt_client_set_server_ip(&g_dltclient, argv[index]) == -1) {
+ fprintf(stderr, "set server ip didn't succeed\n");
return -1;
}
- }
- if (g_dltclient.servIP == 0)
- {
+
+
+ if (g_dltclient.servIP == 0) {
/* no hostname selected, show usage and terminate */
- fprintf(stderr,"ERROR: No hostname selected\n");
+ fprintf(stderr, "ERROR: No hostname selected\n");
usage();
- dlt_client_cleanup(&g_dltclient,dltdata.vflag);
+ dlt_client_cleanup(&g_dltclient, dltdata.vflag);
return -1;
}
}
- else
- {
+ else {
for (index = optind; index < argc; index++)
- {
- if(dlt_client_set_serial_device(&g_dltclient, argv[index]) == -1)
- {
- fprintf(stderr,"set serial device didn't succeed\n");
+ if (dlt_client_set_serial_device(&g_dltclient, argv[index]) == -1) {
+ fprintf(stderr, "set serial device didn't succeed\n");
return -1;
}
- }
- if (g_dltclient.serialDevice == 0)
- {
+
+
+ if (g_dltclient.serialDevice == 0) {
/* no serial device name selected, show usage and terminate */
- fprintf(stderr,"ERROR: No serial device name specified\n");
+ fprintf(stderr, "ERROR: No serial device name specified\n");
usage();
return -1;
}
- dlt_client_setbaudrate(&g_dltclient,dltdata.bvalue);
+ dlt_client_setbaudrate(&g_dltclient, dltdata.bvalue);
}
/* initialise structure to use DLT file */
- dlt_file_init(&(dltdata.file),dltdata.vflag);
+ dlt_file_init(&(dltdata.file), dltdata.vflag);
/* first parse filter file if filter parameter is used */
- dlt_filter_init(&(dltdata.filter),dltdata.vflag);
+ dlt_filter_init(&(dltdata.filter), dltdata.vflag);
- if (dltdata.fvalue)
- {
- if (dlt_filter_load(&(dltdata.filter),dltdata.fvalue,dltdata.vflag) < DLT_RETURN_OK)
- {
- dlt_file_free(&(dltdata.file),dltdata.vflag);
+ if (dltdata.fvalue) {
+ if (dlt_filter_load(&(dltdata.filter), dltdata.fvalue, dltdata.vflag) < DLT_RETURN_OK) {
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
return -1;
}
- dlt_file_set_filter(&(dltdata.file),&(dltdata.filter),dltdata.vflag);
+ dlt_file_set_filter(&(dltdata.file), &(dltdata.filter), dltdata.vflag);
}
/* open DLT output file */
- if (dltdata.ovalue)
- {
- dltdata.ohandle = open(dltdata.ovalue,O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
+ if (dltdata.ovalue) {
+ dltdata.ohandle = open(dltdata.ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
- if (dltdata.ohandle == -1)
- {
- dlt_file_free(&(dltdata.file),dltdata.vflag);
- fprintf(stderr,"ERROR: Output file %s cannot be opened!\n",dltdata.ovalue);
+ if (dltdata.ohandle == -1) {
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
+ fprintf(stderr, "ERROR: Output file %s cannot be opened!\n", dltdata.ovalue);
return -1;
}
}
if (dltdata.evalue)
- {
- dlt_set_id(dltdata.ecuid,dltdata.evalue);
- }
+ dlt_set_id(dltdata.ecuid, dltdata.evalue);
else
- {
- dlt_set_id(dltdata.ecuid,DLT_TESTCLIENT_ECU_ID);
- }
+ dlt_set_id(dltdata.ecuid, DLT_TESTCLIENT_ECU_ID);
/* Connect to TCP socket or open serial device */
- if (dlt_client_connect(&g_dltclient, dltdata.vflag) != DLT_RETURN_ERROR)
- {
+ if (dlt_client_connect(&g_dltclient, dltdata.vflag) != DLT_RETURN_ERROR) {
dltdata.sock = g_dltclient.sock;
/* Dlt Client Main Loop */
dlt_client_main_loop(&g_dltclient, &dltdata, dltdata.vflag);
/* Dlt Client Cleanup */
- dlt_client_cleanup(&g_dltclient,dltdata.vflag);
+ dlt_client_cleanup(&g_dltclient, dltdata.vflag);
}
/* dlt-receive cleanup */
if (dltdata.ovalue)
- {
close(dltdata.ohandle);
- }
- dlt_file_free(&(dltdata.file),dltdata.vflag);
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
- dlt_filter_free(&(dltdata.filter),dltdata.vflag);
+ dlt_filter_free(&(dltdata.filter), dltdata.vflag);
return g_testsFailed == 0 ? 0 : 1;
}
@@ -391,224 +365,188 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
DltTestclientData *dltdata;
uint32_t type_info, type_info_tmp;
- int16_t length,length_tmp; /* the macro can set this variable to -1 */
+ int16_t length, length_tmp; /* the macro can set this variable to -1 */
uint32_t length_tmp32 = 0;
uint8_t *ptr;
int32_t datalength;
- uint32_t id,id_tmp;
+ uint32_t id, id_tmp;
int slen;
int tc_old;
struct iovec iov[2];
int bytes_written;
- if ((message==0) || (data==0))
- {
+ if ((message == 0) || (data == 0))
return -1;
- }
- dltdata = (DltTestclientData*)data;
+ dltdata = (DltTestclientData *)data;
/* prepare storage header */
if (DLT_IS_HTYP_WEID(message->standardheader->htyp))
- {
- dlt_set_storageheader(message->storageheader,message->headerextra.ecu);
- }
+ dlt_set_storageheader(message->storageheader, message->headerextra.ecu);
else
- {
- dlt_set_storageheader(message->storageheader,dltdata->ecuid);
- }
+ dlt_set_storageheader(message->storageheader, dltdata->ecuid);
+
+ if ((dltdata->fvalue == 0) ||
+ (dltdata->fvalue &&
+ (dlt_message_filter_check(message, &(dltdata->filter), dltdata->vflag) == DLT_RETURN_TRUE))) {
- if ((dltdata->fvalue==0) || (dltdata->fvalue && dlt_message_filter_check(message,&(dltdata->filter),dltdata->vflag) == DLT_RETURN_TRUE))
- {
+ dlt_message_header(message, text, sizeof(text), dltdata->vflag);
- dlt_message_header(message,text,sizeof(text),dltdata->vflag);
if (dltdata->aflag)
- {
- printf("%s ",text);
- }
- dlt_message_payload(message,text,sizeof(text),DLT_OUTPUT_ASCII,dltdata->vflag);
+ printf("%s ", text);
+
+ dlt_message_payload(message, text, sizeof(text), DLT_OUTPUT_ASCII, dltdata->vflag);
+
if (dltdata->aflag)
- {
- printf("[%s]\n",text);
- }
+ printf("[%s]\n", text);
- if (strcmp(text,"Tests starting")==0)
- {
+ if (strcmp(text, "Tests starting") == 0)
printf("Tests starting\n");
- }
/* check test 1m */
- if (strcmp(text,"Test1: (Macro IF) Test all log levels")==0)
- {
+ if (strcmp(text, "Test1: (Macro IF) Test all log levels") == 0) {
printf("Test1m: (Macro IF) Test all log levels\n");
dltdata->running_test = 1;
dltdata->test_counter_macro[0] = 0;
}
- else if (strcmp(text,"Test1: (Macro IF) finished")==0)
+ else if (strcmp(text, "Test1: (Macro IF) finished") == 0)
{
/* >=4, as "info" is default log level */
- if (dltdata->test_counter_macro[0]>=4)
- {
+ if (dltdata->test_counter_macro[0] >= 4) {
printf("Test1m PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test1m FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==1)
+ else if (dltdata->running_test == 1)
{
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
- {
- mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_LOG) {
+ mtin = DLT_GET_MSIN_MTIN(message->extendedheader->msin);
- if (mtin==DLT_LOG_FATAL)
- {
+ if (mtin == DLT_LOG_FATAL)
dltdata->test_counter_macro[0]++;
- }
- if (mtin==DLT_LOG_ERROR)
- {
+
+ if (mtin == DLT_LOG_ERROR)
dltdata->test_counter_macro[0]++;
- }
- if (mtin==DLT_LOG_WARN)
- {
+
+ if (mtin == DLT_LOG_WARN)
dltdata->test_counter_macro[0]++;
- }
- if (mtin==DLT_LOG_INFO)
- {
+
+ if (mtin == DLT_LOG_INFO)
dltdata->test_counter_macro[0]++;
- }
- if (mtin==DLT_LOG_DEBUG)
- {
+
+ if (mtin == DLT_LOG_DEBUG)
dltdata->test_counter_macro[0]++;
- }
- if (mtin==DLT_LOG_VERBOSE)
- {
+
+ if (mtin == DLT_LOG_VERBOSE)
dltdata->test_counter_macro[0]++;
- }
}
}
}
/* check test 2m */
- if (strcmp(text,"Test2: (Macro IF) Test all variable types (verbose)")==0)
- {
+ if (strcmp(text, "Test2: (Macro IF) Test all variable types (verbose)") == 0) {
printf("Test2m: (Macro IF) Test all variable types (verbose)\n");
dltdata->running_test = 2;
dltdata->test_counter_macro[1] = 0;
}
- else if (strcmp(text,"Test2: (Macro IF) finished")==0)
+ else if (strcmp(text, "Test2: (Macro IF) finished") == 0)
{
- if (dltdata->test_counter_macro[1]==16)
- {
+ if (dltdata->test_counter_macro[1] == 16) {
printf("Test2m PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test2m FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==2)
+ else if (dltdata->running_test == 2)
{
/* Verbose */
- if (!(DLT_MSG_IS_NONVERBOSE(message)))
- {
- type_info=0;
- type_info_tmp=0;
- length=0; /* the macro can set this variable to -1 */
- length_tmp=0;
+ if (!(DLT_MSG_IS_NONVERBOSE(message))) {
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0; /* the macro can set this variable to -1 */
+ length_tmp = 0;
ptr = message->databuffer;
datalength = message->datasize;
/* Log message */
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
- {
- if (message->extendedheader->noar>=2)
- {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_LOG) {
+ if (message->extendedheader->noar >= 2) {
/* get type of first argument: must be string */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_STRG)
- {
+ if (type_info & DLT_TYPE_INFO_STRG) {
/* skip string */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if (length>=0)
- {
- ptr+=length;
- datalength-=length;
+ if (length >= 0) {
+ ptr += length;
+ datalength -= length;
/* read type of second argument: must be raw */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if ((type_info & DLT_TYPE_INFO_STRG) && ((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_ASCII))
- {
- if (datalength==(sizeof(uint16_t)+strlen("Hello world")+1))
- {
+ if ((type_info & DLT_TYPE_INFO_STRG) &&
+ ((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_ASCII)) {
+ if (datalength == (sizeof(uint16_t) + strlen("Hello world") + 1))
dltdata->test_counter_macro[1]++;
- }
}
- else if ((type_info & DLT_TYPE_INFO_STRG) && ((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_UTF8))
+ else if ((type_info & DLT_TYPE_INFO_STRG) &&
+ ((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_UTF8))
{
- if (datalength==(sizeof(uint16_t)+strlen("Hello world")+1))
- {
+ if (datalength == (sizeof(uint16_t) + strlen("Hello world") + 1))
dltdata->test_counter_macro[1]++;
- }
}
else if (type_info & DLT_TYPE_INFO_BOOL)
{
- if (datalength==sizeof(uint8_t))
- {
+ if (datalength == sizeof(uint8_t))
dltdata->test_counter_macro[1]++;
- }
}
else if (type_info & DLT_TYPE_INFO_SINT)
{
- switch (type_info & DLT_TYPE_INFO_TYLE)
- {
+ switch (type_info & DLT_TYPE_INFO_TYLE) {
case DLT_TYLE_8BIT:
{
- if (datalength==sizeof(int8_t))
- {
+ if (datalength == sizeof(int8_t))
dltdata->test_counter_macro[1]++;
- }
+
break;
}
case DLT_TYLE_16BIT:
{
- if (datalength==sizeof(int16_t))
- {
+ if (datalength == sizeof(int16_t))
dltdata->test_counter_macro[1]++;
- }
+
break;
}
case DLT_TYLE_32BIT:
{
- if (datalength==sizeof(int32_t))
- {
+ if (datalength == sizeof(int32_t))
dltdata->test_counter_macro[1]++;
- }
+
break;
}
case DLT_TYLE_64BIT:
{
- if (datalength==sizeof(int64_t))
- {
+ if (datalength == sizeof(int64_t))
dltdata->test_counter_macro[1]++;
- }
+
break;
}
case DLT_TYLE_128BIT:
@@ -620,38 +558,33 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
else if (type_info & DLT_TYPE_INFO_UINT)
{
- switch (type_info & DLT_TYPE_INFO_TYLE)
- {
+ switch (type_info & DLT_TYPE_INFO_TYLE) {
case DLT_TYLE_8BIT:
{
- if (datalength==sizeof(uint8_t))
- {
+ if (datalength == sizeof(uint8_t))
dltdata->test_counter_macro[1]++;
- }
+
break;
}
case DLT_TYLE_16BIT:
{
- if (datalength==sizeof(uint16_t))
- {
+ if (datalength == sizeof(uint16_t))
dltdata->test_counter_macro[1]++;
- }
+
break;
}
case DLT_TYLE_32BIT:
{
- if (datalength==sizeof(uint32_t))
- {
+ if (datalength == sizeof(uint32_t))
dltdata->test_counter_macro[1]++;
- }
+
break;
}
case DLT_TYLE_64BIT:
{
- if (datalength==sizeof(uint64_t))
- {
+ if (datalength == sizeof(uint64_t))
dltdata->test_counter_macro[1]++;
- }
+
break;
}
case DLT_TYLE_128BIT:
@@ -663,8 +596,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
else if (type_info & DLT_TYPE_INFO_FLOA)
{
- switch (type_info & DLT_TYPE_INFO_TYLE)
- {
+ switch (type_info & DLT_TYPE_INFO_TYLE) {
case DLT_TYLE_8BIT:
{
/* Not tested here */
@@ -677,18 +609,16 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
case DLT_TYLE_32BIT:
{
- if (datalength==(2*sizeof(float)+sizeof(uint32_t)))
- {
+ if (datalength == (2 * sizeof(float) + sizeof(uint32_t)))
dltdata->test_counter_macro[1]++;
- }
+
break;
}
case DLT_TYLE_64BIT:
{
- if (datalength==(2*sizeof(double)+sizeof(uint32_t)))
- {
+ if (datalength == (2 * sizeof(double) + sizeof(uint32_t)))
dltdata->test_counter_macro[1]++;
- }
+
break;
}
case DLT_TYLE_128BIT:
@@ -699,12 +629,11 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
else if (type_info & DLT_TYPE_INFO_RAWD)
{
/* Get length */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if ((length==datalength) && (10 == length))
- {
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+
+ if ((length == datalength) && (10 == length))
dltdata->test_counter_macro[1]++;
- }
}
}
}
@@ -714,313 +643,296 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
/* check test 3m */
- if (strcmp(text,"Test3: (Macro IF) Test all variable types (non-verbose)")==0)
- {
+ if (strcmp(text, "Test3: (Macro IF) Test all variable types (non-verbose)") == 0) {
printf("Test3m: (Macro IF) Test all variable types (non-verbose)\n");
dltdata->running_test = 3;
- dltdata->test_counter_macro[2]=0;
+ dltdata->test_counter_macro[2] = 0;
}
- else if (strcmp(text,"Test3: (Macro IF) finished")==0)
+ else if (strcmp(text, "Test3: (Macro IF) finished") == 0)
{
- if (dltdata->test_counter_macro[2]==16)
- {
+ if (dltdata->test_counter_macro[2] == 16) {
printf("Test3m PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test3m FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==3)
+ else if (dltdata->running_test == 3)
{
/* Nonverbose */
- if (DLT_MSG_IS_NONVERBOSE(message))
- {
- id=0;
- id_tmp=0;
+ if (DLT_MSG_IS_NONVERBOSE(message)) {
+ id = 0;
+ id_tmp = 0;
ptr = message->databuffer;
datalength = message->datasize;
- slen=-1;
+ slen = -1;
- tc_old=dltdata->test_counter_macro[2];
+ tc_old = dltdata->test_counter_macro[2];
/* Get message id */
- DLT_MSG_READ_VALUE(id_tmp,ptr,datalength,uint32_t);
- id=DLT_ENDIAN_GET_32(message->standardheader->htyp, id_tmp);
+ DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t);
+ id = DLT_ENDIAN_GET_32(message->standardheader->htyp, id_tmp);
/* Length of string */
- datalength-=sizeof(uint16_t);
- ptr+=sizeof(uint16_t);
+ datalength -= sizeof(uint16_t);
+ ptr += sizeof(uint16_t);
- switch (id)
- {
+ switch (id) {
case 1:
{
- slen=strlen("string")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint16_t)+strlen("Hello world")+1)
- {
+ slen = strlen("string") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint16_t) + strlen("Hello world") + 1)
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 2:
{
- slen=strlen("utf8")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint16_t)+strlen("Hello world")+1)
- {
+ slen = strlen("utf8") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint16_t) + strlen("Hello world") + 1)
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 3:
{
- slen=strlen("bool")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint8_t))
- {
+ slen = strlen("bool") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint8_t))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 4:
{
- slen=strlen("int")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(int))
- {
+ slen = strlen("int") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(int))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 5:
{
- slen=strlen("int8")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(int8_t))
- {
+ slen = strlen("int8") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(int8_t))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 6:
{
- slen=strlen("int16")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(int16_t))
- {
+ slen = strlen("int16") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(int16_t))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 7:
{
- slen=strlen("int32")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(int32_t))
- {
+ slen = strlen("int32") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(int32_t))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 8:
{
- slen=strlen("int64")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(int64_t))
- {
+ slen = strlen("int64") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(int64_t))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 9:
{
- slen=strlen("uint")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(unsigned int))
- {
+ slen = strlen("uint") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(unsigned int))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 10:
{
- slen=strlen("uint8")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint8_t))
- {
+ slen = strlen("uint8") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint8_t))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 11:
{
- slen=strlen("uint16")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint16_t))
- {
+ slen = strlen("uint16") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint16_t))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 12:
{
- slen=strlen("uint32")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint32_t))
- {
+ slen = strlen("uint32") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint32_t))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 13:
{
- slen=strlen("uint64")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint64_t))
- {
+ slen = strlen("uint64") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint64_t))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 14:
{
- slen=strlen("float32")+1;
- datalength-=slen;
- ptr+=slen;
+ slen = strlen("float32") + 1;
+ datalength -= slen;
+ ptr += slen;
+
/* 2*, as the min and the max is transfered */
- if (datalength==2*sizeof(float))
- {
+ if (datalength == 2 * sizeof(float))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 15:
{
- slen=strlen("float64")+1;
- datalength-=slen;
- ptr+=slen;
+ slen = strlen("float64") + 1;
+ datalength -= slen;
+ ptr += slen;
+
/* 2*, as the min and the max is transfered */
- if (datalength==2*sizeof(double))
- {
+ if (datalength == 2 * sizeof(double))
dltdata->test_counter_macro[2]++;
- }
+
break;
}
case 16:
{
- slen=strlen("raw")+1;
- datalength-=slen;
- ptr+=slen;
- datalength-=sizeof(uint16_t);
- ptr+=sizeof(uint16_t);
- if (datalength==10)
- {
+ slen = strlen("raw") + 1;
+ datalength -= slen;
+ ptr += slen;
+ datalength -= sizeof(uint16_t);
+ ptr += sizeof(uint16_t);
+
+ if (datalength == 10)
dltdata->test_counter_macro[2]++;
- }
+
break;
}
}
- if ((slen>=0) && (tc_old==dltdata->test_counter_macro[2]))
- {
- printf("ID=%d, Datalength=%d => Failed!",id,datalength);
- }
+ if ((slen >= 0) && (tc_old == dltdata->test_counter_macro[2]))
+ printf("ID=%d, Datalength=%d => Failed!", id, datalength);
}
}
/* check test 4m */
- if (strcmp(text,"Test4: (Macro IF) Test different message sizes")==0)
- {
+ if (strcmp(text, "Test4: (Macro IF) Test different message sizes") == 0) {
printf("Test4m: (Macro IF) Test different message sizes\n");
dltdata->running_test = 4;
- dltdata->test_counter_macro[3]=0;
+ dltdata->test_counter_macro[3] = 0;
}
- else if (strcmp(text,"Test4: (Macro IF) finished")==0)
+ else if (strcmp(text, "Test4: (Macro IF) finished") == 0)
{
- if (dltdata->test_counter_macro[3]==4)
- {
+ if (dltdata->test_counter_macro[3] == 4) {
printf("Test4m PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test4m FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==4)
+ else if (dltdata->running_test == 4)
{
/* Extended header */
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
/* Log message */
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
- {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_LOG) {
/* Verbose */
- if (DLT_IS_MSIN_VERB(message->extendedheader->msin))
- {
+ if (DLT_IS_MSIN_VERB(message->extendedheader->msin)) {
/* 2 arguments */
- if (message->extendedheader->noar==2)
- {
+ if (message->extendedheader->noar == 2) {
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0;
- length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0;
+ length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* first read the type info of the first argument: must be string */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_STRG)
- {
+ if (type_info & DLT_TYPE_INFO_STRG) {
/* skip string */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if (length>=0)
- {
- ptr+=length;
- datalength-=length;
+ if (length >= 0) {
+ ptr += length;
+ datalength -= length;
/* read type of second argument: must be raw */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_RAWD)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
/* get length of raw data block */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if ((length>=0) && (length==datalength))
- {
- //printf("Raw data found in payload, length=");
- //printf("%d, datalength=%d \n", length, datalength);
+ if ((length >= 0) && (length == datalength))
+ /*printf("Raw data found in payload, length="); */
+ /*printf("%d, datalength=%d \n", length, datalength); */
dltdata->test_counter_macro[3]++;
- }
}
}
}
@@ -1031,209 +943,171 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
/* check test 5m */
- if (strcmp(text,"Test5: (Macro IF) Test high-level API")==0)
- {
+ if (strcmp(text, "Test5: (Macro IF) Test high-level API") == 0) {
printf("Test5m: (Macro IF) Test high-level API\n");
dltdata->running_test = 5;
- dltdata->test_counter_macro[4]=0;
+ dltdata->test_counter_macro[4] = 0;
}
- else if (strcmp(text,"Test5: (Macro IF) finished")==0)
+ else if (strcmp(text, "Test5: (Macro IF) finished") == 0)
{
- if (dltdata->test_counter_macro[4]==12)
- {
+ if (dltdata->test_counter_macro[4] == 12) {
printf("Test5m PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test5m FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==5)
+ else if (dltdata->running_test == 5)
{
- if (strcmp(text,"Next line: DLT_LOG_INT")==0)
- {
+ if (strcmp(text, "Next line: DLT_LOG_INT") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"-42")==0)
- {
+
+ if (strcmp(text, "-42") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"Next line: DLT_LOG_UINT")==0)
- {
+ if (strcmp(text, "Next line: DLT_LOG_UINT") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"42")==0)
- {
+
+ if (strcmp(text, "42") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"Next line: DLT_LOG_STRING")==0)
- {
+ if (strcmp(text, "Next line: DLT_LOG_STRING") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"String output")==0)
- {
+
+ if (strcmp(text, "String output") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"Next line: DLT_LOG_RAW")==0)
- {
+ if (strcmp(text, "Next line: DLT_LOG_RAW") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f")==0)
- {
+
+ if (strcmp(text, "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"Next line: DLT_LOG_STRING_INT")==0)
- {
+ if (strcmp(text, "Next line: DLT_LOG_STRING_INT") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"String output: -42")==0)
- {
+
+ if (strcmp(text, "String output: -42") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"Next line: DLT_LOG_STRING_UINT")==0)
- {
+ if (strcmp(text, "Next line: DLT_LOG_STRING_UINT") == 0)
dltdata->test_counter_macro[4]++;
- }
- if (strcmp(text,"String output: 42")==0)
- {
+
+ if (strcmp(text, "String output: 42") == 0)
dltdata->test_counter_macro[4]++;
- }
}
/* check test 6m */
- if (strcmp(text,"Test 6: (Macro IF) Test local printing")==0)
- {
+ if (strcmp(text, "Test 6: (Macro IF) Test local printing") == 0) {
printf("Test6m: (Macro IF) Test local printing\n");
dltdata->running_test = 6;
- dltdata->test_counter_macro[5]=0;
+ dltdata->test_counter_macro[5] = 0;
}
- else if (strcmp(text,"Test6: (Macro IF) finished")==0)
+ else if (strcmp(text, "Test6: (Macro IF) finished") == 0)
{
- if (dltdata->test_counter_macro[5]==2)
- {
+ if (dltdata->test_counter_macro[5] == 2) {
printf("Test6m PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test6m FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==6)
+ else if (dltdata->running_test == 6)
{
- if (strcmp(text,"Message (visible: locally printed)")==0)
- {
+ if (strcmp(text, "Message (visible: locally printed)") == 0) {
printf("Message (visible: locally printed)\n");
dltdata->test_counter_macro[5]++;
}
- if (strcmp(text,"Message (invisible: not locally printed)")==0)
- {
+
+ if (strcmp(text, "Message (invisible: not locally printed)") == 0) {
printf("Message (invisible: not locally printed)\n");
dltdata->test_counter_macro[5]++;
}
}
/* check test 7m */
- if (strcmp(text,"Test 7: (Macro IF) Test network trace")==0)
- {
+ if (strcmp(text, "Test 7: (Macro IF) Test network trace") == 0) {
printf("Test7m: (Macro IF) Test network trace\n");
dltdata->running_test = 7;
- dltdata->test_counter_macro[6]=0;
+ dltdata->test_counter_macro[6] = 0;
}
- else if (strcmp(text,"Test7: (Macro IF) finished")==0)
+ else if (strcmp(text, "Test7: (Macro IF) finished") == 0)
{
- if (dltdata->test_counter_macro[6]==8)
- {
+ if (dltdata->test_counter_macro[6] == 8) {
printf("Test7m PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test7m FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==7)
+ else if (dltdata->running_test == 7)
{
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
- {
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_NW_TRACE) {
/* Check message type information*/
/* Each correct message type increases the counter by 1 */
- mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
+ mtin = DLT_GET_MSIN_MTIN(message->extendedheader->msin);
- if (mtin==DLT_NW_TRACE_IPC)
- {
+ if (mtin == DLT_NW_TRACE_IPC)
dltdata->test_counter_macro[6]++;
- }
- if (mtin==DLT_NW_TRACE_CAN)
- {
+
+ if (mtin == DLT_NW_TRACE_CAN)
dltdata->test_counter_macro[6]++;
- }
- if (mtin==DLT_NW_TRACE_FLEXRAY)
- {
+
+ if (mtin == DLT_NW_TRACE_FLEXRAY)
dltdata->test_counter_macro[6]++;
- }
- if (mtin==DLT_NW_TRACE_MOST)
- {
+
+ if (mtin == DLT_NW_TRACE_MOST)
dltdata->test_counter_macro[6]++;
- }
/* Check payload, must be two arguments (2 raw data blocks) */
/* If the payload is correct, the counter is increased by 1 */
- if (message->extendedheader->noar==2)
- {
+ if (message->extendedheader->noar == 2) {
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0,length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0, length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* first read the type info of the first argument: must be string */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_RAWD)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
/* skip string */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if (length>=0)
- {
- ptr+=length;
- datalength-=length;
+ if (length >= 0) {
+ ptr += length;
+ datalength -= length;
/* read type of second argument: must be raw */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_RAWD)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
/* get length of raw data block */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if ((length>=0) && (length==datalength))
- {
- //printf("Raw data found in payload, length=");
- //printf("%d, datalength=%d \n", length, datalength);
+ if ((length >= 0) && (length == datalength))
+ /*printf("Raw data found in payload, length="); */
+ /*printf("%d, datalength=%d \n", length, datalength); */
dltdata->test_counter_macro[6]++;
- }
}
}
}
@@ -1243,116 +1117,100 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
/* check test 8m */
- if (strcmp(text,"Test 8: (Macro IF) Test truncated network trace")==0)
- {
+ if (strcmp(text, "Test 8: (Macro IF) Test truncated network trace") == 0) {
printf("Test8m: (Macro IF) Test truncated network trace\n");
dltdata->running_test = 8;
- dltdata->test_counter_macro[7]=0;
+ dltdata->test_counter_macro[7] = 0;
}
- else if (strcmp(text,"Test8: (Macro IF) finished")==0)
+ else if (strcmp(text, "Test8: (Macro IF) finished") == 0)
{
- if (dltdata->test_counter_macro[7]==20)
- {
+ if (dltdata->test_counter_macro[7] == 20) {
printf("Test8m PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test8m FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==8)
+ else if (dltdata->running_test == 8)
{
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
- {
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_NW_TRACE) {
/* Check message type information*/
/* Each correct message type increases the counter by 1 */
- mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
+ mtin = DLT_GET_MSIN_MTIN(message->extendedheader->msin);
- if (mtin==DLT_NW_TRACE_IPC)
- {
+ if (mtin == DLT_NW_TRACE_IPC)
dltdata->test_counter_macro[7]++;
- }
- if (mtin==DLT_NW_TRACE_CAN)
- {
+
+ if (mtin == DLT_NW_TRACE_CAN)
dltdata->test_counter_macro[7]++;
- }
- if (mtin==DLT_NW_TRACE_FLEXRAY)
- {
+
+ if (mtin == DLT_NW_TRACE_FLEXRAY)
dltdata->test_counter_macro[7]++;
- }
- if (mtin==DLT_NW_TRACE_MOST)
- {
+
+ if (mtin == DLT_NW_TRACE_MOST)
dltdata->test_counter_macro[7]++;
- }
/* Check payload, must be two arguments (2 raw data blocks) */
/* If the payload is correct, the counter is increased by 1 */
- if (message->extendedheader->noar==4)
- {
- type_info=0;
- type_info_tmp=0;
- length=0,length_tmp=0; /* the macro can set this variable to -1 */
+ if (message->extendedheader->noar == 4) {
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0, length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_STRG)
- {
- // Read NWTR
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_STRG) {
+ /* Read NWTR */
char chdr[10];
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
- if(strcmp((char *)chdr, "NWTR")==0)
- {
+ if (strcmp((char *)chdr, "NWTR") == 0)
dltdata->test_counter_macro[7]++;
- }
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_RAWD)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_RAWD) {
char hdr[2048];
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
DLT_MSG_READ_STRING(hdr, ptr, datalength, length);
- if(length == 16 && hdr[15] == 15)
- {
+ if ((length == 16) && (hdr[15] == 15))
dltdata->test_counter_macro[7]++;
- }
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint32_t orig_size;
- DLT_MSG_READ_VALUE(length_tmp32,ptr,datalength,uint32_t);
- orig_size=DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
- if(orig_size == 1024*5)
- {
+ DLT_MSG_READ_VALUE(length_tmp32, ptr, datalength, uint32_t);
+ orig_size = DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
+
+ if (orig_size == 1024 * 5)
dltdata->test_counter_macro[7]++;
- }
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_RAWD)
- {
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- // Size of the truncated message after headers
- if(length == DLT_USER_BUF_MAX_SIZE - 41 - sizeof(uint16_t) - sizeof(uint32_t))
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_RAWD) {
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+
+ /* Size of the truncated message after headers */
+ if (length == DLT_USER_BUF_MAX_SIZE - 41 - sizeof(uint16_t) - sizeof(uint32_t))
dltdata->test_counter_macro[7]++;
- }
}
}
}
@@ -1362,154 +1220,135 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
}
-
/* check test 9m */
- if (strcmp(text,"Test 9: (Macro IF) Test segmented network trace")==0)
- {
+ if (strcmp(text, "Test 9: (Macro IF) Test segmented network trace") == 0) {
printf("Test9m: (Macro IF) Test segmented network trace\n");
dltdata->running_test = 9;
- dltdata->test_counter_macro[8]=0;
+ dltdata->test_counter_macro[8] = 0;
}
- else if (strcmp(text,"Test9: (Macro IF) finished")==0)
+ else if (strcmp(text, "Test9: (Macro IF) finished") == 0)
{
/* (Interface types) * (results per packet)*/
- if (dltdata->test_counter_macro[8]==4*35)
- {
+ if (dltdata->test_counter_macro[8] == 4 * 35) {
printf("Test9m PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test9m FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==9)
+ else if (dltdata->running_test == 9)
{
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
- {
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_NW_TRACE) {
/* Check message type information*/
/* Each correct message type increases the counter by 1 */
- mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
+ mtin = DLT_GET_MSIN_MTIN(message->extendedheader->msin);
- if (mtin==DLT_NW_TRACE_IPC)
- {
+ if (mtin == DLT_NW_TRACE_IPC)
dltdata->test_counter_macro[8]++;
- }
- if (mtin==DLT_NW_TRACE_CAN)
- {
+
+ if (mtin == DLT_NW_TRACE_CAN)
dltdata->test_counter_macro[8]++;
- }
- if (mtin==DLT_NW_TRACE_FLEXRAY)
- {
+
+ if (mtin == DLT_NW_TRACE_FLEXRAY)
dltdata->test_counter_macro[8]++;
- }
- if (mtin==DLT_NW_TRACE_MOST)
- {
+
+ if (mtin == DLT_NW_TRACE_MOST)
dltdata->test_counter_macro[8]++;
- }
/* Payload for first segmented message */
- if (message->extendedheader->noar==6)
- {
+ if (message->extendedheader->noar == 6) {
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0,length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0, length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* NWST */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_STRG)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_STRG) {
char chdr[10];
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
- if(strcmp((char *)chdr, "NWST")==0)
- {
+
+ if (strcmp((char *)chdr, "NWST") == 0)
dltdata->test_counter_macro[8]++;
- }
/* Streahandle */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint32_t handle;
- DLT_MSG_READ_VALUE(length_tmp32,ptr,datalength,uint32_t);
- handle=DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
- if(handle > 0)
- {
+ DLT_MSG_READ_VALUE(length_tmp32, ptr, datalength, uint32_t);
+ handle = DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
+
+ if (handle > 0)
dltdata->test_counter_macro[8]++;
- }
/* Header */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_RAWD)
- {
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- // Test packet header size 16
- if(length == 16)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+
+ /* Test packet header size 16 */
+ if (length == 16)
dltdata->test_counter_macro[8]++;
- }
+
/* Skip data */
- ptr+=length;
- datalength-=length;
+ ptr += length;
+ datalength -= length;
/* Payload size */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint32_t pl_sz;
- DLT_MSG_READ_VALUE(length_tmp32,ptr,datalength,uint32_t);
- pl_sz=DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
+ DLT_MSG_READ_VALUE(length_tmp32, ptr, datalength, uint32_t);
+ pl_sz = DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
- // Test packet payload size.
- if(pl_sz == 5120)
- {
+ /* Test packet payload size. */
+ if (pl_sz == 5120)
dltdata->test_counter_macro[8]++;
- }
/* Segmentcount */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint16_t scount;
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- scount=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ scount = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
/* Test packet segment count 5 */
- if(scount == 5)
- {
+ if (scount == 5)
dltdata->test_counter_macro[8]++;
- }
/* Segment length */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint16_t slen;
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- slen=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ slen = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+
/* Default segment size 1024 */
- if(slen == 1024)
- {
+ if (slen == 1024)
dltdata->test_counter_macro[8]++;
- }
}
}
}
@@ -1518,108 +1357,102 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
}
/* Data segment */
- else if (message->extendedheader->noar==4)
+ else if (message->extendedheader->noar == 4)
{
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0,length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0, length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* NWCH */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_STRG)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_STRG) {
char chdr[10];
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
- if(strcmp((char *)chdr, "NWCH")==0)
- {
+
+ if (strcmp((char *)chdr, "NWCH") == 0)
dltdata->test_counter_macro[8]++;
- }
/* handle */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint32_t handle;
- DLT_MSG_READ_VALUE(length_tmp32,ptr,datalength,uint32_t);
- handle=DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
- if(handle > 0)
- {
+ DLT_MSG_READ_VALUE(length_tmp32, ptr, datalength, uint32_t);
+ handle = DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
+
+ if (handle > 0)
dltdata->test_counter_macro[8]++;
- }
/* Sequence */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
- //uint16_t seq;
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- //seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- dltdata->test_counter_macro[8]++;
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
+ /*uint16_t seq; */
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ /*seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); */
+ dltdata->test_counter_macro[8]++;
/* Data */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_RAWD)
- {
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- // Segment size by default, 1024
- if(length == 1024)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+
+ /* Segment size by default, 1024 */
+ if (length == 1024)
dltdata->test_counter_macro[8]++;
- }
}
}
}
}
}
/* End segment */
- else if (message->extendedheader->noar==2)
+ else if (message->extendedheader->noar == 2)
{
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0,length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0, length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* NWEN */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_STRG)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_STRG) {
char chdr[10];
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
- if(strcmp((char *)chdr, "NWEN")==0)
- {
+
+ if (strcmp((char *)chdr, "NWEN") == 0)
dltdata->test_counter_macro[8]++;
- }
/* handle */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint32_t handle;
- DLT_MSG_READ_VALUE(length_tmp32,ptr,datalength,uint32_t);
- handle=DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
- if(handle > 0)
- {
+ DLT_MSG_READ_VALUE(length_tmp32, ptr, datalength, uint32_t);
+ handle = DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
+
+ if (handle > 0)
dltdata->test_counter_macro[8]++;
- }
}
}
}
@@ -1628,161 +1461,135 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
/* check test 1f */
- if (strcmp(text,"Test1: (Function IF) Test all log levels")==0)
- {
+ if (strcmp(text, "Test1: (Function IF) Test all log levels") == 0) {
printf("Test1f: (Function IF) Test all log levels\n");
dltdata->running_test = 10;
dltdata->test_counter_function[0] = 0;
}
- else if (strcmp(text,"Test1: (Function IF) finished")==0)
+ else if (strcmp(text, "Test1: (Function IF) finished") == 0)
{
/* >=4, as "info" is default log level */
- if (dltdata->test_counter_function[0]>=4)
- {
+ if (dltdata->test_counter_function[0] >= 4) {
printf("Test1f PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test1f FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==10)
+ else if (dltdata->running_test == 10)
{
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
- {
- mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_LOG) {
+ mtin = DLT_GET_MSIN_MTIN(message->extendedheader->msin);
- if (mtin==DLT_LOG_FATAL)
- {
+ if (mtin == DLT_LOG_FATAL)
dltdata->test_counter_function[0]++;
- }
- if (mtin==DLT_LOG_ERROR)
- {
+
+ if (mtin == DLT_LOG_ERROR)
dltdata->test_counter_function[0]++;
- }
- if (mtin==DLT_LOG_WARN)
- {
+
+ if (mtin == DLT_LOG_WARN)
dltdata->test_counter_function[0]++;
- }
- if (mtin==DLT_LOG_INFO)
- {
+
+ if (mtin == DLT_LOG_INFO)
dltdata->test_counter_function[0]++;
- }
- if (mtin==DLT_LOG_DEBUG)
- {
+
+ if (mtin == DLT_LOG_DEBUG)
dltdata->test_counter_function[0]++;
- }
- if (mtin==DLT_LOG_VERBOSE)
- {
+
+ if (mtin == DLT_LOG_VERBOSE)
dltdata->test_counter_function[0]++;
- }
}
}
}
/* check test 2f */
- if (strcmp(text,"Test2: (Function IF) Test all variable types (verbose)")==0)
- {
+ if (strcmp(text, "Test2: (Function IF) Test all variable types (verbose)") == 0) {
printf("Test2f: (Function IF) Test all variable types (verbose)\n");
dltdata->running_test = 11;
dltdata->test_counter_function[1] = 0;
}
- else if (strcmp(text,"Test2: (Function IF) finished")==0)
+ else if (strcmp(text, "Test2: (Function IF) finished") == 0)
{
- if (dltdata->test_counter_function[1]==14)
- {
+ if (dltdata->test_counter_function[1] == 14) {
printf("Test2f PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test2f FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==11)
+ else if (dltdata->running_test == 11)
{
/* Verbose */
- if (!(DLT_MSG_IS_NONVERBOSE(message)))
- {
- type_info=0;
- type_info_tmp=0;
- length=0;
- length_tmp=0; /* the macro can set this variable to -1 */
+ if (!(DLT_MSG_IS_NONVERBOSE(message))) {
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0;
+ length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* Log message */
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
- {
- if (message->extendedheader->noar>=2)
- {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_LOG) {
+ if (message->extendedheader->noar >= 2) {
/* get type of first argument: must be string */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_STRG)
- {
+ if (type_info & DLT_TYPE_INFO_STRG) {
/* skip string */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if (length>=0)
- {
- ptr+=length;
- datalength-=length;
+ if (length >= 0) {
+ ptr += length;
+ datalength -= length;
/* read type of second argument: must be raw */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_BOOL)
- {
- if (datalength==sizeof(uint8_t))
- {
+ if (type_info & DLT_TYPE_INFO_BOOL) {
+ if (datalength == sizeof(uint8_t))
dltdata->test_counter_function[1]++;
- }
}
else if (type_info & DLT_TYPE_INFO_SINT)
{
- switch (type_info & DLT_TYPE_INFO_TYLE)
- {
+ switch (type_info & DLT_TYPE_INFO_TYLE) {
case DLT_TYLE_8BIT:
{
- if (datalength==sizeof(int8_t))
- {
+ if (datalength == sizeof(int8_t))
dltdata->test_counter_function[1]++;
- }
+
break;
}
case DLT_TYLE_16BIT:
{
- if (datalength==sizeof(int16_t))
- {
+ if (datalength == sizeof(int16_t))
dltdata->test_counter_function[1]++;
- }
+
break;
}
case DLT_TYLE_32BIT:
{
- if (datalength==sizeof(int32_t))
- {
+ if (datalength == sizeof(int32_t))
dltdata->test_counter_function[1]++;
- }
+
break;
}
case DLT_TYLE_64BIT:
{
- if (datalength==sizeof(int64_t))
- {
+ if (datalength == sizeof(int64_t))
dltdata->test_counter_function[1]++;
- }
+
break;
}
case DLT_TYLE_128BIT:
@@ -1794,38 +1601,33 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
else if (type_info & DLT_TYPE_INFO_UINT)
{
- switch (type_info & DLT_TYPE_INFO_TYLE)
- {
+ switch (type_info & DLT_TYPE_INFO_TYLE) {
case DLT_TYLE_8BIT:
{
- if (datalength==sizeof(uint8_t))
- {
+ if (datalength == sizeof(uint8_t))
dltdata->test_counter_function[1]++;
- }
+
break;
}
case DLT_TYLE_16BIT:
{
- if (datalength==sizeof(uint16_t))
- {
+ if (datalength == sizeof(uint16_t))
dltdata->test_counter_function[1]++;
- }
+
break;
}
case DLT_TYLE_32BIT:
{
- if (datalength==sizeof(uint32_t))
- {
+ if (datalength == sizeof(uint32_t))
dltdata->test_counter_function[1]++;
- }
+
break;
}
case DLT_TYLE_64BIT:
{
- if (datalength==sizeof(uint64_t))
- {
+ if (datalength == sizeof(uint64_t))
dltdata->test_counter_function[1]++;
- }
+
break;
}
case DLT_TYLE_128BIT:
@@ -1837,8 +1639,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
else if (type_info & DLT_TYPE_INFO_FLOA)
{
- switch (type_info & DLT_TYPE_INFO_TYLE)
- {
+ switch (type_info & DLT_TYPE_INFO_TYLE) {
case DLT_TYLE_8BIT:
{
/* Not tested here */
@@ -1851,18 +1652,16 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
case DLT_TYLE_32BIT:
{
- if (datalength==(2*sizeof(float)+sizeof(uint32_t)))
- {
+ if (datalength == (2 * sizeof(float) + sizeof(uint32_t)))
dltdata->test_counter_function[1]++;
- }
+
break;
}
case DLT_TYLE_64BIT:
{
- if (datalength==(2*sizeof(double)+sizeof(uint32_t)))
- {
+ if (datalength == (2 * sizeof(double) + sizeof(uint32_t)))
dltdata->test_counter_function[1]++;
- }
+
break;
}
case DLT_TYLE_128BIT:
@@ -1875,12 +1674,11 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
else if (type_info & DLT_TYPE_INFO_RAWD)
{
/* Get length */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if ((length==datalength) && (length==10))
- {
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+
+ if ((length == datalength) && (length == 10))
dltdata->test_counter_function[1]++;
- }
}
}
}
@@ -1890,291 +1688,274 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
/* check test 3f */
- if (strcmp(text,"Test3: (Function IF) Test all variable types (non-verbose)")==0)
- {
+ if (strcmp(text, "Test3: (Function IF) Test all variable types (non-verbose)") == 0) {
printf("Test3f: (Function IF) Test all variable types (non-verbose)\n");
dltdata->running_test = 12;
- dltdata->test_counter_function[2]=0;
+ dltdata->test_counter_function[2] = 0;
}
- else if (strcmp(text,"Test3: (Function IF) finished")==0)
+ else if (strcmp(text, "Test3: (Function IF) finished") == 0)
{
- if (dltdata->test_counter_function[2]==14)
- {
+ if (dltdata->test_counter_function[2] == 14) {
printf("Test3f PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test3f FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==12)
+ else if (dltdata->running_test == 12)
{
/* Nonverbose */
- if (DLT_MSG_IS_NONVERBOSE(message))
- {
- id=0;
- id_tmp=0;
+ if (DLT_MSG_IS_NONVERBOSE(message)) {
+ id = 0;
+ id_tmp = 0;
ptr = message->databuffer;
datalength = message->datasize;
- slen=-1;
+ slen = -1;
- tc_old=dltdata->test_counter_function[2];
+ tc_old = dltdata->test_counter_function[2];
/* Get message id */
- DLT_MSG_READ_VALUE(id_tmp,ptr,datalength,uint32_t);
- id=DLT_ENDIAN_GET_32(message->standardheader->htyp, id_tmp);
+ DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t);
+ id = DLT_ENDIAN_GET_32(message->standardheader->htyp, id_tmp);
/* Length of string */
- datalength-=sizeof(uint16_t);
- ptr+=sizeof(uint16_t);
+ datalength -= sizeof(uint16_t);
+ ptr += sizeof(uint16_t);
- switch (id)
- {
+ switch (id) {
case 1:
{
- slen=strlen("bool")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint8_t))
- {
+ slen = strlen("bool") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint8_t))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 2:
{
- slen=strlen("int")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(int))
- {
+ slen = strlen("int") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(int))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 3:
{
- slen=strlen("int8")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(int8_t))
- {
+ slen = strlen("int8") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(int8_t))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 4:
{
- slen=strlen("int16")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(int16_t))
- {
+ slen = strlen("int16") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(int16_t))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 5:
{
- slen=strlen("int32")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(int32_t))
- {
+ slen = strlen("int32") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(int32_t))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 6:
{
- slen=strlen("int64")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(int64_t))
- {
+ slen = strlen("int64") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(int64_t))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 7:
{
- slen=strlen("uint")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(unsigned int))
- {
+ slen = strlen("uint") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(unsigned int))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 8:
{
- slen=strlen("uint8")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint8_t))
- {
+ slen = strlen("uint8") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint8_t))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 9:
{
- slen=strlen("uint16")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint16_t))
- {
+ slen = strlen("uint16") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint16_t))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 10:
{
- slen=strlen("uint32")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint32_t))
- {
+ slen = strlen("uint32") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint32_t))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 11:
{
- slen=strlen("uint64")+1;
- datalength-=slen;
- ptr+=slen;
- if (datalength==sizeof(uint64_t))
- {
+ slen = strlen("uint64") + 1;
+ datalength -= slen;
+ ptr += slen;
+
+ if (datalength == sizeof(uint64_t))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 12:
{
- slen=strlen("float32")+1;
- datalength-=slen;
- ptr+=slen;
+ slen = strlen("float32") + 1;
+ datalength -= slen;
+ ptr += slen;
+
/* 2*, as the min and the max is transfered */
- if (datalength==2*sizeof(float))
- {
+ if (datalength == 2 * sizeof(float))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 13:
{
- slen=strlen("float64")+1;
- datalength-=slen;
- ptr+=slen;
+ slen = strlen("float64") + 1;
+ datalength -= slen;
+ ptr += slen;
+
/* 2*, as the min and the max is transfered */
- if (datalength==2*sizeof(double))
- {
+ if (datalength == 2 * sizeof(double))
dltdata->test_counter_function[2]++;
- }
+
break;
}
case 14:
{
- slen=strlen("raw")+1;
- datalength-=slen;
- ptr+=slen;
- datalength-=sizeof(uint16_t);
- ptr+=sizeof(uint16_t);
- if (datalength==10)
- {
+ slen = strlen("raw") + 1;
+ datalength -= slen;
+ ptr += slen;
+ datalength -= sizeof(uint16_t);
+ ptr += sizeof(uint16_t);
+
+ if (datalength == 10)
dltdata->test_counter_function[2]++;
- }
+
break;
}
}
- if ((slen>=0) && (tc_old==dltdata->test_counter_function[2]))
- {
- printf("ID=%d, Datalength=%d => Failed!",id,datalength);
- }
+ if ((slen >= 0) && (tc_old == dltdata->test_counter_function[2]))
+ printf("ID=%d, Datalength=%d => Failed!", id, datalength);
}
}
/* check test 4f */
- if (strcmp(text,"Test4: (Function IF) Test different message sizes")==0)
- {
+ if (strcmp(text, "Test4: (Function IF) Test different message sizes") == 0) {
printf("Test4f: (Function IF) Test different message sizes\n");
dltdata->running_test = 13;
- dltdata->test_counter_function[3]=0;
+ dltdata->test_counter_function[3] = 0;
}
- else if (strcmp(text,"Test4: (Function IF) finished")==0)
+ else if (strcmp(text, "Test4: (Function IF) finished") == 0)
{
- if (dltdata->test_counter_function[3]==4)
- {
+ if (dltdata->test_counter_function[3] == 4) {
printf("Test4f PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test4f FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==13)
+ else if (dltdata->running_test == 13)
{
/* Extended header */
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
/* Log message */
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
- {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_LOG) {
/* Verbose */
- if (DLT_IS_MSIN_VERB(message->extendedheader->msin))
- {
+ if (DLT_IS_MSIN_VERB(message->extendedheader->msin)) {
/* 2 arguments */
- if (message->extendedheader->noar==2)
- {
+ if (message->extendedheader->noar == 2) {
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0;
- length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0;
+ length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* first read the type info of the first argument: should be string */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_STRG)
- {
+ if (type_info & DLT_TYPE_INFO_STRG) {
/* skip string */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if (length>=0)
- {
- ptr+=length;
- datalength-=length;
+ if (length >= 0) {
+ ptr += length;
+ datalength -= length;
/* read type of second argument: should be raw */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_RAWD)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
/* get length of raw data block */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if ((length>=0) && (length==datalength))
- {
- //printf("Raw data found in payload, length=");
- //printf("%d, datalength=%d \n", length, datalength);
+ if ((length >= 0) && (length == datalength))
+ /*printf("Raw data found in payload, length="); */
+ /*printf("%d, datalength=%d \n", length, datalength); */
dltdata->test_counter_function[3]++;
- }
}
}
}
@@ -2185,210 +1966,172 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
/* check test 5f */
- if (strcmp(text,"Test5: (Function IF) Test high-level API")==0)
- {
+ if (strcmp(text, "Test5: (Function IF) Test high-level API") == 0) {
printf("Test5f: (Function IF) Test high-level API\n");
dltdata->running_test = 14;
- dltdata->test_counter_function[4]=0;
+ dltdata->test_counter_function[4] = 0;
}
- else if (strcmp(text,"Test5: (Function IF) finished")==0)
+ else if (strcmp(text, "Test5: (Function IF) finished") == 0)
{
- if (dltdata->test_counter_function[4]==12)
- {
+ if (dltdata->test_counter_function[4] == 12) {
printf("Test5f PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test5f FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==14)
+ else if (dltdata->running_test == 14)
{
- if (strcmp(text,"Next line: dlt_log_int()")==0)
- {
+ if (strcmp(text, "Next line: dlt_log_int()") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"-42")==0)
- {
+
+ if (strcmp(text, "-42") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"Next line: dlt_log_uint()")==0)
- {
+ if (strcmp(text, "Next line: dlt_log_uint()") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"42")==0)
- {
+
+ if (strcmp(text, "42") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"Next line: dlt_log_string()")==0)
- {
+ if (strcmp(text, "Next line: dlt_log_string()") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"String output")==0)
- {
+
+ if (strcmp(text, "String output") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"Next line: dlt_log_raw()")==0)
- {
+ if (strcmp(text, "Next line: dlt_log_raw()") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f")==0)
- {
+
+ if (strcmp(text, "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"Next line: dlt_log_string_int()")==0)
- {
+ if (strcmp(text, "Next line: dlt_log_string_int()") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"String output: -42")==0)
- {
+
+ if (strcmp(text, "String output: -42") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"Next line: dlt_log_string_uint()")==0)
- {
+ if (strcmp(text, "Next line: dlt_log_string_uint()") == 0)
dltdata->test_counter_function[4]++;
- }
- if (strcmp(text,"String output: 42")==0)
- {
+
+ if (strcmp(text, "String output: 42") == 0)
dltdata->test_counter_function[4]++;
- }
}
/* check test 6f */
- if (strcmp(text,"Test 6: (Function IF) Test local printing")==0)
- {
+ if (strcmp(text, "Test 6: (Function IF) Test local printing") == 0) {
printf("Test6f: (Function IF) Test local printing\n");
dltdata->running_test = 15;
- dltdata->test_counter_function[5]=0;
+ dltdata->test_counter_function[5] = 0;
}
- else if (strcmp(text,"Test6: (Function IF) finished")==0)
+ else if (strcmp(text, "Test6: (Function IF) finished") == 0)
{
- if (dltdata->test_counter_function[5]==2)
- {
+ if (dltdata->test_counter_function[5] == 2) {
printf("Test6f PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test6f FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==15)
+ else if (dltdata->running_test == 15)
{
- if (strcmp(text,"Message (visible: locally printed)")==0)
- {
+ if (strcmp(text, "Message (visible: locally printed)") == 0) {
printf("Message (visible: locally printed)\n");
dltdata->test_counter_function[5]++;
}
- if (strcmp(text,"Message (invisible: not locally printed)")==0)
- {
+
+ if (strcmp(text, "Message (invisible: not locally printed)") == 0) {
printf("Message (invisible: not locally printed)\n");
dltdata->test_counter_function[5]++;
}
}
/* check test 7f */
- if (strcmp(text,"Test 7: (Function IF) Test network trace")==0)
- {
+ if (strcmp(text, "Test 7: (Function IF) Test network trace") == 0) {
printf("Test7f: (Function IF) Test network trace\n");
dltdata->running_test = 16;
- dltdata->test_counter_function[6]=0;
+ dltdata->test_counter_function[6] = 0;
}
- else if (strcmp(text,"Test7: (Function IF) finished")==0)
+ else if (strcmp(text, "Test7: (Function IF) finished") == 0)
{
- if (dltdata->test_counter_function[6]==8)
- {
+ if (dltdata->test_counter_function[6] == 8) {
printf("Test7f PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test7f FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==16)
+ else if (dltdata->running_test == 16)
{
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
- {
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_NW_TRACE) {
/* Check message type information*/
/* Each correct message type increases the counter by 1 */
- mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
+ mtin = DLT_GET_MSIN_MTIN(message->extendedheader->msin);
- if (mtin==DLT_NW_TRACE_IPC)
- {
+ if (mtin == DLT_NW_TRACE_IPC)
dltdata->test_counter_function[6]++;
- }
- if (mtin==DLT_NW_TRACE_CAN)
- {
+
+ if (mtin == DLT_NW_TRACE_CAN)
dltdata->test_counter_function[6]++;
- }
- if (mtin==DLT_NW_TRACE_FLEXRAY)
- {
+
+ if (mtin == DLT_NW_TRACE_FLEXRAY)
dltdata->test_counter_function[6]++;
- }
- if (mtin==DLT_NW_TRACE_MOST)
- {
+
+ if (mtin == DLT_NW_TRACE_MOST)
dltdata->test_counter_function[6]++;
- }
/* Check payload, must be two arguments (2 raw data blocks) */
/* If the payload is correct, the counter is increased by 1 */
- if (message->extendedheader->noar==2)
- {
+ if (message->extendedheader->noar == 2) {
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0;
- length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0;
+ length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* first read the type info of the first argument: should be string */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_RAWD)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
/* skip string */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if (length>=0)
- {
- ptr+=length;
- datalength-=length;
+ if (length >= 0) {
+ ptr += length;
+ datalength -= length;
/* read type of second argument: should be raw */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_RAWD)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
/* get length of raw data block */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if ((length>=0) && (length==datalength))
- {
- //printf("Raw data found in payload, length=");
- //printf("%d, datalength=%d \n", length, datalength);
+ if ((length >= 0) && (length == datalength))
+ /*printf("Raw data found in payload, length="); */
+ /*printf("%d, datalength=%d \n", length, datalength); */
dltdata->test_counter_function[6]++;
- }
}
}
}
@@ -2398,116 +2141,100 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
/* check test 8f */
- if (strcmp(text,"Test 8: (Function IF) Test truncated network trace")==0)
- {
+ if (strcmp(text, "Test 8: (Function IF) Test truncated network trace") == 0) {
printf("Test8f: (Function IF) Test truncated network trace\n");
dltdata->running_test = 17;
- dltdata->test_counter_function[7]=0;
+ dltdata->test_counter_function[7] = 0;
}
- else if (strcmp(text,"Test8: (Function IF) finished")==0)
+ else if (strcmp(text, "Test8: (Function IF) finished") == 0)
{
- if (dltdata->test_counter_function[7]==20)
- {
+ if (dltdata->test_counter_function[7] == 20) {
printf("Test8f PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test8f FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==17)
+ else if (dltdata->running_test == 17)
{
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
- {
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_NW_TRACE) {
/* Check message type information*/
/* Each correct message type increases the counter by 1 */
- mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
+ mtin = DLT_GET_MSIN_MTIN(message->extendedheader->msin);
- if (mtin==DLT_NW_TRACE_IPC)
- {
+ if (mtin == DLT_NW_TRACE_IPC)
dltdata->test_counter_function[7]++;
- }
- if (mtin==DLT_NW_TRACE_CAN)
- {
+
+ if (mtin == DLT_NW_TRACE_CAN)
dltdata->test_counter_function[7]++;
- }
- if (mtin==DLT_NW_TRACE_FLEXRAY)
- {
+
+ if (mtin == DLT_NW_TRACE_FLEXRAY)
dltdata->test_counter_function[7]++;
- }
- if (mtin==DLT_NW_TRACE_MOST)
- {
+
+ if (mtin == DLT_NW_TRACE_MOST)
dltdata->test_counter_function[7]++;
- }
/* Check payload, must be two arguments (2 raw data blocks) */
/* If the payload is correct, the counter is increased by 1 */
- if (message->extendedheader->noar==4)
- {
- type_info=0;
- type_info_tmp=0;
- length=0,length_tmp=0; /* the macro can set this variable to -1 */
+ if (message->extendedheader->noar == 4) {
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0, length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_STRG)
- {
- // Read NWTR
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_STRG) {
+ /* Read NWTR */
char chdr[10];
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
- if(strcmp((char *)chdr, "NWTR")==0)
- {
+ if (strcmp((char *)chdr, "NWTR") == 0)
dltdata->test_counter_function[7]++;
- }
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_RAWD)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_RAWD) {
char hdr[2048];
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
DLT_MSG_READ_STRING(hdr, ptr, datalength, length);
- if(length == 16 && hdr[15] == 15)
- {
+ if ((length == 16) && (hdr[15] == 15))
dltdata->test_counter_function[7]++;
- }
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint32_t orig_size;
- DLT_MSG_READ_VALUE(length_tmp32,ptr,datalength,uint32_t);
- orig_size=DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
- if(orig_size == 1024*5)
- {
+ DLT_MSG_READ_VALUE(length_tmp32, ptr, datalength, uint32_t);
+ orig_size = DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
+
+ if (orig_size == 1024 * 5)
dltdata->test_counter_function[7]++;
- }
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_RAWD)
- {
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- // Size of the truncated message after headers
- if(length == DLT_USER_BUF_MAX_SIZE - 41 - sizeof(uint16_t) - sizeof(uint32_t))
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_RAWD) {
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+
+ /* Size of the truncated message after headers */
+ if (length == DLT_USER_BUF_MAX_SIZE - 41 - sizeof(uint16_t) - sizeof(uint32_t))
dltdata->test_counter_function[7]++;
- }
}
}
}
@@ -2518,152 +2245,134 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
/* check test 9f */
- if (strcmp(text,"Test 9: (Function IF) Test segmented network trace")==0)
- {
+ if (strcmp(text, "Test 9: (Function IF) Test segmented network trace") == 0) {
printf("Test9f: (Function IF) Test segmented network trace\n");
dltdata->running_test = 18;
- dltdata->test_counter_function[8]=0;
+ dltdata->test_counter_function[8] = 0;
}
- else if (strcmp(text,"Test9: (Function IF) finished")==0)
+ else if (strcmp(text, "Test9: (Function IF) finished") == 0)
{
/* (Interface types) * (number of messages per complete message) */
- if (dltdata->test_counter_function[8]==4*35)
- {
+ if (dltdata->test_counter_function[8] == 4 * 35) {
printf("Test9f PASSED\n");
dltdata->tests_passed++;
}
- else
- {
+ else {
printf("Test9f FAILED\n");
dltdata->tests_failed++;
}
+
dltdata->running_test = 0;
}
- else if (dltdata->running_test==18)
+ else if (dltdata->running_test == 18)
{
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
- {
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_NW_TRACE) {
/* Check message type information*/
/* Each correct message type increases the counter by 1 */
- mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
+ mtin = DLT_GET_MSIN_MTIN(message->extendedheader->msin);
- if (mtin==DLT_NW_TRACE_IPC)
- {
+ if (mtin == DLT_NW_TRACE_IPC)
dltdata->test_counter_function[8]++;
- }
- if (mtin==DLT_NW_TRACE_CAN)
- {
+
+ if (mtin == DLT_NW_TRACE_CAN)
dltdata->test_counter_function[8]++;
- }
- if (mtin==DLT_NW_TRACE_FLEXRAY)
- {
+
+ if (mtin == DLT_NW_TRACE_FLEXRAY)
dltdata->test_counter_function[8]++;
- }
- if (mtin==DLT_NW_TRACE_MOST)
- {
+
+ if (mtin == DLT_NW_TRACE_MOST)
dltdata->test_counter_function[8]++;
- }
/* Payload for first segmented message */
- if (message->extendedheader->noar==6)
- {
+ if (message->extendedheader->noar == 6) {
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0,length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0, length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* NWST */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_STRG)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_STRG) {
char chdr[10];
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
- if(strcmp((char *)chdr, "NWST")==0)
- {
+
+ if (strcmp((char *)chdr, "NWST") == 0)
dltdata->test_counter_function[8]++;
- }
/* Streahandle */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint32_t handle;
- DLT_MSG_READ_VALUE(length_tmp32,ptr,datalength,uint32_t);
- handle=DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
- if(handle > 0)
- {
+ DLT_MSG_READ_VALUE(length_tmp32, ptr, datalength, uint32_t);
+ handle = DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
+
+ if (handle > 0)
dltdata->test_counter_function[8]++;
- }
/* Header */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_RAWD)
- {
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- // Test packet header size 16
- if(length == 16)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+
+ /* Test packet header size 16 */
+ if (length == 16)
dltdata->test_counter_function[8]++;
- }
+
/* Skip data */
- ptr+=length;
- datalength-=length;
+ ptr += length;
+ datalength -= length;
/* Payload size */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint32_t pl_sz;
- DLT_MSG_READ_VALUE(length_tmp32,ptr,datalength,uint32_t);
- pl_sz=DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
+ DLT_MSG_READ_VALUE(length_tmp32, ptr, datalength, uint32_t);
+ pl_sz = DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
- // Test packet payload size.
- if(pl_sz == 5120)
- {
+ /* Test packet payload size. */
+ if (pl_sz == 5120)
dltdata->test_counter_function[8]++;
- }
/* Segmentcount */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint16_t scount;
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- scount=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ scount = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
/* Test packet segment count 5 */
- if(scount == 5)
- {
+ if (scount == 5)
dltdata->test_counter_function[8]++;
- }
/* Segment length */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint16_t slen;
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- slen=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ slen = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+
/* Default segment size 1024 */
- if(slen == 1024)
- {
+ if (slen == 1024)
dltdata->test_counter_function[8]++;
- }
}
}
}
@@ -2672,126 +2381,118 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
}
}
/* Data segment */
- else if (message->extendedheader->noar==4)
+ else if (message->extendedheader->noar == 4)
{
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0,length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0, length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* NWCH */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_STRG)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_STRG) {
char chdr[10];
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
- if(strcmp((char *)chdr, "NWCH")==0)
- {
+
+ if (strcmp((char *)chdr, "NWCH") == 0)
dltdata->test_counter_function[8]++;
- }
/* handle */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint32_t handle;
- DLT_MSG_READ_VALUE(length_tmp32,ptr,datalength,uint32_t);
- handle=DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
- if(handle > 0)
- {
+ DLT_MSG_READ_VALUE(length_tmp32, ptr, datalength, uint32_t);
+ handle = DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
+
+ if (handle > 0)
dltdata->test_counter_function[8]++;
- }
/* Sequence */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
- //uint16_t seq;
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- //seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
+ /*uint16_t seq; */
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ /*seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); */
dltdata->test_counter_function[8]++;
/* Data */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_RAWD)
- {
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- // Segment size by default, 1024
- if(length == 1024)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+
+ /* Segment size by default, 1024 */
+ if (length == 1024)
dltdata->test_counter_function[8]++;
- }
}
}
}
}
}
/* End segment */
- else if (message->extendedheader->noar==2)
+ else if (message->extendedheader->noar == 2)
{
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0,length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0, length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* NWEN */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_STRG)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_STRG) {
char chdr[10];
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
- if(strcmp((char *)chdr, "NWEN")==0)
- {
+
+ if (strcmp((char *)chdr, "NWEN") == 0)
dltdata->test_counter_function[8]++;
- }
/* handle */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if(type_info & DLT_TYPE_INFO_UINT)
- {
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+
+ if (type_info & DLT_TYPE_INFO_UINT) {
uint32_t handle;
- DLT_MSG_READ_VALUE(length_tmp32,ptr,datalength,uint32_t);
- handle=DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
- if(handle > 0)
- {
+ DLT_MSG_READ_VALUE(length_tmp32, ptr, datalength, uint32_t);
+ handle = DLT_ENDIAN_GET_32(message->standardheader->htyp, length_tmp32);
+
+ if (handle > 0)
dltdata->test_counter_function[8]++;
- }
}
}
}
}
}
}
- if (strcmp(text,"Tests finished")==0)
- {
+
+ if (strcmp(text, "Tests finished") == 0) {
printf("Tests finished\n");
dltdata->running_test = 1;
- printf("%d tests passed\n",dltdata->tests_passed);
- printf("%d tests failed\n",dltdata->tests_failed);
+ printf("%d tests passed\n", dltdata->tests_passed);
+ printf("%d tests failed\n", dltdata->tests_failed);
- if (dltdata->sock!=-1)
- {
+ if (dltdata->sock != -1)
close(dltdata->sock);
- }
g_testsFailed = dltdata->tests_failed;
@@ -2800,30 +2501,24 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
/* if no filter set or filter is matching display message */
if (dltdata->xflag)
- {
- dlt_message_print_hex(message,text,DLT_TESTCLIENT_TEXTBUFSIZE,dltdata->vflag);
- }
+ dlt_message_print_hex(message, text, DLT_TESTCLIENT_TEXTBUFSIZE, dltdata->vflag);
else if (dltdata->mflag)
- {
- dlt_message_print_mixed_plain(message,text,DLT_TESTCLIENT_TEXTBUFSIZE,dltdata->vflag);
- }
+ dlt_message_print_mixed_plain(message, text, DLT_TESTCLIENT_TEXTBUFSIZE, dltdata->vflag);
else if (dltdata->sflag)
- {
- dlt_message_print_header(message,text,sizeof(text),dltdata->vflag);
- }
+ dlt_message_print_header(message, text, sizeof(text), dltdata->vflag);
/* if file output enabled write message */
- if (dltdata->ovalue)
- {
+ if (dltdata->ovalue) {
iov[0].iov_base = message->headerbuffer;
iov[0].iov_len = message->headersize;
iov[1].iov_base = message->databuffer;
iov[1].iov_len = message->datasize;
bytes_written = writev(dltdata->ohandle, iov, 2);
- if (0 > bytes_written){
- printf("dlt_testclient_message_callback, error in: writev(dltdata->ohandle, iov, 2)\n");
- return -1;
+
+ if (0 > bytes_written) {
+ printf("dlt_testclient_message_callback, error in: writev(dltdata->ohandle, iov, 2)\n");
+ return -1;
}
}
}
diff --git a/src/tests/dlt-test-filetransfer.c b/src/tests/dlt-test-filetransfer.c
index 591714a..05a54d9 100644
--- a/src/tests/dlt-test-filetransfer.c
+++ b/src/tests/dlt-test-filetransfer.c
@@ -58,337 +58,347 @@
#include <dlt_filetransfer.h> /*Needed for transferring files with the dlt protocol*/
#include <dlt.h> /*Needed for dlt logging*/
-//!Declare some context for the main program. It's a must have to do this, when you want to log with dlt.
+/*!Declare some context for the main program. It's a must have to do this, when you want to log with dlt. */
DLT_DECLARE_CONTEXT(mainContext)
-//!Declare some context for the file transfer. It's not a must have to do this, but later you can set a filter on this context in the dlt viewer.
+/*!Declare some context for the file transfer. It's not a must have to do this, but later you can set a filter on this context in the dlt viewer. */
DLT_DECLARE_CONTEXT(fileContext)
-//!Textfile which will be transferred.
+/*!Textfile which will be transferred. */
char *file1;
-//!Image which will be transferred.
+/*!Image which will be transferred. */
char *file2;
-//!Not existing file which will be transferred.
+/*!Not existing file which will be transferred. */
char *file3_1;
-//!Not existing file which will be transferred.
+/*!Not existing file which will be transferred. */
char *file3_2;
-//!Not existing file which will be transferred.
+/*!Not existing file which will be transferred. */
char *file3_3;
-//!Just some variables
-int i,countPackages, transferResult;
+/*!Just some variables */
+int i, countPackages, transferResult;
static int g_numFailed = 0;
-//!Prints the test result
-void printTestResultPositiveExpected(const char *function, int result){
+/*!Prints the test result */
+void printTestResultPositiveExpected(const char *function, int result)
+{
- if(result >= 0){
- printf("%s successful\n",function);
+ if (result >= 0) {
+ printf("%s successful\n", function);
}
- else
- {
- printf("%s failed\n",function);
+ else {
+ printf("%s failed\n", function);
g_numFailed++;
}
-
}
-//!Prints the test result
-void printTestResultNegativeExpected(const char *function, int result){
+/*!Prints the test result */
+void printTestResultNegativeExpected(const char *function, int result)
+{
- if(result < 0){
- printf("%s successful\n",function);
+ if (result < 0) {
+ printf("%s successful\n", function);
}
- else
- {
- printf("%s failed\n",function);
+ else {
+ printf("%s failed\n", function);
g_numFailed++;
}
-
}
-//!Test the file transfer with the condition that the transferred file is smaller as the file transfer buffer using dlt_user_log_file_complete.
-int testFile1Run1(){
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF1P1 - dlt_user_log_file_complete"),DLT_STRING(file1));
+/*!Test the file transfer with the condition that the transferred file is smaller as the file transfer buffer using dlt_user_log_file_complete. */
+int testFile1Run1()
+{
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Started testF1P1 - dlt_user_log_file_complete"), DLT_STRING(file1));
- //Here's the line where the dlt file transfer is called. The method call needs a context, the absolute file path, will the file be deleted after transfer and the timeout between the packages
- transferResult = dlt_user_log_file_complete(&fileContext,file1,0,20);
- if(transferResult < 0 )
- {
- printf("Error: dlt_user_log_file_complete\n");
- return transferResult;
+ /*Here's the line where the dlt file transfer is called. The method call needs a context, the absolute file path, will the file be deleted after transfer and the timeout between the packages */
+ transferResult = dlt_user_log_file_complete(&fileContext, file1, 0, 20);
+
+ if (transferResult < 0) {
+ printf("Error: dlt_user_log_file_complete\n");
+ return transferResult;
}
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Finished testF1P1"),DLT_STRING(file1));
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Finished testF1P1"), DLT_STRING(file1));
+
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return transferResult;
}
-//!Test the file transfer with the condition that the transferred file is smaller as the file transfer buffer using single package transfer
-int testFile1Run2(){
+/*!Test the file transfer with the condition that the transferred file is smaller as the file transfer buffer using single package transfer */
+int testFile1Run2()
+{
int total_size, used_size;
- //Get the information how many packages have the file
- countPackages = dlt_user_log_file_packagesCount(&fileContext,file1);
- if(countPackages < 0 )
- {
- printf("Error: dlt_user_log_file_packagesCount\n");
- printTestResultPositiveExpected(__FUNCTION__,countPackages);
- return -1;
+ /*Get the information how many packages have the file */
+ countPackages = dlt_user_log_file_packagesCount(&fileContext, file1);
+
+ if (countPackages < 0) {
+ printf("Error: dlt_user_log_file_packagesCount\n");
+ printTestResultPositiveExpected(__FUNCTION__, countPackages);
+ return -1;
}
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF1P2 - transfer single package"),DLT_STRING(file1));
-
- //Logs the header of the file transfer. For more details see Mainpage.c.
- //The header gives information about the file serial number, filename (with absolute path), filesize, packages of file, buffer size
- transferResult = dlt_user_log_file_header(&fileContext,file1);
- if(transferResult >= 0)
- {
- //Loop to log all packages
- for(i=1;i<=countPackages;i++)
- {
+
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Started testF1P2 - transfer single package"), DLT_STRING(file1));
+
+ /*Logs the header of the file transfer. For more details see Mainpage.c. */
+ /*The header gives information about the file serial number, filename (with absolute path), filesize, packages of file, buffer size */
+ transferResult = dlt_user_log_file_header(&fileContext, file1);
+
+ if (transferResult >= 0) {
+ /*Loop to log all packages */
+ for (i = 1; i <= countPackages; i++) {
dlt_user_check_buffer(&total_size, &used_size);
- if((total_size - used_size) < (total_size/2))
- {
+
+ if ((total_size - used_size) < (total_size / 2)) {
printf("Error: dlt_user_log_file_data\n");
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
break;
}
- //Logs one single package to the file context
- transferResult = dlt_user_log_file_data(&fileContext,file1,i,20);
- if(transferResult < 0)
- {
+ /*Logs one single package to the file context */
+ transferResult = dlt_user_log_file_data(&fileContext, file1, i, 20);
+
+ if (transferResult < 0) {
printf("Error: dlt_user_log_file_data\n");
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return transferResult;
}
}
- //Logs the end of the file transfer. For more details see Mainpage.c
- //The end gives just information about the file serial number but is needed to signal that the file transfer has correctly finished and needed for the file transfer plugin of the dlt viewer.
- transferResult = dlt_user_log_file_end(&fileContext,file1,0);
- if(transferResult < 0)
- {
+ /*Logs the end of the file transfer. For more details see Mainpage.c */
+ /*The end gives just information about the file serial number but is needed to signal that the file transfer has correctly finished and needed for the file transfer plugin of the dlt viewer. */
+ transferResult = dlt_user_log_file_end(&fileContext, file1, 0);
+
+ if (transferResult < 0) {
printf("Error: dlt_user_log_file_end\n");
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return transferResult;
}
}
- else
- {
+ else {
printf("Error: dlt_user_log_file_header\n");
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return transferResult;
}
- //Just some log to main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Finished testF1P2 - transfer single package"),DLT_STRING(file1));
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ /*Just some log to main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Finished testF1P2 - transfer single package"), DLT_STRING(file1));
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return 0;
}
-//!Test the file transfer with the condition that the transferred file is bigger as the file transfer buffer using dlt_user_log_file_complete.
-int testFile2Run1(){
- //Just some log to main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF2P1 - dlt_user_log_file_complete"),DLT_STRING(file2));
-
- //Here's the line where the dlt file transfer is called. The method call needs a context, the absolute file path, will the file be deleted after transfer and the timeout between the packages
- transferResult = dlt_user_log_file_complete(&fileContext,file2,0,20);
- if(transferResult < 0)
- {
+/*!Test the file transfer with the condition that the transferred file is bigger as the file transfer buffer using dlt_user_log_file_complete. */
+int testFile2Run1()
+{
+ /*Just some log to main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Started testF2P1 - dlt_user_log_file_complete"), DLT_STRING(file2));
+
+ /*Here's the line where the dlt file transfer is called. The method call needs a context, the absolute file path, will the file be deleted after transfer and the timeout between the packages */
+ transferResult = dlt_user_log_file_complete(&fileContext, file2, 0, 20);
+
+ if (transferResult < 0) {
printf("Error: dlt_user_log_file_complete\n");
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return transferResult;
}
- //Just some log to main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Finished testF2P1"),DLT_STRING(file2));
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+
+ /*Just some log to main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Finished testF2P1"), DLT_STRING(file2));
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return transferResult;
}
-//!Test the file transfer with the condition that the transferred file is bigger as the file transfer buffer using single package transfer
-int testFile2Run2(){
+/*!Test the file transfer with the condition that the transferred file is bigger as the file transfer buffer using single package transfer */
+int testFile2Run2()
+{
int total_size, used_size;
- //Get the information how many packages have the file
- countPackages = dlt_user_log_file_packagesCount(&fileContext,file2);
- if(countPackages < 0 )
- {
- printf("Error: dlt_user_log_file_packagesCount\n");
- printTestResultPositiveExpected(__FUNCTION__,countPackages);
- return -1;
+ /*Get the information how many packages have the file */
+ countPackages = dlt_user_log_file_packagesCount(&fileContext, file2);
+
+ if (countPackages < 0) {
+ printf("Error: dlt_user_log_file_packagesCount\n");
+ printTestResultPositiveExpected(__FUNCTION__, countPackages);
+ return -1;
}
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF2P2 - transfer single package"),DLT_STRING(file2));
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Started testF2P2 - transfer single package"), DLT_STRING(file2));
+
+ /*Logs the header of the file transfer. For more details see Mainpage.c. */
+ /*The header gives information about the file serial number, filename (with absolute path), filesize, packages of file, buffer size */
+ transferResult = dlt_user_log_file_header(&fileContext, file2);
- //Logs the header of the file transfer. For more details see Mainpage.c.
- //The header gives information about the file serial number, filename (with absolute path), filesize, packages of file, buffer size
- transferResult = dlt_user_log_file_header(&fileContext,file2);
- if( transferResult >= 0){
+ if (transferResult >= 0) {
- //Loop to log all packages
- for(i=1;i<=countPackages;i++)
- {
+ /*Loop to log all packages */
+ for (i = 1; i <= countPackages; i++) {
dlt_user_check_buffer(&total_size, &used_size);
- if((total_size - used_size) < (total_size/2))
- {
+
+ if ((total_size - used_size) < (total_size / 2)) {
printf("Error: dlt_user_log_file_data\n");
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
break;
}
- //Logs one single package to the file context
- transferResult = dlt_user_log_file_data(&fileContext,file2,i,20);
- if(transferResult < 0)
- {
+ /*Logs one single package to the file context */
+ transferResult = dlt_user_log_file_data(&fileContext, file2, i, 20);
+
+ if (transferResult < 0) {
printf("Error: dlt_user_log_file_data\n");
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return transferResult;
}
}
- //Logs the end of the file transfer. For more details see Mainpage.c
- //The end gives just information about the file serial number but is needed to signal that the file transfer has correctly finished and needed for the file transfer plugin of the dlt viewer.
- transferResult = dlt_user_log_file_end(&fileContext,file2,0);
- if(transferResult < 0)
- {
+ /*Logs the end of the file transfer. For more details see Mainpage.c */
+ /*The end gives just information about the file serial number but is needed to signal that the file transfer has correctly finished and needed for the file transfer plugin of the dlt viewer. */
+ transferResult = dlt_user_log_file_end(&fileContext, file2, 0);
+
+ if (transferResult < 0) {
printf("Error: dlt_user_log_file_end\n");
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return transferResult;
}
}
- else
- {
+ else {
printf("Error: dlt_user_log_file_header\n");
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return transferResult;
}
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Finished testF2P2"),DLT_STRING(file2));
- printTestResultPositiveExpected(__FUNCTION__,transferResult);
+
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Finished testF2P2"), DLT_STRING(file2));
+ printTestResultPositiveExpected(__FUNCTION__, transferResult);
return 0;
}
-//!Test the file transfer with the condition that the transferred file does not exist using dlt_user_log_file_complete.
-int testFile3Run1(){
-
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF3P1"),DLT_STRING(file3_1));
-
- //Here's the line where the dlt file transfer is called. The method call needs a context, the absolute file path, will the file be deleted after transfer and the timeout between the packages
- transferResult = dlt_user_log_file_complete(&fileContext,file3_1,0,20);
- if(transferResult < 0)
- {
- //Error expected because file doesn't exist
- //printf("Error: dlt_user_log_file_complete\n");
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Finished testF3P1"),DLT_STRING(file3_1));
- printTestResultNegativeExpected(__FUNCTION__,transferResult);
+/*!Test the file transfer with the condition that the transferred file does not exist using dlt_user_log_file_complete. */
+int testFile3Run1()
+{
+
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Started testF3P1"), DLT_STRING(file3_1));
+
+ /*Here's the line where the dlt file transfer is called. The method call needs a context, the absolute file path, will the file be deleted after transfer and the timeout between the packages */
+ transferResult = dlt_user_log_file_complete(&fileContext, file3_1, 0, 20);
+
+ if (transferResult < 0) {
+ /*Error expected because file doesn't exist */
+ /*printf("Error: dlt_user_log_file_complete\n"); */
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Finished testF3P1"), DLT_STRING(file3_1));
+ printTestResultNegativeExpected(__FUNCTION__, transferResult);
return transferResult;
}
- printTestResultNegativeExpected(__FUNCTION__,transferResult);
+
+ printTestResultNegativeExpected(__FUNCTION__, transferResult);
return transferResult;
}
-//!Test the file transfer with the condition that the transferred file does not exist using single package transfer
-int testFile3Run2(){
+/*!Test the file transfer with the condition that the transferred file does not exist using single package transfer */
+int testFile3Run2()
+{
- //Get the information how many packages have the file
- countPackages = dlt_user_log_file_packagesCount(&fileContext,file3_2);
- if(countPackages < 0 )
- {
- //Error expected because file doesn't exist
- //printf("Error: dlt_user_log_file_packagesCount\n");
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Finished testF3P1"),DLT_STRING(file3_2));
- printTestResultNegativeExpected(__FUNCTION__,countPackages);
- return -1;
+ /*Get the information how many packages have the file */
+ countPackages = dlt_user_log_file_packagesCount(&fileContext, file3_2);
+
+ if (countPackages < 0) {
+ /*Error expected because file doesn't exist */
+ /*printf("Error: dlt_user_log_file_packagesCount\n"); */
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Finished testF3P1"), DLT_STRING(file3_2));
+ printTestResultNegativeExpected(__FUNCTION__, countPackages);
+ return -1;
}
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF3P1"),DLT_STRING(file3_2));
-
- //Logs the header of the file transfer. For more details see Mainpage.c.
- //The header gives information about the file serial number, filename (with absolute path), filesize, packages of file, buffer size
- transferResult = dlt_user_log_file_header(&fileContext,file3_2);
- if( transferResult >= 0){
-
- //Loop to log all packages
- for(i=1;i<=countPackages;i++)
- {
- //Logs one single package to the file context
- transferResult = dlt_user_log_file_data(&fileContext,file3_2,i,20);
- if(transferResult < 0)
- {
+
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Started testF3P1"), DLT_STRING(file3_2));
+
+ /*Logs the header of the file transfer. For more details see Mainpage.c. */
+ /*The header gives information about the file serial number, filename (with absolute path), filesize, packages of file, buffer size */
+ transferResult = dlt_user_log_file_header(&fileContext, file3_2);
+
+ if (transferResult >= 0) {
+
+ /*Loop to log all packages */
+ for (i = 1; i <= countPackages; i++) {
+ /*Logs one single package to the file context */
+ transferResult = dlt_user_log_file_data(&fileContext, file3_2, i, 20);
+
+ if (transferResult < 0) {
printf("Error: dlt_user_log_file_data\n");
- printTestResultNegativeExpected(__FUNCTION__,transferResult);
+ printTestResultNegativeExpected(__FUNCTION__, transferResult);
return transferResult;
}
}
- //Logs the end of the file transfer. For more details see Mainpage.c
- //The end gives just information about the file serial number but is needed to signal that the file transfer has correctly finished and needed for the file transfer plugin of the dlt viewer.
- transferResult = dlt_user_log_file_end(&fileContext,file3_2,0);
- if(transferResult < 0)
- {
+ /*Logs the end of the file transfer. For more details see Mainpage.c */
+ /*The end gives just information about the file serial number but is needed to signal that the file transfer has correctly finished and needed for the file transfer plugin of the dlt viewer. */
+ transferResult = dlt_user_log_file_end(&fileContext, file3_2, 0);
+
+ if (transferResult < 0) {
printf("Error: dlt_user_log_file_end\n");
- printTestResultNegativeExpected(__FUNCTION__,transferResult);
+ printTestResultNegativeExpected(__FUNCTION__, transferResult);
return transferResult;
}
}
- printTestResultNegativeExpected(__FUNCTION__,transferResult);
+
+ printTestResultNegativeExpected(__FUNCTION__, transferResult);
return 0;
}
-//!Logs some information about the file.
-int testFile3Run3(){
+/*!Logs some information about the file. */
+int testFile3Run3()
+{
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF3P2"),DLT_STRING(file3_3));
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Started testF3P2"), DLT_STRING(file3_3));
- //Here's the line where the dlt file file info is called. The method call logs some information to dlt about the file, filesize, file serial number and number of packages
- transferResult = dlt_user_log_file_infoAbout(&fileContext,file3_3);
- if(transferResult < 0)
- {
- //Error expected because file doesn't exist
- //printf("Error: dlt_user_log_file_infoAbout\n");
- //Just some log to the main context
- DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Finished testF3P2"),DLT_STRING(file3_3));
- printTestResultNegativeExpected(__FUNCTION__,transferResult);
+ /*Here's the line where the dlt file file info is called. The method call logs some information to dlt about the file, filesize, file serial number and number of packages */
+ transferResult = dlt_user_log_file_infoAbout(&fileContext, file3_3);
+
+ if (transferResult < 0) {
+ /*Error expected because file doesn't exist */
+ /*printf("Error: dlt_user_log_file_infoAbout\n"); */
+ /*Just some log to the main context */
+ DLT_LOG(mainContext, DLT_LOG_INFO, DLT_STRING("Finished testF3P2"), DLT_STRING(file3_3));
+ printTestResultNegativeExpected(__FUNCTION__, transferResult);
return transferResult;
}
- printTestResultNegativeExpected(__FUNCTION__,transferResult);
+
+ printTestResultNegativeExpected(__FUNCTION__, transferResult);
return 0;
}
-//!Main program dlt-test-filestransfer starts here
+/*!Main program dlt-test-filestransfer starts here */
int main(void)
{
- //First file contains some text
+ /*First file contains some text */
file1 = "/usr/local/share/dlt-filetransfer/dlt-test-filetransfer-file";
- //Second file is a picture
+ /*Second file is a picture */
file2 = "/usr/local/share/dlt-filetransfer/dlt-test-filetransfer-image.png";
- //Third file doesn't exist. Just to test the reaction when the file isn't available.
+ /*Third file doesn't exist. Just to test the reaction when the file isn't available. */
file3_1 = "dlt-test-filetransfer-doesntExist_1";
- //Third file doesn't exist. Just to test the reaction when the file isn't available.
+ /*Third file doesn't exist. Just to test the reaction when the file isn't available. */
file3_2 = "dlt-test-filetransfer-doesntExist_2";
- //Third file doesn't exist. Just to test the reaction when the file isn't available.
+ /*Third file doesn't exist. Just to test the reaction when the file isn't available. */
file3_3 = "dlt-test-filetransfer-doesntExist_3";
- //Register the application at the dlt-daemon
- DLT_REGISTER_APP("FLTR","Test Application filetransfer");
+ /*Register the application at the dlt-daemon */
+ DLT_REGISTER_APP("FLTR", "Test Application filetransfer");
- //Register the context of the main program at the dlt-daemon
- DLT_REGISTER_CONTEXT(mainContext,"MAIN","Main context for filetransfer test");
+ /*Register the context of the main program at the dlt-daemon */
+ DLT_REGISTER_CONTEXT(mainContext, "MAIN", "Main context for filetransfer test");
- //Register the context in which the file transfer will be logged at the dlt-daemon
- DLT_REGISTER_CONTEXT(fileContext,"FLTR","Test Context for filetransfer");
+ /*Register the context in which the file transfer will be logged at the dlt-daemon */
+ DLT_REGISTER_CONTEXT(fileContext, "FLTR", "Test Context for filetransfer");
- //More details in corresponding methods
+ /*More details in corresponding methods */
testFile1Run1();
testFile1Run2();
testFile2Run1();
@@ -397,11 +407,11 @@ int main(void)
testFile3Run2();
testFile3Run3();
- //Unregister the context in which the file transfer happened from the dlt-daemon
+ /*Unregister the context in which the file transfer happened from the dlt-daemon */
DLT_UNREGISTER_CONTEXT(fileContext);
- //Unregister the context of the main program from the dlt-daemon
+ /*Unregister the context of the main program from the dlt-daemon */
DLT_UNREGISTER_CONTEXT(mainContext);
- //Unregister the app from the dlt-daemon
+ /*Unregister the app from the dlt-daemon */
DLT_UNREGISTER_APP();
return g_numFailed == 0 ? 0 : 1;
diff --git a/src/tests/dlt-test-fork-handler.c b/src/tests/dlt-test-fork-handler.c
index 84685f9..4bd3321 100644
--- a/src/tests/dlt-test-fork-handler.c
+++ b/src/tests/dlt-test-fork-handler.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt-test-fork-handler.c
-*/
+ */
#include <unistd.h> /* for fork() */
@@ -41,8 +41,8 @@ int main()
usleep(200000);
pid_t pid = fork();
- if (pid == 0) /* child process */
- {
+
+ if (pid == 0) { /* child process */
/* this message should not be visible */
/* DLT_LOG(mainContext, DLT_LOG_WARN, DLT_STRING("Child's first message after fork, pid: "), DLT_INT32(getpid())); */
/* unfortunately, this message does arrive, I assume because it still has (locally) valid data ... */
@@ -56,8 +56,7 @@ int main()
{
return -1;
}
- else /* parent */
- {
+ else { /* parent */
DLT_LOG(mainContext, DLT_LOG_WARN, DLT_STRING("Parent's first message after fork, pid: "), DLT_INT32(getpid()));
usleep(500000);
}
diff --git a/src/tests/dlt-test-init-free.c b/src/tests/dlt-test-init-free.c
index 81083e3..bce4b0b 100644
--- a/src/tests/dlt-test-init-free.c
+++ b/src/tests/dlt-test-init-free.c
@@ -1,28 +1,28 @@
/*
-* @licence app begin@
-* SPDX license identifier: MPL-2.0
-*
-* Copyright (C) 2011-2015, BMW AG
-*
-* This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
-*
-* This Source Code Form is subject to the terms of the
-* Mozilla Public License (MPL), v. 2.0.
-* If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* For further information see http://www.genivi.org/.
-* @licence end@
-*/
+ * @licence app begin@
+ * SPDX license identifier: MPL-2.0
+ *
+ * Copyright (C) 2011-2015, BMW AG
+ *
+ * This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
+ *
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License (MPL), v. 2.0.
+ * If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * For further information see http://www.genivi.org/.
+ * @licence end@
+ */
/*!
-* \author Sven Hassler <sven_hassler@mentor.com>
-*
-* \copyright Copyright © 2011-2015 BMW AG. \n
-* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
-*
-* \file dlt-test-init-free.c
-*/
+ * \author Sven Hassler <sven_hassler@mentor.com>
+ *
+ * \copyright Copyright © 2011-2015 BMW AG. \n
+ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+ *
+ * \file dlt-test-init-free.c
+ */
#include <stdio.h>
#include <stdlib.h>
@@ -32,9 +32,9 @@
#include "dlt_common.h"
#include "dlt_user.h"
-void exec(const char* cmd, char *buffer, size_t length);
+void exec(const char *cmd, char *buffer, size_t length);
void printMemoryUsage();
-char* occupyMemory(uint size);
+char *occupyMemory(uint size);
void do_example_test();
void do_dlt_test();
@@ -49,7 +49,7 @@ int main(int argc, char **argv)
printf("Will do %d repetitions.\n", num_repetitions);
- //do_example_test();
+ /*do_example_test(); */
do_dlt_test();
printf("Done.\n");
@@ -57,25 +57,23 @@ int main(int argc, char **argv)
return 0;
}
-// Should increase and then decrease memory amount.
+/* Should increase and then decrease memory amount. */
void do_example_test()
{
const int immediatelyFree = 0;
int numBufs = 1024;
- int sizePerBuf = 1024 * 1024; // 1MB
+ int sizePerBuf = 1024 * 1024; /* 1MB */
- char** bufs = (char**) malloc(numBufs * sizeof(char*));
+ char **bufs = (char **)malloc(numBufs * sizeof(char *));
- for (int i = 0; i < numBufs; i++)
- {
+ for (int i = 0; i < numBufs; i++) {
bufs[i] = occupyMemory(sizePerBuf);
printf("after alloc: ");
printMemoryUsage();
- if (immediatelyFree)
- {
+ if (immediatelyFree) {
free(bufs[i]);
printf("after free: ");
@@ -86,9 +84,8 @@ void do_example_test()
printf("deleting memory:\n");
if (!immediatelyFree)
- for (int i = 0; i < numBufs; i++)
- //for (int i = numBufs - 1; i >= 0; i--) // other way round works, too
- {
+ for (int i = 0; i < numBufs; i++) {
+ /*for (int i = numBufs - 1; i >= 0; i--) // other way round works, too */
free(bufs[i]);
printf("after free: ");
@@ -98,11 +95,10 @@ void do_example_test()
free(bufs);
}
-// Should give stable amount of memory across all iterations.
+/* Should give stable amount of memory across all iterations. */
void do_dlt_test()
{
- for (int i = 0; i < num_repetitions; i++)
- {
+ for (int i = 0; i < num_repetitions; i++) {
dlt_init();
dlt_free();
@@ -111,17 +107,17 @@ void do_dlt_test()
}
}
-void exec(const char* cmd, char *buffer, size_t length)
+void exec(const char *cmd, char *buffer, size_t length)
{
- FILE* pipe = NULL;
+ FILE *pipe = NULL;
strncpy(buffer, "ERROR", length);
- if ( (pipe = popen(cmd, "r")) == NULL )
+ if ((pipe = popen(cmd, "r")) == NULL)
return;
while (fgets(buffer, length, pipe) != NULL);
- if(pipe != NULL)
+ if (pipe != NULL)
pclose(pipe);
}
@@ -137,13 +133,12 @@ void printMemoryUsage()
printf("%s", result);
}
-char* occupyMemory(uint size)
+char *occupyMemory(uint size)
{
- char* buf = (char*) malloc(size * sizeof(char));
+ char *buf = (char *)malloc(size * sizeof(char));
+
for (int i = 0; i < 1; i++)
- {
buf[i] = 1;
- }
return buf;
}
diff --git a/src/tests/dlt-test-multi-process-client.c b/src/tests/dlt-test-multi-process-client.c
index 72a9ea4..ab434cc 100644
--- a/src/tests/dlt-test-multi-process-client.c
+++ b/src/tests/dlt-test-multi-process-client.c
@@ -25,25 +25,25 @@
*/
/*******************************************************************************
- ** **
- ** SRC-MODULE: dlt-test-multi-process-client.c **
- ** **
- ** TARGET : linux **
- ** **
- ** PROJECT : DLT **
- ** **
- ** AUTHOR : Lassi Marttala <Lassi.LM.Marttala@partner.bmw.de> **
- ** **
- ** PURPOSE : Receive, validate and measure data from multi process tester **
- ** **
- ** REMARKS : **
- ** **
- ** PLATFORM DEPENDANT [yes/no]: yes **
- ** **
- ** TO BE CHANGED BY USER [yes/no]: no **
- ** **
- *******************************************************************************/
-// System includes
+** **
+** SRC-MODULE: dlt-test-multi-process-client.c **
+** **
+** TARGET : linux **
+** **
+** PROJECT : DLT **
+** **
+** AUTHOR : Lassi Marttala <Lassi.LM.Marttala@partner.bmw.de> **
+** **
+** PURPOSE : Receive, validate and measure data from multi process tester **
+** **
+** REMARKS : **
+** **
+** PLATFORM DEPENDANT [yes/no]: yes **
+** **
+** TO BE CHANGED BY USER [yes/no]: no **
+** **
+*******************************************************************************/
+/* System includes */
#include <string.h>
#include <stdio.h>
#include <unistd.h>
@@ -54,14 +54,14 @@
#include <sys/uio.h>
#include <sys/stat.h>
-// DLT Library includes
+/* DLT Library includes */
#include "dlt_client.h"
#include "dlt_protocol.h"
#include "dlt_user.h"
-// PRivate includes
+/* PRivate includes */
#include "dlt-test-multi-process.h"
-// Local data structures
+/* Local data structures */
typedef struct {
int max_messages;
int verbose;
@@ -74,22 +74,23 @@ typedef struct {
} s_parameters;
typedef struct {
- int messages_received;
- int broken_messages_received;
- int bytes_received;
- int first_message_time;
- int output_bytes;
+ int messages_received;
+ int broken_messages_received;
+ int bytes_received;
+ int first_message_time;
+ int output_bytes;
} s_statistics;
-// Forward declarations
+/* Forward declarations */
int receive(DltMessage *msg, void *data);
/**
* Print usage information
*/
-void usage(char *name) {
+void usage(char *name)
+{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: %s [options] <remote address|serial device>\n", name);
printf("Receive messages from dlt-test-multi-process.\n");
@@ -105,7 +106,8 @@ void usage(char *name) {
/**
* Initialize reasonable default parameters.
*/
-void init_params(s_parameters *params) {
+void init_params(s_parameters *params)
+{
params->max_messages = 10000;
params->verbose = 0;
params->serial = 0;
@@ -117,11 +119,13 @@ void init_params(s_parameters *params) {
/**
* Read the command line parameters
*/
-int read_params(s_parameters *params, int argc, char *argv[]) {
+int read_params(s_parameters *params, int argc, char *argv[])
+{
init_params(params);
int c;
opterr = 0;
- while ((c = getopt(argc, argv, "m:yb:vo:")) != -1) {
+
+ while ((c = getopt(argc, argv, "m:yb:vo:")) != -1)
switch (c) {
case 'm':
params->max_messages = atoi(optarg);
@@ -139,49 +143,49 @@ int read_params(s_parameters *params, int argc, char *argv[]) {
params->output = optarg;
break;
case '?':
- if(optopt == 'm' || optopt == 'b' || optopt == 'o')
- {
+
+ if ((optopt == 'm') || (optopt == 'b') || (optopt == 'o'))
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
- }
- if (isprint(optopt)) {
+
+ if (isprint(optopt))
fprintf(stderr, "Unknown option '-%c'.\n", optopt);
- } else {
+ else
fprintf(stderr, "Unknown option character '\\x%x'.\n", optopt);
- }
+
return -1;
break;
default:
return -1;
}
- }
+
return 0;
}
/**
* Set the connection parameters for dlt client
*/
-int init_dlt_connect(DltClient *client, const s_parameters *params, int argc, char *argv[]) {
+int init_dlt_connect(DltClient *client, const s_parameters *params, int argc, char *argv[])
+{
char id[4];
+
if (argc < 2)
return -1;
- if(params->serial > 0)
- {
+
+ if (params->serial > 0) {
client->mode = 1;
- if(dlt_client_set_serial_device(client, argv[argc - 1]) == -1)
- {
- fprintf(stderr,"set serial device didn't succeed\n");
+
+ if (dlt_client_set_serial_device(client, argv[argc - 1]) == -1) {
+ fprintf(stderr, "set serial device didn't succeed\n");
return -1;
}
+
dlt_client_setbaudrate(client, params->baudrate);
}
- else
- {
- if(dlt_client_set_server_ip(client, argv[argc - 1]) == -1)
- {
- fprintf(stderr,"set serial ip didn't succeed\n");
- return -1;
- }
+ else if (dlt_client_set_server_ip(client, argv[argc - 1]) == -1) {
+ fprintf(stderr, "set serial ip didn't succeed\n");
+ return -1;
}
+
dlt_set_id(id, ECUID);
return 0;
}
@@ -189,7 +193,8 @@ int init_dlt_connect(DltClient *client, const s_parameters *params, int argc, ch
/**
* Entry point
*/
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
s_parameters params;
DltClient client;
params.client_ref = &client;
@@ -204,24 +209,24 @@ int main(int argc, char *argv[]) {
dlt_client_register_message_callback(receive);
err = init_dlt_connect(&client, &params, argc, argv);
+
if (err != 0) {
usage(argv[0]);
return err;
}
err = dlt_client_connect(&client, params.verbose);
+
if (err != DLT_RETURN_OK) {
- printf("Failed to connect %s.\n", client.mode > 0 ? client.serialDevice : client.servIP);
+ printf("Failed to connect %s.\n", client.mode > 0 ? client.serialDevice : client.servIP);
return err;
}
- if(params.output)
- {
- params.output_handle = open(params.output,O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (params.output) {
+ params.output_handle = open(params.output, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (params.output_handle == -1)
- {
- fprintf(stderr,"Failed to open %s for writing.\n",params.output);
+ if (params.output_handle == -1) {
+ fprintf(stderr, "Failed to open %s for writing.\n", params.output);
return -1;
}
}
@@ -230,10 +235,9 @@ int main(int argc, char *argv[]) {
dlt_client_main_loop(&client, &params, params.verbose);
- if(params.output_handle > 0)
- {
+ if (params.output_handle > 0)
close(params.output_handle);
- }
+
return 0;
}
@@ -243,36 +247,38 @@ int main(int argc, char *argv[]) {
void print_stats(s_statistics stats, s_parameters params)
{
static int last_print_time;
- if(last_print_time >= time(NULL) && // Only print once a second
- (stats.messages_received+stats.broken_messages_received) % 1000 != 0 &&
- params.messages_left != 0) // Print also every 1000th message
- {
+
+ if ((last_print_time >= time(NULL)) && /* Only print once a second */
+ ((stats.messages_received + stats.broken_messages_received) % 1000 != 0) &&
+ (params.messages_left != 0)) /* Print also every 1000th message */
+
return;
- }
- printf("\033[2J\033[1;1H"); // Clear screen.
+
+ printf("\033[2J\033[1;1H"); /* Clear screen. */
printf("Statistics:\n");
printf(" Messages received : %d\n", stats.messages_received);
printf(" Broken messages received : %d\n", stats.broken_messages_received);
printf(" Bytes received : %d\n", stats.bytes_received);
- printf(" Time running (seconds) : %ld\n", time(NULL)-stats.first_message_time);
+ printf(" Time running (seconds) : %ld\n", time(NULL) - stats.first_message_time);
printf(" Throughput (msgs/sec)/(B/sec) : %ld/%ld\n",
- stats.messages_received/((time(NULL)-stats.first_message_time)+1),
- (stats.bytes_received)/((time(NULL)-stats.first_message_time)+1));
- if(params.messages_left == 0)
- {
- if(stats.broken_messages_received == 0)
+ stats.messages_received / ((time(NULL) - stats.first_message_time) + 1),
+ (stats.bytes_received) / ((time(NULL) - stats.first_message_time) + 1));
+
+ if (params.messages_left == 0) {
+ if (stats.broken_messages_received == 0)
printf("All messages received succesfully!\n");
else
printf("Test failure! There were %d broken messages.", stats.broken_messages_received);
-
}
+
fflush(stdout);
last_print_time = time(NULL);
}
/**
* Callback for dlt client
*/
-int receive(DltMessage *msg, void *data) {
+int receive(DltMessage *msg, void *data)
+{
static s_statistics stats;
char apid[5];
struct iovec iov[2];
@@ -281,43 +287,38 @@ int receive(DltMessage *msg, void *data) {
memset(apid, 0, 5);
memcpy(apid, msg->extendedheader->apid, 4);
- if(apid[0] != 'M' || apid[1] != 'T') // TODO: Check through the app description
+ if ((apid[0] != 'M') || (apid[1] != 'T')) /* TODO: Check through the app description */
return 0;
params->messages_left--;
- if(stats.first_message_time == 0)
- {
+ if (stats.first_message_time == 0)
stats.first_message_time = time(NULL);
- }
int buflen = msg->datasize + 1;
char *buf = malloc(buflen);
- if(buf==0)
- {
+
+ if (buf == 0) {
printf("Out of memory\n");
return -1;
}
+
memset(buf, 0, buflen);
- dlt_message_payload(msg,buf,buflen-1,DLT_OUTPUT_ASCII,0);
+ dlt_message_payload(msg, buf, buflen - 1, DLT_OUTPUT_ASCII, 0);
- if(strcmp(buf, PAYLOAD_DATA) == 0)
- {
+ if (strcmp(buf, PAYLOAD_DATA) == 0)
stats.messages_received++;
- }
else
- {
stats.broken_messages_received++;
- }
- stats.bytes_received += msg->datasize+msg->headersize-sizeof(DltStorageHeader);;
+
+ stats.bytes_received += msg->datasize + msg->headersize - sizeof(DltStorageHeader);
free(buf);
print_stats(stats, *params);
- if (params->output_handle > 0)
- {
+ if (params->output_handle > 0) {
iov[0].iov_base = msg->headerbuffer;
iov[0].iov_len = msg->headersize;
iov[1].iov_base = msg->databuffer;
@@ -325,9 +326,9 @@ int receive(DltMessage *msg, void *data) {
stats.output_bytes += writev(params->output_handle, iov, 2);
}
- if(params->messages_left < 1)
- {
+
+ if (params->messages_left < 1)
dlt_client_cleanup(params->client_ref, params->verbose);
- }
+
return 0;
}
diff --git a/src/tests/dlt-test-multi-process.c b/src/tests/dlt-test-multi-process.c
index 0726b9a..5b508f3 100644
--- a/src/tests/dlt-test-multi-process.c
+++ b/src/tests/dlt-test-multi-process.c
@@ -58,30 +58,30 @@
#include "dlt_common.h"
#include "dlt-test-multi-process.h"
-// Constants
+/* Constants */
#define MAX_PROCS 100
#define MAX_THREADS 100
#ifndef WAIT_ANY
-#define WAIT_ANY -1
+# define WAIT_ANY -1
#endif
-// Structs
+/* Structs */
typedef struct {
- int nmsgs; // Number of messages to send
- int nprocs; // Number of processes to start
- int nthreads; // Number of threads to start
- int delay; // Delay between logs messages for each process
- int delay_fudge; // Fudge the delay by 0-n to cause desynchronization
+ int nmsgs; /* Number of messages to send */
+ int nprocs; /* Number of processes to start */
+ int nthreads; /* Number of threads to start */
+ int delay; /* Delay between logs messages for each process */
+ int delay_fudge; /* Fudge the delay by 0-n to cause desynchronization */
} s_parameters;
typedef struct {
- s_parameters params;
- DltContext ctx;
+ s_parameters params;
+ DltContext ctx;
} s_thread_data;
-// Forward declarations
-void init_params(s_parameters * params);
+/* Forward declarations */
+void init_params(s_parameters *params);
void quit_handler(int signum);
void cleanup();
void do_forks(s_parameters params);
@@ -89,10 +89,10 @@ void run_threads(s_parameters params);
void do_logging(s_thread_data *data);
int wait_for_death();
-// State information
+/* State information */
volatile sig_atomic_t in_handler = 0;
-// Globals for cleanup from main and signal handler
+/* Globals for cleanup from main and signal handler */
pid_t pids[MAX_PROCS];
unsigned int pidcount = 0;
@@ -102,7 +102,7 @@ unsigned int pidcount = 0;
void usage(char *prog_name)
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
s_parameters defaults;
init_params(&defaults);
@@ -120,12 +120,13 @@ void usage(char *prog_name)
/**
* Set nice default values for parameters
*/
-void init_params(s_parameters * params) {
- params->nmsgs = 100;
- params->nprocs = 10;
- params->nthreads = 2;
- params->delay = 1000;
- params->delay_fudge = 100;
+void init_params(s_parameters *params)
+{
+ params->nmsgs = 100;
+ params->nprocs = 10;
+ params->nthreads = 2;
+ params->delay = 1000;
+ params->delay_fudge = 100;
}
/**
@@ -135,55 +136,52 @@ int read_cli(s_parameters *params, int argc, char **argv)
{
int c;
opterr = 0;
+
while ((c = getopt (argc, argv, "m:p:t:d:f:")) != -1)
- {
- switch(c)
- {
- case 'm':
- params->nmsgs = atoi(optarg);
- break;
- case 'p':
- params->nprocs = atoi(optarg);
- if(params->nprocs > MAX_PROCS)
- {
- fprintf(stderr, "Too many processes selected.\n");
- return -1;
- }
- break;
- case 't':
- params->nthreads = atoi(optarg);
- if(params->nprocs > MAX_PROCS)
- {
- fprintf(stderr, "Too many threads selected.\n");
- return -1;
- }
- break;
- case 'd':
- params->delay = atoi(optarg);
- break;
- case 'f':
- params->delay_fudge = atoi(optarg);
- break;
- case '?':
- if(optopt == 'n' || optopt == 'd' || optopt == 'f')
- {
- fprintf(stderr, "Option -%c requires an argument.\n", optopt);
- }
- else if(isprint(optopt))
- {
- fprintf(stderr, "Unknown option '-%c'.\n", optopt);
- }
- else
- {
- fprintf(stderr, "Unknown option character '\\x%x'.\n", optopt);
- }
+ switch (c) {
+ case 'm':
+ params->nmsgs = atoi(optarg);
+ break;
+ case 'p':
+ params->nprocs = atoi(optarg);
+
+ if (params->nprocs > MAX_PROCS) {
+ fprintf(stderr, "Too many processes selected.\n");
return -1;
- break;
- default:
- abort();
- return -1;//for parasoft
+ }
+
+ break;
+ case 't':
+ params->nthreads = atoi(optarg);
+
+ if (params->nprocs > MAX_PROCS) {
+ fprintf(stderr, "Too many threads selected.\n");
+ return -1;
+ }
+
+ break;
+ case 'd':
+ params->delay = atoi(optarg);
+ break;
+ case 'f':
+ params->delay_fudge = atoi(optarg);
+ break;
+ case '?':
+
+ if ((optopt == 'n') || (optopt == 'd') || (optopt == 'f'))
+ fprintf(stderr, "Option -%c requires an argument.\n", optopt);
+ else if (isprint(optopt))
+ fprintf(stderr, "Unknown option '-%c'.\n", optopt);
+ else
+ fprintf(stderr, "Unknown option character '\\x%x'.\n", optopt);
+
+ return -1;
+ break;
+ default:
+ abort();
+ return -1; /*for parasoft */
}
- }
+
return 0;
}
@@ -192,24 +190,27 @@ int read_cli(s_parameters *params, int argc, char **argv)
*/
int main(int argc, char **argv)
{
- // Prepare parameters
+ /* Prepare parameters */
s_parameters params;
init_params(&params);
- if(read_cli(&params, argc, argv) != 0) {
+
+ if (read_cli(&params, argc, argv) != 0) {
usage(argv[0]);
exit(-1);
}
- // Launch the child processes
+ /* Launch the child processes */
do_forks(params);
- // Register signal handlers
- if(signal(SIGINT, quit_handler) == SIG_IGN)
- signal(SIGINT, SIG_IGN); // C-c
- if(signal(SIGHUP, quit_handler) == SIG_IGN)
- signal(SIGHUP, SIG_IGN); // Terminal closed
- if(signal(SIGTERM, quit_handler) == SIG_IGN)
- signal(SIGTERM, SIG_IGN); // kill (nice)
+ /* Register signal handlers */
+ if (signal(SIGINT, quit_handler) == SIG_IGN)
+ signal(SIGINT, SIG_IGN); /* C-c */
+
+ if (signal(SIGHUP, quit_handler) == SIG_IGN)
+ signal(SIGHUP, SIG_IGN); /* Terminal closed */
+
+ if (signal(SIGTERM, quit_handler) == SIG_IGN)
+ signal(SIGTERM, SIG_IGN); /* kill (nice) */
printf("Setup done. Listening. My pid: %d\n", getpid());
fflush(stdout);
@@ -227,30 +228,30 @@ void do_forks(s_parameters params)
{
int i;
- // Launch child processes
- for(i=0;i<params.nprocs;i++)
- {
+ /* Launch child processes */
+ for (i = 0; i < params.nprocs; i++) {
pid_t pid = fork();
- switch(pid)
- {
- case -1: // An error occured
- if(errno == EAGAIN)
- {
+
+ switch (pid) {
+ case -1: /* An error occured */
+
+ if (errno == EAGAIN) {
fprintf(stderr, "Could not allocate resources for child process.\n");
cleanup();
abort();
}
- if(errno == ENOMEM)
- {
+
+ if (errno == ENOMEM) {
fprintf(stderr, "Could not allocate memory for child process' kernel structure.\n");
cleanup();
abort();
}
+
break;
- case 0: // Child process, start threads
+ case 0: /* Child process, start threads */
run_threads(params);
break;
- default: // Parent process, store the childs pid
+ default: /* Parent process, store the childs pid */
pids[pidcount++] = pid;
break;
}
@@ -263,8 +264,9 @@ void do_forks(s_parameters params)
*/
void quit_handler(int signum)
{
- if(in_handler)
+ if (in_handler)
raise(signum);
+
in_handler = 1;
cleanup();
@@ -279,10 +281,9 @@ void quit_handler(int signum)
void cleanup()
{
unsigned int i;
- for(i=0;i<pidcount;i++)
- {
+
+ for (i = 0; i < pidcount; i++)
kill(pids[i], SIGINT);
- }
}
/**
@@ -291,9 +292,9 @@ void cleanup()
time_t mksleep_time(int delay, int fudge)
{
if (!fudge)
- return delay*1000;
+ return delay * 1000;
else
- return (delay+rand()%fudge)*1000;
+ return (delay + rand() % fudge) * 1000;
}
/**
@@ -301,21 +302,22 @@ time_t mksleep_time(int delay, int fudge)
*/
void do_logging(s_thread_data *data)
{
- DltContext mycontext;
- char ctid[5];
- char ctid_name[256];
+ DltContext mycontext;
+ char ctid[5];
+ char ctid_name[256];
- snprintf(ctid,5,"%.2x", rand() & 0x0000ffff);
- snprintf(ctid_name,256, "Child %s in dlt-test-multi-process", ctid);
+ snprintf(ctid, 5, "%.2x", rand() & 0x0000ffff);
+ snprintf(ctid_name, 256, "Child %s in dlt-test-multi-process", ctid);
DLT_REGISTER_CONTEXT(mycontext, ctid, ctid_name);
int msgs_left = data->params.nmsgs;
- while(msgs_left-- > 0)
- {
+
+ while (msgs_left-- > 0) {
DLT_LOG(mycontext, DLT_LOG_INFO, DLT_STRING(PAYLOAD_DATA));
usleep(mksleep_time(data->params.delay, data->params.delay_fudge));
}
+
DLT_UNREGISTER_CONTEXT(mycontext);
}
@@ -324,38 +326,34 @@ void do_logging(s_thread_data *data)
*/
void run_threads(s_parameters params)
{
- pthread_t thread[params.nthreads];
- s_thread_data thread_data;
- char apid[5];
- char apid_name[256];
- int i;
+ pthread_t thread[params.nthreads];
+ s_thread_data thread_data;
+ char apid[5];
+ char apid_name[256];
+ int i;
srand(getpid());
- snprintf(apid,5,"MT%02u", pidcount);
- snprintf(apid_name,256, "Apps %s.", apid);
+ snprintf(apid, 5, "MT%02u", pidcount);
+ snprintf(apid_name, 256, "Apps %s.", apid);
DLT_REGISTER_APP(apid, apid_name);
- thread_data.params = params;
+ thread_data.params = params;
- for(i=0;i<params.nthreads;i++)
- {
- if(pthread_create(&(thread[i]), NULL, (void *) &do_logging, &thread_data) != 0)
- {
+ for (i = 0; i < params.nthreads; i++)
+ if (pthread_create(&(thread[i]), NULL, (void *)&do_logging, &thread_data) != 0) {
printf("Error creating thread.\n");
abort();
}
- }
- for(i=0;i<params.nthreads;i++)
- {
- pthread_join(thread[i], NULL);
- }
+ for (i = 0; i < params.nthreads; i++)
+ pthread_join(thread[i], NULL);
+
DLT_UNREGISTER_APP();
- // We can exit now
+ /* We can exit now */
exit(0);
}
@@ -365,26 +363,24 @@ void run_threads(s_parameters params)
int wait_for_death()
{
int pids_left = pidcount;
- while(pids_left > 0)
- {
+
+ while (pids_left > 0) {
int status;
pid_t w = waitpid(WAIT_ANY, &status, 0);
- if(status < 0)
- {
+
+ if (status < 0) {
return -1;
}
- else
- {
+ else {
unsigned int i;
- for(i=0;i<pidcount;i++)
- {
- if(pids[i] == w)
- {
+
+ for (i = 0; i < pidcount; i++)
+ if (pids[i] == w) {
pids_left--;
break;
}
- }
}
}
+
return 0;
}
diff --git a/src/tests/dlt-test-stress-client.c b/src/tests/dlt-test-stress-client.c
index 8a9e2ba..e2d0cfa 100644
--- a/src/tests/dlt-test-stress-client.c
+++ b/src/tests/dlt-test-stress-client.c
@@ -63,8 +63,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <ctype.h> /* for isprint() */
@@ -117,7 +117,7 @@ typedef struct
int sock;
- // test values
+ /* test values */
unsigned long bytes_received;
unsigned long time_elapsed;
int last_value;
@@ -133,7 +133,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-test-stress-client [options] hostname/serial_device_name\n");
printf("Test against received data from dlt-test-stress-user.\n");
@@ -156,11 +156,11 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- DltClient dltclient;
+ DltClient dltclient;
DltTestclientData dltdata;
- int c,i;
+ int c, i;
int index;
/* Initialize dltclient */
@@ -178,14 +178,13 @@ int main(int argc, char* argv[])
dltdata.evalue = 0;
dltdata.bvalue = 0;
dltdata.nvalue = 10000;
- dltdata.ohandle= -1;
+ dltdata.ohandle = -1;
dltdata.running_test = 0;
- for (i=0;i<DLT_TESTCLIENT_NUM_TESTS;i++)
- {
- dltdata.test_counter_macro[i]=0;
- dltdata.test_counter_function[i]=0;
+ for (i = 0; i < DLT_TESTCLIENT_NUM_TESTS; i++) {
+ dltdata.test_counter_macro[i] = 0;
+ dltdata.test_counter_function[i] = 0;
}
dltdata.tests_passed = 0;
@@ -205,9 +204,7 @@ int main(int argc, char* argv[])
opterr = 0;
while ((c = getopt (argc, argv, "vashyxmf:o:e:b:n:")) != -1)
- {
- switch (c)
- {
+ switch (c) {
case 'v':
{
dltdata.vflag = 1;
@@ -270,18 +267,13 @@ int main(int argc, char* argv[])
}
case '?':
{
- if (optopt == 'o' || optopt == 'f' || optopt == 't')
- {
+ if ((optopt == 'o') || (optopt == 'f') || (optopt == 't'))
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
/* unknown or wrong option used, show usage information and terminate */
usage();
return -1;
@@ -289,10 +281,9 @@ int main(int argc, char* argv[])
default:
{
abort ();
- return -1;//for parasoft
+ return -1;/*for parasoft */
}
}
- }
/* Initialize DLT Client */
dlt_client_init(&dltclient, dltdata.vflag);
@@ -303,108 +294,91 @@ int main(int argc, char* argv[])
/* Setup DLT Client structure */
dltclient.mode = dltdata.yflag;
- if (dltclient.mode==0)
- {
+ if (dltclient.mode == 0) {
for (index = optind; index < argc; index++)
- {
- if(dlt_client_set_server_ip(&dltclient, argv[index]) == -1)
- {
- fprintf(stderr,"set server ip didn't succeed\n");
+ if (dlt_client_set_server_ip(&dltclient, argv[index]) == -1) {
+ fprintf(stderr, "set server ip didn't succeed\n");
return -1;
}
- }
- if (dltclient.servIP == 0)
- {
+
+
+ if (dltclient.servIP == 0) {
/* no hostname selected, show usage and terminate */
- fprintf(stderr,"ERROR: No hostname selected\n");
+ fprintf(stderr, "ERROR: No hostname selected\n");
usage();
- dlt_client_cleanup(&dltclient,dltdata.vflag);
+ dlt_client_cleanup(&dltclient, dltdata.vflag);
return -1;
}
}
- else
- {
+ else {
for (index = optind; index < argc; index++)
- {
- if(dlt_client_set_serial_device(&dltclient, argv[index]) == -1)
- {
- fprintf(stderr,"set serial device didn't succeed\n");
+ if (dlt_client_set_serial_device(&dltclient, argv[index]) == -1) {
+ fprintf(stderr, "set serial device didn't succeed\n");
return -1;
}
- }
- if (dltclient.serialDevice == 0)
- {
+
+
+ if (dltclient.serialDevice == 0) {
/* no serial device name selected, show usage and terminate */
- fprintf(stderr,"ERROR: No serial device name specified\n");
+ fprintf(stderr, "ERROR: No serial device name specified\n");
usage();
return -1;
}
- dlt_client_setbaudrate(&dltclient,dltdata.bvalue);
+ dlt_client_setbaudrate(&dltclient, dltdata.bvalue);
}
/* initialise structure to use DLT file */
- dlt_file_init(&(dltdata.file),dltdata.vflag);
+ dlt_file_init(&(dltdata.file), dltdata.vflag);
/* first parse filter file if filter parameter is used */
- dlt_filter_init(&(dltdata.filter),dltdata.vflag);
+ dlt_filter_init(&(dltdata.filter), dltdata.vflag);
- if (dltdata.fvalue)
- {
- if (dlt_filter_load(&(dltdata.filter),dltdata.fvalue,dltdata.vflag) < DLT_RETURN_OK)
- {
- dlt_file_free(&(dltdata.file),dltdata.vflag);
+ if (dltdata.fvalue) {
+ if (dlt_filter_load(&(dltdata.filter), dltdata.fvalue, dltdata.vflag) < DLT_RETURN_OK) {
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
return -1;
}
- dlt_file_set_filter(&(dltdata.file),&(dltdata.filter),dltdata.vflag);
+ dlt_file_set_filter(&(dltdata.file), &(dltdata.filter), dltdata.vflag);
}
/* open DLT output file */
- if (dltdata.ovalue)
- {
- dltdata.ohandle = open(dltdata.ovalue,O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
+ if (dltdata.ovalue) {
+ dltdata.ohandle = open(dltdata.ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
- if (dltdata.ohandle == -1)
- {
- dlt_file_free(&(dltdata.file),dltdata.vflag);
- fprintf(stderr,"ERROR: Output file %s cannot be opened!\n",dltdata.ovalue);
+ if (dltdata.ohandle == -1) {
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
+ fprintf(stderr, "ERROR: Output file %s cannot be opened!\n", dltdata.ovalue);
return -1;
}
}
if (dltdata.evalue)
- {
- dlt_set_id(dltdata.ecuid,dltdata.evalue);
- }
+ dlt_set_id(dltdata.ecuid, dltdata.evalue);
else
- {
- dlt_set_id(dltdata.ecuid,DLT_TESTCLIENT_ECU_ID);
- }
+ dlt_set_id(dltdata.ecuid, DLT_TESTCLIENT_ECU_ID);
/* Connect to TCP socket or open serial device */
- if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR)
- {
+ if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR) {
dltdata.sock = dltclient.sock;
/* Dlt Client Main Loop */
dlt_client_main_loop(&dltclient, &dltdata, dltdata.vflag);
/* Dlt Client Cleanup */
- dlt_client_cleanup(&dltclient,dltdata.vflag);
+ dlt_client_cleanup(&dltclient, dltdata.vflag);
}
/* dlt-receive cleanup */
if (dltdata.ovalue)
- {
close(dltdata.ohandle);
- }
- dlt_file_free(&(dltdata.file),dltdata.vflag);
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
- dlt_filter_free(&(dltdata.filter),dltdata.vflag);
+ dlt_filter_free(&(dltdata.filter), dltdata.vflag);
return 0;
}
@@ -415,7 +389,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
DltTestclientData *dltdata;
uint32_t type_info, type_info_tmp;
- int16_t length,length_tmp; /* the macro can set this variable to -1 */
+ int16_t length, length_tmp; /* the macro can set this variable to -1 */
uint8_t *ptr;
int32_t datalength;
int32_t value;
@@ -424,122 +398,109 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
struct iovec iov[2];
int bytes_written;
- if ((message==0) || (data==0))
- {
+ if ((message == 0) || (data == 0))
return -1;
- }
- dltdata = (DltTestclientData*)data;
+ dltdata = (DltTestclientData *)data;
/* prepare storage header */
if (DLT_IS_HTYP_WEID(message->standardheader->htyp))
- {
- dlt_set_storageheader(message->storageheader,message->headerextra.ecu);
- }
+ dlt_set_storageheader(message->storageheader, message->headerextra.ecu);
else
- {
- dlt_set_storageheader(message->storageheader,dltdata->ecuid);
- }
+ dlt_set_storageheader(message->storageheader, dltdata->ecuid);
- if ((dltdata->fvalue==0) || (dltdata->fvalue && dlt_message_filter_check(message,&(dltdata->filter),dltdata->vflag) == DLT_RETURN_TRUE))
- {
+ if ((dltdata->fvalue == 0) ||
+ (dltdata->fvalue &&
+ (dlt_message_filter_check(message, &(dltdata->filter), dltdata->vflag) == DLT_RETURN_TRUE))) {
- //dlt_message_header(message,text,sizeof(text),dltdata->vflag);
- if (dltdata->aflag)
- {
- //printf("%s ",text);
+ /*dlt_message_header(message,text,sizeof(text),dltdata->vflag); */
+ if (dltdata->aflag) {
+ /*printf("%s ",text); */
}
- //dlt_message_payload(message,text,sizeof(text),DLT_OUTPUT_ASCII,dltdata->vflag);
- if (dltdata->aflag)
- {
- //printf("[%s]\n",text);
+
+ /*dlt_message_payload(message,text,sizeof(text),DLT_OUTPUT_ASCII,dltdata->vflag); */
+ if (dltdata->aflag) {
+ /*printf("[%s]\n",text); */
}
/* do something here */
- // Count number of received bytes
- dltdata->bytes_received += message->datasize+message->headersize-sizeof(DltStorageHeader);
+ /* Count number of received bytes */
+ dltdata->bytes_received += message->datasize + message->headersize - sizeof(DltStorageHeader);
- // print number of received bytes
- if((dlt_uptime() - dltdata->time_elapsed) > 10000)
- {
- printf("Received %lu Bytes/s\n",dltdata->bytes_received/**10000/(dlt_uptime()-dltdata->time_elapsed)*/);
- //printf("Received %lu Bytes received\n",dltdata->bytes_received);
+ /* print number of received bytes */
+ if ((dlt_uptime() - dltdata->time_elapsed) > 10000) {
+ printf("Received %lu Bytes/s\n", dltdata->bytes_received /**10000/(dlt_uptime()-dltdata->time_elapsed)*/);
+ /*printf("Received %lu Bytes received\n",dltdata->bytes_received); */
dltdata->time_elapsed = dlt_uptime();
dltdata->bytes_received = 0;
}
/* Extended header */
- if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
- {
+ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) {
/* Log message */
- if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
- {
+ if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin)) == DLT_TYPE_LOG) {
/* Verbose */
- if (DLT_IS_MSIN_VERB(message->extendedheader->msin))
- {
+ if (DLT_IS_MSIN_VERB(message->extendedheader->msin)) {
/* 2 arguments */
- if (message->extendedheader->noar==2)
- {
+ if (message->extendedheader->noar == 2) {
/* verbose mode */
- type_info=0;
- type_info_tmp=0;
- length=0;
- length_tmp=0; /* the macro can set this variable to -1 */
+ type_info = 0;
+ type_info_tmp = 0;
+ length = 0;
+ length_tmp = 0; /* the macro can set this variable to -1 */
ptr = message->databuffer;
datalength = message->datasize;
/* first read the type info of the first argument: must be string */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_SINT)
- {
+ if (type_info & DLT_TYPE_INFO_SINT) {
/* read value */
- DLT_MSG_READ_VALUE(value_tmp,ptr,datalength,int32_t);
- value=DLT_ENDIAN_GET_32(message->standardheader->htyp, value_tmp);
- //printf("%d\n",value);
-
- if(value < dltdata->last_value)
- {
- if(dltdata->nvalue == dltdata->count_received_messages)
- printf("PASSED: %d Msg received, %d not received\n",dltdata->count_received_messages,dltdata->count_not_received_messages);
+ DLT_MSG_READ_VALUE(value_tmp, ptr, datalength, int32_t);
+ value = DLT_ENDIAN_GET_32(message->standardheader->htyp, value_tmp);
+ /*printf("%d\n",value); */
+
+ if (value < dltdata->last_value) {
+ if (dltdata->nvalue == dltdata->count_received_messages)
+ printf("PASSED: %d Msg received, %d not received\n",
+ dltdata->count_received_messages,
+ dltdata->count_not_received_messages);
else
- printf("FAILED: %d Msg received, %d not received\n",dltdata->count_received_messages,dltdata->count_not_received_messages);
+ printf("FAILED: %d Msg received, %d not received\n",
+ dltdata->count_received_messages,
+ dltdata->count_not_received_messages);
dltdata->last_value = 0;
dltdata->count_received_messages = 0;
- dltdata->count_not_received_messages = value -1;
+ dltdata->count_not_received_messages = value - 1;
}
- else
- {
- dltdata->count_not_received_messages += value - dltdata->last_value -1;
+ else {
+ dltdata->count_not_received_messages += value - dltdata->last_value - 1;
}
+
dltdata->last_value = value;
dltdata->count_received_messages++;
- if (length>=0)
- {
- ptr+=length;
- datalength-=length;
+ if (length >= 0) {
+ ptr += length;
+ datalength -= length;
/* read type of second argument: must be raw */
- DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
- type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
+ DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+ type_info = DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
- if (type_info & DLT_TYPE_INFO_RAWD)
- {
+ if (type_info & DLT_TYPE_INFO_RAWD) {
/* get length of raw data block */
- DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ DLT_MSG_READ_VALUE(length_tmp, ptr, datalength, uint16_t);
+ length = DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- if ((length>=0) && (length==datalength))
- {
- //printf("Raw data found in payload, length=");
- //printf("%d, datalength=%d \n", length, datalength);
+ if ((length >= 0) && (length == datalength))
+ /*printf("Raw data found in payload, length="); */
+ /*printf("%d, datalength=%d \n", length, datalength); */
dltdata->test_counter_macro[3]++;
- }
}
}
}
@@ -550,30 +511,24 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
/* if no filter set or filter is matching display message */
if (dltdata->xflag)
- {
- dlt_message_print_hex(message,text,DLT_TESTCLIENT_TEXTBUFSIZE,dltdata->vflag);
- }
+ dlt_message_print_hex(message, text, DLT_TESTCLIENT_TEXTBUFSIZE, dltdata->vflag);
else if (dltdata->mflag)
- {
- dlt_message_print_mixed_plain(message,text,DLT_TESTCLIENT_TEXTBUFSIZE,dltdata->vflag);
- }
+ dlt_message_print_mixed_plain(message, text, DLT_TESTCLIENT_TEXTBUFSIZE, dltdata->vflag);
else if (dltdata->sflag)
- {
- dlt_message_print_header(message,text,sizeof(text),dltdata->vflag);
- }
+ dlt_message_print_header(message, text, sizeof(text), dltdata->vflag);
/* if file output enabled write message */
- if (dltdata->ovalue)
- {
+ if (dltdata->ovalue) {
iov[0].iov_base = message->headerbuffer;
iov[0].iov_len = message->headersize;
iov[1].iov_base = message->databuffer;
iov[1].iov_len = message->datasize;
bytes_written = writev(dltdata->ohandle, iov, 2);
- if (0 > bytes_written){
- printf("dlt_testclient_message_callback, error when: writev(dltdata->ohandle, iov, 2) \n");
- return -1;
+
+ if (0 > bytes_written) {
+ printf("dlt_testclient_message_callback, error when: writev(dltdata->ohandle, iov, 2) \n");
+ return -1;
}
}
}
diff --git a/src/tests/dlt-test-stress-user.c b/src/tests/dlt-test-stress-user.c
index 6fe73d9..5cd3a65 100644
--- a/src/tests/dlt-test-stress-user.c
+++ b/src/tests/dlt-test-stress-user.c
@@ -64,8 +64,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <stdio.h> /* for printf() and fprintf() */
@@ -80,7 +80,7 @@
/* Test functions... */
-int testall(int count,int repeat,int delay,int size);
+int testall(int count, int repeat, int delay, int size);
/* Context declaration.. */
DLT_DECLARE_CONTEXT(context_info)
@@ -102,7 +102,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-test-stress-user [options]\n");
printf("Test user application providing Test messages.\n");
@@ -119,9 +119,9 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- //int vflag = 0;
+ /*int vflag = 0; */
char *fvalue = 0;
int nvalue = 10000;
int rvalue = 100;
@@ -133,12 +133,10 @@ int main(int argc, char* argv[])
opterr = 0;
while ((c = getopt (argc, argv, "vf:n:r:d:s:")) != -1)
- {
- switch (c)
- {
+ switch (c) {
case 'v':
{
- //vflag = 1;
+ /*vflag = 1; */
break;
}
case 'f':
@@ -168,18 +166,14 @@ int main(int argc, char* argv[])
}
case '?':
{
- if (optopt == 'd' || optopt == 'f' || optopt == 'n' || optopt == 'r' || optopt == 'd' || optopt == 's')
- {
+ if ((optopt == 'd') || (optopt == 'f') || (optopt == 'n') || (optopt == 'r') || (optopt == 'd') ||
+ (optopt == 's'))
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
/* unknown or wrong option used, show usage information and terminate */
usage();
return -1;
@@ -187,41 +181,39 @@ int main(int argc, char* argv[])
default:
{
abort ();
- return -1;//for parasoft
+ return -1;/*for parasoft */
}
}
- }
- if (fvalue)
- {
+
+
+ if (fvalue) {
/* DLT is intialised automatically, except another output target will be used */
- if (dlt_init_file(fvalue)<0) /* log to file */
- {
+ if (dlt_init_file(fvalue) < 0) /* log to file */
return -1;
- }
}
/* Register APP */
- DLT_REGISTER_APP("DIFT","DLT Interface Test");
+ DLT_REGISTER_APP("DIFT", "DLT Interface Test");
/* Register CONTEXTS... */
- DLT_REGISTER_CONTEXT(context_info,"INFO","Information context");
+ DLT_REGISTER_CONTEXT(context_info, "INFO", "Information context");
/* Tests starting */
printf("Tests starting\n");
- //DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Tests starting"));
+ /*DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Tests starting")); */
/* wait 3 seconds before starting */
- //sleep(3);
+ /*sleep(3); */
- testall(nvalue,rvalue,dvalue,svalue);
+ testall(nvalue, rvalue, dvalue, svalue);
/* Tests finished */
printf("Tests finished\n");
- //DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Tests finished"));
+ /*DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Tests finished")); */
/* wait 3 seconds before terminating application */
- //sleep(3);
+ /*sleep(3); */
/* Unregister CONTEXTS... */
DLT_UNREGISTER_CONTEXT(context_info);
@@ -236,32 +228,27 @@ int main(int argc, char* argv[])
/* The test cases */
/******************/
-int testall(int count,int repeat,int delay,int size)
+int testall(int count, int repeat, int delay, int size)
{
char buffer[size];
- int num,rnum;
+ int num, rnum;
- for(num=0;num< size;num++)
- {
+ for (num = 0; num < size; num++)
buffer[num] = num;
- }
/* Test All: Test all start */
- //printf("Test1: Test all\n");
- //DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test1: Test all"));
+ /*printf("Test1: Test all\n"); */
+ /*DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test1: Test all")); */
- for(rnum=0;rnum<repeat;rnum++)
- {
- for(num=1;num<=count;num++)
- {
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_INT(num),DLT_RAW(buffer, size));
+ for (rnum = 0; rnum < repeat; rnum++)
+ for (num = 1; num <= count; num++) {
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_INT(num), DLT_RAW(buffer, size));
usleep(delay);
}
- }
/* wait 5 seconds after test */
- //sleep(5);
- //DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test1: finished"));
+ /*sleep(5); */
+ /*DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test1: finished")); */
return 0;
}
diff --git a/src/tests/dlt-test-stress.c b/src/tests/dlt-test-stress.c
index 14067f1..ddfe937 100644
--- a/src/tests/dlt-test-stress.c
+++ b/src/tests/dlt-test-stress.c
@@ -64,8 +64,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <netdb.h>
#include <ctype.h> /* for isprint() */
@@ -106,7 +106,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-test-stress [options]\n");
printf("Test application executing several stress tests.\n");
@@ -122,28 +122,24 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- //int vflag = 0;
+ /*int vflag = 0; */
char *fvalue = 0;
int test[MAX_TESTS];
- int i,c,help;
+ int i, c, help;
- for (i=0;i<MAX_TESTS;i++)
- {
- test[i]=0;
- }
+ for (i = 0; i < MAX_TESTS; i++)
+ test[i] = 0;
opterr = 0;
while ((c = getopt (argc, argv, "vf:123")) != -1)
- {
- switch (c)
- {
+ switch (c) {
case 'v':
{
- //vflag = 1;
+ /*vflag = 1; */
break;
}
case 'f':
@@ -169,17 +165,12 @@ int main(int argc, char* argv[])
case '?':
{
if (optopt == 'f')
- {
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
/* unknown or wrong option used, show usage information and terminate */
usage();
return -1;
@@ -187,50 +178,43 @@ int main(int argc, char* argv[])
default:
{
abort ();
- return -1;//for parasoft
+ return -1;/*for parasoft */
}
}
- }
- if (fvalue)
- {
+
+
+ if (fvalue) {
/* DLT is intialised automatically, except another output target will be used */
- if (dlt_init_file(fvalue)<0) /* log to file */
- {
+ if (dlt_init_file(fvalue) < 0) /* log to file */
return -1;
- }
}
- help=0;
- for (i=0;i<MAX_TESTS;i++)
- {
- if (test[i]==1)
- {
- help=1;
+ help = 0;
+
+ for (i = 0; i < MAX_TESTS; i++)
+ if (test[i] == 1) {
+ help = 1;
break;
}
- }
- if (help==0)
- {
+
+
+ if (help == 0) {
usage();
return -1;
}
- DLT_REGISTER_APP("DSTS","DLT daemon stress tests");
+ DLT_REGISTER_APP("DSTS", "DLT daemon stress tests");
if (test[0])
- {
stress1();
- }
+
if (test[1])
- {
stress2();
- }
+
if (test[2])
- {
stress3();
- }
DLT_UNREGISTER_APP();
@@ -241,39 +225,35 @@ int main(int argc, char* argv[])
void stress1(void)
{
- int i,c;
+ int i, c;
char ctid[5];
printf("Starting stress test1... (press \"Enter\" to terminate test) \n");
- printf("* Register %d contexts...\n",STRESS1_NUM_CONTEXTS);
+ printf("* Register %d contexts...\n", STRESS1_NUM_CONTEXTS);
- for (i=0; i<STRESS1_NUM_CONTEXTS; i++)
- {
+ for (i = 0; i < STRESS1_NUM_CONTEXTS; i++) {
/* Generate id */
- memset(ctid,0,5);
- snprintf(ctid,5,"%d",i);
+ memset(ctid, 0, 5);
+ snprintf(ctid, 5, "%d", i);
- //printf("%i: '%s' \n",i,ctid);
+ /*printf("%i: '%s' \n",i,ctid); */
- dlt_register_context(&(mycontext[i]),ctid,ctid);
+ dlt_register_context(&(mycontext[i]), ctid, ctid);
usleep(500);
}
- while (1)
- {
- c=getchar();
+ while (1) {
+ c = getchar();
+
/* if "Return" is pressed, exit loop; */
- if (c==10)
- {
+ if (c == 10)
break;
- }
}
- printf("* Unregister %d contexts...\n",STRESS1_NUM_CONTEXTS);
+ printf("* Unregister %d contexts...\n", STRESS1_NUM_CONTEXTS);
- for (i=0; i<STRESS1_NUM_CONTEXTS; i++)
- {
+ for (i = 0; i < STRESS1_NUM_CONTEXTS; i++) {
DLT_UNREGISTER_CONTEXT(mycontext[i]);
usleep(500);
}
@@ -283,7 +263,7 @@ void stress1(void)
void stress2(void)
{
- int ret,index;
+ int ret, index;
pthread_t thread[STRESS2_MAX_NUM_THREADS];
thread_data_t thread_data[STRESS2_MAX_NUM_THREADS];
@@ -292,47 +272,43 @@ void stress2(void)
srand(time(NULL));
- printf("* Creating %d Threads, each of them registers one context,\n",STRESS2_MAX_NUM_THREADS);
+ printf("* Creating %d Threads, each of them registers one context,\n", STRESS2_MAX_NUM_THREADS);
printf(" sending one log message, then unregisters the context\n");
- for (index=0;index<STRESS2_MAX_NUM_THREADS;index++)
- {
+ for (index = 0; index < STRESS2_MAX_NUM_THREADS; index++) {
thread_data[index].num = index;
- ret=pthread_create(&(thread[index]), NULL, (void *) &thread_function, (void *) &(thread_data[index]));
- if (ret!=0)
- {
+ ret = pthread_create(&(thread[index]), NULL, (void *)&thread_function, (void *)&(thread_data[index]));
+
+ if (ret != 0)
printf("Error creating thread %d: %s \n", index, strerror(errno));
- }
usleep(1000);
}
- for (index=0;index<STRESS2_MAX_NUM_THREADS;index++)
- {
+ for (index = 0; index < STRESS2_MAX_NUM_THREADS; index++)
pthread_join(thread[index], NULL);
- }
printf("Finished stress test2 \n\n");
}
void thread_function(void)
{
- //thread_data_t *data;
+ /*thread_data_t *data; */
DLT_DECLARE_CONTEXT(context_thread1);
char ctid[5];
- //data = (thread_data_t *) ptr;
+ /*data = (thread_data_t *) ptr; */
- memset(ctid,0,5);
+ memset(ctid, 0, 5);
/* Create random context id */
- snprintf(ctid,5,"%.2x", rand() & 0x0000ffff);
+ snprintf(ctid, 5, "%.2x", rand() & 0x0000ffff);
- usleep(rand()/1000);
+ usleep(rand() / 1000);
- DLT_REGISTER_CONTEXT(context_thread1,ctid,ctid);
+ DLT_REGISTER_CONTEXT(context_thread1, ctid, ctid);
- DLT_LOG(context_thread1,DLT_LOG_INFO,DLT_STRING(ctid));
+ DLT_LOG(context_thread1, DLT_LOG_INFO, DLT_STRING(ctid));
DLT_UNREGISTER_CONTEXT(context_thread1);
}
@@ -344,15 +320,14 @@ void stress3(void)
int num;
/* Performance test */
- DLT_REGISTER_CONTEXT(context_stress3,"TST3","Stress Test 3 - Performance");
+ DLT_REGISTER_CONTEXT(context_stress3, "TST3", "Stress Test 3 - Performance");
printf("Starting stress test3... \n");
- printf("* Logging raw data, up to a size of %d\n",STRESS3_MAX_NUM_MESSAGES);
+ printf("* Logging raw data, up to a size of %d\n", STRESS3_MAX_NUM_MESSAGES);
- for (num=0;num<STRESS3_MAX_NUM_MESSAGES;num++)
- {
+ for (num = 0; num < STRESS3_MAX_NUM_MESSAGES; num++) {
buffer[num] = num;
- DLT_LOG(context_stress3,DLT_LOG_INFO,DLT_INT(num),DLT_RAW(buffer,num));
+ DLT_LOG(context_stress3, DLT_LOG_INFO, DLT_INT(num), DLT_RAW(buffer, num));
usleep(10000);
}
diff --git a/src/tests/dlt-test-user.c b/src/tests/dlt-test-user.c
index 9a57573..5e0fe47 100644
--- a/src/tests/dlt-test-user.c
+++ b/src/tests/dlt-test-user.c
@@ -64,8 +64,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <stdio.h> /* for printf() and fprintf() */
@@ -79,15 +79,14 @@
#define DLT_TEST_NUM_CONTEXT 9
/* LogLevel string representation */
-static const char *loglevelstr[DLT_LOG_MAX] =
-{
- "DLT_LOG_OFF",
- "DLT_LOG_FATAL",
- "DLT_LOG_ERROR",
- "DLT_LOG_WARN",
- "DLT_LOG_INFO",
- "DLT_LOG_DEBUG",
- "DLT_LOG_VERBOSE"
+static const char *loglevelstr[DLT_LOG_MAX] = {
+ "DLT_LOG_OFF",
+ "DLT_LOG_FATAL",
+ "DLT_LOG_ERROR",
+ "DLT_LOG_WARN",
+ "DLT_LOG_INFO",
+ "DLT_LOG_DEBUG",
+ "DLT_LOG_VERBOSE"
};
/* Test functions... */
@@ -138,7 +137,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-test-user [options]\n");
printf("Test user application providing several Tests.\n");
@@ -171,9 +170,9 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- //int vflag = 0;
+ /*int vflag = 0; */
char *fvalue = 0;
char *nvalue = 0;
@@ -182,17 +181,15 @@ int main(int argc, char* argv[])
int i;
char ctid[4], ctdesc[255];
- int num,maxnum;
+ int num, maxnum;
opterr = 0;
while ((c = getopt (argc, argv, "vf:n:")) != -1)
- {
- switch (c)
- {
+ switch (c) {
case 'v':
{
- //vflag = 1;
+ /*vflag = 1; */
break;
}
case 'f':
@@ -207,18 +204,13 @@ int main(int argc, char* argv[])
}
case '?':
{
- if (optopt == 'd' || optopt == 'f' || optopt == 'n')
- {
+ if ((optopt == 'd') || (optopt == 'f') || (optopt == 'n'))
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
/* unknown or wrong option used, show usage information and terminate */
usage();
return -1;
@@ -226,76 +218,70 @@ int main(int argc, char* argv[])
default:
{
abort ();
- return -1;//for parasoft
+ return -1;/*for parasoft */
}
}
- }
- if (fvalue)
- {
+
+
+ if (fvalue) {
/* DLT is intialised automatically, except another output target will be used */
- if (dlt_init_file(fvalue)<0) /* log to file */
- {
+ if (dlt_init_file(fvalue) < 0) /* log to file */
return -1;
- }
}
if (nvalue)
- {
maxnum = atoi(nvalue);
- }
else
- {
maxnum = 1;
- }
/* Register APP */
- DLT_REGISTER_APP("DIFT","DLT Interface Test");
+ DLT_REGISTER_APP("DIFT", "DLT Interface Test");
/* Register CONTEXTS... */
- DLT_REGISTER_CONTEXT(context_info,"INFO","Information context");
+ DLT_REGISTER_CONTEXT(context_info, "INFO", "Information context");
/* used for macro interface tests */
- DLT_REGISTER_CONTEXT(context_macro_callback,"CBM","Callback Test context for macro interface");
- for (i=0;i<DLT_TEST_NUM_CONTEXT;i++)
- {
- snprintf(ctid,4,"TM%d",i+1);
- snprintf(ctdesc,255,"Test %d context for macro interface",i+1);
- DLT_REGISTER_CONTEXT(context_macro_test[i],ctid,ctdesc);
+ DLT_REGISTER_CONTEXT(context_macro_callback, "CBM", "Callback Test context for macro interface");
+
+ for (i = 0; i < DLT_TEST_NUM_CONTEXT; i++) {
+ snprintf(ctid, 4, "TM%d", i + 1);
+ snprintf(ctdesc, 255, "Test %d context for macro interface", i + 1);
+ DLT_REGISTER_CONTEXT(context_macro_test[i], ctid, ctdesc);
}
/* used for function interface tests */
- dlt_register_context(&context_function_callback,"CBF","Callback Test context for function interface");
- for (i=0;i<DLT_TEST_NUM_CONTEXT;i++)
- {
- snprintf(ctid,4,"TF%d",i+1);
- snprintf(ctdesc,255,"Test %d context for function interface",i+1);
- dlt_register_context(&(context_function_test[i]),ctid,ctdesc);
+ dlt_register_context(&context_function_callback, "CBF", "Callback Test context for function interface");
+
+ for (i = 0; i < DLT_TEST_NUM_CONTEXT; i++) {
+ snprintf(ctid, 4, "TF%d", i + 1);
+ snprintf(ctdesc, 255, "Test %d context for function interface", i + 1);
+ dlt_register_context(&(context_function_test[i]), ctid, ctdesc);
}
/* Register callbacks... */
/* with macro interface */
- DLT_LOG(context_macro_callback,DLT_LOG_INFO,DLT_STRING("Register callback (Macro Interface) for Injection ID: 0xFFF"));
+ DLT_LOG(context_macro_callback, DLT_LOG_INFO,
+ DLT_STRING("Register callback (Macro Interface) for Injection ID: 0xFFF"));
DLT_REGISTER_INJECTION_CALLBACK(context_macro_callback, 0xFFF, test_injection_macro_callback);
/* with function interface */
- if (dlt_user_log_write_start(&context_function_callback,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Register callback (Function Interface) for Injection ID: 0xFFF");
+ if (dlt_user_log_write_start(&context_function_callback, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Register callback (Function Interface) for Injection ID: 0xFFF");
dlt_user_log_write_finish(&context_data);
}
+
dlt_register_injection_callback(&context_function_callback, 0xFFF, test_injection_function_callback);
/* Tests starting */
printf("Tests starting\n");
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Tests starting"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Tests starting"));
/* wait 3 seconds before starting */
sleep(3);
- for (num=0;num<maxnum;num++)
- {
+ for (num = 0; num < maxnum; num++) {
/* Execute tests... */
/* with macro interface */
@@ -326,7 +312,7 @@ int main(int argc, char* argv[])
/* Tests finished */
printf("Tests finished\n");
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Tests finished"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Tests finished"));
/* wait 3 seconds before terminating application */
sleep(3);
@@ -335,17 +321,15 @@ int main(int argc, char* argv[])
DLT_UNREGISTER_CONTEXT(context_info);
/* used for macro interface tests */
- for (i=0;i<DLT_TEST_NUM_CONTEXT;i++)
- {
+ for (i = 0; i < DLT_TEST_NUM_CONTEXT; i++)
DLT_UNREGISTER_CONTEXT(context_macro_test[i]);
- }
+
DLT_UNREGISTER_CONTEXT(context_macro_callback);
/* used for function interface tests */
- for (i=0;i<DLT_TEST_NUM_CONTEXT;i++)
- {
+ for (i = 0; i < DLT_TEST_NUM_CONTEXT; i++)
dlt_unregister_context(&(context_function_test[i]));
- }
+
dlt_unregister_context(&context_function_callback);
/* Unregister APP */
@@ -362,18 +346,18 @@ int test1m(void)
{
/* Test 1: (Macro IF) Test all log levels */
printf("Test1m: (Macro IF) Test all log levels\n");
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test1: (Macro IF) Test all log levels"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test1: (Macro IF) Test all log levels"));
- DLT_LOG(context_macro_test[0],DLT_LOG_FATAL,DLT_STRING("fatal"));
- DLT_LOG(context_macro_test[0],DLT_LOG_ERROR,DLT_STRING("error"));
- DLT_LOG(context_macro_test[0],DLT_LOG_WARN,DLT_STRING("warn"));
- DLT_LOG(context_macro_test[0],DLT_LOG_INFO,DLT_STRING("info"));
- DLT_LOG(context_macro_test[0],DLT_LOG_DEBUG,DLT_STRING("debug"));
- DLT_LOG(context_macro_test[0],DLT_LOG_VERBOSE,DLT_STRING("verbose"));
+ DLT_LOG(context_macro_test[0], DLT_LOG_FATAL, DLT_STRING("fatal"));
+ DLT_LOG(context_macro_test[0], DLT_LOG_ERROR, DLT_STRING("error"));
+ DLT_LOG(context_macro_test[0], DLT_LOG_WARN, DLT_STRING("warn"));
+ DLT_LOG(context_macro_test[0], DLT_LOG_INFO, DLT_STRING("info"));
+ DLT_LOG(context_macro_test[0], DLT_LOG_DEBUG, DLT_STRING("debug"));
+ DLT_LOG(context_macro_test[0], DLT_LOG_VERBOSE, DLT_STRING("verbose"));
/* wait 2 second before next test */
sleep(2);
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test1: (Macro IF) finished"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test1: (Macro IF) finished"));
return 0;
}
@@ -385,34 +369,32 @@ int test2m(void)
/* Test 2: (Macro IF) Test all variable types (verbose) */
printf("Test2m: (Macro IF) Test all variable types (verbose)\n");
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test2: (Macro IF) Test all variable types (verbose)"));
-
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("string"),DLT_STRING("Hello world"));
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("utf8"),DLT_UTF8("Hello world"));
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("bool"),DLT_BOOL(1));
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("int"),DLT_INT(INT32_MIN)); /* (-2147483647-1) */
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("int8"),DLT_INT8(INT8_MIN)); /* (-128) */
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("int16"),DLT_INT16(INT16_MIN)); /* (-32767-1) */
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("int32"),DLT_INT32(INT32_MIN)); /* (-2147483647-1) */
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("int64"),DLT_INT64(INT64_MIN)); /* (-__INT64_C(9223372036854775807)-1) */
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("uint"),DLT_UINT(UINT32_MAX)); /* (4294967295U) */
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("uint8"),DLT_UINT8(UINT8_MAX)); /* (255) */
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("uint16"),DLT_UINT16(UINT16_MAX)); /* (65535) */
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("uint32"),DLT_UINT32(UINT32_MAX)); /* (4294967295U) */
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("uint64"),DLT_UINT64(UINT64_MAX)); /* (__UINT64_C(18446744073709551615)) */
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("float32"),DLT_FLOAT32(FLT_MIN),DLT_FLOAT32(FLT_MAX));
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("float64"),DLT_FLOAT64(DBL_MIN),DLT_FLOAT64(DBL_MAX));
-
- for(num2=0;num2<10;num2++)
- {
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test2: (Macro IF) Test all variable types (verbose)"));
+
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("string"), DLT_STRING("Hello world"));
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("utf8"), DLT_UTF8("Hello world"));
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("bool"), DLT_BOOL(1));
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("int"), DLT_INT(INT32_MIN)); /* (-2147483647-1) */
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("int8"), DLT_INT8(INT8_MIN)); /* (-128) */
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("int16"), DLT_INT16(INT16_MIN)); /* (-32767-1) */
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("int32"), DLT_INT32(INT32_MIN)); /* (-2147483647-1) */
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("int64"), DLT_INT64(INT64_MIN)); /* (-__INT64_C(9223372036854775807)-1) */
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("uint"), DLT_UINT(UINT32_MAX)); /* (4294967295U) */
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("uint8"), DLT_UINT8(UINT8_MAX)); /* (255) */
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("uint16"), DLT_UINT16(UINT16_MAX)); /* (65535) */
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("uint32"), DLT_UINT32(UINT32_MAX)); /* (4294967295U) */
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("uint64"), DLT_UINT64(UINT64_MAX)); /* (__UINT64_C(18446744073709551615)) */
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("float32"), DLT_FLOAT32(FLT_MIN), DLT_FLOAT32(FLT_MAX));
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("float64"), DLT_FLOAT64(DBL_MIN), DLT_FLOAT64(DBL_MAX));
+
+ for (num2 = 0; num2 < 10; num2++)
buffer[num2] = num2;
- }
- DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("raw"),DLT_RAW(buffer,10));
+ DLT_LOG(context_macro_test[1], DLT_LOG_INFO, DLT_STRING("raw"), DLT_RAW(buffer, 10));
/* wait 2 second before next test */
sleep(2);
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test2: (Macro IF) finished"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test2: (Macro IF) finished"));
return 0;
}
@@ -424,38 +406,46 @@ int test3m(void)
/* Test 3: (Macro IF) Test all variable types (non-verbose) */
printf("Test3m: (Macro IF) Test all variable types (non-verbose)\n");
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test3: (Macro IF) Test all variable types (non-verbose)"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test3: (Macro IF) Test all variable types (non-verbose)"));
DLT_NONVERBOSE_MODE();
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,1,DLT_STRING("string"),DLT_STRING("Hello world"));
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,2,DLT_STRING("utf8"),DLT_UTF8("Hello world"));
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,3,DLT_STRING("bool"),DLT_BOOL(1));
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,4,DLT_STRING("int"),DLT_INT(INT32_MIN)); /* (-2147483647-1) */
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,5,DLT_STRING("int8"),DLT_INT8(INT8_MIN)); /* (-128) */
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,6,DLT_STRING("int16"),DLT_INT16(INT16_MIN)); /* (-32767-1) */
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,7,DLT_STRING("int32"),DLT_INT32(INT32_MIN)); /* (-2147483647-1) */
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,8,DLT_STRING("int64"),DLT_INT64(INT64_MIN)); /* (-__INT64_C(9223372036854775807)-1) */
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,9,DLT_STRING("uint"),DLT_UINT(UINT32_MAX)); /* (4294967295U) */
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,10,DLT_STRING("uint8"),DLT_UINT8(UINT8_MAX)); /* (255) */
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,11,DLT_STRING("uint16"),DLT_UINT16(UINT16_MAX)); /* (65535) */
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,12,DLT_STRING("uint32"),DLT_UINT32(UINT32_MAX)); /* (4294967295U) */
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,13,DLT_STRING("uint64"),DLT_UINT64(UINT64_MAX)); /* (__UINT64_C(18446744073709551615)) */
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,14,DLT_STRING("float32"),DLT_FLOAT32(FLT_MIN),DLT_FLOAT32(FLT_MAX));
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,15,DLT_STRING("float64"),DLT_FLOAT64(DBL_MIN),DLT_FLOAT64(DBL_MAX));
-
-
- for(num2=0;num2<10;num2++)
- {
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 1, DLT_STRING("string"), DLT_STRING("Hello world"));
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 2, DLT_STRING("utf8"), DLT_UTF8("Hello world"));
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 3, DLT_STRING("bool"), DLT_BOOL(1));
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 4, DLT_STRING("int"), DLT_INT(INT32_MIN)); /* (-2147483647-1) */
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 5, DLT_STRING("int8"), DLT_INT8(INT8_MIN)); /* (-128) */
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 6, DLT_STRING("int16"), DLT_INT16(INT16_MIN)); /* (-32767-1) */
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 7, DLT_STRING("int32"), DLT_INT32(INT32_MIN)); /* (-2147483647-1) */
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 8, DLT_STRING("int64"), DLT_INT64(INT64_MIN)); /* (-__INT64_C(9223372036854775807)-1) */
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 9, DLT_STRING("uint"), DLT_UINT(UINT32_MAX)); /* (4294967295U) */
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 10, DLT_STRING("uint8"), DLT_UINT8(UINT8_MAX)); /* (255) */
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 11, DLT_STRING("uint16"), DLT_UINT16(UINT16_MAX)); /* (65535) */
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 12, DLT_STRING("uint32"), DLT_UINT32(UINT32_MAX)); /* (4294967295U) */
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 13, DLT_STRING("uint64"), DLT_UINT64(UINT64_MAX)); /* (__UINT64_C(18446744073709551615)) */
+ DLT_LOG_ID(context_macro_test[2],
+ DLT_LOG_INFO,
+ 14,
+ DLT_STRING("float32"),
+ DLT_FLOAT32(FLT_MIN),
+ DLT_FLOAT32(FLT_MAX));
+ DLT_LOG_ID(context_macro_test[2],
+ DLT_LOG_INFO,
+ 15,
+ DLT_STRING("float64"),
+ DLT_FLOAT64(DBL_MIN),
+ DLT_FLOAT64(DBL_MAX));
+
+ for (num2 = 0; num2 < 10; num2++)
buffer[num2] = num2;
- }
- DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,14,DLT_STRING("raw"),DLT_RAW(buffer,10));
+
+ DLT_LOG_ID(context_macro_test[2], DLT_LOG_INFO, 14, DLT_STRING("raw"), DLT_RAW(buffer, 10));
DLT_VERBOSE_MODE();
/* wait 2 second before next test */
sleep(2);
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test3: (Macro IF) finished"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test3: (Macro IF) finished"));
return 0;
}
@@ -465,23 +455,21 @@ int test4m(void)
char buffer[1024];
int num;
- for(num=0;num<1024;num++)
- {
+ for (num = 0; num < 1024; num++)
buffer[num] = num;
- }
/* Test 4: (Macro IF) Message size test */
printf("Test4m: (Macro IF) Test different message sizes\n");
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test4: (Macro IF) Test different message sizes"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test4: (Macro IF) Test different message sizes"));
- DLT_LOG(context_macro_test[3],DLT_LOG_INFO,DLT_STRING("1"),DLT_RAW(buffer,1));
- DLT_LOG(context_macro_test[3],DLT_LOG_INFO,DLT_STRING("16"),DLT_RAW(buffer,16));
- DLT_LOG(context_macro_test[3],DLT_LOG_INFO,DLT_STRING("256"),DLT_RAW(buffer,256));
- DLT_LOG(context_macro_test[3],DLT_LOG_INFO,DLT_STRING("1024"),DLT_RAW(buffer,1024));
+ DLT_LOG(context_macro_test[3], DLT_LOG_INFO, DLT_STRING("1"), DLT_RAW(buffer, 1));
+ DLT_LOG(context_macro_test[3], DLT_LOG_INFO, DLT_STRING("16"), DLT_RAW(buffer, 16));
+ DLT_LOG(context_macro_test[3], DLT_LOG_INFO, DLT_STRING("256"), DLT_RAW(buffer, 256));
+ DLT_LOG(context_macro_test[3], DLT_LOG_INFO, DLT_STRING("1024"), DLT_RAW(buffer, 1024));
/* wait 2 second before next test */
sleep(2);
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test4: (Macro IF) finished"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test4: (Macro IF) finished"));
return 0;
}
@@ -494,58 +482,52 @@ int test5m(void)
void *ptr = malloc(sizeof(int));
- for(num=0;num<32;num++)
- {
+ for (num = 0; num < 32; num++)
buffer[num] = num;
- }
/* Test 5: (Macro IF) Test high-level API */
printf("Test5m: (Macro IF) Test high-level API\n");
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test5: (Macro IF) Test high-level API"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test5: (Macro IF) Test high-level API"));
- DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_INT"));
+ DLT_LOG(context_macro_test[4], DLT_LOG_INFO, DLT_STRING("Next line: DLT_LOG_INT"));
DLT_LOG_INT(context_macro_test[4], DLT_LOG_INFO, -42);
- DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_UINT"));
+ DLT_LOG(context_macro_test[4], DLT_LOG_INFO, DLT_STRING("Next line: DLT_LOG_UINT"));
DLT_LOG_UINT(context_macro_test[4], DLT_LOG_INFO, 42);
- DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_STRING"));
+ DLT_LOG(context_macro_test[4], DLT_LOG_INFO, DLT_STRING("Next line: DLT_LOG_STRING"));
DLT_LOG_STRING(context_macro_test[4], DLT_LOG_INFO, "String output");
- DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_RAW"));
- DLT_LOG_RAW(context_macro_test[4],DLT_LOG_INFO, buffer,16);
+ DLT_LOG(context_macro_test[4], DLT_LOG_INFO, DLT_STRING("Next line: DLT_LOG_RAW"));
+ DLT_LOG_RAW(context_macro_test[4], DLT_LOG_INFO, buffer, 16);
- DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_STRING_INT"));
+ DLT_LOG(context_macro_test[4], DLT_LOG_INFO, DLT_STRING("Next line: DLT_LOG_STRING_INT"));
DLT_LOG_STRING_INT(context_macro_test[4], DLT_LOG_INFO, "String output: ", -42);
- DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_STRING_UINT"));
- DLT_LOG_STRING_UINT(context_macro_test[4], DLT_LOG_INFO,"String output: ", 42);
+ DLT_LOG(context_macro_test[4], DLT_LOG_INFO, DLT_STRING("Next line: DLT_LOG_STRING_UINT"));
+ DLT_LOG_STRING_UINT(context_macro_test[4], DLT_LOG_INFO, "String output: ", 42);
- DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_PTR"));
- DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_PTR(ptr));
+ DLT_LOG(context_macro_test[4], DLT_LOG_INFO, DLT_STRING("Next line: DLT_LOG_PTR"));
+ DLT_LOG(context_macro_test[4], DLT_LOG_INFO, DLT_PTR(ptr));
- DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next lines: DLT_IS_LOG_LEVEL_ENABLED"));
- for (i = DLT_LOG_FATAL; i < DLT_LOG_MAX; i++)
- {
- if (DLT_IS_LOG_LEVEL_ENABLED(context_macro_test[4],i))
- {
+ DLT_LOG(context_macro_test[4], DLT_LOG_INFO, DLT_STRING("Next lines: DLT_IS_LOG_LEVEL_ENABLED"));
+
+ for (i = DLT_LOG_FATAL; i < DLT_LOG_MAX; i++) {
+ if (DLT_IS_LOG_LEVEL_ENABLED(context_macro_test[4], i))
DLT_LOG(context_info,
DLT_LOG_INFO,
DLT_STRING("Loglevel is enabled: "),
DLT_STRING(loglevelstr[i]));
- }
else
- {
DLT_LOG(context_info,
DLT_LOG_INFO,
DLT_STRING("Loglevel is disabled: "),
DLT_STRING(loglevelstr[i]));
- }
}
/* wait 2 second before next test */
sleep(2);
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test5: (Macro IF) finished"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test5: (Macro IF) finished"));
free(ptr);
return 0;
@@ -563,9 +545,9 @@ int test6m(void)
DLT_DISABLE_LOCAL_PRINT();
DLT_LOG_STRING(context_macro_test[5], DLT_LOG_INFO, "Message (invisible: not locally printed)");
- /* wait 2 second before next test */
+ /* wait 2 second before next test */
sleep(2);
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test6: (Macro IF) finished"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test6: (Macro IF) finished"));
return 0;
}
@@ -575,10 +557,8 @@ int test7m(void)
char buffer[32];
int num;
- for(num=0;num<32;num++)
- {
+ for (num = 0; num < 32; num++)
buffer[num] = num;
- }
/* Show all log messages and traces */
DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
@@ -595,7 +575,7 @@ int test7m(void)
/* wait 2 second before next test */
sleep(2);
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test7: (Macro IF) finished"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test7: (Macro IF) finished"));
DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT);
sleep(2);
@@ -605,13 +585,11 @@ int test7m(void)
int test8m(void)
{
- char buffer[1024*5];
+ char buffer[1024 * 5];
int num;
- for(num=0;num<1024*5;num++)
- {
+ for (num = 0; num < 1024 * 5; num++)
buffer[num] = num;
- }
/* Show all log messages and traces */
DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
@@ -621,14 +599,14 @@ int test8m(void)
DLT_LOG_STRING(context_info, DLT_LOG_INFO, "Test 8: (Macro IF) Test truncated network trace");
/* Dummy messages: 16 byte header, 5k payload */
- DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_IPC, 16, buffer, 1024*5, buffer);
- DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_CAN, 16, buffer, 1024*5, buffer);
- DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024*5, buffer);
- DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_MOST, 16, buffer, 1024*5, buffer);
+ DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_IPC, 16, buffer, 1024 * 5, buffer);
+ DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_CAN, 16, buffer, 1024 * 5, buffer);
+ DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024 * 5, buffer);
+ DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_MOST, 16, buffer, 1024 * 5, buffer);
/* wait 2 second before next test */
sleep(2);
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test8: (Macro IF) finished"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test8: (Macro IF) finished"));
DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT);
sleep(2);
@@ -638,13 +616,11 @@ int test8m(void)
int test9m(void)
{
- char buffer[1024*5];
+ char buffer[1024 * 5];
int num;
- for(num=0;num<1024*5;num++)
- {
+ for (num = 0; num < 1024 * 5; num++)
buffer[num] = num;
- }
/* Show all log messages and traces */
DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
@@ -654,14 +630,14 @@ int test9m(void)
DLT_LOG_STRING(context_info, DLT_LOG_INFO, "Test 9: (Macro IF) Test segmented network trace");
/* Dummy messages: 16 byte header, 5k payload */
- DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_IPC, 16, buffer, 1024*5, buffer);
- DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_CAN, 16, buffer, 1024*5, buffer);
- DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024*5, buffer);
- DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_MOST, 16, buffer, 1024*5, buffer);
+ DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_IPC, 16, buffer, 1024 * 5, buffer);
+ DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_CAN, 16, buffer, 1024 * 5, buffer);
+ DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024 * 5, buffer);
+ DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_MOST, 16, buffer, 1024 * 5, buffer);
/* wait 2 second before next test */
sleep(2);
- DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test9: (Macro IF) finished"));
+ DLT_LOG(context_info, DLT_LOG_INFO, DLT_STRING("Test9: (Macro IF) finished"));
DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT);
sleep(2);
@@ -673,48 +649,47 @@ int test1f(void)
{
/* Test 1: (Function IF) Test all log levels */
printf("Test1f: (Function IF) Test all log levels\n");
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test1: (Function IF) Test all log levels");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test1: (Function IF) Test all log levels");
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_FATAL)>0)
- {
- dlt_user_log_write_string(&context_data,"fatal");
+ if (dlt_user_log_write_start(&(context_function_test[0]), &context_data, DLT_LOG_FATAL) > 0) {
+ dlt_user_log_write_string(&context_data, "fatal");
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_ERROR)>0)
- {
- dlt_user_log_write_string(&context_data,"error");
+
+ if (dlt_user_log_write_start(&(context_function_test[0]), &context_data, DLT_LOG_ERROR) > 0) {
+ dlt_user_log_write_string(&context_data, "error");
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_WARN)>0)
- {
- dlt_user_log_write_string(&context_data,"warn");
+
+ if (dlt_user_log_write_start(&(context_function_test[0]), &context_data, DLT_LOG_WARN) > 0) {
+ dlt_user_log_write_string(&context_data, "warn");
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"info");
+
+ if (dlt_user_log_write_start(&(context_function_test[0]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "info");
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_DEBUG)>0)
- {
- dlt_user_log_write_string(&context_data,"debug");
+
+ if (dlt_user_log_write_start(&(context_function_test[0]), &context_data, DLT_LOG_DEBUG) > 0) {
+ dlt_user_log_write_string(&context_data, "debug");
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_VERBOSE)>0)
- {
- dlt_user_log_write_string(&context_data,"verbose");
+
+ if (dlt_user_log_write_start(&(context_function_test[0]), &context_data, DLT_LOG_VERBOSE) > 0) {
+ dlt_user_log_write_string(&context_data, "verbose");
dlt_user_log_write_finish(&context_data);
}
/* wait 2 second before next test */
sleep(2);
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test1: (Function IF) finished");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test1: (Function IF) finished");
dlt_user_log_write_finish(&context_data);
}
@@ -728,113 +703,106 @@ int test2f(void)
/* Test 2: (Function IF) Test all variable types (verbose) */
printf("Test2f: (Function IF) Test all variable types (verbose)\n");
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test2: (Function IF) Test all variable types (verbose)");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test2: (Function IF) Test all variable types (verbose)");
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"bool");
- dlt_user_log_write_bool(&context_data,1);
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "bool");
+ dlt_user_log_write_bool(&context_data, 1);
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"int");
- dlt_user_log_write_int(&context_data,INT32_MIN); /* (-2147483647-1) */
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "int");
+ dlt_user_log_write_int(&context_data, INT32_MIN); /* (-2147483647-1) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"int8");
- dlt_user_log_write_int8(&context_data,INT8_MIN); /* (-128) */
+
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "int8");
+ dlt_user_log_write_int8(&context_data, INT8_MIN); /* (-128) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"int16");
- dlt_user_log_write_int16(&context_data,INT16_MIN); /* (-32767-1) */
+
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "int16");
+ dlt_user_log_write_int16(&context_data, INT16_MIN); /* (-32767-1) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"int32");
- dlt_user_log_write_int32(&context_data,INT32_MIN); /* (-2147483647-1) */
+
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "int32");
+ dlt_user_log_write_int32(&context_data, INT32_MIN); /* (-2147483647-1) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"int64");
- dlt_user_log_write_int64(&context_data,INT64_MIN); /* (-__INT64_C(9223372036854775807)-1) */
+
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "int64");
+ dlt_user_log_write_int64(&context_data, INT64_MIN); /* (-__INT64_C(9223372036854775807)-1) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"uint");
- dlt_user_log_write_uint(&context_data,UINT32_MAX); /* (4294967295U) */
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "uint");
+ dlt_user_log_write_uint(&context_data, UINT32_MAX); /* (4294967295U) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"uint8");
- dlt_user_log_write_uint8(&context_data,UINT8_MAX); /* (255) */
+
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "uint8");
+ dlt_user_log_write_uint8(&context_data, UINT8_MAX); /* (255) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"uint16");
- dlt_user_log_write_uint16(&context_data,UINT16_MAX); /* (65535) */
+
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "uint16");
+ dlt_user_log_write_uint16(&context_data, UINT16_MAX); /* (65535) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"uint32");
- dlt_user_log_write_uint32(&context_data,UINT32_MAX); /* (4294967295U) */
+
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "uint32");
+ dlt_user_log_write_uint32(&context_data, UINT32_MAX); /* (4294967295U) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"uint64");
- dlt_user_log_write_uint64(&context_data,UINT64_MAX); /* (__UINT64_C(18446744073709551615)) */
+
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "uint64");
+ dlt_user_log_write_uint64(&context_data, UINT64_MAX); /* (__UINT64_C(18446744073709551615)) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"float32");
- dlt_user_log_write_float32(&context_data,FLT_MIN);
- dlt_user_log_write_float32(&context_data,FLT_MAX);
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "float32");
+ dlt_user_log_write_float32(&context_data, FLT_MIN);
+ dlt_user_log_write_float32(&context_data, FLT_MAX);
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"float64");
- dlt_user_log_write_float64(&context_data,DBL_MIN);
- dlt_user_log_write_float64(&context_data,DBL_MAX);
+
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "float64");
+ dlt_user_log_write_float64(&context_data, DBL_MIN);
+ dlt_user_log_write_float64(&context_data, DBL_MAX);
dlt_user_log_write_finish(&context_data);
}
- for(num2=0;num2<10;num2++)
- {
+ for (num2 = 0; num2 < 10; num2++)
buffer[num2] = num2;
- }
- if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"raw");
- dlt_user_log_write_raw(&context_data,buffer,10);
+ if (dlt_user_log_write_start(&(context_function_test[1]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "raw");
+ dlt_user_log_write_raw(&context_data, buffer, 10);
dlt_user_log_write_finish(&context_data);
}
/* wait 2 second before next test */
sleep(2);
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test2: (Function IF) finished");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test2: (Function IF) finished");
dlt_user_log_write_finish(&context_data);
}
@@ -848,107 +816,100 @@ int test3f(void)
/* Test 3: (Function IF) Test all variable types (non-verbose) */
printf("Test3f: (Function IF) Test all variable types (non-verbose)\n");
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test3: (Function IF) Test all variable types (non-verbose)");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test3: (Function IF) Test all variable types (non-verbose)");
dlt_user_log_write_finish(&context_data);
}
dlt_nonverbose_mode();
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,1)>0) // bug mb: we have to compare against >0. in case of error -1 is returned!
- {
- dlt_user_log_write_string(&context_data,"bool");
- dlt_user_log_write_bool(&context_data,1);
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 1) > 0) { /* bug mb: we have to compare against >0. in case of error -1 is returned! */
+ dlt_user_log_write_string(&context_data, "bool");
+ dlt_user_log_write_bool(&context_data, 1);
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,2)>0)
- {
- dlt_user_log_write_string(&context_data,"int");
- dlt_user_log_write_int(&context_data,INT32_MIN); /* (-2147483647-1) */
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 2) > 0) {
+ dlt_user_log_write_string(&context_data, "int");
+ dlt_user_log_write_int(&context_data, INT32_MIN); /* (-2147483647-1) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,3)>0)
- {
- dlt_user_log_write_string(&context_data,"int8");
- dlt_user_log_write_int8(&context_data,INT8_MIN); /* (-128) */
+
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 3) > 0) {
+ dlt_user_log_write_string(&context_data, "int8");
+ dlt_user_log_write_int8(&context_data, INT8_MIN); /* (-128) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,4)>0)
- {
- dlt_user_log_write_string(&context_data,"int16");
- dlt_user_log_write_int16(&context_data,INT16_MIN); /* (-32767-1) */
+
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 4) > 0) {
+ dlt_user_log_write_string(&context_data, "int16");
+ dlt_user_log_write_int16(&context_data, INT16_MIN); /* (-32767-1) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,5)>0)
- {
- dlt_user_log_write_string(&context_data,"int32");
- dlt_user_log_write_int32(&context_data,INT32_MIN); /* (-2147483647-1) */
+
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 5) > 0) {
+ dlt_user_log_write_string(&context_data, "int32");
+ dlt_user_log_write_int32(&context_data, INT32_MIN); /* (-2147483647-1) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,6)>0)
- {
- dlt_user_log_write_string(&context_data,"int64");
- dlt_user_log_write_int64(&context_data,INT64_MIN); /* (-__INT64_C(9223372036854775807)-1) */
+
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 6) > 0) {
+ dlt_user_log_write_string(&context_data, "int64");
+ dlt_user_log_write_int64(&context_data, INT64_MIN); /* (-__INT64_C(9223372036854775807)-1) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,7)>0)
- {
- dlt_user_log_write_string(&context_data,"uint");
- dlt_user_log_write_uint(&context_data,UINT32_MAX); /* (4294967295U) */
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 7) > 0) {
+ dlt_user_log_write_string(&context_data, "uint");
+ dlt_user_log_write_uint(&context_data, UINT32_MAX); /* (4294967295U) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,8)>0)
- {
- dlt_user_log_write_string(&context_data,"uint8");
- dlt_user_log_write_uint8(&context_data,UINT8_MAX); /* (255) */
+
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 8) > 0) {
+ dlt_user_log_write_string(&context_data, "uint8");
+ dlt_user_log_write_uint8(&context_data, UINT8_MAX); /* (255) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,9)>0)
- {
- dlt_user_log_write_string(&context_data,"uint16");
- dlt_user_log_write_uint16(&context_data,UINT16_MAX); /* (65535) */
+
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 9) > 0) {
+ dlt_user_log_write_string(&context_data, "uint16");
+ dlt_user_log_write_uint16(&context_data, UINT16_MAX); /* (65535) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,10)>0)
- {
- dlt_user_log_write_string(&context_data,"uint32");
- dlt_user_log_write_uint32(&context_data,UINT32_MAX); /* (4294967295U) */
+
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 10) > 0) {
+ dlt_user_log_write_string(&context_data, "uint32");
+ dlt_user_log_write_uint32(&context_data, UINT32_MAX); /* (4294967295U) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,11)>0)
- {
- dlt_user_log_write_string(&context_data,"uint64");
- dlt_user_log_write_uint64(&context_data,UINT64_MAX); /* (__UINT64_C(18446744073709551615)) */
+
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 11) > 0) {
+ dlt_user_log_write_string(&context_data, "uint64");
+ dlt_user_log_write_uint64(&context_data, UINT64_MAX); /* (__UINT64_C(18446744073709551615)) */
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,12)>0)
- {
- dlt_user_log_write_string(&context_data,"float32");
- dlt_user_log_write_float32(&context_data,FLT_MIN);
- dlt_user_log_write_float32(&context_data,FLT_MAX);
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 12) > 0) {
+ dlt_user_log_write_string(&context_data, "float32");
+ dlt_user_log_write_float32(&context_data, FLT_MIN);
+ dlt_user_log_write_float32(&context_data, FLT_MAX);
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,13)>0)
- {
- dlt_user_log_write_string(&context_data,"float64");
- dlt_user_log_write_float64(&context_data,DBL_MIN);
- dlt_user_log_write_float64(&context_data,DBL_MAX);
+
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 13) > 0) {
+ dlt_user_log_write_string(&context_data, "float64");
+ dlt_user_log_write_float64(&context_data, DBL_MIN);
+ dlt_user_log_write_float64(&context_data, DBL_MAX);
dlt_user_log_write_finish(&context_data);
}
- for(num2=0;num2<10;num2++)
- {
+ for (num2 = 0; num2 < 10; num2++)
buffer[num2] = num2;
- }
- if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,14)>0)
- {
- dlt_user_log_write_string(&context_data,"raw");
- dlt_user_log_write_raw(&context_data,buffer,10);
+ if (dlt_user_log_write_start_id(&(context_function_test[2]), &context_data, DLT_LOG_INFO, 14) > 0) {
+ dlt_user_log_write_string(&context_data, "raw");
+ dlt_user_log_write_raw(&context_data, buffer, 10);
dlt_user_log_write_finish(&context_data);
}
@@ -956,9 +917,9 @@ int test3f(void)
/* wait 2 second before next test */
sleep(2);
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test3: (Function IF) finished");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test3: (Function IF) finished");
dlt_user_log_write_finish(&context_data);
}
@@ -970,49 +931,46 @@ int test4f(void)
char buffer[1024];
int num;
- for(num=0;num<1024;num++)
- {
+ for (num = 0; num < 1024; num++)
buffer[num] = num;
- }
/* Test 4: (Function IF) Message size test */
printf("Test4f: (Function IF) Test different message sizes\n");
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test4: (Function IF) Test different message sizes");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test4: (Function IF) Test different message sizes");
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"1");
- dlt_user_log_write_raw(&context_data,buffer,1);
+ if (dlt_user_log_write_start(&(context_function_test[3]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "1");
+ dlt_user_log_write_raw(&context_data, buffer, 1);
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"16");
- dlt_user_log_write_raw(&context_data,buffer,16);
+
+ if (dlt_user_log_write_start(&(context_function_test[3]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "16");
+ dlt_user_log_write_raw(&context_data, buffer, 16);
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"256");
- dlt_user_log_write_raw(&context_data,buffer,256);
+
+ if (dlt_user_log_write_start(&(context_function_test[3]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "256");
+ dlt_user_log_write_raw(&context_data, buffer, 256);
dlt_user_log_write_finish(&context_data);
}
- if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"1024");
- dlt_user_log_write_raw(&context_data,buffer,1024);
+
+ if (dlt_user_log_write_start(&(context_function_test[3]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "1024");
+ dlt_user_log_write_raw(&context_data, buffer, 1024);
dlt_user_log_write_finish(&context_data);
}
/* wait 2 second before next test */
sleep(2);
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test4: (Function IF) finished");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test4: (Function IF) finished");
dlt_user_log_write_finish(&context_data);
}
@@ -1026,51 +984,47 @@ int test5f(void)
int i;
char log[DLT_USER_BUF_MAX_SIZE];
- for(num=0;num<32;num++)
- {
+ for (num = 0; num < 32; num++)
buffer[num] = num;
- }
/* Test 5: (Function IF) Test high-level API */
printf("Test5f: (Function IF) Test high-level API\n");
- dlt_log_string(&context_info,DLT_LOG_INFO,"Test5: (Function IF) Test high-level API");
+ dlt_log_string(&context_info, DLT_LOG_INFO, "Test5: (Function IF) Test high-level API");
- dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_int()");
- dlt_log_int(&(context_function_test[4]),DLT_LOG_INFO, -42);
+ dlt_log_string(&(context_function_test[4]), DLT_LOG_INFO, "Next line: dlt_log_int()");
+ dlt_log_int(&(context_function_test[4]), DLT_LOG_INFO, -42);
- dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_uint()");
- dlt_log_uint(&(context_function_test[4]),DLT_LOG_INFO, 42);
+ dlt_log_string(&(context_function_test[4]), DLT_LOG_INFO, "Next line: dlt_log_uint()");
+ dlt_log_uint(&(context_function_test[4]), DLT_LOG_INFO, 42);
- dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_string()");
- dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO, "String output");
+ dlt_log_string(&(context_function_test[4]), DLT_LOG_INFO, "Next line: dlt_log_string()");
+ dlt_log_string(&(context_function_test[4]), DLT_LOG_INFO, "String output");
- dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_raw()");
- dlt_log_raw(&(context_function_test[4]),DLT_LOG_INFO, buffer,16);
+ dlt_log_string(&(context_function_test[4]), DLT_LOG_INFO, "Next line: dlt_log_raw()");
+ dlt_log_raw(&(context_function_test[4]), DLT_LOG_INFO, buffer, 16);
- dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_string_int()");
+ dlt_log_string(&(context_function_test[4]), DLT_LOG_INFO, "Next line: dlt_log_string_int()");
dlt_log_string_int(&(context_function_test[4]), DLT_LOG_INFO, "String output: ", -42);
- dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_string_uint()");
- dlt_log_string_uint(&(context_function_test[4]), DLT_LOG_INFO,"String output: ", 42);
+ dlt_log_string(&(context_function_test[4]), DLT_LOG_INFO, "Next line: dlt_log_string_uint()");
+ dlt_log_string_uint(&(context_function_test[4]), DLT_LOG_INFO, "String output: ", 42);
- dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO, "Next lines: dlt_user_is_logLevel_enabled");
- for (i = DLT_LOG_FATAL; i < DLT_LOG_MAX; i++)
- {
- if (dlt_user_is_logLevel_enabled(&(context_function_test[4]),i) == DLT_RETURN_TRUE)
- {
+ dlt_log_string(&(context_function_test[4]), DLT_LOG_INFO, "Next lines: dlt_user_is_logLevel_enabled");
+
+ for (i = DLT_LOG_FATAL; i < DLT_LOG_MAX; i++) {
+ if (dlt_user_is_logLevel_enabled(&(context_function_test[4]), i) == DLT_RETURN_TRUE) {
snprintf(log, DLT_USER_BUF_MAX_SIZE, "Loglevel is enabled: %s", loglevelstr[i]);
- dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO, log);
+ dlt_log_string(&(context_function_test[4]), DLT_LOG_INFO, log);
}
- else
- {
+ else {
snprintf(log, DLT_USER_BUF_MAX_SIZE, "Loglevel is disabled: %s", loglevelstr[i]);
- dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO, log);
+ dlt_log_string(&(context_function_test[4]), DLT_LOG_INFO, log);
}
}
/* wait 2 second before next test */
sleep(2);
- dlt_log_string(&context_info,DLT_LOG_INFO,"Test5: (Function IF) finished");
+ dlt_log_string(&context_info, DLT_LOG_INFO, "Test5: (Function IF) finished");
return 0;
}
@@ -1079,31 +1033,31 @@ int test6f(void)
{
/* Test 6: (Function IF) Test local printing */
printf("Test6f: (Function IF) Test local printing\n");
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test 6: (Function IF) Test local printing");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test 6: (Function IF) Test local printing");
dlt_user_log_write_finish(&context_data);
}
dlt_enable_local_print();
- if (dlt_user_log_write_start(&(context_function_test[5]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Message (visible: locally printed)");
+
+ if (dlt_user_log_write_start(&(context_function_test[5]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Message (visible: locally printed)");
dlt_user_log_write_finish(&context_data);
}
dlt_disable_local_print();
- if (dlt_user_log_write_start(&(context_function_test[5]),&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Message (invisible: not locally printed)");
+
+ if (dlt_user_log_write_start(&(context_function_test[5]), &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Message (invisible: not locally printed)");
dlt_user_log_write_finish(&context_data);
}
- /* wait 2 second before next test */
+ /* wait 2 second before next test */
sleep(2);
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test6: (Function IF) finished");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test6: (Function IF) finished");
dlt_user_log_write_finish(&context_data);
}
@@ -1115,19 +1069,17 @@ int test7f(void)
char buffer[32];
int num;
- for(num=0;num<32;num++)
- {
+ for (num = 0; num < 32; num++)
buffer[num] = num;
- }
/* Show all log messages and traces */
dlt_set_application_ll_ts_limit(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
/* Test 7: (Function IF) Test network trace */
printf("Test7f: (Function IF) Test network trace\n");
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test 7: (Function IF) Test network trace");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test 7: (Function IF) Test network trace");
dlt_user_log_write_finish(&context_data);
}
@@ -1139,9 +1091,9 @@ int test7f(void)
/* wait 2 second before next test */
sleep(2);
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test7: (Function IF) finished");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test7: (Function IF) finished");
dlt_user_log_write_finish(&context_data);
}
@@ -1153,36 +1105,35 @@ int test7f(void)
int test8f(void)
{
- char buffer[1024*5];
+ char buffer[1024 * 5];
int num;
- for(num=0;num<1024*5;num++)
- {
+ for (num = 0; num < 1024 * 5; num++)
buffer[num] = num;
- }
/* Show all log messages and traces */
dlt_set_application_ll_ts_limit(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
/* Test 8: (Function IF) Test truncated network trace */
printf("Test8f: (Function IF) Test truncated network trace\n");
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test 8: (Function IF) Test truncated network trace");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test 8: (Function IF) Test truncated network trace");
dlt_user_log_write_finish(&context_data);
}
/* Dummy message: 16 byte header, 32 byte payload */
- dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_IPC, 16, buffer, 1024*5, buffer, 1);
- dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_CAN, 16, buffer, 1024*5, buffer, 1);
- dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024*5, buffer, 1);
- dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_MOST, 16, buffer, 1024*5, buffer, 1);
+ dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_IPC, 16, buffer, 1024 * 5, buffer, 1);
+ dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_CAN, 16, buffer, 1024 * 5, buffer, 1);
+ dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024 * 5, buffer,
+ 1);
+ dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_MOST, 16, buffer, 1024 * 5, buffer, 1);
/* wait 2 second before next test */
sleep(2);
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test8: (Function IF) finished");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test8: (Function IF) finished");
dlt_user_log_write_finish(&context_data);
}
@@ -1194,36 +1145,34 @@ int test8f(void)
int test9f(void)
{
- char buffer[1024*5];
+ char buffer[1024 * 5];
int num;
- for(num=0;num<1024*5;num++)
- {
+ for (num = 0; num < 1024 * 5; num++)
buffer[num] = num;
- }
/* Show all log messages and traces */
dlt_set_application_ll_ts_limit(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
/* Test 9: (Function IF) Test segmented network trace */
printf("Test9f: (Function IF) Test segmented network trace\n");
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test 9: (Function IF) Test segmented network trace");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test 9: (Function IF) Test segmented network trace");
dlt_user_log_write_finish(&context_data);
}
/* Dummy message: 16 byte header, 5k payload */
- dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_IPC, 16, buffer, 1024*5, buffer);
- dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_CAN, 16, buffer, 1024*5, buffer);
- dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024*5, buffer);
- dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_MOST, 16, buffer, 1024*5, buffer);
+ dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_IPC, 16, buffer, 1024 * 5, buffer);
+ dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_CAN, 16, buffer, 1024 * 5, buffer);
+ dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024 * 5, buffer);
+ dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_MOST, 16, buffer, 1024 * 5, buffer);
/* wait 2 second before next test */
sleep(2);
- if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
- {
- dlt_user_log_write_string(&context_data,"Test9: (Function IF) finished");
+
+ if (dlt_user_log_write_start(&context_info, &context_data, DLT_LOG_INFO) > 0) {
+ dlt_user_log_write_string(&context_data, "Test9: (Function IF) finished");
dlt_user_log_write_finish(&context_data);
}
@@ -1237,15 +1186,15 @@ int test_injection_macro_callback(uint32_t service_id, void *data, uint32_t leng
{
char text[1024];
- memset(text,0,1024);
- snprintf(text,1024,"Injection received (macro IF). ID: 0x%.4x, Length: %d",service_id,length);
+ memset(text, 0, 1024);
+ snprintf(text, 1024, "Injection received (macro IF). ID: 0x%.4x, Length: %d", service_id, length);
printf("%s \n", text);
- DLT_LOG(context_macro_callback, DLT_LOG_INFO, DLT_STRING("Injection received (macro IF). ID: "), DLT_UINT32(service_id),DLT_STRING("Data:"),DLT_STRING(text));
- memset(text,0,1024);
+ DLT_LOG(context_macro_callback, DLT_LOG_INFO, DLT_STRING("Injection received (macro IF). ID: "),
+ DLT_UINT32(service_id), DLT_STRING("Data:"), DLT_STRING(text));
+ memset(text, 0, 1024);
- if (length>0)
- {
- dlt_print_mixed_string(text,1024,data,length,0);
+ if (length > 0) {
+ dlt_print_mixed_string(text, 1024, data, length, 0);
printf("%s \n", text);
}
@@ -1256,16 +1205,16 @@ int test_injection_function_callback(uint32_t service_id, void *data, uint32_t l
{
char text[1024];
- memset(text,0,1024);
+ memset(text, 0, 1024);
- snprintf(text,1024,"Injection received (function IF). ID: 0x%.4x, Length: %d",service_id,length);
+ snprintf(text, 1024, "Injection received (function IF). ID: 0x%.4x, Length: %d", service_id, length);
printf("%s \n", text);
- DLT_LOG(context_function_callback, DLT_LOG_INFO, DLT_STRING("Injection received (function IF). ID: "), DLT_UINT32(service_id),DLT_STRING("Data:"),DLT_STRING(text));
- memset(text,0,1024);
+ DLT_LOG(context_function_callback, DLT_LOG_INFO, DLT_STRING("Injection received (function IF). ID: "),
+ DLT_UINT32(service_id), DLT_STRING("Data:"), DLT_STRING(text));
+ memset(text, 0, 1024);
- if (length>0)
- {
- dlt_print_mixed_string(text,1024,data,length,0);
+ if (length > 0) {
+ dlt_print_mixed_string(text, 1024, data, length, 0);
printf("%s \n", text);
}
diff --git a/tests/dlt-test-cpp-extension.cpp b/tests/dlt-test-cpp-extension.cpp
index c4cf70c..342f977 100644
--- a/tests/dlt-test-cpp-extension.cpp
+++ b/tests/dlt-test-cpp-extension.cpp
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt-test-cpp-extension.cpp
-*/
+ */
#include "dlt_cpp_extension.hpp"
#include <stdio.h>
@@ -36,7 +36,7 @@ struct MyStruct
};
template<>
-inline int logToDlt(DltContextData & log, MyStruct const & value)
+inline int logToDlt(DltContextData &log, MyStruct const &value)
{
int result = 0;
@@ -49,9 +49,7 @@ inline int logToDlt(DltContextData & log, MyStruct const & value)
result += dlt_user_log_write_string(&log, ")");
if (result != 0)
- {
result = -1;
- }
return result;
}
@@ -62,15 +60,14 @@ inline int logToDlt(DltContextData & log, MyStruct const & value)
*/
int main()
{
- if (dlt_register_app("TCPP", "Test cpp extension") < 0)
- {
+ if (dlt_register_app("TCPP", "Test cpp extension") < 0) {
printf("Failed to register application\n");
return -1;
}
DltContext ctx;
- if (dlt_register_context_ll_ts(&ctx, "TCPP", "Test cpp extension", DLT_LOG_INFO, DLT_TRACE_STATUS_OFF) < 0)
- {
+
+ if (dlt_register_context_ll_ts(&ctx, "TCPP", "Test cpp extension", DLT_LOG_INFO, DLT_TRACE_STATUS_OFF) < 0) {
printf("Failed to register context\n");
return -1;
}
@@ -89,7 +86,7 @@ int main()
MyStruct myData = { 1u, 2u, 3u };
DLT_LOG_CXX(ctx, DLT_LOG_WARN, "MyStruct myData", myData);
- char * non_const_string = (char *) malloc(17);
+ char *non_const_string = (char *)malloc(17);
memcpy(non_const_string, "non_const_string", 16);
non_const_string[16] = 0;
DLT_LOG_CXX(ctx, DLT_LOG_WARN, "char *", non_const_string);
diff --git a/tests/dlt-test-preregister-context.c b/tests/dlt-test-preregister-context.c
index 2f66347..ea70789 100644
--- a/tests/dlt-test-preregister-context.c
+++ b/tests/dlt-test-preregister-context.c
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt-test-preregister-context.c
-*/
+ */
#include <unistd.h> /* for fork() */
diff --git a/tests/dlt_env_ll_unit_test.cpp b/tests/dlt_env_ll_unit_test.cpp
index a5387bf..3c8e5f1 100644
--- a/tests/dlt_env_ll_unit_test.cpp
+++ b/tests/dlt_env_ll_unit_test.cpp
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_env_ll_unit_test.cpp
-*/
+ */
#include "gtest/gtest.h"
#include "dlt_user.h"
@@ -31,7 +31,7 @@
/* simply include the whole file to allow testing it */
#include "src/lib/dlt_env_ll.c"
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
@@ -45,7 +45,7 @@ TEST(DltExtensionTests, extract_id)
char env0[] = "abcd:1234:3";
char *tmp = &env0[0];
ASSERT_EQ(dlt_env_extract_id(&tmp, id), 0);
- ASSERT_EQ(tmp - &env0[0], 4); // moved 4 bytes
+ ASSERT_EQ(tmp - &env0[0], 4); /* moved 4 bytes */
ASSERT_EQ(id[0], 'a');
ASSERT_EQ(id[1], 'b');
ASSERT_EQ(id[2], 'c');
@@ -54,7 +54,7 @@ TEST(DltExtensionTests, extract_id)
char env1[] = "abc:1234:3";
tmp = &env1[0];
ASSERT_EQ(dlt_env_extract_id(&tmp, id), 0);
- ASSERT_EQ(tmp - &env1[0], 3); // moved 3 bytes
+ ASSERT_EQ(tmp - &env1[0], 3); /* moved 3 bytes */
ASSERT_EQ(id[0], 'a');
ASSERT_EQ(id[1], 'b');
ASSERT_EQ(id[2], 'c');
@@ -63,7 +63,7 @@ TEST(DltExtensionTests, extract_id)
char env2[] = "ab:1234:3";
tmp = &env2[0];
ASSERT_EQ(dlt_env_extract_id(&tmp, id), 0);
- ASSERT_EQ(tmp - &env2[0], 2); // moved 2 bytes
+ ASSERT_EQ(tmp - &env2[0], 2); /* moved 2 bytes */
ASSERT_EQ(id[0], 'a');
ASSERT_EQ(id[1], 'b');
ASSERT_EQ(id[2], 0);
@@ -72,7 +72,7 @@ TEST(DltExtensionTests, extract_id)
char env3[] = "a:1234:3";
tmp = &env3[0];
ASSERT_EQ(dlt_env_extract_id(&tmp, id), 0);
- ASSERT_EQ(tmp - &env3[0], 1); // moved 1 byte
+ ASSERT_EQ(tmp - &env3[0], 1); /* moved 1 byte */
ASSERT_EQ(id[0], 'a');
ASSERT_EQ(id[1], 0);
ASSERT_EQ(id[2], 0);
@@ -81,7 +81,7 @@ TEST(DltExtensionTests, extract_id)
char env4[] = ":1234:3";
tmp = &env4[0];
ASSERT_EQ(dlt_env_extract_id(&tmp, id), 0);
- ASSERT_EQ(tmp - &env4[0], 0); // moved 1 byte
+ ASSERT_EQ(tmp - &env4[0], 0); /* moved 1 byte */
ASSERT_EQ(id[0], 0);
ASSERT_EQ(id[1], 0);
ASSERT_EQ(id[2], 0);
@@ -90,7 +90,7 @@ TEST(DltExtensionTests, extract_id)
char env5[] = "abcd:1234:3;";
tmp = &env5[0];
ASSERT_EQ(dlt_env_extract_id(&tmp, id), 0);
- ASSERT_EQ(tmp - &env5[0], 4); // moved 4 bytes
+ ASSERT_EQ(tmp - &env5[0], 4); /* moved 4 bytes */
ASSERT_EQ(id[0], 'a');
ASSERT_EQ(id[1], 'b');
ASSERT_EQ(id[2], 'c');
@@ -129,49 +129,49 @@ TEST(DltExtensionTests, extract_ll)
char env_1[] = "-1";
char *tmp = &env_1[0];
ASSERT_EQ(dlt_env_extract_ll(&tmp, &ll), 0);
- ASSERT_EQ(tmp - &env_1[0], 2); // moved 2 bytes
+ ASSERT_EQ(tmp - &env_1[0], 2); /* moved 2 bytes */
ASSERT_EQ(ll, -1);
char env0[] = "0;";
tmp = &env0[0];
ASSERT_EQ(dlt_env_extract_ll(&tmp, &ll), 0);
- ASSERT_EQ(tmp - &env0[0], 1); // moved 1 byte
+ ASSERT_EQ(tmp - &env0[0], 1); /* moved 1 byte */
ASSERT_EQ(ll, 0);
char env1[] = "1;";
tmp = &env1[0];
ASSERT_EQ(dlt_env_extract_ll(&tmp, &ll), 0);
- ASSERT_EQ(tmp - &env1[0], 1); // moved 1 byte
+ ASSERT_EQ(tmp - &env1[0], 1); /* moved 1 byte */
ASSERT_EQ(ll, 1);
char env2[] = "2;";
tmp = &env2[0];
ASSERT_EQ(dlt_env_extract_ll(&tmp, &ll), 0);
- ASSERT_EQ(tmp - &env2[0], 1); // moved 1 byte
+ ASSERT_EQ(tmp - &env2[0], 1); /* moved 1 byte */
ASSERT_EQ(ll, 2);
char env3[] = "3;";
tmp = &env3[0];
ASSERT_EQ(dlt_env_extract_ll(&tmp, &ll), 0);
- ASSERT_EQ(tmp - &env3[0], 1); // moved 1 byte
+ ASSERT_EQ(tmp - &env3[0], 1); /* moved 1 byte */
ASSERT_EQ(ll, 3);
char env4[] = "4;";
tmp = &env4[0];
ASSERT_EQ(dlt_env_extract_ll(&tmp, &ll), 0);
- ASSERT_EQ(tmp - &env4[0], 1); // moved 1 byte
+ ASSERT_EQ(tmp - &env4[0], 1); /* moved 1 byte */
ASSERT_EQ(ll, 4);
char env5[] = "5;";
tmp = &env5[0];
ASSERT_EQ(dlt_env_extract_ll(&tmp, &ll), 0);
- ASSERT_EQ(tmp - &env5[0], 1); // moved 1 byte
+ ASSERT_EQ(tmp - &env5[0], 1); /* moved 1 byte */
ASSERT_EQ(ll, 5);
char env6[] = "6;";
tmp = &env6[0];
ASSERT_EQ(dlt_env_extract_ll(&tmp, &ll), 0);
- ASSERT_EQ(tmp - &env6[0], 1); // moved 1 byte
+ ASSERT_EQ(tmp - &env6[0], 1); /* moved 1 byte */
ASSERT_EQ(ll, 6);
/* testing invalid input */
@@ -211,7 +211,7 @@ TEST(DltExtensionTests, extract_ll_item)
char env0[] = "abcd:1234:3";
char *tmp = &env0[0];
ASSERT_EQ(dlt_env_extract_ll_item(&tmp, &item), 0);
- ASSERT_EQ(tmp - &env0[0], 11); // moved 11 bytes
+ ASSERT_EQ(tmp - &env0[0], 11); /* moved 11 bytes */
ASSERT_EQ(item.appId[0], 'a');
ASSERT_EQ(item.appId[1], 'b');
ASSERT_EQ(item.appId[2], 'c');
@@ -225,7 +225,7 @@ TEST(DltExtensionTests, extract_ll_item)
char env1[] = "::-1;";
tmp = &env1[0];
ASSERT_EQ(dlt_env_extract_ll_item(&tmp, &item), 0);
- ASSERT_EQ(tmp - &env1[0], 4); // moved 4 bytes
+ ASSERT_EQ(tmp - &env1[0], 4); /* moved 4 bytes */
ASSERT_EQ(item.appId[0], 0);
ASSERT_EQ(item.appId[1], 0);
ASSERT_EQ(item.appId[2], 0);
@@ -271,9 +271,9 @@ TEST(DltExtensionTests, extract_ll_item)
TEST(DltExtensionTests, basic_ll_set_handling)
{
- dlt_env_init_ll_set(NULL); // must not crash
- dlt_env_free_ll_set(NULL); // must not crash
- dlt_env_increase_ll_set(NULL); // must not crash
+ dlt_env_init_ll_set(NULL); /* must not crash */
+ dlt_env_free_ll_set(NULL); /* must not crash */
+ dlt_env_increase_ll_set(NULL); /* must not crash */
dlt_env_ll_set ll_set;
dlt_env_init_ll_set(&ll_set);
@@ -287,16 +287,16 @@ TEST(DltExtensionTests, basic_ll_set_handling)
EXPECT_EQ(0, ll_set.num_elem);
dlt_env_init_ll_set(&ll_set);
+
for (int i = 0; i < DLT_ENV_LL_SET_INCREASE; ++i)
- {
ll_set.item[i].ll = i;
- }
+
dlt_env_increase_ll_set(&ll_set);
EXPECT_EQ(2 * DLT_ENV_LL_SET_INCREASE, ll_set.array_size);
+
for (int i = 0; i < DLT_ENV_LL_SET_INCREASE; ++i)
- {
EXPECT_EQ(ll_set.item[i].ll, i);
- }
+
dlt_env_free_ll_set(&ll_set);
EXPECT_TRUE(NULL == ll_set.item);
EXPECT_EQ(0, ll_set.array_size);
@@ -320,15 +320,14 @@ TEST(DltExtensionTests, extract_ll_set)
/* force increasing the list */
char env1[] =
- "abcd:0000:3;abcd:0001:3;abcd:0002:3;abcd:0003:3;abcd:0004:3;abcd:0005:3;abcd:0006:3;abcd:0007:3;abcd:0008:3;abcd:0009:3;abcd:0010:3";
+ "abcd:0000:3;abcd:0001:3;abcd:0002:3;abcd:0003:3;abcd:0004:3;abcd:0005:3;abcd:0006:3;abcd:0007:3;abcd:0008:3;abcd:0009:3;abcd:0010:3";
tmp = &env1[0];
ASSERT_EQ(dlt_env_extract_ll_set(&tmp, &ll_set), 0);
EXPECT_EQ(ll_set.array_size, 2 * DLT_ENV_LL_SET_INCREASE);
EXPECT_EQ(ll_set.num_elem, 11);
+
for (size_t i = 0; i < ll_set.num_elem; ++i)
- {
EXPECT_EQ(ll_set.item[i].ctxId[3], i % 10 + '0');
- }
dlt_env_free_ll_set(&ll_set);
@@ -439,56 +438,56 @@ TEST(DltExtensionTests, adjust_ll_from_env)
dlt_env_free_ll_set(&ll_set);
}
-// int dlt_env_helper_to_lower(char **env, char *result, int res_len)
+/* int dlt_env_helper_to_lower(char **env, char *result, int res_len) */
TEST(DltExtensionTests, dlt_env_helper_to_lower)
{
- // default behavior
+ /* default behavior */
char env0[] = "1238<><<>>>>#$//abcdABCDEDFGHIJKLMNOPQRSTUVWXYZpo;ABcd";
char res0[] = "1238<><<>>>>#$//abcdabcdedfghijklmnopqrstuvwxyzpo";
char *tmp0 = &env0[0];
char result0[sizeof(res0)];
ASSERT_EQ(0, dlt_env_helper_to_lower(&tmp0, result0, sizeof(result0)));
- ASSERT_EQ(';', *tmp0); // next char is ';'
- ASSERT_STREQ(res0, result0); // stops at ';' and is correctly converted
+ ASSERT_EQ(';', *tmp0); /* next char is ';' */
+ ASSERT_STREQ(res0, result0); /* stops at ';' and is correctly converted */
- // default behavior with end of string
+ /* default behavior with end of string */
char env1[] = "1238<><<>>>>#$//abcdABCDEDFGHIJKLMNOPQRSTUVWXYZpo";
char res1[] = "1238<><<>>>>#$//abcdabcdedfghijklmnopqrstuvwxyzpo";
char *tmp1 = &env1[0];
char result1[sizeof(res1)];
ASSERT_EQ(0, dlt_env_helper_to_lower(&tmp1, result1, sizeof(result1)));
- ASSERT_EQ(0, *tmp1); // next char is void
- ASSERT_STREQ(res1, result1); // stops at end-of-string and is correctly converted
+ ASSERT_EQ(0, *tmp1); /* next char is void */
+ ASSERT_STREQ(res1, result1); /* stops at end-of-string and is correctly converted */
- // result string too short
+ /* result string too short */
char env2[] = "2238<><<>>>>#$//abcdABCDEDFGHIJKLMNOPQRSTUVWXYZpo";
char res2[] = "2238<><<>>>>#$//abcdabcdedfg";
char *tmp2 = &env2[0];
char result2[sizeof(res2)];
ASSERT_EQ(-1, dlt_env_helper_to_lower(&tmp2, result2, sizeof(result2)));
- ASSERT_EQ('H', *tmp2); // next char is void
- ASSERT_STREQ(res2, result2); // stops at end-of-string and is partially converted
+ ASSERT_EQ('H', *tmp2); /* next char is void */
+ ASSERT_STREQ(res2, result2); /* stops at end-of-string and is partially converted */
- // input string shorter than result
+ /* input string shorter than result */
char env3[] = "3338<><<>>>>#$//abcdABCDEDFGHIJKLMNOPQRSTUVWXYZpo";
char res3[] = "3338<><<>>>>#$//abcdabcdedfghijklmnopqrstuvwxyzpo";
char *tmp3 = &env3[0];
char result3[sizeof(res3) + 5];
ASSERT_EQ(0, dlt_env_helper_to_lower(&tmp3, result3, sizeof(result3)));
- ASSERT_EQ(0, *tmp3); // next char is void
- ASSERT_STREQ(res3, result3); // stops at end-of-string and is correctly converted
+ ASSERT_EQ(0, *tmp3); /* next char is void */
+ ASSERT_STREQ(res3, result3); /* stops at end-of-string and is correctly converted */
}
-// int dlt_env_extract_symbolic_ll(char **env, int8_t * ll)
+/* int dlt_env_extract_symbolic_ll(char **env, int8_t * ll) */
TEST(DltExtensionTests, dlt_env_extract_symbolic_ll)
{
int8_t result;
- // correct behavior
+ /* correct behavior */
char env0[] = "DEFAULT;off;fatal;error;warning;info;DeBuG;verbose";
char *tmp0 = &env0[0];
@@ -524,7 +523,7 @@ TEST(DltExtensionTests, dlt_env_extract_symbolic_ll)
ASSERT_EQ(0, *tmp0);
ASSERT_EQ(6, result);
- // incorrect behavior
+ /* incorrect behavior */
char env1[] = "DEF";
char *tmp1 = &env1[0];
@@ -533,7 +532,7 @@ TEST(DltExtensionTests, dlt_env_extract_symbolic_ll)
ASSERT_EQ(0, *tmp1);
ASSERT_EQ(18, result); /* 'result' is not touched */
- // incorrect behavior
+ /* incorrect behavior */
char env2[] = "DEFaultingfBa";
char *tmp2 = &env2[0];
diff --git a/tests/dlt_test_receiver.c b/tests/dlt_test_receiver.c
index 555d5da..80ae900 100644
--- a/tests/dlt_test_receiver.c
+++ b/tests/dlt_test_receiver.c
@@ -25,7 +25,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_test_receiver.c
-*/
+ */
/*******************************************************************************
@@ -67,8 +67,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <ctype.h> /* for isprint() */
@@ -112,7 +112,7 @@ void usage()
{
char version[255];
- dlt_get_version(version,255);
+ dlt_get_version(version, 255);
printf("Usage: dlt-receive [options] hostname/serial_device_name\n");
printf("Receive DLT messages from DLT daemon and print or store the messages.\n");
@@ -133,9 +133,9 @@ void usage()
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- DltClient dltclient;
+ DltClient dltclient;
DltReceiveData dltdata;
int c;
int index;
@@ -146,7 +146,7 @@ int main(int argc, char* argv[])
dltdata.ovalue = 0;
dltdata.evalue = 0;
dltdata.bvalue = 0;
- dltdata.ohandle=-1;
+ dltdata.ohandle = -1;
dltdata.filetransfervalue = 0;
dltdata.systemjournalvalue = 0;
@@ -154,76 +154,70 @@ int main(int argc, char* argv[])
opterr = 0;
while ((c = getopt (argc, argv, "vshyfla:o:e:b:")) != -1)
- switch (c)
- {
+ switch (c) {
case 'v':
- {
- dltdata.vflag = 1;
- break;
- }
+ {
+ dltdata.vflag = 1;
+ break;
+ }
case 'h':
- {
- usage();
- return -1;
- }
+ {
+ usage();
+ return -1;
+ }
case 'y':
- {
- dltdata.yflag = 1;
- break;
- }
+ {
+ dltdata.yflag = 1;
+ break;
+ }
case 'f':
- {
- dltdata.filetransfervalue = 1;
- break;
- }
+ {
+ dltdata.filetransfervalue = 1;
+ break;
+ }
case 's':
- {
- dltdata.systemjournalvalue = 1;
- break;
- }
+ {
+ dltdata.systemjournalvalue = 1;
+ break;
+ }
case 'l':
- {
- dltdata.systemloggervalue = 1;
- break;
- }
+ {
+ dltdata.systemloggervalue = 1;
+ break;
+ }
case 'o':
- {
- dltdata.ovalue = optarg;
- break;
- }
+ {
+ dltdata.ovalue = optarg;
+ break;
+ }
case 'e':
- {
- dltdata.evalue = optarg;
- break;
- }
+ {
+ dltdata.evalue = optarg;
+ break;
+ }
case 'b':
- {
- dltdata.bvalue = atoi(optarg);
- break;
- }
+ {
+ dltdata.bvalue = atoi(optarg);
+ break;
+ }
case '?':
- {
- if (optopt == 'o')
- {
- fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
- else if (isprint (optopt))
- {
- fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
- else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
- /* unknown or wrong option used, show usage information and terminate */
- usage();
- return -1;
- }
+ {
+ if (optopt == 'o')
+ fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+ else if (isprint (optopt))
+ fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+ else
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
+ /* unknown or wrong option used, show usage information and terminate */
+ usage();
+ return -1;
+ }
default:
- {
- abort ();
- return -1;//for parasoft
- }
+ {
+ abort ();
+ return -1; /*for parasoft */
+ }
}
/* Initialize DLT Client */
@@ -235,96 +229,81 @@ int main(int argc, char* argv[])
/* Setup DLT Client structure */
dltclient.mode = dltdata.yflag;
- if (dltclient.mode==0)
- {
+ if (dltclient.mode == 0) {
for (index = optind; index < argc; index++)
- {
- if(dlt_client_set_server_ip(&dltclient, argv[index]) == -1)
- {
- fprintf(stderr,"set server ip didn't succeed\n");
+ if (dlt_client_set_server_ip(&dltclient, argv[index]) == -1) {
+ fprintf(stderr, "set server ip didn't succeed\n");
return -1;
}
- }
- if (dltclient.servIP == 0)
- {
+
+
+ if (dltclient.servIP == 0) {
/* no hostname selected, show usage and terminate */
- fprintf(stderr,"ERROR: No hostname selected\n");
+ fprintf(stderr, "ERROR: No hostname selected\n");
usage();
- dlt_client_cleanup(&dltclient,dltdata.vflag);
+ dlt_client_cleanup(&dltclient, dltdata.vflag);
return -1;
}
}
- else
- {
+ else {
for (index = optind; index < argc; index++)
- {
- if(dlt_client_set_serial_device(&dltclient, argv[index]) == -1)
- {
- fprintf(stderr,"set serial device didn't succeed\n");
+ if (dlt_client_set_serial_device(&dltclient, argv[index]) == -1) {
+ fprintf(stderr, "set serial device didn't succeed\n");
return -1;
}
- }
- if (dltclient.serialDevice == 0)
- {
+
+
+ if (dltclient.serialDevice == 0) {
/* no serial device name selected, show usage and terminate */
- fprintf(stderr,"ERROR: No serial device name specified\n");
+ fprintf(stderr, "ERROR: No serial device name specified\n");
usage();
return -1;
}
- dlt_client_setbaudrate(&dltclient,dltdata.bvalue);
+ dlt_client_setbaudrate(&dltclient, dltdata.bvalue);
}
/* initialise structure to use DLT file */
- dlt_file_init(&(dltdata.file),dltdata.vflag);
+ dlt_file_init(&(dltdata.file), dltdata.vflag);
/* first parse filter file if filter parameter is used */
- dlt_filter_init(&(dltdata.filter),dltdata.vflag);
+ dlt_filter_init(&(dltdata.filter), dltdata.vflag);
/* open DLT output file */
- if (dltdata.ovalue)
- {
- dltdata.ohandle = open(dltdata.ovalue,O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
+ if (dltdata.ovalue) {
+ dltdata.ohandle = open(dltdata.ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
- if (dltdata.ohandle == -1)
- {
- dlt_file_free(&(dltdata.file),dltdata.vflag);
- fprintf(stderr,"ERROR: Output file %s cannot be opened!\n",dltdata.ovalue);
+ if (dltdata.ohandle == -1) {
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
+ fprintf(stderr, "ERROR: Output file %s cannot be opened!\n", dltdata.ovalue);
return -1;
}
}
if (dltdata.evalue)
- {
- dlt_set_id(dltdata.ecuid,dltdata.evalue);
- }
+ dlt_set_id(dltdata.ecuid, dltdata.evalue);
else
- {
- dlt_set_id(dltdata.ecuid,DLT_RECEIVE_ECU_ID);
- }
+ dlt_set_id(dltdata.ecuid, DLT_RECEIVE_ECU_ID);
/* Connect to TCP socket or open serial device */
- if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR)
- {
+ if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR) {
/* Dlt Client Main Loop */
dlt_client_main_loop(&dltclient, &dltdata, dltdata.vflag);
/* Dlt Client Cleanup */
- dlt_client_cleanup(&dltclient,dltdata.vflag);
+ dlt_client_cleanup(&dltclient, dltdata.vflag);
}
/* dlt-receive cleanup */
if (dltdata.ovalue)
- {
close(dltdata.ohandle);
- }
- dlt_file_free(&(dltdata.file),dltdata.vflag);
+ dlt_file_free(&(dltdata.file), dltdata.vflag);
- dlt_filter_free(&(dltdata.filter),dltdata.vflag);
+ dlt_filter_free(&(dltdata.filter), dltdata.vflag);
return 0;
}
@@ -337,113 +316,104 @@ int dlt_receive_filetransfer_callback(DltMessage *message, void *data)
struct iovec iov[2];
int bytes_written;
- if ((message==0) || (data==0))
- {
+ if ((message == 0) || (data == 0))
return -1;
- }
- dltdata = (DltReceiveData*)data;
+ dltdata = (DltReceiveData *)data;
- if(dltdata->filetransfervalue)
- {
+ if (dltdata->filetransfervalue) {
dlt_message_print_ascii(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
- // 1st find starting point of tranfering data packages
- if( strncmp(text, "FLST", 4) == 0)
- {
+ /* 1st find starting point of tranfering data packages */
+ if (strncmp(text, "FLST", 4) == 0) {
char *tmpFilename;
tmpFilename = strrchr(text, '/') + 1;
unsigned int i;
- for(i=0; i<strlen(tmpFilename);i++)
- {
- if(isspace(tmpFilename[i]))
- {
- tmpFilename[i] ='\0';
+
+ for (i = 0; i < strlen(tmpFilename); i++)
+ if (isspace(tmpFilename[i])) {
+ tmpFilename[i] = '\0';
break;
}
- }
- // create file for each received file, as named as crc value
+
+ /* create file for each received file, as named as crc value */
snprintf(filename, 255, "/tmp/%s", tmpFilename);
fp = fopen(filename, "w+");
}
- // 3rd close fp
- if( strncmp(text, "FLFI", 4) == 0)
- {
+ /* 3rd close fp */
+ if (strncmp(text, "FLFI", 4) == 0) {
printf("TEST FILETRANSFER PASSED\n");
fclose(fp);
}
- // 2nd check if incomming data are filetransfer data
- if( strncmp(text, "FLDA", 4) == 0)
- {
- // truncate beginning of data stream ( FLDA, File identifier and package number)
- char *position = strchr(text, 32); // search for space
- strncpy(text, position+1, DLT_RECEIVE_BUFSIZE);
+ /* 2nd check if incomming data are filetransfer data */
+ if (strncmp(text, "FLDA", 4) == 0) {
+ /* truncate beginning of data stream ( FLDA, File identifier and package number) */
+ char *position = strchr(text, 32); /* search for space */
+ strncpy(text, position + 1, DLT_RECEIVE_BUFSIZE);
position = strchr(text, 32);
- strncpy(text, position+1, DLT_RECEIVE_BUFSIZE);
+ strncpy(text, position + 1, DLT_RECEIVE_BUFSIZE);
position = strchr(text, 32);
- strncpy(text, position+1, DLT_RECEIVE_BUFSIZE);
+ strncpy(text, position + 1, DLT_RECEIVE_BUFSIZE);
- // truncate ending of data stream ( FLDA )
+ /* truncate ending of data stream ( FLDA ) */
int len = strlen(text);
text[len - 4] = '\0';
- // hex to ascii and store at /tmp
+ /* hex to ascii and store at /tmp */
char tmp[3];
int i;
- for(i = 0;i< (int) strlen(text); i = i+3)
- {
+
+ for (i = 0; i < (int)strlen(text); i = i + 3) {
tmp[0] = text[i];
- tmp[1] = text[i+1];
+ tmp[1] = text[i + 1];
tmp[2] = '\0';
unsigned long h = strtoul(tmp, NULL, 16);
- fprintf(fp, "%c", (int) h);
+ fprintf(fp, "%c", (int)h);
}
}
}
- if(dltdata->systemjournalvalue)
- {
+ if (dltdata->systemjournalvalue) {
dlt_message_print_ascii(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
- // 1st find the relevant packages
- char * tmp = message->extendedheader->ctid;
+ /* 1st find the relevant packages */
+ char *tmp = message->extendedheader->ctid;
tmp[4] = '\0';
- if( strcmp( tmp , (const char *) "JOUR") == 0)
- {
- if(strstr(text,"DLT SYSTEM JOURNAL TEST"))
- {
- result ++;
- if( result == 1000)
+
+ if (strcmp(tmp, (const char *)"JOUR") == 0) {
+ if (strstr(text, "DLT SYSTEM JOURNAL TEST")) {
+ result++;
+
+ if (result == 1000)
exit(159);
}
}
}
- if(dltdata->systemloggervalue)
- {
+ if (dltdata->systemloggervalue) {
dlt_message_print_ascii(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
- // 1st find the relevant packages
- char * tmp = message->extendedheader->ctid;
+ /* 1st find the relevant packages */
+ char *tmp = message->extendedheader->ctid;
tmp[4] = '\0';
- const char * substring = text;
- const char * founding = "Test Systemlogger";
+ const char *substring = text;
+ const char *founding = "Test Systemlogger";
int length = strlen(founding);
- if( strcmp( tmp , (const char *) "PROC") == 0)
- {
+
+ if (strcmp(tmp, (const char *)"PROC") == 0) {
substring = strstr(text, founding);
- while (substring != NULL)
- {
- result ++;
- substring +=length;
- if(result == 1000)
+
+ while (substring != NULL) {
+ result++;
+ substring += length;
+
+ if (result == 1000)
exit(159);
}
}
}
/* if file output enabled write message */
- if (dltdata->ovalue)
- {
+ if (dltdata->ovalue) {
iov[0].iov_base = message->headerbuffer;
iov[0].iov_len = message->headersize;
iov[1].iov_base = message->databuffer;
@@ -451,9 +421,9 @@ int dlt_receive_filetransfer_callback(DltMessage *message, void *data)
bytes_written = writev(dltdata->ohandle, iov, 2);
- if (0 > bytes_written){
- printf("dlt_receive_message_callback: writev(dltdata->ohandle, iov, 2); returned an error!" );
- return -1;
+ if (0 > bytes_written) {
+ printf("dlt_receive_message_callback: writev(dltdata->ohandle, iov, 2); returned an error!");
+ return -1;
}
}
diff --git a/tests/gtest_dlt_common.cpp b/tests/gtest_dlt_common.cpp
index 27831d3..b944f4d 100644
--- a/tests/gtest_dlt_common.cpp
+++ b/tests/gtest_dlt_common.cpp
@@ -23,7 +23,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file gtest_dlt_common.cpp
-*/
+ */
#include <stdio.h>
#include <gtest/gtest.h>
@@ -40,14 +40,20 @@ extern "C"
int dlt_buffer_increase_size(DltBuffer *);
int dlt_buffer_minimize_size(DltBuffer *);
int dlt_buffer_reset(DltBuffer *);
-DltReturnValue dlt_buffer_push(DltBuffer *,const unsigned char *,unsigned int);
-DltReturnValue dlt_buffer_push3(DltBuffer *,const unsigned char *,unsigned int,const unsigned char *,unsigned int,const unsigned char *,unsigned int);
-int dlt_buffer_get(DltBuffer *,unsigned char *, int,int);
-int dlt_buffer_pull(DltBuffer *,unsigned char *, int);
+DltReturnValue dlt_buffer_push(DltBuffer *, const unsigned char *, unsigned int);
+DltReturnValue dlt_buffer_push3(DltBuffer *,
+ const unsigned char *,
+ unsigned int,
+ const unsigned char *,
+ unsigned int,
+ const unsigned char *,
+ unsigned int);
+int dlt_buffer_get(DltBuffer *, unsigned char *, int, int);
+int dlt_buffer_pull(DltBuffer *, unsigned char *, int);
int dlt_buffer_remove(DltBuffer *);
void dlt_buffer_status(DltBuffer *);
-void dlt_buffer_write_block(DltBuffer *,int *, const unsigned char *,unsigned int);
-void dlt_buffer_read_block(DltBuffer *, int *, unsigned char*, unsigned int);
+void dlt_buffer_write_block(DltBuffer *, int *, const unsigned char *, unsigned int);
+void dlt_buffer_read_block(DltBuffer *, int *, unsigned char *, unsigned int);
void dlt_buffer_info(DltBuffer *);
}
@@ -57,60 +63,70 @@ TEST(t_dlt_buffer_init_dynamic, normal)
{
DltBuffer init_dynamic;
- // Normal Use-Case for initializing a buffer
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&init_dynamic, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&init_dynamic));
+ /* Normal Use-Case for initializing a buffer */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&init_dynamic, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&init_dynamic));
- // Min Values for a success init
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&init_dynamic, 12,12,12));
- EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&init_dynamic));
+ /* Min Values for a success init */
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&init_dynamic, 12, 12, 12));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&init_dynamic));
}
TEST(t_dlt_buffer_init_dynamic, abnormal)
{
-// DltBuffer buf;
+/* DltBuffer buf; */
- // Initialze buffer twice, expected -1 for second init
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(-1, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&buf));
+ /* Initialze buffer twice, expected -1 for second init */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(-1, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&buf)); */
- // Initialize buffer with max-value of uint32, expected 0
- // TODO: what should the maximum parameter values be? UINT_MAX is too large and leads to segfault
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, UINT_MAX,UINT_MAX,UINT_MAX));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&buf));
+ /* Initialize buffer with max-value of uint32, expected 0 */
+ /* TODO: what should the maximum parameter values be? UINT_MAX is too large and leads to segfault */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, UINT_MAX,UINT_MAX,UINT_MAX)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&buf)); */
- // Initialize buffer with min-value of uint32, expected 0
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, 0,0,0));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&buf));
+ /* Initialize buffer with min-value of uint32, expected 0 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, 0,0,0)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&buf)); */
- // Initialize buffer min-value > max-value, expected -1
-// EXPECT_GE(-1, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&buf));
+ /* Initialize buffer min-value > max-value, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&buf)); */
- // Initialsize buffer step-value > max-value, expected -1
-// EXPECT_GE(-1,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE * 2));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&buf));
+ /* Initialsize buffer step-value > max-value, expected -1 */
+/* EXPECT_GE(-1,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE * 2)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_free_dynamic(&buf)); */
}
TEST(t_dlt_buffer_init_dynamic, nullpointer)
{
DltBuffer buf;
- // NULL-Pointer, expect -1
+ /* NULL-Pointer, expect -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(NULL, 0, 0, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(NULL, 0, 0, DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(NULL, 0, DLT_USER_RINGBUFFER_MAX_SIZE, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(NULL, 0, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_init_dynamic(NULL, 0, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(NULL, DLT_USER_RINGBUFFER_MIN_SIZE, 0, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(NULL, DLT_USER_RINGBUFFER_MIN_SIZE, 0, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(NULL, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(NULL, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_init_dynamic(NULL, DLT_USER_RINGBUFFER_MIN_SIZE, 0, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_init_dynamic(NULL, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_init_dynamic(NULL, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(&buf, 0, 0, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(&buf, 0, 0, DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(&buf, 0, DLT_USER_RINGBUFFER_MAX_SIZE, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(&buf, 0, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_init_dynamic(&buf, 0, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, 0, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, 0, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, 0, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, 0));
}
/* End Method: dlt_common::dlt_buffer_init_dynamic */
@@ -122,30 +138,32 @@ TEST(t_dlt_buffer_free_dynamic, normal)
{
DltBuffer buf;
- // Normal Use-Case szenario
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ /* Normal Use-Case szenario */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Normal Use-Case szenario
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, 12,12,12));
+ /* Normal Use-Case szenario */
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, 12, 12, 12));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_free_dynamic, abnormal)
{
-// DltBuffer buf;
+/* DltBuffer buf; */
- // Free uninizialised buffer, expected -1
-// EXPECT_GE(-1, dlt_buffer_free_dynamic(&buf));
+ /* Free uninizialised buffer, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_free_dynamic(&buf)); */
- // Free buffer twice, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_GE(-1, dlt_buffer_free_dynamic(&buf));
+ /* Free buffer twice, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_GE(-1, dlt_buffer_free_dynamic(&buf)); */
}
TEST(t_dlt_buffer_free_dynamic, nullpointer)
{
- // NULL-POinter
+ /* NULL-POinter */
EXPECT_GE(-1, dlt_buffer_free_dynamic(NULL));
}
/* End Method: dlt_common::dlt_buffer_free_dynamic */
@@ -158,44 +176,50 @@ TEST(t_dlt_buffer_increase_size, normal)
{
DltBuffer buf;
- // Normal Use-Case, expected 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ /* Normal Use-Case, expected 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_LE(0, dlt_buffer_increase_size(&buf));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Fill buffer to max-value, expected 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- for(int i = 0; i <= (DLT_USER_RINGBUFFER_MAX_SIZE / DLT_USER_RINGBUFFER_MIN_SIZE); i += DLT_USER_RINGBUFFER_STEP_SIZE)
- {
+ /* Fill buffer to max-value, expected 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+
+ for (int i = 0;
+ i <= (DLT_USER_RINGBUFFER_MAX_SIZE / DLT_USER_RINGBUFFER_MIN_SIZE);
+ i += DLT_USER_RINGBUFFER_STEP_SIZE)
EXPECT_LE(0, dlt_buffer_increase_size(&buf));
- }
+
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_increase_size, abnormal)
{
-// DltBuffer buf;
+/* DltBuffer buf; */
- // Increase uninizialised buffer
-// EXPECT_GE(-1, dlt_buffer_increase_size(&buf));
+ /* Increase uninizialised buffer */
+/* EXPECT_GE(-1, dlt_buffer_increase_size(&buf)); */
- // Fill buffer over max-value, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(-1, dlt_buffer_increase_size(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* Fill buffer over max-value, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(-1, dlt_buffer_increase_size(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
- // min-value > max-value, trying to increase buffer, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(-1, dlt_buffer_increase_size(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* min-value > max-value, trying to increase buffer, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(-1, dlt_buffer_increase_size(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
- // trying to increase buffer with 0 , expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, 0));
-// EXPECT_GE(-1, dlt_buffer_increase_size(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* trying to increase buffer with 0 , expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, 0)); */
+/* EXPECT_GE(-1, dlt_buffer_increase_size(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
}
TEST(t_dlt_buffer_increase_size, nullpointer)
{
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
EXPECT_GE(-1, dlt_buffer_increase_size(NULL));
}
/* End Method: dlt_common::dlt_buffer_increase_size */
@@ -208,44 +232,50 @@ TEST(t_dlt_buffer_minimize_size, normal)
{
DltBuffer buf;
- // Normal Use-Case, expected 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ /* Normal Use-Case, expected 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_LE(0, dlt_buffer_minimize_size(&buf));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // minimize buffer to min-value, expected 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- for(int i = (DLT_USER_RINGBUFFER_MAX_SIZE / DLT_USER_RINGBUFFER_MIN_SIZE); i >= 0; i -= DLT_USER_RINGBUFFER_STEP_SIZE)
- {
+ /* minimize buffer to min-value, expected 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+
+ for (int i = (DLT_USER_RINGBUFFER_MAX_SIZE / DLT_USER_RINGBUFFER_MIN_SIZE);
+ i >= 0;
+ i -= DLT_USER_RINGBUFFER_STEP_SIZE)
EXPECT_LE(0, dlt_buffer_minimize_size(&buf));
- }
+
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_minimize_size, abnormal)
{
-// DltBuffer buf;
+/* DltBuffer buf; */
- // Minimize uninizialised buffer
-// EXPECT_GE(-1, dlt_buffer_minimize_size(&buf));
+ /* Minimize uninizialised buffer */
+/* EXPECT_GE(-1, dlt_buffer_minimize_size(&buf)); */
- // minimize buffer under min-value, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(-1, dlt_buffer_minimize_size(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* minimize buffer under min-value, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(-1, dlt_buffer_minimize_size(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
- // min-value > max-value, trying to minimize buffer, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(-1, dlt_buffer_minimize_size(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* min-value > max-value, trying to minimize buffer, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(-1, dlt_buffer_minimize_size(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
- // trying to minimize buffer with 0 , expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, 0));
-// EXPECT_GE(-1, dlt_buffer_minimize_size(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* trying to minimize buffer with 0 , expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, 0)); */
+/* EXPECT_GE(-1, dlt_buffer_minimize_size(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
}
TEST(t_dlt_buffer_minimize_size, nullpointer)
{
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
EXPECT_GE(-1, dlt_buffer_minimize_size(NULL));
}
/* End Method: dlt_common::dlt_buffer_minimize_size */
@@ -258,21 +288,23 @@ TEST(t_dlt_buffer_reset, normal)
{
DltBuffer buf;
- // Normal Use-Case. expect 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ /* Normal Use-Case. expect 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_LE(0, dlt_buffer_reset(&buf));
}
TEST(t_dlt_buffer_reset, abnormal)
{
-// DltBuffer buf;
+/* DltBuffer buf; */
- //Use uninizialsied buffer, expected -1
-// EXPECT_GE(-1, dlt_buffer_reset(&buf));
+ /*Use uninizialsied buffer, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_reset(&buf)); */
}
TEST(t_dlt_buffer_reset, nullpointer)
{
- //Use NULL-Pointer, expected -1
+ /*Use NULL-Pointer, expected -1 */
EXPECT_GE(-1, dlt_buffer_reset(NULL));
}
/* End Method: dlt_common::dlt_buffer_reset */
@@ -284,72 +316,76 @@ TEST(t_dlt_buffer_reset, nullpointer)
TEST(t_dlt_buffer_push, normal)
{
DltBuffer buf;
- char * test;
+ char *test;
unsigned int size = sizeof(test);
- // Normal Use-Case, expected 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&test,size));
+ /* Normal Use-Case, expected 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&test, size));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Push till buffer is full, expected 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- for(unsigned int i=0; i<= (DLT_USER_RINGBUFFER_MIN_SIZE/size); i++)
- {
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&test,size));
- }
+ /* Push till buffer is full, expected 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+
+ for (unsigned int i = 0; i <= (DLT_USER_RINGBUFFER_MIN_SIZE / size); i++)
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&test, size));
+
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_push, abnormal)
{
-// DltBuffer buf;
-// char * test;
-// int size = sizeof(test);
+/* DltBuffer buf; */
+/* char * test; */
+/* int size = sizeof(test); */
- // Use uninizialsied, expected -1
-// EXPECT_GE(-1, dlt_buffer_push(&buf,(unsigned char *)&test,size));
+ /* Use uninizialsied, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_push(&buf,(unsigned char *)&test,size)); */
- // set size == 0, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(&buf,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* set size == 0, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(&buf,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
- // set size == 0 and char == 0 expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(&buf,0,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* set size == 0 and char == 0 expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(&buf,0,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
- // Push till buffer is overfilled , expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// for(int i=0; i<= (DLT_USER_RINGBUFFER_MIN_SIZE/size) + size; i++)
-// {
-// if(i <= DLT_USER_RINGBUFFER_MIN_SIZE)
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&test,size));
-// else
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(&buf,(unsigned char *)&test,size));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* Push till buffer is overfilled , expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* for(int i=0; i<= (DLT_USER_RINGBUFFER_MIN_SIZE/size) + size; i++) */
+/* { */
+/* if(i <= DLT_USER_RINGBUFFER_MIN_SIZE) */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&test,size)); */
+/* else */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(&buf,(unsigned char *)&test,size)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
- // All use-case, wich works with null pointer, has to discuss
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(&buf,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(&buf,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* All use-case, wich works with null pointer, has to discuss */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(&buf,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(&buf,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
}
TEST(t_dlt_buffer_push, nullpointer)
{
- char * test;
+ char *test;
int size = sizeof(test);
- // NULL-Pointer, expected -1
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(NULL,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(NULL,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(NULL,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(NULL,(unsigned char *)&test,size));
+ /* NULL-Pointer, expected -1 */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(NULL, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(NULL, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(NULL, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push(NULL, (unsigned char *)&test, size));
}
/* End Method: dlt_common::dlt_buffer_push*/
@@ -360,299 +396,346 @@ TEST(t_dlt_buffer_push, nullpointer)
TEST(t_dlt_buffer_push3, normal)
{
DltBuffer buf;
- char * test;
+ char *test;
int size = sizeof(test);
- // Normal Use-Case, expected 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push3(&buf,(unsigned char *)&test,size,0,0,0,0));
+ /* Normal Use-Case, expected 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push3(&buf, (unsigned char *)&test, size, 0, 0, 0, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,(unsigned char *)&test,size));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_push3(&buf, (unsigned char *)&test, size, (unsigned char *)&test, size, (unsigned char *)&test,
+ size));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Push till buffer is full, expected 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- for(int i=0; i<= (DLT_USER_RINGBUFFER_MIN_SIZE/size); i++)
- {
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,(unsigned char *)&test,size));
- }
+ /* Push till buffer is full, expected 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+
+ for (int i = 0; i <= (DLT_USER_RINGBUFFER_MIN_SIZE / size); i++)
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_push3(&buf, (unsigned char *)&test, size, (unsigned char *)&test, size,
+ (unsigned char *)&test,
+ size));
+
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_push3, abnormal)
{
-// DltBuffer buf;
-// char * test;
-// int size = sizeof(test);
-
- // Use uninizialsied, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,(unsigned char *)&test,size));
-
-
- // set size == 0, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0, (unsigned char *)&test,0, (unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-
- // set size == 0 and char == 0 expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,0,0,0,0,0,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-
- // works with null pointer, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,0,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-
- // Push till buffer is overfilled , expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// for(int i=0; i<= (DLT_USER_RINGBUFFER_MIN_SIZE/size) + size; i++)
-// {
-// if(i <= DLT_USER_RINGBUFFER_MIN_SIZE)
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,(unsigned char *)&test,size));
-// else
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,(unsigned char *)&test,size));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-
- // All use-case, wich works with null pointer, has to discuss
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,0,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,0,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,0,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,size,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,size,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,size,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,size,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,0,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,0,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,0,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,0,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,size,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,size,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,size,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,size,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,0,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,0,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,0,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,0,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,size,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,size,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,size,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,size,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,0,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,0,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,0,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,0,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,size,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,size,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,size,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,size,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,0,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,0,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,0,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,0,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,size,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,size,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,size,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,size,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,(unsigned char *)&test,0,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,(unsigned char *)&test,0,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,(unsigned char *)&test,size,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,(unsigned char *)&test,size,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,0,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,0,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,0,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,0,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,size,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,size,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,size,(unsigned char *)&test,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,size,(unsigned char *)&test,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,0,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,0,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,NULL,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-// EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,NULL,size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+/* DltBuffer buf; */
+/* char * test; */
+/* int size = sizeof(test); */
+
+ /* Use uninizialsied, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,(unsigned char *)&test,size)); */
+
+
+ /* set size == 0, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0, (unsigned char *)&test,0, (unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+
+ /* set size == 0 and char == 0 expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,0,0,0,0,0,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+
+ /* works with null pointer, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,0,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+
+ /* Push till buffer is overfilled , expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* for(int i=0; i<= (DLT_USER_RINGBUFFER_MIN_SIZE/size) + size; i++) */
+/* { */
+/* if(i <= DLT_USER_RINGBUFFER_MIN_SIZE) */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,(unsigned char *)&test,size)); */
+/* else */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,(unsigned char *)&test,size)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+
+ /* All use-case, wich works with null pointer, has to discuss */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,0,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,0,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,0,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,size,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,size,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,size,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,NULL,size,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,0,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,0,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,0,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,0,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,size,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,size,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,size,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,0,(unsigned char *)&test,size,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,0,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,0,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,0,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,0,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,size,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,size,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,size,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,NULL,size,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,0,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,0,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,0,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,0,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,size,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,size,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,size,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,NULL,size,(unsigned char *)&test,size,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,0,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,0,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,0,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,0,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,size,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,size,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,size,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,NULL,size,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,(unsigned char *)&test,0,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,(unsigned char *)&test,0,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,(unsigned char *)&test,size,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,0,(unsigned char *)&test,size,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,0,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,0,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,0,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,0,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,size,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,size,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,size,(unsigned char *)&test,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,NULL,size,(unsigned char *)&test,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,0,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,0,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,NULL,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK,dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(&buf,(unsigned char *)&test,size,(unsigned char *)&test,size,NULL,size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
}
TEST(t_dlt_buffer_push3, nullpointer)
{
- char * test;
+ char *test;
int size = sizeof(test);
- //Null Pointer, expected -1
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,NULL,0,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,NULL,0,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,NULL,0,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,NULL,0,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,NULL,size,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,NULL,size,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,NULL,size,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,NULL,size,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,(unsigned char *)&test,0,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,(unsigned char *)&test,0,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,(unsigned char *)&test,0,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,(unsigned char *)&test,0,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,(unsigned char *)&test,size,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,(unsigned char *)&test,size,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,(unsigned char *)&test,size,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,0,(unsigned char *)&test,size,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,NULL,0,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,NULL,0,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,NULL,0,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,NULL,0,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,NULL,size,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,NULL,size,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,NULL,size,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,NULL,size,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,(unsigned char *)&test,0,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,(unsigned char *)&test,0,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,(unsigned char *)&test,0,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,(unsigned char *)&test,0,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,(unsigned char *)&test,size,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,(unsigned char *)&test,size,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,(unsigned char *)&test,size,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,NULL,size,(unsigned char *)&test,size,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,NULL,0,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,NULL,0,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,NULL,0,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,NULL,0,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,NULL,size,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,NULL,size,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,NULL,size,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,NULL,size,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,(unsigned char *)&test,0,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,(unsigned char *)&test,0,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,(unsigned char *)&test,0,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,(unsigned char *)&test,0,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,(unsigned char *)&test,size,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,(unsigned char *)&test,size,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,(unsigned char *)&test,size,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,0,(unsigned char *)&test,size,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,NULL,0,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,NULL,0,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,NULL,0,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,NULL,0,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,NULL,size,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,NULL,size,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,NULL,size,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,NULL,size,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,(unsigned char *)&test,0,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,(unsigned char *)&test,0,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,(unsigned char *)&test,0,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,(unsigned char *)&test,0,(unsigned char *)&test,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,(unsigned char *)&test,size,NULL,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,(unsigned char *)&test,size,NULL,size));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,(unsigned char *)&test,size,(unsigned char *)&test,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL,(unsigned char *)&test,size,(unsigned char *)&test,size,(unsigned char *)&test,size));
+ /*Null Pointer, expected -1 */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, NULL, 0, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, NULL, 0, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, NULL, 0, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, NULL, 0, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, NULL, size, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, NULL, size, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, NULL, size, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, NULL, size, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, (unsigned char *)&test, 0, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, (unsigned char *)&test, 0, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, (unsigned char *)&test, 0, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, NULL, 0, (unsigned char *)&test, 0, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, (unsigned char *)&test, size, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, 0, (unsigned char *)&test, size, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, NULL, 0, (unsigned char *)&test, size, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, NULL, 0, (unsigned char *)&test, size, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, NULL, 0, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, NULL, 0, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, NULL, 0, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, NULL, 0, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, NULL, size, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, NULL, size, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, NULL, size, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, NULL, size, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, (unsigned char *)&test, 0, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, (unsigned char *)&test, 0, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, NULL, size, (unsigned char *)&test, 0, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, NULL, size, (unsigned char *)&test, 0, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, (unsigned char *)&test, size, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, NULL, size, (unsigned char *)&test, size, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, NULL, size, (unsigned char *)&test, size, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, NULL, size, (unsigned char *)&test, size, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, (unsigned char *)&test, 0, NULL, 0, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, (unsigned char *)&test, 0, NULL, 0, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, (unsigned char *)&test, 0, NULL, 0, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, 0, NULL, 0, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, (unsigned char *)&test, 0, NULL, size, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, (unsigned char *)&test, 0, NULL, size, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, 0, NULL, size, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, 0, NULL, size, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, (unsigned char *)&test, 0, (unsigned char *)&test, 0, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, 0, (unsigned char *)&test, 0, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, 0, (unsigned char *)&test, 0, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, 0, (unsigned char *)&test, 0, (unsigned char *)&test,
+ size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, 0, (unsigned char *)&test, size, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, 0, (unsigned char *)&test, size, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, 0, (unsigned char *)&test, size, (unsigned char *)&test,
+ 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, 0, (unsigned char *)&test, size, (unsigned char *)&test,
+ size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, (unsigned char *)&test, size, NULL, 0, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, (unsigned char *)&test, size, NULL, 0, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, NULL, 0, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, NULL, 0, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, (unsigned char *)&test, size, NULL, size, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_buffer_push3(NULL, (unsigned char *)&test, size, NULL, size, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, NULL, size, (unsigned char *)&test, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, NULL, size, (unsigned char *)&test, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, (unsigned char *)&test, 0, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, (unsigned char *)&test, 0, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, (unsigned char *)&test, 0, (unsigned char *)&test,
+ 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, (unsigned char *)&test, 0, (unsigned char *)&test,
+ size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, (unsigned char *)&test, size, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, (unsigned char *)&test, size, NULL, size));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, (unsigned char *)&test, size, (unsigned char *)&test,
+ 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_buffer_push3(NULL, (unsigned char *)&test, size, (unsigned char *)&test, size, (unsigned char *)&test,
+ size));
}
/* End Method: dlt_common::dlt_buffer_push3 */
@@ -662,55 +745,63 @@ TEST(t_dlt_buffer_push3, nullpointer)
/* Begin Method: dlt_common::dlt_buffer_pull */
TEST(t_dlt_buffer_pull, normal)
{
- //Normal Use Cases, expected 0 or -1 in return
+ /*Normal Use Cases, expected 0 or -1 in return */
DltBuffer buf;
DltUserHeader header;
int size = sizeof(DltUserHeader);
- // Normal Use-Case, empty pull, expected -1
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_GE(-1, dlt_buffer_pull(&buf, (unsigned char*)&header, size));
+ /* Normal Use-Case, empty pull, expected -1 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_GE(-1, dlt_buffer_pull(&buf, (unsigned char *)&header, size));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Normal Use-Case, expected > 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,sizeof(DltUserHeader)));
- EXPECT_LE(1, dlt_buffer_pull(&buf, (unsigned char*)&header, size));
+ /* Normal Use-Case, expected > 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, sizeof(DltUserHeader)));
+ EXPECT_LE(1, dlt_buffer_pull(&buf, (unsigned char *)&header, size));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_pull, abnormal)
{
-// DltBuffer buf;
-// DltUserHeader header;
+/* DltBuffer buf; */
+/* DltUserHeader header; */
- // Uninizialised, expected -1
-// EXPECT_GE(-1, dlt_buffer_pull(&buf, (unsigned char*)&header, sizeof(DltUserHeader)));
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_pull(&buf, (unsigned char*)&header, sizeof(DltUserHeader))); */
- // data == 0 and max_size == 0, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,sizeof(DltUserHeader)));
-// EXPECT_GE(-1, dlt_buffer_pull(&buf, 0, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* data == 0 and max_size == 0, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,sizeof(DltUserHeader))); */
+/* EXPECT_GE(-1, dlt_buffer_pull(&buf, 0, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
- // no push before pull, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(-1, dlt_buffer_pull(&buf, 0, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* no push before pull, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(-1, dlt_buffer_pull(&buf, 0, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
}
TEST(t_dlt_buffer_pull, nullpointer)
{
DltBuffer buf;
DltUserHeader header;
- // NULL-Point, expected -1
+ /* NULL-Point, expected -1 */
EXPECT_GE(-1, dlt_buffer_pull(NULL, NULL, 0));
EXPECT_GE(-1, dlt_buffer_pull(NULL, NULL, sizeof(DltUserHeader)));
EXPECT_GE(-1, dlt_buffer_pull(NULL, (unsigned char *)&header, 0));
EXPECT_GE(-1, dlt_buffer_pull(NULL, (unsigned char *)&header, sizeof(DltUserHeader)));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(-1, dlt_buffer_pull(&buf, NULL, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(-1, dlt_buffer_pull(&buf, NULL, sizeof(DltUserHeader)));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
@@ -725,47 +816,51 @@ TEST(t_dlt_buffer_remove, normal)
DltUserHeader header;
int size = sizeof(DltUserHeader);
- // Normal Use-Case, empty pull, expected -1
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ /* Normal Use-Case, empty pull, expected -1 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(-1, dlt_buffer_remove(&buf));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Normal Use-Case, expected > 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,size));
+ /* Normal Use-Case, expected > 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, size));
EXPECT_LE(0, dlt_buffer_remove(&buf));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_remove, abnormal)
{
-// DltBuffer buf;
-// DltUserHeader header;
-// int size = sizeof(DltUserHeader);
-
- // Uninizialised, expected -1
-// EXPECT_GE(-1, dlt_buffer_remove(&buf));
-
- // no push before remove, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_GE(-1, dlt_buffer_remove(&buf));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
-
- // Call remove 10 time, expected > 1 till buffer is empty
- // pushed one time so expect one > 1 and 9 times < 0
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,size));
-// for(int i=0; i<10;i++)
-// {
-// if(i == 0)
-// EXPECT_LE(1, dlt_buffer_remove(&buf));
-// else
-// EXPECT_GE(-1, dlt_buffer_remove(&buf));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+/* DltBuffer buf; */
+/* DltUserHeader header; */
+/* int size = sizeof(DltUserHeader); */
+
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_remove(&buf)); */
+
+ /* no push before remove, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_GE(-1, dlt_buffer_remove(&buf)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
+
+ /* Call remove 10 time, expected > 1 till buffer is empty */
+ /* pushed one time so expect one > 1 and 9 times < 0 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,size)); */
+/* for(int i=0; i<10;i++) */
+/* { */
+/* if(i == 0) */
+/* EXPECT_LE(1, dlt_buffer_remove(&buf)); */
+/* else */
+/* EXPECT_GE(-1, dlt_buffer_remove(&buf)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
}
TEST(t_dlt_buffer_remove, nullpointer)
{
- // NULL_Pointer, expected -1
+ /* NULL_Pointer, expected -1 */
EXPECT_GE(-1, dlt_buffer_remove(NULL));
}
/* End Method: dlt_common::dlt_buffer_remove*/
@@ -780,30 +875,34 @@ TEST(t_dlt_buffer_copy, normal)
DltUserHeader header;
int size = sizeof(DltUserHeader);
- // Normal Use-Case, empty pull, expected -1
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ /* Normal Use-Case, empty pull, expected -1 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(-1, dlt_buffer_copy(&buf, (unsigned char *)&header, size));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Normal Use-Case, expected > 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,sizeof(DltUserHeader)));
+ /* Normal Use-Case, expected > 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, sizeof(DltUserHeader)));
EXPECT_LE(1, dlt_buffer_copy(&buf, (unsigned char *)&header, size));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_copy, abnormal)
{
-// DltBuffer buf;
-// DltUserHeader header;
-// int size = sizeof(DltUserHeader);
+/* DltBuffer buf; */
+/* DltUserHeader header; */
+/* int size = sizeof(DltUserHeader); */
- // Uninizialised buffer , expected -1
-// EXPECT_LE(-1, dlt_buffer_copy(&buf, (unsigned char *)&header, size));
+ /* Uninizialised buffer , expected -1 */
+/* EXPECT_LE(-1, dlt_buffer_copy(&buf, (unsigned char *)&header, size)); */
- // no push before copy, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_LE(-1, dlt_buffer_copy(&buf, (unsigned char *)&header, size));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* no push before copy, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_LE(-1, dlt_buffer_copy(&buf, (unsigned char *)&header, size)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
}
TEST(t_dlt_buffer_copy, nullpointer)
{
@@ -811,16 +910,20 @@ TEST(t_dlt_buffer_copy, nullpointer)
DltUserHeader header;
int size = sizeof(DltUserHeader);
- // NULL-Pointer, expected -1
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(NULL,NULL,size));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(NULL,NULL,0));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(NULL,(unsigned char *)&header,size));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(NULL,(unsigned char *)&header,0));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(&buf,NULL,size));
+ /* NULL-Pointer, expected -1 */
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(NULL, NULL, size));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(NULL, NULL, 0));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(NULL, (unsigned char *)&header, size));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(NULL, (unsigned char *)&header, 0));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(&buf, NULL, size));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(&buf,NULL,0));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_buffer_copy(&buf, NULL, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
/* End Method: dlt_common::dlt_buffer_copy */
@@ -835,99 +938,123 @@ TEST(t_dlt_buffer_get, normal)
DltUserHeader header;
int size = sizeof(DltUserHeader);
- // Normal Use-Case
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,size));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- EXPECT_LE(0, dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
+ /* Normal Use-Case */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, size));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ EXPECT_LE(0, dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,size));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- EXPECT_LE(0, dlt_buffer_get(&buf,(unsigned char*)&header,size,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, size));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ EXPECT_LE(0, dlt_buffer_get(&buf, (unsigned char *)&header, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char*)&header,size,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ EXPECT_GE(-1, dlt_buffer_get(&buf, (unsigned char *)&header, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- ((int*)(buf.shm))[0] = 50000;
- EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char*)&header,size,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ ((int *)(buf.shm))[0] = 50000;
+ EXPECT_GE(-1, dlt_buffer_get(&buf, (unsigned char *)&header, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- ((int*)(buf.shm))[1] = 50000;
- EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char*)&header,size,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ ((int *)(buf.shm))[1] = 50000;
+ EXPECT_GE(-1, dlt_buffer_get(&buf, (unsigned char *)&header, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- ((int*)(buf.shm))[2] = -50000;
- EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char*)&header,size,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ ((int *)(buf.shm))[2] = -50000;
+ EXPECT_GE(-1, dlt_buffer_get(&buf, (unsigned char *)&header, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- ((int*)(buf.shm))[2] = 0;
- EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char*)&header,size,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ ((int *)(buf.shm))[2] = 0;
+ EXPECT_GE(-1, dlt_buffer_get(&buf, (unsigned char *)&header, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- ((int*)(buf.shm))[0] = 4000;
- ((int*)(buf.shm))[1] = 5000;
- ((int*)(buf.shm))[2] = 0;
- EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char*)&header,size,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ ((int *)(buf.shm))[0] = 4000;
+ ((int *)(buf.shm))[1] = 5000;
+ ((int *)(buf.shm))[2] = 0;
+ EXPECT_GE(-1, dlt_buffer_get(&buf, (unsigned char *)&header, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- ((int*)(buf.shm))[0] = 10;
- ((int*)(buf.shm))[1] = 5;
- ((int*)(buf.shm))[2] = 5;
- EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char*)&header,size,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ ((int *)(buf.shm))[0] = 10;
+ ((int *)(buf.shm))[1] = 5;
+ ((int *)(buf.shm))[2] = 5;
+ EXPECT_GE(-1, dlt_buffer_get(&buf, (unsigned char *)&header, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- ((int*)(buf.shm))[2] = 50000;
- EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char*)&header,size,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ ((int *)(buf.shm))[2] = 50000;
+ EXPECT_GE(-1, dlt_buffer_get(&buf, (unsigned char *)&header, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,size));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- ((int*)(buf.shm))[0] = 19;
- EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char*)&header,size,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, size));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ ((int *)(buf.shm))[0] = 19;
+ EXPECT_GE(-1, dlt_buffer_get(&buf, (unsigned char *)&header, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,size));
- printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
- ((int*)(buf.shm))[2] = 19;
- EXPECT_LE(0, dlt_buffer_get(&buf,(unsigned char*)&header,5,1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, size));
+ printf("#### %i\n", dlt_buffer_get(&buf, (unsigned char *)&header, size, 0));
+ ((int *)(buf.shm))[2] = 19;
+ EXPECT_LE(0, dlt_buffer_get(&buf, (unsigned char *)&header, 5, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_get, abnormal)
{
-// DltBuffer buf;
-// DltUserHeader header;
-// int size = sizeof(DltUserHeader);
+/* DltBuffer buf; */
+/* DltUserHeader header; */
+/* int size = sizeof(DltUserHeader); */
- // Uninizialsied, expected -1
-// EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char *)&header,size, 0));
+ /* Uninizialsied, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_get(&buf,(unsigned char *)&header,size, 0)); */
- // Integer with 12345678
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,size));
-// printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0));
-// EXPECT_LE(0, dlt_buffer_get(&buf,(unsigned char*)&header,size,12345678));
-// EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
+ /* Integer with 12345678 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,size)); */
+/* printf("#### %i\n", dlt_buffer_get(&buf,(unsigned char*)&header,size,0)); */
+/* EXPECT_LE(0, dlt_buffer_get(&buf,(unsigned char*)&header,size,12345678)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf)); */
}
TEST(t_dlt_buffer_get, nullpointer)
{
@@ -935,25 +1062,33 @@ TEST(t_dlt_buffer_get, nullpointer)
DltUserHeader header;
int size = sizeof(DltUserHeader);
- // NULL-Pointer
+ /* NULL-Pointer */
EXPECT_GE(-1, dlt_buffer_get(NULL, NULL, 0, 0));
EXPECT_GE(-1, dlt_buffer_get(NULL, NULL, 0, 1));
EXPECT_GE(-1, dlt_buffer_get(NULL, NULL, size, 0));
EXPECT_GE(-1, dlt_buffer_get(NULL, NULL, size, 1));
- EXPECT_GE(-1, dlt_buffer_get(NULL, (unsigned char*)&header, 0, 0));
- EXPECT_GE(-1, dlt_buffer_get(NULL, (unsigned char*)&header, 0, 1));
- EXPECT_GE(-1, dlt_buffer_get(NULL, (unsigned char*)&header, size, 0));
- EXPECT_GE(-1, dlt_buffer_get(NULL, (unsigned char*)&header, size, 1));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_GE(-1, dlt_buffer_get(NULL, (unsigned char *)&header, 0, 0));
+ EXPECT_GE(-1, dlt_buffer_get(NULL, (unsigned char *)&header, 0, 1));
+ EXPECT_GE(-1, dlt_buffer_get(NULL, (unsigned char *)&header, size, 0));
+ EXPECT_GE(-1, dlt_buffer_get(NULL, (unsigned char *)&header, size, 1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(-1, dlt_buffer_get(&buf, NULL, 0, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(-1, dlt_buffer_get(&buf, NULL, 0, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(-1, dlt_buffer_get(&buf, NULL, size, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_GE(-1, dlt_buffer_get(&buf, NULL, size, 1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
@@ -968,41 +1103,48 @@ TEST(t_dlt_buffer_get_message_count, normal)
DltBuffer buf;
DltUserHeader header;
- // Normal Usce-Case without pushing data, expected 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- //printf("##### %i\n", dlt_buffer_get_message_count(&buf));
+ /* Normal Usce-Case without pushing data, expected 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ /*printf("##### %i\n", dlt_buffer_get_message_count(&buf)); */
EXPECT_LE(0, dlt_buffer_get_message_count(&buf));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Normal Use-Case, with pushing data, expected > 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,sizeof(DltUserHeader)));
- //printf("#### %i\n", dlt_buffer_get_message_count(&buf));
+ /* Normal Use-Case, with pushing data, expected > 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, sizeof(DltUserHeader)));
+ /*printf("#### %i\n", dlt_buffer_get_message_count(&buf)); */
EXPECT_LE(0, dlt_buffer_get_message_count(&buf));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Pushing 1000 mesages, expected 10000
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- for(int i = 1; i <= 10000; i++)
- {
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,sizeof(DltUserHeader)));
- //printf("#### %i\n", dlt_buffer_get_message_count(&buf));
+ /* Pushing 1000 mesages, expected 10000 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+
+ for (int i = 1; i <= 10000; i++) {
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, sizeof(DltUserHeader)));
+ /*printf("#### %i\n", dlt_buffer_get_message_count(&buf)); */
EXPECT_LE(i, dlt_buffer_get_message_count(&buf));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_get_message_count, abnormal)
{
-// DltBuffer buf;
+/* DltBuffer buf; */
- // Uninizialised, expected -1
-// EXPECT_GE(-1, dlt_buffer_get_message_count(&buf));
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_get_message_count(&buf)); */
}
TEST(t_dlt_buffer_get_message_count, nullpointer)
{
- //NULL-Pointer, expected -1
-// EXPECT_GE(-1, dlt_buffer_get_message_count(NULL));
+ /*NULL-Pointer, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_get_message_count(NULL)); */
}
/* Begin MEthod: dlt_common::dlt_buffer_get_message_count */
@@ -1015,29 +1157,33 @@ TEST(t_dlt_buffer_get_total_size, normal)
DltBuffer buf;
DltUserHeader header;
- // Normal Use-Case, expected max buffer size (DLT_USER_RINGBUFFER_MAX_SIZE)
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- //printf("##### %i\n", dlt_buffer_get_total_size(&buf));
+ /* Normal Use-Case, expected max buffer size (DLT_USER_RINGBUFFER_MAX_SIZE) */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ /*printf("##### %i\n", dlt_buffer_get_total_size(&buf)); */
EXPECT_LE(DLT_USER_RINGBUFFER_MAX_SIZE, dlt_buffer_get_total_size(&buf));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Normal Use-Case, 1st pushing data, expected max buffer size (DLT_USER_RINGBUFFER_MAX_SIZE)
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,sizeof(DltUserHeader)));
- //printf("##### %i\n", dlt_buffer_get_total_size(&buf));
+ /* Normal Use-Case, 1st pushing data, expected max buffer size (DLT_USER_RINGBUFFER_MAX_SIZE) */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, sizeof(DltUserHeader)));
+ /*printf("##### %i\n", dlt_buffer_get_total_size(&buf)); */
EXPECT_LE(DLT_USER_RINGBUFFER_MAX_SIZE, dlt_buffer_get_total_size(&buf));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_get_total_size, abnormal)
{
-// DltBuffer buf;
+/* DltBuffer buf; */
- // Uninizialised, expected -1
-// EXPECT_GE(-1, dlt_buffer_get_total_size(&buf));
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_get_total_size(&buf)); */
}
TEST(t_dlt_buffer_get_total_size, nullpointer)
{
- // NULL-Pointer, expect -1
+ /* NULL-Pointer, expect -1 */
EXPECT_GE(-1, dlt_buffer_get_total_size(NULL));
}
/* End Method: dlt_common::dlt_buffer_get_total_size*/
@@ -1050,39 +1196,46 @@ TEST(t_dlt_buffer_get_used_size, normal)
DltBuffer buf;
DltUserHeader header;
- // Normal Use Cas buffer empty, expected 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- //printf("##### %i\n", dlt_buffer_get_used_size(&buf));
+ /* Normal Use Cas buffer empty, expected 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ /*printf("##### %i\n", dlt_buffer_get_used_size(&buf)); */
EXPECT_LE(0, dlt_buffer_get_used_size(&buf));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Normal Use-Case with pushing data, expected > 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_LE(DLT_RETURN_OK,dlt_buffer_push(&buf,(unsigned char *)&header,sizeof(DltUserHeader)));
- //printf("##### %i\n", dlt_buffer_get_used_size(&buf));
+ /* Normal Use-Case with pushing data, expected > 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, sizeof(DltUserHeader)));
+ /*printf("##### %i\n", dlt_buffer_get_used_size(&buf)); */
EXPECT_LE(0, dlt_buffer_get_used_size(&buf));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- // Normal Use-Case with pushing 10000 data, expected > 0
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- for(int i = 1; i <= 10000; i++)
- {
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf,(unsigned char *)&header,sizeof(DltUserHeader)));
- //printf("#### %i\n", dlt_buffer_get_used_size(&buf));
+ /* Normal Use-Case with pushing 10000 data, expected > 0 */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+
+ for (int i = 1; i <= 10000; i++) {
+ EXPECT_LE(DLT_RETURN_OK, dlt_buffer_push(&buf, (unsigned char *)&header, sizeof(DltUserHeader)));
+ /*printf("#### %i\n", dlt_buffer_get_used_size(&buf)); */
EXPECT_LE(1, dlt_buffer_get_used_size(&buf));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_get_used_size, abnormal)
{
-// DltBuffer buf;
+/* DltBuffer buf; */
- // Uninizialised, expected -1
-// EXPECT_GE(-1, dlt_buffer_get_used_size(&buf));
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(-1, dlt_buffer_get_used_size(&buf)); */
}
TEST(t_dlt_buffer_get_used_size, nullpointer)
{
- //NULL-Pointer, expcted -1
+ /*NULL-Pointer, expcted -1 */
EXPECT_GE(-1, dlt_buffer_get_used_size(NULL));
}
/* End Method: dlt_common::dlt_buffer_get_used_size*/
@@ -1094,42 +1247,49 @@ TEST(t_dlt_buffer_get_used_size, nullpointer)
TEST(t_dlt_buffer_write_block, normal)
{
DltBuffer buf;
- unsigned char * data = NULL;
+ unsigned char *data = NULL;
int write;
int size1 = 516;
int size2 = 1024;
- // Normal Use-Case, void method, expected no error
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_NO_THROW(dlt_buffer_write_block(&buf,&write, data, size1));
+ /* Normal Use-Case, void method, expected no error */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_NO_THROW(dlt_buffer_write_block(&buf, &write, data, size1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_NO_THROW(dlt_buffer_write_block(&buf,&write, data, size2));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_NO_THROW(dlt_buffer_write_block(&buf, &write, data, size2));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- int tmp =0;
- for(int i = 0; i<= 10000; i+=10)
- {
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ int tmp = 0;
+
+ for (int i = 0; i <= 10000; i += 10) {
tmp += i;
- EXPECT_NO_THROW(dlt_buffer_write_block(&buf,&write, data, i));
+ EXPECT_NO_THROW(dlt_buffer_write_block(&buf, &write, data, i));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_write_block, abnormal)
{
- // actual no abnormal test cases
- // because of void funktion and missing gtest tools for that
+ /* actual no abnormal test cases */
+ /* because of void funktion and missing gtest tools for that */
}
TEST(t_dlt_buffer_write_block, nullpointer)
{
DltBuffer buf;
- char * data;
+ char *data;
int write;
int test1 = 1000;
- // NULL-Pointer, expected < 0
+ /* NULL-Pointer, expected < 0 */
EXPECT_NO_THROW(dlt_buffer_write_block(NULL, NULL, NULL, 0));
EXPECT_NO_THROW(dlt_buffer_write_block(NULL, NULL, NULL, test1));
EXPECT_NO_THROW(dlt_buffer_write_block(NULL, NULL, (unsigned char *)&data, 0));
@@ -1138,22 +1298,34 @@ TEST(t_dlt_buffer_write_block, nullpointer)
EXPECT_NO_THROW(dlt_buffer_write_block(NULL, &write, NULL, test1));
EXPECT_NO_THROW(dlt_buffer_write_block(NULL, &write, (unsigned char *)&data, 0));
EXPECT_NO_THROW(dlt_buffer_write_block(NULL, &write, (unsigned char *)&data, test1));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_write_block(&buf, NULL, NULL, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_write_block(&buf, NULL, NULL, test1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_write_block(&buf, NULL, (unsigned char *)&data, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_write_block(&buf, NULL, (unsigned char *)&data, test1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_write_block(&buf, &write, NULL, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_write_block(&buf, &write, NULL, test1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
@@ -1166,35 +1338,39 @@ TEST(t_dlt_buffer_write_block, nullpointer)
TEST(t_dlt_buffer_read_block, normal)
{
DltBuffer buf;
- unsigned char * data = NULL;
+ unsigned char *data = NULL;
int write, read;
int size1 = 516;
int size2 = 1024;
- // Normal Use-Case, void method, expected no error
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_NO_THROW(dlt_buffer_write_block(&buf,&write, data, size1));
- EXPECT_NO_THROW(dlt_buffer_read_block(&buf,&write, data, size1));
+ /* Normal Use-Case, void method, expected no error */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_NO_THROW(dlt_buffer_write_block(&buf, &write, data, size1));
+ EXPECT_NO_THROW(dlt_buffer_read_block(&buf, &write, data, size1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
- EXPECT_NO_THROW(dlt_buffer_write_block(&buf,&read, data, size2));
- EXPECT_NO_THROW(dlt_buffer_read_block(&buf,&write, data, size2));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_NO_THROW(dlt_buffer_write_block(&buf, &read, data, size2));
+ EXPECT_NO_THROW(dlt_buffer_read_block(&buf, &write, data, size2));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_buffer_read_block, abnormal)
{
- // actual no abnormal test cases
- // because of void funktion and missing gtest tools for that
+ /* actual no abnormal test cases */
+ /* because of void funktion and missing gtest tools for that */
}
TEST(t_dlt_buffer_read_block, nullpointer)
{
DltBuffer buf;
- char * data;
+ char *data;
int read = -1;
int test1 = 1000;
- // NULL-Pointer, expected < 0
+ /* NULL-Pointer, expected < 0 */
EXPECT_NO_THROW(dlt_buffer_read_block(NULL, NULL, NULL, 0));
EXPECT_NO_THROW(dlt_buffer_read_block(NULL, NULL, NULL, test1));
EXPECT_NO_THROW(dlt_buffer_read_block(NULL, NULL, (unsigned char *)&data, 0));
@@ -1203,25 +1379,39 @@ TEST(t_dlt_buffer_read_block, nullpointer)
EXPECT_NO_THROW(dlt_buffer_read_block(NULL, &read, NULL, test1));
EXPECT_NO_THROW(dlt_buffer_read_block(NULL, &read, (unsigned char *)&data, 0));
EXPECT_NO_THROW(dlt_buffer_read_block(NULL, &read, (unsigned char *)&data, test1));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_read_block(&buf, NULL, NULL, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_read_block(&buf, NULL, NULL, test1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_read_block(&buf, NULL, (unsigned char *)&data, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_read_block(&buf, NULL, (unsigned char *)&data, test1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_read_block(&buf, &read, NULL, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_read_block(&buf, &read, NULL, test1));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_read_block(&buf, &read, (unsigned char *)&data, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
@@ -1235,18 +1425,20 @@ TEST(t_dlt_buffer_info, normal)
{
DltBuffer buf;
- // Normal Use-Case
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ /* Normal Use-Case */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_info(&buf));
}
TEST(t_dlt_buffer_info, abnormal)
{
- // actually no abnormal test cases
- // because of void function and missing gtest tools for that
+ /* actually no abnormal test cases */
+ /* because of void function and missing gtest tools for that */
}
TEST(t_dlt_buffer_info, nullpointer)
{
- // NULL-Pointer, no throw
+ /* NULL-Pointer, no throw */
EXPECT_NO_THROW(dlt_buffer_info(NULL));
}
/* End Method: dlt_common::dlt_buffer_info */
@@ -1259,18 +1451,20 @@ TEST(t_dlt_buffer_status, normal)
{
DltBuffer buf;
- // Normal Use-Case
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ /* Normal Use-Case */
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_NO_THROW(dlt_buffer_status(&buf));
}
TEST(t_dlt_buffer_status, abnormal)
{
- // actual no abnormal test cases
- // because of void funktion and missing gtest tools for that
+ /* actual no abnormal test cases */
+ /* because of void funktion and missing gtest tools for that */
}
TEST(t_dlt_buffer_status, nullpointer)
{
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
EXPECT_NO_THROW(dlt_buffer_status(NULL));
}
/* End Method: dlt_common::dlt_buffer_status */
@@ -1290,7 +1484,7 @@ TEST(t_dlt_message_init, normal)
{
DltMessage msg;
- // Normal Use-Case, expected 0
+ /* Normal Use-Case, expected 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_message_init(&msg, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_free(&msg, 0));
@@ -1299,22 +1493,22 @@ TEST(t_dlt_message_init, normal)
}
TEST(t_dlt_message_init, abnormal)
{
-// DltMessage msg;
+/* DltMessage msg; */
- // Double use init, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_message_init(&msg,0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_init(&msg,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_message_free(&msg,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_message_init(&msg,1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_init(&msg,1));
-// EXPECT_LE(DLT_RETURN_OK, dlt_message_free(&msg,1));
+ /* Double use init, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_message_init(&msg,0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_init(&msg,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_message_free(&msg,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_message_init(&msg,1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_init(&msg,1)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_message_free(&msg,1)); */
- // set Verbose to 12345678, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_init(&msg,12345678));
+ /* set Verbose to 12345678, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_init(&msg,12345678)); */
}
TEST(t_dlt_message_init, nullpointer)
{
- //NULL-Pointer, expected -1
+ /*NULL-Pointer, expected -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_init(NULL, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_init(NULL, 1));
}
@@ -1328,7 +1522,7 @@ TEST(t_dlt_message_free, normal)
{
DltMessage msg;
- // Normal Use Case, expected 0
+ /* Normal Use Case, expected 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_message_init(&msg, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_free(&msg, 0));
@@ -1337,23 +1531,23 @@ TEST(t_dlt_message_free, normal)
}
TEST(t_dlt_message_free, abnormal)
{
-// DltMessage msg;
+/* DltMessage msg; */
- // Double use free, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_message_init(&msg,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_message_free(&msg,0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_free(&msg,0));
+ /* Double use free, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_message_init(&msg,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_message_free(&msg,0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_free(&msg,0)); */
-// EXPECT_LE(DLT_RETURN_OK, dlt_message_init(&msg,0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_message_free(&msg,1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_free(&msg,1));
+/* EXPECT_LE(DLT_RETURN_OK, dlt_message_init(&msg,0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_message_free(&msg,1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_free(&msg,1)); */
- // set Verbose to 12345678, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_free(&msg,12345678));
+ /* set Verbose to 12345678, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_free(&msg,12345678)); */
}
TEST(t_dlt_message_free, nullpointer)
{
- //NULL-Pointer, expected -1
+ /*NULL-Pointer, expected -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_free(NULL, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_free(NULL, 1));
}
@@ -1368,15 +1562,15 @@ TEST(t_dlt_file_open, normal)
DltFile file;
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expected 0
+ /* Normal Use-Case, expected 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
@@ -1387,38 +1581,38 @@ TEST(t_dlt_file_open, normal)
}
TEST(t_dlt_file_open, abnormal)
{
-// DltFile file;
-// /* Get PWD so file can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* DltFile file; */
+/* / * Get PWD so file can be used* / */
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // Uninizialsied, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(&file, openfile, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(&file, openfile, 1));
+ /* Uninizialsied, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(&file, openfile, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(&file, openfile, 1)); */
- // Verbose set to 12345678
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(&file, openfile, 12345678));
+ /* Verbose set to 12345678 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(&file, openfile, 12345678)); */
- // Path doesn't exist, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(&file, "This Path doesn't exist!!", 0));
+ /* Path doesn't exist, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(&file, "This Path doesn't exist!!", 0)); */
}
TEST(t_dlt_file_open, nullpointer)
{
DltFile file;
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(NULL, NULL, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(NULL, NULL, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_file_open(NULL, openfile, 0));
@@ -1440,58 +1634,60 @@ TEST(t_dlt_message_print_ascii, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expected 0
+ /* Normal Use-Case, expected 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_print_ascii, abnormal)
{
-// DltFile file;
-// static char text[DLT_DAEMON_TEXTSIZE];
+/* DltFile file; */
+/* static char text[DLT_DAEMON_TEXTSIZE]; */
-// /* Get PWD so file and filter can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* / * Get PWD so file and filter can be used* / */
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // No messages read, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
+ /* No messages read, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1)); */
- // Set verbose to 12345678
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
+ /* Set verbose to 12345678 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_print_ascii, nullpointer)
{
@@ -1500,27 +1696,27 @@ TEST(t_dlt_message_print_ascii, nullpointer)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // NULL-Pointer, expected -1
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL,NULL,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL,NULL,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL,NULL,DLT_DAEMON_TEXTSIZE,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL,text,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL,text,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL,text,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL,text,DLT_DAEMON_TEXTSIZE,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg,NULL,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg,NULL,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg,NULL,DLT_DAEMON_TEXTSIZE,1));
+ /* NULL-Pointer, expected -1 */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL, NULL, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL, NULL, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL, NULL, DLT_DAEMON_TEXTSIZE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL, text, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL, text, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL, text, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(NULL, text, DLT_DAEMON_TEXTSIZE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, NULL, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_ascii(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 1));
}
/* End Method: dlt_common::dlt_message_print_ascii*/
@@ -1536,9 +1732,9 @@ TEST(t_dlt_message_print_ascii_with_filter, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
char openfilter[117];
@@ -1546,32 +1742,34 @@ TEST(t_dlt_message_print_ascii_with_filter, normal)
sprintf(openfilter, "%s/testfilter.txt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expect 0
+ /* Normal Use-Case, expect 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_init(&filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_load(&filter, openfilter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_set_filter(&file, &filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_print_ascii_with_filter, abnormal)
{
- // equal with t_dlt_message_print_ascii
+ /* equal with t_dlt_message_print_ascii */
}
TEST(t_dlt_message_print_ascii_with_filter, nullpointer)
{
- // equal with t_dlt_message_print_ascii
+ /* equal with t_dlt_message_print_ascii */
}
/* End Method: dlt_common::dlt_message_print_ascii with filter*/
@@ -1586,58 +1784,60 @@ TEST(t_dlt_message_print_header, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expected 0
+ /* Normal Use-Case, expected 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_print_header, abnormal)
{
-// DltFile file;
-// static char text[DLT_DAEMON_TEXTSIZE];
+/* DltFile file; */
+/* static char text[DLT_DAEMON_TEXTSIZE]; */
-// /* Get PWD so file and filter can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* / * Get PWD so file and filter can be used* / */
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // No messages read, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
+ /* No messages read, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1)); */
- // Set verbose to 12345678
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
+ /* Set verbose to 12345678 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_print_header, nullpointer)
{
@@ -1646,27 +1846,27 @@ TEST(t_dlt_message_print_header, nullpointer)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // NULL-Pointer, expected -1
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL,NULL,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL,NULL,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL,NULL,DLT_DAEMON_TEXTSIZE,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL,text,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL,text,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL,text,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL,text,DLT_DAEMON_TEXTSIZE,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg,NULL,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg,NULL,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg,NULL,DLT_DAEMON_TEXTSIZE,1));
+ /* NULL-Pointer, expected -1 */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL, NULL, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL, NULL, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL, NULL, DLT_DAEMON_TEXTSIZE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL, text, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL, text, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL, text, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(NULL, text, DLT_DAEMON_TEXTSIZE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, NULL, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_header(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 1));
}
/* End Method: dlt_common::dlt_message_print_header */
@@ -1683,9 +1883,9 @@ TEST(t_dlt_message_print_header_with_filter, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
char openfilter[117];
@@ -1693,32 +1893,34 @@ TEST(t_dlt_message_print_header_with_filter, normal)
sprintf(openfilter, "%s/testfilter.txt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expect 0
+ /* Normal Use-Case, expect 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_init(&filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_load(&filter, openfilter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_set_filter(&file, &filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_print_header_with_filter, abnormal)
{
- // equal with t_dlt_message_print_header
+ /* equal with t_dlt_message_print_header */
}
TEST(t_dlt_message_print_header_with_filter, nullpointer)
{
- // equal with t_dlt_message_print_header
+ /* equal with t_dlt_message_print_header */
}
/* End Method: dlt_common::dlt_message_print_header with filter */
@@ -1733,58 +1935,60 @@ TEST(t_dlt_message_print_hex, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expected 0
+ /* Normal Use-Case, expected 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_print_hex, abnormal)
{
-// DltFile file;
-// static char text[DLT_DAEMON_TEXTSIZE];
+/* DltFile file; */
+/* static char text[DLT_DAEMON_TEXTSIZE]; */
-// /* Get PWD so file and filter can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* / * Get PWD so file and filter can be used* / */
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // No messages read, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
+ /* No messages read, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1)); */
- // Set verbose to 12345678
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
+ /* Set verbose to 12345678 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_print_hex, nullpointer)
{
@@ -1793,27 +1997,27 @@ TEST(t_dlt_message_print_hex, nullpointer)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // NULL-Pointer, expected -1
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL,NULL,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL,NULL,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL,NULL,DLT_DAEMON_TEXTSIZE,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL,text,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL,text,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL,text,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL,text,DLT_DAEMON_TEXTSIZE,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg,NULL,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg,NULL,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg,NULL,DLT_DAEMON_TEXTSIZE,1));
+ /* NULL-Pointer, expected -1 */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL, NULL, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL, NULL, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL, NULL, DLT_DAEMON_TEXTSIZE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL, text, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL, text, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL, text, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(NULL, text, DLT_DAEMON_TEXTSIZE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, NULL, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_hex(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 1));
}
/* End Method: dlt_common::dlt_message_print_hex */
@@ -1830,9 +2034,9 @@ TEST(t_dlt_message_print_hex_with_filter, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
char openfilter[117];
@@ -1840,32 +2044,34 @@ TEST(t_dlt_message_print_hex_with_filter, normal)
sprintf(openfilter, "%s/testfilter.txt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expect 0
+ /* Normal Use-Case, expect 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_init(&filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_load(&filter, openfilter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_set_filter(&file, &filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_hex(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_print_hex_with_filter, abnormal)
{
- // equal with t_dlt_message_print_hex
+ /* equal with t_dlt_message_print_hex */
}
TEST(t_dlt_message_print_hex_with_filter, nullpointer)
{
- // equal with t_dlt_message_print_hex
+ /* equal with t_dlt_message_print_hex */
}
/* End Method: dlt_common::dlt_message_print_hex with filter */
@@ -1880,58 +2086,60 @@ TEST(t_dlt_message_print_mixed_plain, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expected 0
+ /* Normal Use-Case, expected 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_print_mixed_plain, abnormal)
{
-// DltFile file;
-// static char text[DLT_DAEMON_TEXTSIZE];
+/* DltFile file; */
+/* static char text[DLT_DAEMON_TEXTSIZE]; */
-// /* Get PWD so file and filter can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* / * Get PWD so file and filter can be used* / */
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // No messages read, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
+ /* No messages read, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1)); */
- // Set verbose to 12345678
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
+ /* Set verbose to 12345678 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_print_mixed_plain, nullpointer)
{
@@ -1940,27 +2148,27 @@ TEST(t_dlt_message_print_mixed_plain, nullpointer)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // NULL-Pointer, expected -1
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL,NULL,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL,NULL,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL,NULL,DLT_DAEMON_TEXTSIZE,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL,text,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL,text,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL,text,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL,text,DLT_DAEMON_TEXTSIZE,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg,NULL,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg,NULL,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg,NULL,DLT_DAEMON_TEXTSIZE,1));
+ /* NULL-Pointer, expected -1 */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL, NULL, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL, NULL, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL, NULL, DLT_DAEMON_TEXTSIZE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL, text, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL, text, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL, text, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(NULL, text, DLT_DAEMON_TEXTSIZE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, NULL, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_plain(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 1));
}
/* End Method: dlt_common::dlt_message_print_mixed_pain */
@@ -1977,9 +2185,9 @@ TEST(t_dlt_message_print_mixed_plain_with_filter, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
char openfilter[117];
@@ -1987,32 +2195,34 @@ TEST(t_dlt_message_print_mixed_plain_with_filter, normal)
sprintf(openfilter, "%s/testfilter.txt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expect 0
+ /* Normal Use-Case, expect 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_init(&filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_load(&filter, openfilter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_set_filter(&file, &filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_mixed_plain(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_print_mixed_plain_with_filter, abnormal)
{
- // equal with t_dlt_message_print_mixed_plain
+ /* equal with t_dlt_message_print_mixed_plain */
}
TEST(t_dlt_message_print_mixed_plain_with_filter, nullpointer)
{
- // equal with t_dlt_message_print_mixed_plain
+ /* equal with t_dlt_message_print_mixed_plain */
}
/* End Method: dlt_common::dlt_message_print_mixed_pain with filter */
@@ -2026,58 +2236,60 @@ TEST(t_dlt_message_print_mixed_html, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expected 0
+ /* Normal Use-Case, expected 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_print_mixed_html, abnormal)
{
-// DltFile file;
-// static char text[DLT_DAEMON_TEXTSIZE];
+/* DltFile file; */
+/* static char text[DLT_DAEMON_TEXTSIZE]; */
-// /* Get PWD so file and filter can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* / * Get PWD so file and filter can be used* / */
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // No messages read, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
+ /* No messages read, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1)); */
- // Set verbose to 12345678
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
+ /* Set verbose to 12345678 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_print_mixed_html, nullpointer)
{
@@ -2086,27 +2298,27 @@ TEST(t_dlt_message_print_mixed_html, nullpointer)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // NULL-Pointer, expected -1
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL,NULL,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL,NULL,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL,NULL,DLT_DAEMON_TEXTSIZE,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL,text,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL,text,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL,text,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL,text,DLT_DAEMON_TEXTSIZE,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg,NULL,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg,NULL,DLT_DAEMON_TEXTSIZE,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg,NULL,DLT_DAEMON_TEXTSIZE,1));
+ /* NULL-Pointer, expected -1 */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL, NULL, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL, NULL, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL, NULL, DLT_DAEMON_TEXTSIZE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL, text, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL, text, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL, text, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(NULL, text, DLT_DAEMON_TEXTSIZE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, NULL, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_print_mixed_html(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 1));
}
/* End Method: dlt_common::dlt_message_print_mixed_html */
@@ -2122,9 +2334,9 @@ TEST(t_dlt_message_print_mixed_html_with_filter, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
char openfilter[117];
@@ -2132,32 +2344,34 @@ TEST(t_dlt_message_print_mixed_html_with_filter, normal)
sprintf(openfilter, "%s/testfilter.txt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expect 0
+ /* Normal Use-Case, expect 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_init(&filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_load(&filter, openfilter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_set_filter(&file, &filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_print_mixed_html(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_print_mixed_html_with_filter, abnormal)
{
- // equal with t_dlt_message_print_mixed_html
+ /* equal with t_dlt_message_print_mixed_html */
}
TEST(t_dlt_message_print_mixed_html_with_filter, nullpointer)
{
- // equal with t_dlt_message_print_mixed_html
+ /* equal with t_dlt_message_print_mixed_html */
}
/* End Method: dlt_common::dlt_message_print_mixed_html_with filter */
@@ -2172,9 +2386,9 @@ TEST(t_dlt_message_filter_check, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
char openfilter[117];
@@ -2182,55 +2396,57 @@ TEST(t_dlt_message_filter_check, normal)
sprintf(openfilter, "%s/testfilter.txt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expected > 0
+ /* Normal Use-Case, expected > 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_init(&filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_filter_load(&filter, openfilter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_set_filter(&file, &filter, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_filter_check(&file.msg, &filter, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_filter_check(&file.msg, &filter, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_filter_check, abnormal)
{
-// DltFile file;
-// DltFilter filter;
+/* DltFile file; */
+/* DltFilter filter; */
/* Get PWD so file and filter can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// char openfilter[117];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
-// sprintf(openfilter, "%s/testfilter.txt", pwd);
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* char openfilter[117]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
+/* sprintf(openfilter, "%s/testfilter.txt", pwd); */
/*---------------------------------------*/
- // No messages read, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(&file.msg, &filter, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(&file.msg, &filter, 1));
+ /* No messages read, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(&file.msg, &filter, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(&file.msg, &filter, 1)); */
- // Set verbose to 12345678
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(&file.msg, &filter, 12345678));
+ /* Set verbose to 12345678 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(&file.msg, &filter, 12345678)); */
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(&file.msg, &filter, 12345678));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(&file.msg, &filter, 12345678)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_filter_check, nullpointer)
{
@@ -2239,9 +2455,9 @@ TEST(t_dlt_message_filter_check, nullpointer)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
char openfilter[117];
@@ -2249,7 +2465,7 @@ TEST(t_dlt_message_filter_check, nullpointer)
sprintf(openfilter, "%s/testfilter.txt", pwd);
/*---------------------------------------*/
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(NULL, NULL, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(NULL, NULL, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_filter_check(NULL, &filter, 0));
@@ -2269,61 +2485,63 @@ TEST(t_dlt_message_get_extraparamters, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expect >0
+ /* Normal Use-Case, expect >0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_get_extraparameters(&file.msg, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_get_extraparameters(&file.msg, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_get_extraparamters, abnormal)
{
-// DltFile file;
+/* DltFile file; */
/* Get PWD so file and filter can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // Uninizialised, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_get_extraparameters(&file.msg, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_get_extraparameters(&file.msg, 1));
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_get_extraparameters(&file.msg, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_get_extraparameters(&file.msg, 1)); */
- // set verbose to 12345678, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_get_extraparameters(&file.msg, 12345678));
+ /* set verbose to 12345678, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_get_extraparameters(&file.msg, 12345678)); */
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_get_extraparameters(&file.msg, 12345678));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_get_extraparameters(&file.msg, 12345678)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_get_extraparamters, nullpointer)
{
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_get_extraparameters(NULL, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_get_extraparameters(NULL, 1));
}
@@ -2340,61 +2558,63 @@ TEST(t_dlt_message_header, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expect 0
+ /* Normal Use-Case, expect 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
- printf("%s \n",text);
+ printf("%s \n", text);
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
- printf("%s \n",text);
+ printf("%s \n", text);
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_header, abnormal)
{
-// DltFile file;
-// static char text[DLT_DAEMON_TEXTSIZE];
+/* DltFile file; */
+/* static char text[DLT_DAEMON_TEXTSIZE]; */
/* Get PWD so file and filter can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // Uninizialised, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1)); */
- // set verbose to 12345678, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
+ /* set verbose to 12345678, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678));
-// printf("%s \n",text);
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(&file.msg, text, DLT_DAEMON_TEXTSIZE, 12345678)); */
+/* printf("%s \n",text); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_header, nullpointer)
{
@@ -2403,15 +2623,15 @@ TEST(t_dlt_message_header, nullpointer)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(NULL, NULL, 0, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(NULL, NULL, 0, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header(NULL, NULL, DLT_DAEMON_TEXTSIZE, 0));
@@ -2436,18 +2656,18 @@ TEST(t_dlt_message_header, nullpointer)
TEST(t_dlt_message_header_flags, normal)
{
/* Possible Flags*/
- //#define DLT_HEADER_SHOW_NONE 0x0000
- //#define DLT_HEADER_SHOW_TIME 0x0001
- //#define DLT_HEADER_SHOW_TMSTP 0x0002
- //#define DLT_HEADER_SHOW_MSGCNT 0x0004
- //#define DLT_HEADER_SHOW_ECUID 0x0008
- //#define DLT_HEADER_SHOW_APID 0x0010
- //#define DLT_HEADER_SHOW_CTID 0x0020
- //#define DLT_HEADER_SHOW_MSGTYPE 0x0040
- //#define DLT_HEADER_SHOW_MSGSUBTYPE 0x0080
- //#define DLT_HEADER_SHOW_VNVSTATUS 0x0100
- //#define DLT_HEADER_SHOW_NOARG 0x0200
- //#define DLT_HEADER_SHOW_ALL 0xFFFF
+ /*#define DLT_HEADER_SHOW_NONE 0x0000 */
+ /*#define DLT_HEADER_SHOW_TIME 0x0001 */
+ /*#define DLT_HEADER_SHOW_TMSTP 0x0002 */
+ /*#define DLT_HEADER_SHOW_MSGCNT 0x0004 */
+ /*#define DLT_HEADER_SHOW_ECUID 0x0008 */
+ /*#define DLT_HEADER_SHOW_APID 0x0010 */
+ /*#define DLT_HEADER_SHOW_CTID 0x0020 */
+ /*#define DLT_HEADER_SHOW_MSGTYPE 0x0040 */
+ /*#define DLT_HEADER_SHOW_MSGSUBTYPE 0x0080 */
+ /*#define DLT_HEADER_SHOW_VNVSTATUS 0x0100 */
+ /*#define DLT_HEADER_SHOW_NOARG 0x0200 */
+ /*#define DLT_HEADER_SHOW_ALL 0xFFFF */
/*########################################*/
@@ -2456,127 +2676,153 @@ TEST(t_dlt_message_header_flags, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expected 0
+ /* Normal Use-Case, expected 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 0));
- printf("%s \n",text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 0));
+ printf("%s \n", text);
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 1));
- printf("%s \n",text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 1));
+ printf("%s \n", text);
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_header_flags, abnormal)
{
-// DltFile file;
-// static char text[DLT_DAEMON_TEXTSIZE];
+/* DltFile file; */
+/* static char text[DLT_DAEMON_TEXTSIZE]; */
-// /* Get PWD so file and filter can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];;
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* / * Get PWD so file and filter can be used* / */
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114];; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // Uninizialised, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 1));
-
- // USE own DLT_HEADER_SHOW , expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0x1234, 0));
-
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0x1234, 0));
-// printf("%s \n",text);
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 1)); */
+
+ /* USE own DLT_HEADER_SHOW , expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0x1234, 0)); */
+
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0x1234, 0)); */
+/* printf("%s \n",text); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_header_flags, nullpointer)
{
@@ -2585,15 +2831,15 @@ TEST(t_dlt_message_header_flags, nullpointer)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, 0, 0, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, 0, 0, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, 0, DLT_HEADER_SHOW_NONE, 0));
@@ -2630,8 +2876,10 @@ TEST(t_dlt_message_header_flags, nullpointer)
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 1));
@@ -2642,8 +2890,10 @@ TEST(t_dlt_message_header_flags, nullpointer)
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, 0, 0, 0));
@@ -2682,8 +2932,10 @@ TEST(t_dlt_message_header_flags, nullpointer)
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 1));
@@ -2694,8 +2946,10 @@ TEST(t_dlt_message_header_flags, nullpointer)
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(NULL, text, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, 0, 0, 0));
@@ -2726,29 +2980,51 @@ TEST(t_dlt_message_header_flags, nullpointer)
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, 0, DLT_HEADER_SHOW_ALL, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 0, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 0, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NONE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TIME, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_TMSTP, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGCNT, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ECUID, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_APID, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_CTID, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGTYPE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_MSGSUBTYPE, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_VNVSTATUS, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_NOARG, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_HEADER_SHOW_ALL, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, 0, 0, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_header_flags(&file.msg, text, 0, 0, 1));
@@ -2786,11 +3062,11 @@ TEST(t_dlt_message_header_flags, nullpointer)
TEST(t_dlt_message_payload, normal)
{
/* Types */
- //#define DLT_OUTPUT_HEX 1
- //#define DLT_OUTPUT_ASCII 2
- //#define DLT_OUTPUT_MIXED_FOR_PLAIN 3
- //#define DLT_OUTPUT_MIXED_FOR_HTML 4
- //#define DLT_OUTPUT_ASCII_LIMITED 5
+ /*#define DLT_OUTPUT_HEX 1 */
+ /*#define DLT_OUTPUT_ASCII 2 */
+ /*#define DLT_OUTPUT_MIXED_FOR_PLAIN 3 */
+ /*#define DLT_OUTPUT_MIXED_FOR_HTML 4 */
+ /*#define DLT_OUTPUT_ASCII_LIMITED 5 */
/*####################################*/
DltFile file;
@@ -2798,107 +3074,115 @@ TEST(t_dlt_message_payload, normal)
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expected 0
+ /* Normal Use-Case, expected 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_HEX, 0));
- printf("%s \n",text);
+ printf("%s \n", text);
EXPECT_LE(DLT_RETURN_OK, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 0));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 0));
- printf("%s \n",text);
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 0));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 0));
+ printf("%s \n", text);
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_HEX, 1));
- printf("%s \n",text);
+ printf("%s \n", text);
EXPECT_LE(DLT_RETURN_OK, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 1));
- printf("%s \n",text);
- EXPECT_LE(DLT_RETURN_OK, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 1));
- printf("%s \n",text);
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 1));
+ printf("%s \n", text);
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 1));
+ printf("%s \n", text);
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_payload, abnormal)
{
-// DltFile file;
-// static char text[DLT_DAEMON_TEXTSIZE];
+/* DltFile file; */
+/* static char text[DLT_DAEMON_TEXTSIZE]; */
/* Get PWD so file and filter can be used*/
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // Uninizialised, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_HEX, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_HEX, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 1));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 1));
-
- // USE own DLT_HEADER_SHOW , expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, 99, 0));
-
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, 99, 0));
-// printf("%s \n",text);
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
-
- // set verbose to 12345678
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_HEX, 12345678));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, 12345678));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 12345678));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 12345678));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 12345678));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_HEX, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_HEX, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 1)); */
+
+ /* USE own DLT_HEADER_SHOW , expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, 99, 0)); */
+
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, 99, 0)); */
+/* printf("%s \n",text); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
+
+ /* set verbose to 12345678 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_HEX, 12345678)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, 12345678)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 12345678)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 12345678)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 12345678)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_payload, nullpointer)
{
DltFile file;
static char text[DLT_DAEMON_TEXTSIZE];
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(NULL, NULL, 0, 0, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(NULL, NULL, 0, 0, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(NULL, NULL, 0, DLT_OUTPUT_HEX, 0));
@@ -2963,13 +3247,17 @@ TEST(t_dlt_message_payload, nullpointer)
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, 0, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_HEX, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 0));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_HEX, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_PLAIN, 1));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_MIXED_FOR_HTML, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, NULL, DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII_LIMITED, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, 0, 0, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, 0, 0, 1));
@@ -2984,14 +3272,14 @@ TEST(t_dlt_message_payload, nullpointer)
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, 0, DLT_OUTPUT_MIXED_FOR_HTML, 1));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, 0, DLT_OUTPUT_ASCII_LIMITED, 1));
- // file.msg is not initialised which causes problems when textsize is > 0 but
- // we don't have text:
- // dlt_common.c line 943: ptr = msg->databuffer;
- // (gdb) p ptr
- // $28 = (uint8_t *) 0x5124010337d46c00 <error: Cannot access memory at address 0x5124010337d46c00>
+ /* file.msg is not initialised which causes problems when textsize is > 0 but */
+ /* we don't have text: */
+ /* dlt_common.c line 943: ptr = msg->databuffer; */
+ /* (gdb) p ptr */
+ /* $28 = (uint8_t *) 0x5124010337d46c00 <error: Cannot access memory at address 0x5124010337d46c00> */
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0, 1));
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_payload(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0, 1)); */
}
/* End Method:dlt_common::dlt_message_payload */
@@ -3004,58 +3292,60 @@ TEST(t_dlt_message_set_extraparamters, normal)
DltFile file;
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
/*---------------------------------------*/
- // Normal Use-Case, expect 0
+ /* Normal Use-Case, expect 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_set_extraparameters(&file.msg, 0));
}
- for(int i=0;i<file.counter;i++)
- {
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_message_set_extraparameters(&file.msg, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_set_extraparamters, abnormal)
{
-// DltFile file;
-// // Get PWD so file and filter can be used
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
+/* DltFile file; */
+/* // Get PWD so file and filter can be used */
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
/*---------------------------------------*/
- // Uninizialised, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_set_extraparameters(&file.msg, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_set_extraparameters(&file.msg, 1));
-
- // set verbos to 12345678
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_set_extraparameters(&file.msg, 12345678));
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_set_extraparameters(&file.msg, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_set_extraparameters(&file.msg, 1)); */
+
+ /* set verbos to 12345678 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_set_extraparameters(&file.msg, 12345678)); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_set_extraparamters, nullpointer)
{
- // NULL-Pointer, expect -1
+ /* NULL-Pointer, expect -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_set_extraparameters(NULL, 0));
EXPECT_GE(DLT_RETURN_ERROR, dlt_message_set_extraparameters(NULL, 1));
}
@@ -3069,11 +3359,11 @@ TEST(t_dlt_message_set_extraparamters, nullpointer)
TEST(t_dlt_message_read, normal)
{
DltFile file;
- // Get PWD so file can be used
+ /* Get PWD so file can be used */
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
@@ -3082,40 +3372,46 @@ TEST(t_dlt_message_read, normal)
DltBuffer buf;
char *buffer = NULL;
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
- EXPECT_LE(DLT_RETURN_ERROR, dlt_message_read(&file.msg,(unsigned char*) buffer,255,0,1));
+ EXPECT_LE(DLT_RETURN_ERROR, dlt_message_read(&file.msg, (unsigned char *)buffer, 255, 0, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
- EXPECT_LE(DLT_RETURN_OK, dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE, DLT_USER_RINGBUFFER_STEP_SIZE));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_buffer_init_dynamic(&buf, DLT_USER_RINGBUFFER_MIN_SIZE, DLT_USER_RINGBUFFER_MAX_SIZE,
+ DLT_USER_RINGBUFFER_STEP_SIZE));
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
- EXPECT_LE(DLT_RETURN_ERROR, dlt_message_read(&file.msg,(unsigned char *) buffer,255,1,1));
+ EXPECT_LE(DLT_RETURN_ERROR, dlt_message_read(&file.msg, (unsigned char *)buffer, 255, 1, 1));
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_buffer_free_dynamic(&buf));
}
TEST(t_dlt_message_read, abnormal)
-{
-
-}
+{}
TEST(t_dlt_message_read, nullpointer)
{
DltFile file;
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
@@ -3123,11 +3419,11 @@ TEST(t_dlt_message_read, nullpointer)
DltBuffer buf;
- // NULL_Pointer, expected -1
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_read(NULL, NULL, 0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_read(NULL, (uint8_t *)&buf, 0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_read(&file.msg, NULL, 0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_read(&file.msg, (uint8_t *)&buf, 0,0,0));
+ /* NULL_Pointer, expected -1 */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_read(NULL, NULL, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_read(NULL, (uint8_t *)&buf, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_read(&file.msg, NULL, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_read(&file.msg, (uint8_t *)&buf, 0, 0, 0));
}
/* End Method:dlt_common::dlt_message_read */
@@ -3141,9 +3437,9 @@ TEST(t_dlt_message_argument_print, normal)
DltFile file;
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
@@ -3154,80 +3450,88 @@ TEST(t_dlt_message_argument_print, normal)
uint8_t **pptr;
int32_t *pdatalength;
- // Normal Use-Case, expect 0
+ /* Normal Use-Case, expect 0 */
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
ptr = file.msg.databuffer;
datalength = file.msg.datasize;
pptr = &ptr;
pdatalength = &datalength;
- EXPECT_GE(DLT_RETURN_OK, dlt_message_argument_print(&file.msg,DLT_TYPE_INFO_BOOL,pptr,pdatalength,text,DLT_DAEMON_TEXTSIZE,0,1));
- //printf("### ARGUMENT:%s\n", text);
+ EXPECT_GE(DLT_RETURN_OK,
+ dlt_message_argument_print(&file.msg, DLT_TYPE_INFO_BOOL, pptr, pdatalength, text,
+ DLT_DAEMON_TEXTSIZE, 0, 1));
+ /*printf("### ARGUMENT:%s\n", text); */
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
- while (dlt_file_read(&file,0)>=0){}
- for(int i=0;i<file.counter;i++)
- {
+
+ while (dlt_file_read(&file, 0) >= 0) {}
+
+ for (int i = 0; i < file.counter; i++) {
EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
ptr = file.msg.databuffer;
datalength = file.msg.datasize;
pptr = &ptr;
pdatalength = &datalength;
- EXPECT_GE(DLT_RETURN_OK, dlt_message_argument_print(&file.msg,DLT_TYPE_INFO_RAWD,pptr,pdatalength,text,DLT_DAEMON_TEXTSIZE,0,1));
- //printf("### ARGUMENT:%s\n", text);
+ EXPECT_GE(DLT_RETURN_OK,
+ dlt_message_argument_print(&file.msg, DLT_TYPE_INFO_RAWD, pptr, pdatalength, text,
+ DLT_DAEMON_TEXTSIZE, 0, 1));
+ /*printf("### ARGUMENT:%s\n", text); */
}
+
EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
}
TEST(t_dlt_message_argument_print, abnormal)
{
-// DltFile file;
- // Get PWD so file and filter can be used
-// char pwd[100];
-// getcwd(pwd, 100);
-// char openfile[114];
-// sprintf(openfile, "%s/testfile.dlt", pwd);
-// static char text[DLT_DAEMON_TEXTSIZE];
+/* DltFile file; */
+ /* Get PWD so file and filter can be used */
+/* char pwd[100]; */
+/* getcwd(pwd, 100); */
+/* char openfile[114]; */
+/* sprintf(openfile, "%s/testfile.dlt", pwd); */
+/* static char text[DLT_DAEMON_TEXTSIZE]; */
/*---------------------------------------*/
-// uint8_t *ptr;
-// int32_t datalength;
-// uint8_t **pptr;
-// int32_t *pdatalength;
-
- // Uninizialised, expected -1
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,12345678,pptr,pdatalength,text,DLT_DAEMON_TEXTSIZE,0,1));
-
- // Use a non defined type_info, expected -1
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0));
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0));
-// while (dlt_file_read(&file,0)>=0){}
-// for(int i=0;i<file.counter;i++)
-// {
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0));
-// ptr = file.msg.databuffer;
-// datalength = file.msg.datasize;
-// pptr = &ptr;
-// pdatalength = &datalength;
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,12345678,pptr,pdatalength,text,DLT_DAEMON_TEXTSIZE,0,1));
-// //printf("### ARGUMENT:%s\n", text);
-// }
-// EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0));
+/* uint8_t *ptr; */
+/* int32_t datalength; */
+/* uint8_t **pptr; */
+/* int32_t *pdatalength; */
+
+ /* Uninizialised, expected -1 */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,12345678,pptr,pdatalength,text,DLT_DAEMON_TEXTSIZE,0,1)); */
+
+ /* Use a non defined type_info, expected -1 */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); */
+/* while (dlt_file_read(&file,0)>=0){} */
+/* for(int i=0;i<file.counter;i++) */
+/* { */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_message(&file, i, 0)); */
+/* ptr = file.msg.databuffer; */
+/* datalength = file.msg.datasize; */
+/* pptr = &ptr; */
+/* pdatalength = &datalength; */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,12345678,pptr,pdatalength,text,DLT_DAEMON_TEXTSIZE,0,1)); */
+/* //printf("### ARGUMENT:%s\n", text); */
+/* } */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); */
}
TEST(t_dlt_message_argument_print, nullpointer)
{
DltFile file;
/* Get PWD so file can be used*/
char pwd[100];
- char openfile[114];
+ char openfile[114];
- // ignore returned value from getcwd
+ /* ignore returned value from getcwd */
if (getcwd(pwd, 100) == NULL) {}
sprintf(openfile, "%s/testfile.dlt", pwd);
@@ -3240,23 +3544,23 @@ TEST(t_dlt_message_argument_print, nullpointer)
pptr = &ptr;
pdatalength = &datalength;
- // NULL-Pointer, expected -1
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL,0,NULL,NULL,NULL,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL,0,NULL,NULL,text,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL,0,NULL,pdatalength,NULL,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL,0,NULL,pdatalength,text,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL,0,pptr,NULL,NULL,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL,0,pptr,NULL,text,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL,0,pptr,pdatalength,NULL,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL,0,pptr,pdatalength,text,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,0,NULL,NULL,NULL,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,0,NULL,NULL,text,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,0,NULL,pdatalength,NULL,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,0,NULL,pdatalength,text,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,0,pptr,NULL,NULL,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,0,pptr,NULL,text,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,0,pptr,pdatalength,NULL,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg,0,pptr,pdatalength,text,0,0,0));
+ /* NULL-Pointer, expected -1 */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL, 0, NULL, NULL, NULL, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL, 0, NULL, NULL, text, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL, 0, NULL, pdatalength, NULL, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL, 0, NULL, pdatalength, text, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL, 0, pptr, NULL, NULL, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL, 0, pptr, NULL, text, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL, 0, pptr, pdatalength, NULL, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(NULL, 0, pptr, pdatalength, text, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg, 0, NULL, NULL, NULL, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg, 0, NULL, NULL, text, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg, 0, NULL, pdatalength, NULL, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg, 0, NULL, pdatalength, text, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg, 0, pptr, NULL, NULL, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg, 0, pptr, NULL, text, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg, 0, pptr, pdatalength, NULL, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_message_argument_print(&file.msg, 0, pptr, pdatalength, text, 0, 0, 0));
}
/* End Method:dlt_common::dlt_message_argument_print */
@@ -3274,13 +3578,13 @@ TEST(t_dlt_message_argument_print, nullpointer)
TEST(t_dlt_log_set_level, normal)
{
/* Possible Falgs */
- // DLT_LOG_TO_CONSOLE=0,
- // DLT_LOG_TO_SYSLOG=1,
- // DLT_LOG_TO_FILE=2,
- // DLT_LOG_DROPPED=3
- //#######################
+ /* DLT_LOG_TO_CONSOLE=0, */
+ /* DLT_LOG_TO_SYSLOG=1, */
+ /* DLT_LOG_TO_FILE=2, */
+ /* DLT_LOG_DROPPED=3 */
+ /*####################### */
- // Normal Use-Case, expcect 0-3
+ /* Normal Use-Case, expcect 0-3 */
EXPECT_NO_THROW(dlt_log_set_level(DLT_LOG_TO_CONSOLE));
EXPECT_NO_THROW(dlt_log_set_level(DLT_LOG_TO_SYSLOG));
EXPECT_NO_THROW(dlt_log_set_level(DLT_LOG_TO_FILE));
@@ -3288,12 +3592,12 @@ TEST(t_dlt_log_set_level, normal)
}
TEST(t_dlt_log_set_level, abnormal)
{
- // actual no test cases
- // because of void method and missing gtest function
+ /* actual no test cases */
+ /* because of void method and missing gtest function */
}
TEST(t_dlt_log_set_level, nullpointer)
{
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
}
/* End Method:dlt_common::dlt_log_set_level */
@@ -3304,18 +3608,18 @@ TEST(t_dlt_log_set_level, nullpointer)
/* Begin MEthod:dlt_common::dlt_log_set_filename */
TEST(dlt_log_set_filename, normal)
{
- // Normal Use-Case, exptected PATH
- const char * filename = "/tmp/dlt.log";
+ /* Normal Use-Case, exptected PATH */
+ const char *filename = "/tmp/dlt.log";
EXPECT_NO_THROW(dlt_log_set_filename(filename));
}
TEST(dlt_log_set_filename, abnormal)
{
- // actual no test cases
- // because of void method and missing gtest function
+ /* actual no test cases */
+ /* because of void method and missing gtest function */
}
TEST(dlt_log_set_filename, nullpointer)
{
- // NULL-Pointer, expected -1 or "no file"
+ /* NULL-Pointer, expected -1 or "no file" */
EXPECT_NO_THROW(dlt_log_set_filename(NULL));
}
/* End MEthod:dlt_common::dlt_log_set_filename */
@@ -3327,13 +3631,13 @@ TEST(dlt_log_set_filename, nullpointer)
TEST(t_dlt_log_init, normal)
{
/* Possible Falgs */
- // DLT_LOG_TO_CONSOLE=0,
- // DLT_LOG_TO_SYSLOG=1,
- // DLT_LOG_TO_FILE=2,
- // DLT_LOG_DROPPED=3
- //#######################
+ /* DLT_LOG_TO_CONSOLE=0, */
+ /* DLT_LOG_TO_SYSLOG=1, */
+ /* DLT_LOG_TO_FILE=2, */
+ /* DLT_LOG_DROPPED=3 */
+ /*####################### */
- // Normal Use-Case, exptect 0-3
+ /* Normal Use-Case, exptect 0-3 */
EXPECT_NO_THROW(dlt_log_init(DLT_LOG_TO_CONSOLE));
EXPECT_NO_THROW(dlt_log_init(DLT_LOG_TO_SYSLOG));
EXPECT_NO_THROW(dlt_log_set_filename("/tmp/dlt.log"));
@@ -3343,12 +3647,12 @@ TEST(t_dlt_log_init, normal)
}
TEST(t_dlt_log_init, abnormal)
{
- // actual no test cases
- // because of void method and missing gtest function
+ /* actual no test cases */
+ /* because of void method and missing gtest function */
}
TEST(t_dlt_log_init, nullpointer)
{
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
}
/* End Method: dlt_common::dlt_log_init */
@@ -3359,25 +3663,25 @@ TEST(t_dlt_log_init, nullpointer)
TEST(t_dlt_log_free, normal)
{
/* Possible Falgs */
- // DLT_LOG_TO_CONSOLE=0,
- // DLT_LOG_TO_SYSLOG=1,
- // DLT_LOG_TO_FILE=2,
- // DLT_LOG_DROPPED=3
- //#######################
+ /* DLT_LOG_TO_CONSOLE=0, */
+ /* DLT_LOG_TO_SYSLOG=1, */
+ /* DLT_LOG_TO_FILE=2, */
+ /* DLT_LOG_DROPPED=3 */
+ /*####################### */
- // Normal Use-Case, expected 0
+ /* Normal Use-Case, expected 0 */
EXPECT_NO_THROW(dlt_log_init(DLT_LOG_TO_CONSOLE));
EXPECT_NO_THROW(dlt_log_init(DLT_LOG_TO_SYSLOG));
EXPECT_NO_THROW(dlt_log_init(DLT_LOG_DROPPED));
}
TEST(t_dlt_log_free, abnormal)
{
- // actual no test cases
- // because of void method and missing gtest function
+ /* actual no test cases */
+ /* because of void method and missing gtest function */
}
TEST(t_dlt_log_free, nullpointer)
{
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
}
/* End Method:dlt_common::dlt_log_free */
@@ -3388,55 +3692,55 @@ TEST(t_dlt_log_free, nullpointer)
TEST(t_dlt_log, normal)
{
/* Possible Falgs */
- // #define LOG_EMERG 0
- // #define LOG_ALERT 1
- // #define LOG_CRIT 2
- // #define LOG_ERR 3
- // #define LOG_WARNING 4
- // #define LOG_NOTICE 5
- // #define LOG_INFO 6
- // #define LOG_DEBUG 7
-
- const char * EMERG = "SYSLOG EMERG\n";
- const char * ALERT = "SYSLOG ALERT\n";
- const char * CRIT = "SYSLOG CRIT\n";
- const char * ERR = "SYSLOG ERR\n";
- const char * WARNING = "SYSLOG WARNING\n";
- const char * NOTICE = "SYSLOG NOTICE\n";
- const char * INFO = "SYSLOG INFO\n";
- const char * DEBUG = "SYSLOG DEBUG\n";
-
- // Normal Use-Case, expected 0
+ /* #define LOG_EMERG 0 */
+ /* #define LOG_ALERT 1 */
+ /* #define LOG_CRIT 2 */
+ /* #define LOG_ERR 3 */
+ /* #define LOG_WARNING 4 */
+ /* #define LOG_NOTICE 5 */
+ /* #define LOG_INFO 6 */
+ /* #define LOG_DEBUG 7 */
+
+ const char *EMERG = "SYSLOG EMERG\n";
+ const char *ALERT = "SYSLOG ALERT\n";
+ const char *CRIT = "SYSLOG CRIT\n";
+ const char *ERR = "SYSLOG ERR\n";
+ const char *WARNING = "SYSLOG WARNING\n";
+ const char *NOTICE = "SYSLOG NOTICE\n";
+ const char *INFO = "SYSLOG INFO\n";
+ const char *DEBUG = "SYSLOG DEBUG\n";
+
+ /* Normal Use-Case, expected 0 */
dlt_log_init(DLT_LOG_TO_CONSOLE);
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_EMERG, (char *) EMERG));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_ALERT, (char *) ALERT));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_CRIT, (char *) CRIT));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_ERR, (char *) ERR));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_WARNING, (char *) WARNING));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_NOTICE, (char *) NOTICE));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_INFO, (char *) INFO));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_DEBUG, (char *) DEBUG));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_EMERG, (char *)EMERG));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_ALERT, (char *)ALERT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_CRIT, (char *)CRIT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_ERR, (char *)ERR));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_WARNING, (char *)WARNING));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_NOTICE, (char *)NOTICE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_INFO, (char *)INFO));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_DEBUG, (char *)DEBUG));
dlt_log_init(DLT_LOG_DROPPED);
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_EMERG, (char *) EMERG));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_ALERT, (char *) ALERT));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_CRIT, (char *) CRIT));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_ERR, (char *) ERR));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_WARNING, (char *) WARNING));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_NOTICE, (char *) NOTICE));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_INFO, (char *) INFO));
- EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_DEBUG, (char *) DEBUG));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_EMERG, (char *)EMERG));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_ALERT, (char *)ALERT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_CRIT, (char *)CRIT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_ERR, (char *)ERR));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_WARNING, (char *)WARNING));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_NOTICE, (char *)NOTICE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_INFO, (char *)INFO));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log(LOG_DEBUG, (char *)DEBUG));
}
TEST(t_dlt_log, abnormal)
{
- // LOG MODE don't exists, expected -1
-// int DLT_LOG_DONT_EXISTS = 123456789;
-// const char * EXIST = "SYSLOG DONT EXISTS\n";
-// EXPECT_GE(DLT_RETURN_ERROR, dlt_log(DLT_LOG_DONT_EXISTS, (char *) EXIST));
+ /* LOG MODE don't exists, expected -1 */
+/* int DLT_LOG_DONT_EXISTS = 123456789; */
+/* const char * EXIST = "SYSLOG DONT EXISTS\n"; */
+/* EXPECT_GE(DLT_RETURN_ERROR, dlt_log(DLT_LOG_DONT_EXISTS, (char *) EXIST)); */
}
TEST(t_dlt_log, nullpointer)
{
- // NULL-Pointer, expected -1
+ /* NULL-Pointer, expected -1 */
EXPECT_GE(DLT_RETURN_ERROR, dlt_log(0, NULL));
}
/* End Method: dlt_common::dlt_log_init_init */
@@ -3456,13 +3760,9 @@ TEST(t_dlt_uptime, normal)
EXPECT_LE(1, dlt_uptime());
}
TEST(t_dlt_uptime, abnormal)
-{
-
-}
+{}
TEST(t_dlt_uptime, nullpointer)
-{
-
-}
+{}
/* End Method:dlt_common::dlt_uptime */
@@ -3471,22 +3771,22 @@ TEST(t_dlt_uptime, nullpointer)
/* Begin Method:dlt_common::dlt_set_id */
TEST(t_dlt_set_id, normal)
{
-// char id[4];
-// const char * text = "DLTD";
-// dlt_set_id(id, text);
-// EXPECT_STREQ(text, id);
+/* char id[4]; */
+/* const char * text = "DLTD"; */
+/* dlt_set_id(id, text); */
+/* EXPECT_STREQ(text, id); */
}
TEST(t_dlt_set_id, abnormal)
{
-// char id[10];
-// const char * text = "1234567890";
-// dlt_set_id(id, text);
-// EXPECT_STRNE(text, id);
+/* char id[10]; */
+/* const char * text = "1234567890"; */
+/* dlt_set_id(id, text); */
+/* EXPECT_STRNE(text, id); */
}
TEST(t_dlt_set_id, nullpointer)
{
char id[4];
- const char * text = "TEST";
+ const char *text = "TEST";
EXPECT_NO_THROW(dlt_set_id(NULL, NULL));
EXPECT_NO_THROW(dlt_set_id(NULL, text));
@@ -3500,103 +3800,105 @@ TEST(t_dlt_set_id, nullpointer)
/* Begin Method:dlt_common::dlt_print_hex_string */
TEST(t_dlt_print_hex_string, normal)
{
- // Normal Use-Case, exptect 0
- const char * test1 = "HELLO_HEX";
+ /* Normal Use-Case, exptect 0 */
+ const char *test1 = "HELLO_HEX";
char text1[DLT_DAEMON_TEXTSIZE];
EXPECT_LE(DLT_RETURN_OK, dlt_print_hex_string(text1, DLT_DAEMON_TEXTSIZE, (unsigned char *)test1, strlen(test1)));
- //printf("text:%s\n", text1);
- // convert text1 to an ascii string to compare with the original
- char * converted = (char*) malloc(strlen(test1) +1);
+ /*printf("text:%s\n", text1); */
+ /* convert text1 to an ascii string to compare with the original */
+ char *converted = (char *)malloc(strlen(test1) + 1);
int t = 0;
- for(unsigned int i=0;i<strlen(text1);i+=3)
- {
- char tmp[3] = {'\0'};
+
+ for (unsigned int i = 0; i < strlen(text1); i += 3) {
+ char tmp[3] = { '\0' };
tmp[0] = text1[i];
- tmp[1] = text1[i+1];
- char k = (int) strtol(tmp, NULL, 16);
- converted[i-t] = k;
- t +=2;
+ tmp[1] = text1[i + 1];
+ char k = (int)strtol(tmp, NULL, 16);
+ converted[i - t] = k;
+ t += 2;
}
+
converted[strlen(test1)] = '\0';
- //printf("%s\n", converted);
+ /*printf("%s\n", converted); */
EXPECT_STREQ(test1, converted);
free(converted);
- const char * test2 = "qwertzuiopasdfghjklyxcvbnm1234567890";
+ const char *test2 = "qwertzuiopasdfghjklyxcvbnm1234567890";
char text2[DLT_DAEMON_TEXTSIZE];
- EXPECT_LE(DLT_RETURN_OK, dlt_print_hex_string(text2,DLT_DAEMON_TEXTSIZE,(unsigned char *)test2, strlen(test2)));
- //printf("text:%s\n", text2);
- // convert text2 to an ascii string to compare with the original
- converted = (char*) malloc(strlen(test2) +1);
+ EXPECT_LE(DLT_RETURN_OK, dlt_print_hex_string(text2, DLT_DAEMON_TEXTSIZE, (unsigned char *)test2, strlen(test2)));
+ /*printf("text:%s\n", text2); */
+ /* convert text2 to an ascii string to compare with the original */
+ converted = (char *)malloc(strlen(test2) + 1);
t = 0;
- for(unsigned int i=0;i<strlen(text2);i+=3)
- {
- char tmp[3] = {'\0'};
+
+ for (unsigned int i = 0; i < strlen(text2); i += 3) {
+ char tmp[3] = { '\0' };
tmp[0] = text2[i];
- tmp[1] = text2[i+1];
- char k = (int) strtol(tmp, NULL, 16);
- converted[i-t] = k;
- t +=2;
+ tmp[1] = text2[i + 1];
+ char k = (int)strtol(tmp, NULL, 16);
+ converted[i - t] = k;
+ t += 2;
}
+
converted[strlen(test2)] = '\0';
- //printf("%s\n", converted);
+ /*printf("%s\n", converted); */
EXPECT_STREQ(test2, converted);
free(converted);
}
TEST(t_dlt_print_hex_string, abnormal)
{
- // print special characters, expected 0
-// const char * test3 = "^°!\"§$%&/()=?`´¹²³¼½¬{[]}\\¸@€üöä+#*'~`,.-;:_·…–<>|";
-// char text3[DLT_DAEMON_TEXTSIZE];
-// EXPECT_LE(DLT_RETURN_OK, dlt_print_hex_string(text3,DLT_DAEMON_TEXTSIZE,(unsigned char *)test3, strlen(test3)));
- //printf("text:%s\n", text3);
- // convert text3 to an ascii string to compare with the original
-// char * converted = (char*) malloc(strlen(test3) +1);
-// int t = 0;
-// for(unsigned int i=0;i<strlen(text3);i+=3)
-// {
-// char tmp[2];
-// tmp[0] = text3[i];
-// tmp[1] = text3[i+1];
-// char k = (int) strtol(tmp, NULL, 16);
-// converted[i-t] = k;
-// t +=2;
-// }
-// converted[strlen(test3)] = '\0';
- //printf("%s\n", converted);
-// EXPECT_STREQ(test3, converted);
-// free(converted);
-
- // Empty char *, expect 0
-// const char * test4 = "";
-// char text4[DLT_DAEMON_TEXTSIZE];
-// EXPECT_LE(DLT_RETURN_OK, dlt_print_hex_string(text4,DLT_DAEMON_TEXTSIZE,(unsigned char *)test4, strlen(test4)));
- //printf("text:%s\n", text4);
- // convert text4 to an ascii string to compare with the original
-// converted = (char*) malloc(strlen(test4) +1);
-// t = 0;
-// for(unsigned int i=0;i<strlen(text4);i+=3)
-// {
-// char tmp[2];
-// tmp[0] = text4[i];
-// tmp[1] = text4[i+1];
-// char k = (int) strtol(tmp, NULL, 16);
-// converted[i-t] = k;
-// t +=2;
-// }
-// converted[strlen(test4)] = '\0';
- //printf("%s\n", converted);
-// EXPECT_STREQ(test4, converted);
-// free(converted);
+ /* print special characters, expected 0 */
+/* const char * test3 = "^°!\"§$%&/()=?`´¹²³¼½¬{[]}\\¸@€üöä+#*'~`,.-;:_·…–<>|"; */
+/* char text3[DLT_DAEMON_TEXTSIZE]; */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_print_hex_string(text3,DLT_DAEMON_TEXTSIZE,(unsigned char *)test3, strlen(test3))); */
+ /*printf("text:%s\n", text3); */
+ /* convert text3 to an ascii string to compare with the original */
+/* char * converted = (char*) malloc(strlen(test3) +1); */
+/* int t = 0; */
+/* for(unsigned int i=0;i<strlen(text3);i+=3) */
+/* { */
+/* char tmp[2]; */
+/* tmp[0] = text3[i]; */
+/* tmp[1] = text3[i+1]; */
+/* char k = (int) strtol(tmp, NULL, 16); */
+/* converted[i-t] = k; */
+/* t +=2; */
+/* } */
+/* converted[strlen(test3)] = '\0'; */
+ /*printf("%s\n", converted); */
+/* EXPECT_STREQ(test3, converted); */
+/* free(converted); */
+
+ /* Empty char *, expect 0 */
+/* const char * test4 = ""; */
+/* char text4[DLT_DAEMON_TEXTSIZE]; */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_print_hex_string(text4,DLT_DAEMON_TEXTSIZE,(unsigned char *)test4, strlen(test4))); */
+ /*printf("text:%s\n", text4); */
+ /* convert text4 to an ascii string to compare with the original */
+/* converted = (char*) malloc(strlen(test4) +1); */
+/* t = 0; */
+/* for(unsigned int i=0;i<strlen(text4);i+=3) */
+/* { */
+/* char tmp[2]; */
+/* tmp[0] = text4[i]; */
+/* tmp[1] = text4[i+1]; */
+/* char k = (int) strtol(tmp, NULL, 16); */
+/* converted[i-t] = k; */
+/* t +=2; */
+/* } */
+/* converted[strlen(test4)] = '\0'; */
+ /*printf("%s\n", converted); */
+/* EXPECT_STREQ(test4, converted); */
+/* free(converted); */
}
TEST(t_dlt_print_hex_string, nullpointer)
{
- const char * test5 = "HELLO";
+ const char *test5 = "HELLO";
char text5[DLT_DAEMON_TEXTSIZE];
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_hex_string(NULL,0,NULL, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_hex_string(NULL,0,(unsigned char *)test5, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_hex_string(text5,0,NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_hex_string(NULL, 0, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_hex_string(NULL, 0, (unsigned char *)test5, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_hex_string(text5, 0, NULL, 0));
}
/* End Method:dlt_common::dlt_print_hex_string */
@@ -3606,59 +3908,63 @@ TEST(t_dlt_print_hex_string, nullpointer)
/* Begin Method:dlt_common::dlt_print_mixed_string */
TEST(t_dlt_print_mixed_string, normal)
{
- const char * test1 = "HELLO_MIXED";
+ const char *test1 = "HELLO_MIXED";
char text1[DLT_DAEMON_TEXTSIZE];
- EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text1,DLT_DAEMON_TEXTSIZE,(unsigned char *)test1,strlen(test1),0));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_print_mixed_string(text1, DLT_DAEMON_TEXTSIZE, (unsigned char *)test1, strlen(test1), 0));
printf("%s\n", text1);
- const char * test2 = "HELLO_MIXED";
+ const char *test2 = "HELLO_MIXED";
char text2[DLT_DAEMON_TEXTSIZE];
- EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text2,DLT_DAEMON_TEXTSIZE,(unsigned char *)test2,strlen(test2),1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_print_mixed_string(text2, DLT_DAEMON_TEXTSIZE, (unsigned char *)test2, strlen(test2), 1));
printf("%s\n", text2);
- const char * test3 = "qwertzuiopasdfghjklyxcvbnm1234567890";
+ const char *test3 = "qwertzuiopasdfghjklyxcvbnm1234567890";
char text3[DLT_DAEMON_TEXTSIZE];
- EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text3,DLT_DAEMON_TEXTSIZE,(unsigned char *)test3,strlen(test3),0));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_print_mixed_string(text3, DLT_DAEMON_TEXTSIZE, (unsigned char *)test3, strlen(test3), 0));
printf("%s\n", text3);
- const char * test4 = "qwertzuiopasdfghjklyxcvbnm1234567890";
+ const char *test4 = "qwertzuiopasdfghjklyxcvbnm1234567890";
char text4[DLT_DAEMON_TEXTSIZE];
- EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text4,DLT_DAEMON_TEXTSIZE,(unsigned char *)test4,strlen(test4),1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_print_mixed_string(text4, DLT_DAEMON_TEXTSIZE, (unsigned char *)test4, strlen(test4), 1));
printf("%s\n", text4);
}
TEST(t_dlt_print_mixed_string, abnormal)
{
-// const char * test5 = "^°!\"§$%&/()=?`´¹²³¼½¬{[]}\\¸@€üöä+#*'~`,.-;:_·…–<>|";
-// char text5[DLT_DAEMON_TEXTSIZE];
-// EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text5,DLT_DAEMON_TEXTSIZE,(unsigned char *)test5,strlen(test5),0));
-// printf("%s\n", text5);
+/* const char * test5 = "^°!\"§$%&/()=?`´¹²³¼½¬{[]}\\¸@€üöä+#*'~`,.-;:_·…–<>|"; */
+/* char text5[DLT_DAEMON_TEXTSIZE]; */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text5,DLT_DAEMON_TEXTSIZE,(unsigned char *)test5,strlen(test5),0)); */
+/* printf("%s\n", text5); */
-// const char * test6 = "^°!\"§$%&/()=?`´¹²³¼½¬{[]}\\¸@€üöä+#*'~`,.-;:_·…–<>|";
-// char text6[DLT_DAEMON_TEXTSIZE];
-// EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text6,DLT_DAEMON_TEXTSIZE,(unsigned char *)test6,strlen(test6),1));
-// printf("%s\n", text6);
+/* const char * test6 = "^°!\"§$%&/()=?`´¹²³¼½¬{[]}\\¸@€üöä+#*'~`,.-;:_·…–<>|"; */
+/* char text6[DLT_DAEMON_TEXTSIZE]; */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text6,DLT_DAEMON_TEXTSIZE,(unsigned char *)test6,strlen(test6),1)); */
+/* printf("%s\n", text6); */
-// const char * test7 = "";
-// char text7[DLT_DAEMON_TEXTSIZE];
-// EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text7,DLT_DAEMON_TEXTSIZE,(unsigned char *)test7,strlen(test7),0));
-// printf("%s\n", text7);
+/* const char * test7 = ""; */
+/* char text7[DLT_DAEMON_TEXTSIZE]; */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text7,DLT_DAEMON_TEXTSIZE,(unsigned char *)test7,strlen(test7),0)); */
+/* printf("%s\n", text7); */
-// const char * test8 = "";
-// char text8[DLT_DAEMON_TEXTSIZE];
-// EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text8,DLT_DAEMON_TEXTSIZE,(unsigned char *)test8,strlen(test8),1));
-// printf("%s\n", text8);
+/* const char * test8 = ""; */
+/* char text8[DLT_DAEMON_TEXTSIZE]; */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_print_mixed_string(text8,DLT_DAEMON_TEXTSIZE,(unsigned char *)test8,strlen(test8),1)); */
+/* printf("%s\n", text8); */
}
TEST(t_dlt_print_mixed_string, nullpointer)
{
- const char * test9 = "";
+ const char *test9 = "";
char text9[DLT_DAEMON_TEXTSIZE];
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(NULL,0,0,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(NULL,0,0,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(NULL,0,(unsigned char *)test9,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(NULL,0,(unsigned char *)test9,0,1));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(text9,0,NULL,0,0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(text9,0,NULL,0,1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(NULL, 0, 0, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(NULL, 0, 0, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(NULL, 0, (unsigned char *)test9, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(NULL, 0, (unsigned char *)test9, 0, 1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(text9, 0, NULL, 0, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_mixed_string(text9, 0, NULL, 0, 1));
}
/* End Method:dlt_common::dlt_print_mixed_string */
@@ -3668,48 +3974,48 @@ TEST(t_dlt_print_mixed_string, nullpointer)
/* Begin Method:dlt_common::dlt_print_char_string */
TEST(t_dlt_print_char_string, normal)
{
- // Normal Use-Case, expect 0
- const char * test1 = "HELLO";
+ /* Normal Use-Case, expect 0 */
+ const char *test1 = "HELLO";
char text1[DLT_DAEMON_TEXTSIZE];
- char * ptr1 = text1;
- EXPECT_LE(DLT_RETURN_OK, dlt_print_char_string(&ptr1,DLT_DAEMON_TEXTSIZE,(unsigned char *)test1, strlen(test1)));
+ char *ptr1 = text1;
+ EXPECT_LE(DLT_RETURN_OK, dlt_print_char_string(&ptr1, DLT_DAEMON_TEXTSIZE, (unsigned char *)test1, strlen(test1)));
printf("text:%s\n", text1);
EXPECT_STREQ(text1, test1);
- const char * test2 = "qwertzuiopasdfghjklyxcvbnm1234567890";
+ const char *test2 = "qwertzuiopasdfghjklyxcvbnm1234567890";
char text2[DLT_DAEMON_TEXTSIZE];
- char * ptr2 = text2;
- EXPECT_LE(DLT_RETURN_OK, dlt_print_char_string(&ptr2,DLT_DAEMON_TEXTSIZE,(unsigned char *)test2, strlen(test2)));
+ char *ptr2 = text2;
+ EXPECT_LE(DLT_RETURN_OK, dlt_print_char_string(&ptr2, DLT_DAEMON_TEXTSIZE, (unsigned char *)test2, strlen(test2)));
printf("text:%s\n", text2);
EXPECT_STREQ(text2, test2);
}
TEST(t_dlt_print_char_string, abnormal)
{
- // print special characters, expected 0
-// const char * test3 = "^°!\"§$%&/()=?`´¹²³¼½¬{[]}\\¸@€üöä+#*'~`,.-;:_·…–<>|";
-// char text3[DLT_DAEMON_TEXTSIZE];
-// char * ptr3 = text3;
-// EXPECT_LE(DLT_RETURN_OK, dlt_print_char_string(&ptr3,DLT_DAEMON_TEXTSIZE,(unsigned char *)test3, strlen(test3)));
-// printf("text:%s\n", text3);
-// EXPECT_STREQ(text3, test3);
-
- // Empty char *, expect 0
-// const char * test4 = "";
-// char text4[DLT_DAEMON_TEXTSIZE];
-// char * ptr4 = text4;
-// EXPECT_LE(DLT_RETURN_OK, dlt_print_char_string(&ptr4,DLT_DAEMON_TEXTSIZE,(unsigned char *)test4, strlen(test4)));
-// printf("text:%s\n", text4);
-// EXPECT_STREQ(text4, test4);
+ /* print special characters, expected 0 */
+/* const char * test3 = "^°!\"§$%&/()=?`´¹²³¼½¬{[]}\\¸@€üöä+#*'~`,.-;:_·…–<>|"; */
+/* char text3[DLT_DAEMON_TEXTSIZE]; */
+/* char * ptr3 = text3; */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_print_char_string(&ptr3,DLT_DAEMON_TEXTSIZE,(unsigned char *)test3, strlen(test3))); */
+/* printf("text:%s\n", text3); */
+/* EXPECT_STREQ(text3, test3); */
+
+ /* Empty char *, expect 0 */
+/* const char * test4 = ""; */
+/* char text4[DLT_DAEMON_TEXTSIZE]; */
+/* char * ptr4 = text4; */
+/* EXPECT_LE(DLT_RETURN_OK, dlt_print_char_string(&ptr4,DLT_DAEMON_TEXTSIZE,(unsigned char *)test4, strlen(test4))); */
+/* printf("text:%s\n", text4); */
+/* EXPECT_STREQ(text4, test4); */
}
TEST(t_dlt_print_char_string, nullpointer)
{
- const char * test5 = "HELLO";
+ const char *test5 = "HELLO";
char text5[DLT_DAEMON_TEXTSIZE];
- char * ptr5 = text5;
+ char *ptr5 = text5;
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_char_string(NULL,0,NULL, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_char_string(NULL,0,(unsigned char *)test5, 0));
- EXPECT_GE(DLT_RETURN_ERROR, dlt_print_char_string(&ptr5,0,NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_char_string(NULL, 0, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_char_string(NULL, 0, (unsigned char *)test5, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_print_char_string(&ptr5, 0, NULL, 0));
}
/* End Method:dlt_common::dlt_print_char_string */
@@ -3719,32 +4025,32 @@ TEST(t_dlt_print_char_string, nullpointer)
/* Begin Method:dlt_common::dlt_print_id */
TEST(t_dlt_print_id, normal)
{
- // Normal Use-Case, expect text==id
- const char* id = "DLTD";
+ /* Normal Use-Case, expect text==id */
+ const char *id = "DLTD";
char text[DLT_DAEMON_TEXTSIZE];
- dlt_print_id(text,id);
- EXPECT_STREQ(text,id);
+ dlt_print_id(text, id);
+ EXPECT_STREQ(text, id);
}
TEST(t_dlt_print_id, abnormal)
{
- // id to long, expect only first 4 chars
-// const char* id = "DLTD123456789";
-// char text[DLT_DAEMON_TEXTSIZE];
-// dlt_print_id(text,id);
-// EXPECT_STREQ(text,"DLTD");
+ /* id to long, expect only first 4 chars */
+/* const char* id = "DLTD123456789"; */
+/* char text[DLT_DAEMON_TEXTSIZE]; */
+/* dlt_print_id(text,id); */
+/* EXPECT_STREQ(text,"DLTD"); */
- // id to short, expect expend with "-" to 4 chars
-// id = "DL";
-// dlt_print_id(text,id);
-// EXPECT_STREQ(text,"DL--");
+ /* id to short, expect expend with "-" to 4 chars */
+/* id = "DL"; */
+/* dlt_print_id(text,id); */
+/* EXPECT_STREQ(text,"DL--"); */
}
TEST(t_dlt_print_id, nullpointer)
{
- const char* id = "DLTD";
+ const char *id = "DLTD";
char text[DLT_DAEMON_TEXTSIZE];
- // NULL-Pointer, expected nothing in return
- EXPECT_NO_THROW(dlt_print_id(NULL,NULL));
+ /* NULL-Pointer, expected nothing in return */
+ EXPECT_NO_THROW(dlt_print_id(NULL, NULL));
EXPECT_NO_THROW(dlt_print_id(NULL, id));
EXPECT_NO_THROW(dlt_print_id(text, NULL));
}
@@ -3756,21 +4062,21 @@ TEST(t_dlt_print_id, nullpointer)
/* Begin Method:dlt_common::dlt_get_version */
TEST(t_dlt_get_version, normal)
{
- // Normal Use-Case
+ /* Normal Use-Case */
char ver[255];
dlt_get_version(ver, 255);
printf("%s\n", ver);
}
TEST(t_dlt_get_version, abnormal)
{
- // Change default length of ver to 1
-// char ver[1];
-// dlt_get_version(ver, DLT_USER_MAX_LIB_VERSION_LENGTH);
-// printf("%s\n", ver);
+ /* Change default length of ver to 1 */
+/* char ver[1]; */
+/* dlt_get_version(ver, DLT_USER_MAX_LIB_VERSION_LENGTH); */
+/* printf("%s\n", ver); */
- // Change default length of ver to 1 and reduce second para to 1, too
-// dlt_get_version(ver, 1);
-// printf("%s\n", ver);
+ /* Change default length of ver to 1 and reduce second para to 1, too */
+/* dlt_get_version(ver, 1); */
+/* printf("%s\n", ver); */
}
TEST(t_dlt_get_version, nullpointer)
{
@@ -3790,18 +4096,18 @@ TEST(dlt_get_major_version, normal)
}
TEST(dlt_get_major_version, abnormal)
{
- // Change default length of ver to 1
-// char ver[1];
-// dlt_get_major_version(ver, DLT_USER_MAX_LIB_VERSION_LENGTH);
-// EXPECT_STREQ(ver, _DLT_PACKAGE_MAJOR_VERSION);
+ /* Change default length of ver to 1 */
+/* char ver[1]; */
+/* dlt_get_major_version(ver, DLT_USER_MAX_LIB_VERSION_LENGTH); */
+/* EXPECT_STREQ(ver, _DLT_PACKAGE_MAJOR_VERSION); */
- // Change default length of ver to 1 and reduce second para to 1, too
-// dlt_get_major_version(ver, 1);
-// EXPECT_STREQ(ver, _DLT_PACKAGE_MAJOR_VERSION);
+ /* Change default length of ver to 1 and reduce second para to 1, too */
+/* dlt_get_major_version(ver, 1); */
+/* EXPECT_STREQ(ver, _DLT_PACKAGE_MAJOR_VERSION); */
}
TEST(dlt_get_major_version, nullpointer)
{
- // NULL-Pointer, expect exeption
+ /* NULL-Pointer, expect exeption */
EXPECT_NO_THROW(dlt_get_major_version(NULL, 0));
}
/* End Method:dlt_common::dlt_get_major_version */
@@ -3818,18 +4124,18 @@ TEST(dlt_get_minor_version, normal)
}
TEST(dlt_get_minor_version, abnormal)
{
- // Change default length of ver to 1
-// char ver[1];
-// dlt_get_minor_version(ver, DLT_USER_MAX_LIB_VERSION_LENGTH);
-// EXPECT_STREQ(ver, _DLT_PACKAGE_MINOR_VERSION);
+ /* Change default length of ver to 1 */
+/* char ver[1]; */
+/* dlt_get_minor_version(ver, DLT_USER_MAX_LIB_VERSION_LENGTH); */
+/* EXPECT_STREQ(ver, _DLT_PACKAGE_MINOR_VERSION); */
- // Change default length of ver to 1 and reduce second para to 1, too
-// dlt_get_minor_version(ver, 1);
-// EXPECT_STREQ(ver, _DLT_PACKAGE_MINOR_VERSION);
+ /* Change default length of ver to 1 and reduce second para to 1, too */
+/* dlt_get_minor_version(ver, 1); */
+/* EXPECT_STREQ(ver, _DLT_PACKAGE_MINOR_VERSION); */
}
TEST(dlt_get_minor_version, nullpointer)
{
- // NULL-Pointer, expect exeption
+ /* NULL-Pointer, expect exeption */
EXPECT_NO_THROW(dlt_get_minor_version(NULL, 0));
}
/* End Method:dlt_common::dlt_get_minor_version */
@@ -3848,6 +4154,6 @@ int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
::testing::FLAGS_gtest_break_on_failure = true;
- //::testing::FLAGS_gtest_filter = "*.normal";
+ /*::testing::FLAGS_gtest_filter = "*.normal"; */
return RUN_ALL_TESTS();
}
diff --git a/tests/gtest_dlt_daemon_common.cpp b/tests/gtest_dlt_daemon_common.cpp
index 5e22c2d..12f4dde 100644
--- a/tests/gtest_dlt_daemon_common.cpp
+++ b/tests/gtest_dlt_daemon_common.cpp
@@ -23,7 +23,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file gtest_dlt_common.cpp
-*/
+ */
#include <stdio.h>
#include <gtest/gtest.h>
@@ -46,12 +46,12 @@ extern "C" {
}
#ifndef DLT_USER_DIR
-#define DLT_USER_DIR "/tmp/dltpipes"
+# define DLT_USER_DIR "/tmp/dltpipes"
#endif
/* Name of named pipe to DLT daemon */
#ifndef DLT_USER_FIFO
-#define DLT_USER_FIFO "/tmp/dlt"
+# define DLT_USER_FIFO "/tmp/dlt"
#endif
/* Begin Method:dlt_daemon_common::dlt_daemon_init_user_information */
@@ -66,7 +66,7 @@ TEST(t_dlt_daemon_init_user_information, normal_one_list)
DLT_DAEMON_RINGBUFFER_MAX_SIZE,
DLT_DAEMON_RINGBUFFER_STEP_SIZE,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
@@ -84,18 +84,18 @@ TEST(t_dlt_daemon_init_user_information, normal_multiple_lists)
char ecu3[] = "ECU3";
gateway.connections =
- (DltGatewayConnection *)calloc(2, sizeof(DltGatewayConnection));
+ (DltGatewayConnection *)calloc(2, sizeof(DltGatewayConnection));
gateway.connections[0].ecuid = &ecu2[0];
gateway.connections[1].ecuid = &ecu3[0];
gateway.num_connections = 2;
- // Normal Use-Case
+ /* Normal Use-Case */
EXPECT_EQ(0, dlt_daemon_init(&daemon,
DLT_DAEMON_RINGBUFFER_MIN_SIZE,
DLT_DAEMON_RINGBUFFER_MAX_SIZE,
DLT_DAEMON_RINGBUFFER_STEP_SIZE,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 1, 0));
@@ -132,7 +132,7 @@ TEST(t_dlt_daemon_find_users_list, normal_one_list)
DLT_DAEMON_RINGBUFFER_MAX_SIZE,
DLT_DAEMON_RINGBUFFER_STEP_SIZE,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
@@ -157,7 +157,7 @@ TEST(t_dlt_daemon_find_users_list, abnormal)
DLT_DAEMON_RINGBUFFER_MAX_SIZE,
DLT_DAEMON_RINGBUFFER_STEP_SIZE,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
@@ -178,18 +178,18 @@ TEST(t_dlt_daemon_find_users_list, normal_multiple_lists)
DltDaemonRegisteredUsers *user_list;
gateway.connections =
- (DltGatewayConnection *)calloc(2, sizeof(DltGatewayConnection));
+ (DltGatewayConnection *)calloc(2, sizeof(DltGatewayConnection));
gateway.connections[0].ecuid = &ecu2[0];
gateway.connections[1].ecuid = &ecu3[0];
gateway.num_connections = 2;
- // Normal Use-Case
+ /* Normal Use-Case */
EXPECT_EQ(0, dlt_daemon_init(&daemon,
DLT_DAEMON_RINGBUFFER_MIN_SIZE,
DLT_DAEMON_RINGBUFFER_MAX_SIZE,
DLT_DAEMON_RINGBUFFER_STEP_SIZE,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 1, 0));
@@ -229,31 +229,34 @@ TEST(t_dlt_daemon_application_add, normal)
{
DltDaemon daemon;
DltGateway gateway;
- const char * apid = "TEST";
+ const char *apid = "TEST";
pid_t pid = 0;
- const char * desc = "HELLO_TEST";
+ const char *desc = "HELLO_TEST";
DltDaemonApplication *app = NULL;
char ecu[] = "ECU1";
int fd = 15;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
- app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, fd, ecu, 0);
- //printf("### APP: APID=%s DESCR=%s NUMCONTEXT=%i PID=%i USERHANDLE=%i\n", app->apid,app->application_description, app->num_contexts, app->pid, app->user_handle);
+ app = dlt_daemon_application_add(&daemon, (char *)apid, pid, (char *)desc, fd, ecu, 0);
+ /*printf("### APP: APID=%s DESCR=%s NUMCONTEXT=%i PID=%i USERHANDLE=%i\n", app->apid,app->application_description, app->num_contexts, app->pid, app->user_handle); */
EXPECT_STREQ(apid, app->apid);
EXPECT_STREQ(desc, app->application_description);
EXPECT_EQ(pid, app->pid);
- EXPECT_LE(0, dlt_daemon_application_del(&daemon,app, ecu, 0));
+ EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
- // Apid > 4, expected truncate to 4 char or error
+ /* Apid > 4, expected truncate to 4 char or error */
apid = "TO_LONG";
- app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, fd, ecu, 0);
- char tmp[5];
+ app = dlt_daemon_application_add(&daemon, (char *)apid, pid, (char *)desc, fd, ecu, 0);
+ char tmp[5];
strncpy(tmp, apid, 4);
tmp[4] = '\0';
EXPECT_STREQ(tmp, app->apid);
@@ -263,65 +266,65 @@ TEST(t_dlt_daemon_application_add, normal)
}
TEST(t_dlt_daemon_application_add, abnormal)
{
-// DltDaemon daemon;
-// const char * apid = "TEST";
-// pid_t pid = 0;
-// const char * desc = "HELLO_TEST";
-// DltDaemonApplication *app = NULL;
-
- // Add the same application with same pid twice
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// EXPECT_LE((DltDaemonApplication *) 0, app);
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// EXPECT_EQ((DltDaemonApplication *) 0, app);
-// dlt_daemon_application_del(&daemon,app, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
- // Add the same applicaiotn with different pid
-// app = dlt_daemon_application_add(&daemon,(char *) apid, 0, (char *) desc, 0);
-// EXPECT_LE((DltDaemonApplication *) 0, app);
-// app = dlt_daemon_application_add(&daemon,(char *) apid, 123, (char *) desc, 0);
-// EXPECT_EQ((DltDaemonApplication *) 0, app);
-// dlt_daemon_application_del(&daemon,app, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
-
- // verbose value != 0 or 1
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 12345678));
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
- // Apid < 4, expected fill to 4 chars or error
-// apid = "SH";
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// char tmp[5];
-// strncpy(tmp, apid, 4);
-// tmp[4] = '\0';
-// EXPECT_STREQ(tmp, app->apid);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* const char * apid = "TEST"; */
+/* pid_t pid = 0; */
+/* const char * desc = "HELLO_TEST"; */
+/* DltDaemonApplication *app = NULL; */
+
+ /* Add the same application with same pid twice */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* EXPECT_LE((DltDaemonApplication *) 0, app); */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* EXPECT_EQ((DltDaemonApplication *) 0, app); */
+/* dlt_daemon_application_del(&daemon,app, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+ /* Add the same applicaiotn with different pid */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, 0, (char *) desc, 0); */
+/* EXPECT_LE((DltDaemonApplication *) 0, app); */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, 123, (char *) desc, 0); */
+/* EXPECT_EQ((DltDaemonApplication *) 0, app); */
+/* dlt_daemon_application_del(&daemon,app, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+
+ /* verbose value != 0 or 1 */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 12345678)); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+ /* Apid < 4, expected fill to 4 chars or error */
+/* apid = "SH"; */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* char tmp[5]; */
+/* strncpy(tmp, apid, 4); */
+/* tmp[4] = '\0'; */
+/* EXPECT_STREQ(tmp, app->apid); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_application_add, nullpointer)
{
DltDaemon daemon;
- const char * apid = "TEST";
- const char * desc = "HELLO_TEST";
+ const char *apid = "TEST";
+ const char *desc = "HELLO_TEST";
int fd = 42;
char ecu[] = "ECU1";
- // NULL-Pointer test
- EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL,NULL, 0, NULL, 0, NULL, 0));
- EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL,NULL, 0, (char *) desc, 0, NULL, 0));
- EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL,(char *) apid, 0, NULL, 0, NULL, 0));
- EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL,(char *) apid, 0, (char *) desc, 0, NULL, 0));
- EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(&daemon,NULL, 0, NULL, 0, NULL, 0));
- EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(&daemon,NULL, 0, (char *) desc, 0, NULL, 0));
- EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL,NULL, 0, NULL, fd, NULL, 0));
- EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL,NULL, 0, NULL, 0, ecu, 0));
+ /* NULL-Pointer test */
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL, NULL, 0, NULL, 0, NULL, 0));
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL, NULL, 0, (char *)desc, 0, NULL, 0));
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL, (char *)apid, 0, NULL, 0, NULL, 0));
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL, (char *)apid, 0, (char *)desc, 0, NULL, 0));
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(&daemon, NULL, 0, NULL, 0, NULL, 0));
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(&daemon, NULL, 0, (char *)desc, 0, NULL, 0));
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL, NULL, 0, NULL, fd, NULL, 0));
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_add(NULL, NULL, 0, NULL, 0, ecu, 0));
}
/* End Method:dlt_daemon_common::dlt_daemon_application_add */
@@ -333,48 +336,51 @@ TEST(t_dlt_daemon_application_del, normal)
{
DltDaemon daemon;
DltGateway gateway;
- const char * apid = "TEST";
+ const char *apid = "TEST";
pid_t pid = 0;
- const char * desc = "HELLO_TEST";
+ const char *desc = "HELLO_TEST";
DltDaemonApplication *app = NULL;
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case, retrun type cannot be tested, only apid and desc
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case, retrun type cannot be tested, only apid and desc */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
- app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, fd, ecu, 0);
- EXPECT_LE(0, dlt_daemon_application_del(&daemon,app, ecu, 0));
+ app = dlt_daemon_application_add(&daemon, (char *)apid, pid, (char *)desc, fd, ecu, 0);
+ EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_application_del, abnormal)
{
-// DltDaemon daemon;
-// const char * apid = "TEST";
-// pid_t pid = 0;
-// const char * desc = "HELLO_TEST";
-// DltDaemonApplication *app = NULL;
+/* DltDaemon daemon; */
+/* const char * apid = "TEST"; */
+/* pid_t pid = 0; */
+/* const char * desc = "HELLO_TEST"; */
+/* DltDaemonApplication *app = NULL; */
- // no application exists, expect < 0
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_application_del(&daemon, app, 0));
+ /* no application exists, expect < 0 */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_application_del(&daemon, app, 0)); */
- // Call delete two times
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// EXPECT_LE(0, dlt_daemon_application_del(&daemon,app, 0));
-// EXPECT_GE(-1, dlt_daemon_application_del(&daemon,app, 0));
-// dlt_daemon_applications_clear(&daemon, 0);
+ /* Call delete two times */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* EXPECT_LE(0, dlt_daemon_application_del(&daemon,app, 0)); */
+/* EXPECT_GE(-1, dlt_daemon_application_del(&daemon,app, 0)); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
- // Verbose parameter != 0 or 1
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// EXPECT_GE(-1, dlt_daemon_application_del(&daemon,app, 123456789));
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+ /* Verbose parameter != 0 or 1 */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* EXPECT_GE(-1, dlt_daemon_application_del(&daemon,app, 123456789)); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_application_del, nullpointer)
@@ -383,10 +389,10 @@ TEST(t_dlt_daemon_application_del, nullpointer)
DltDaemonApplication app;
char ecu[] = "ECU1";
- // NULL-Pointer
- EXPECT_GE(-1, dlt_daemon_application_del(NULL,NULL, NULL, 0));
+ /* NULL-Pointer */
+ EXPECT_GE(-1, dlt_daemon_application_del(NULL, NULL, NULL, 0));
EXPECT_GE(-1, dlt_daemon_application_del(NULL, &app, NULL, 0));
- EXPECT_GE(-1, dlt_daemon_application_del(&daemon,NULL, ecu, 0));
+ EXPECT_GE(-1, dlt_daemon_application_del(&daemon, NULL, ecu, 0));
}
/* End Method: dlt_daemon_common::dlt_daemon_application_del */
@@ -398,63 +404,66 @@ TEST(t_dlt_daemon_application_find, normal)
{
DltDaemon daemon;
DltGateway gateway;
- const char * apid = "TEST";
+ const char *apid = "TEST";
pid_t pid = 0;
- const char * desc = "HELLO_TEST";
+ const char *desc = "HELLO_TEST";
DltDaemonApplication *app = NULL;
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
- app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, fd, ecu, 0);
+ app = dlt_daemon_application_add(&daemon, (char *)apid, pid, (char *)desc, fd, ecu, 0);
EXPECT_STREQ(apid, app->apid);
EXPECT_STREQ(desc, app->application_description);
EXPECT_EQ(pid, app->pid);
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
- // Application doesn't exist, expect NULL
- EXPECT_EQ((DltDaemonApplication *) 0, dlt_daemon_application_find(&daemon, ecu, (char *) apid, 0));
+ /* Application doesn't exist, expect NULL */
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_find(&daemon, ecu, (char *)apid, 0));
- // Use a different apid, expect NULL
- app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, fd, ecu, 0);
- EXPECT_LE((DltDaemonApplication *) 0, dlt_daemon_application_find(&daemon, ecu, (char *) apid, 0));
- EXPECT_EQ((DltDaemonApplication *) 0, dlt_daemon_application_find(&daemon, ecu, (char *) "NEXI", 0));
+ /* Use a different apid, expect NULL */
+ app = dlt_daemon_application_add(&daemon, (char *)apid, pid, (char *)desc, fd, ecu, 0);
+ EXPECT_LE((DltDaemonApplication *)0, dlt_daemon_application_find(&daemon, ecu, (char *)apid, 0));
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_find(&daemon, ecu, (char *)"NEXI", 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_application_find, abnormal)
{
-// DltDaemon daemon;
-// const char * apid = "TEST";
-// pid_t pid = 0;
-// const char * desc = "HELLO_TEST";
-// DltDaemonApplication *app = NULL;
-
- // Verbose != 0 or 1, expect error
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// dlt_daemon_application_find(&daemon, (char *) apid, 0);
-// EXPECT_EQ((DltDaemonApplication *) 0, dlt_daemon_application_find(&daemon, (char *) apid, 123456789));
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* const char * apid = "TEST"; */
+/* pid_t pid = 0; */
+/* const char * desc = "HELLO_TEST"; */
+/* DltDaemonApplication *app = NULL; */
+
+ /* Verbose != 0 or 1, expect error */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* dlt_daemon_application_find(&daemon, (char *) apid, 0); */
+/* EXPECT_EQ((DltDaemonApplication *) 0, dlt_daemon_application_find(&daemon, (char *) apid, 123456789)); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_application_find, nullpointer)
{
DltDaemon daemon;
- const char * apid = "TEST";
+ const char *apid = "TEST";
- // NULL-Pointer, expected NULL
- EXPECT_EQ((DltDaemonApplication *) 0, dlt_daemon_application_find(NULL, NULL, NULL, 0));
- EXPECT_EQ((DltDaemonApplication *) 0, dlt_daemon_application_find(NULL, (char *) apid, NULL, 0));
- EXPECT_EQ((DltDaemonApplication *) 0, dlt_daemon_application_find(&daemon, NULL, NULL, 0));
+ /* NULL-Pointer, expected NULL */
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_find(NULL, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_find(NULL, (char *)apid, NULL, 0));
+ EXPECT_EQ((DltDaemonApplication *)0, dlt_daemon_application_find(&daemon, NULL, NULL, 0));
}
/* End Method: dlt_daemon_common::dlt_daemon_applikation_find */
@@ -470,34 +479,38 @@ TEST(t_dlt_daemon_applications_clear, normal)
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use Case, expect >= 0
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use Case, expect >= 0 */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
- EXPECT_LE((DltDaemonApplication *) 0, dlt_daemon_application_add(&daemon, (char *) "TES1", pid, (char *) "Test clear 1", fd, ecu, 0));
- dlt_daemon_application_add(&daemon, (char *) "TES2", pid, (char *) "Test clear 2", fd, ecu, 0);
+ EXPECT_LE((DltDaemonApplication *)0,
+ dlt_daemon_application_add(&daemon, (char *)"TES1", pid, (char *)"Test clear 1", fd, ecu, 0));
+ dlt_daemon_application_add(&daemon, (char *)"TES2", pid, (char *)"Test clear 2", fd, ecu, 0);
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_applications_clear, abnormal)
{
-// DltDaemon daemon;
-// pid_t pid = 0;
-
- // No applications added, expect < -1
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_applications_clear(&daemon, 0));
-
- // Verbose != 0 or 1, expect error
-// dlt_daemon_application_add(&daemon, (char *) "TEST", pid, (char *) "Test clear", 0);
-// EXPECT_GE(-1, dlt_daemon_applications_clear(&daemon, 123456789));
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* pid_t pid = 0; */
+
+ /* No applications added, expect < -1 */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_applications_clear(&daemon, 0)); */
+
+ /* Verbose != 0 or 1, expect error */
+/* dlt_daemon_application_add(&daemon, (char *) "TEST", pid, (char *) "Test clear", 0); */
+/* EXPECT_GE(-1, dlt_daemon_applications_clear(&daemon, 123456789)); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_applications_clear, nullpointer)
{
- // NULL-Pointer, expect < 0
+ /* NULL-Pointer, expect < 0 */
EXPECT_GE(-1, dlt_daemon_applications_clear(NULL, NULL, 0));
}
/* End Method: dlt_daemon_common::dlt_daemon_applications_clear */
@@ -509,19 +522,22 @@ TEST(t_dlt_daemon_applications_invalidate_fd, normal)
{
DltDaemon daemon;
DltGateway gateway;
- const char * apid = "TEST";
+ const char *apid = "TEST";
pid_t pid = 0;
- const char * desc = "HELLO_TEST";
+ const char *desc = "HELLO_TEST";
DltDaemonApplication *app = NULL;
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
- app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, fd, ecu, 0);
+ app = dlt_daemon_application_add(&daemon, (char *)apid, pid, (char *)desc, fd, ecu, 0);
EXPECT_LE(0, dlt_daemon_applications_invalidate_fd(&daemon, ecu, app->user_handle, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
@@ -529,26 +545,26 @@ TEST(t_dlt_daemon_applications_invalidate_fd, normal)
}
TEST(t_dlt_daemon_applications_invalidate_fd, abnormal)
{
-// DltDaemon daemon;
-// const char * apid = "TEST";
-// pid_t pid = 0;
-// const char * desc = "HELLO_TEST";
-// DltDaemonApplication *app = NULL;
-
- // Daemon isn't initialized, expected error
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_applications_invalidate_fd(&daemon, 0, 0));
-
- // Verbose != 0 or 1, expect error
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// EXPECT_GE(-1, dlt_daemon_applications_invalidate_fd(&daemon, app->user_handle, 123456789));
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* const char * apid = "TEST"; */
+/* pid_t pid = 0; */
+/* const char * desc = "HELLO_TEST"; */
+/* DltDaemonApplication *app = NULL; */
+
+ /* Daemon isn't initialized, expected error */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_applications_invalidate_fd(&daemon, 0, 0)); */
+
+ /* Verbose != 0 or 1, expect error */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* EXPECT_GE(-1, dlt_daemon_applications_invalidate_fd(&daemon, app->user_handle, 123456789)); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_applications_invalidate_fd, nullpointer)
{
- // NULL-Pointer
+ /* NULL-Pointer */
EXPECT_GE(-1, dlt_daemon_applications_invalidate_fd(NULL, NULL, 0, 0));
}
/* End Method: dlt_daemon_common::dlt_daemon_applications_invalidate_fd */
@@ -561,59 +577,62 @@ TEST(t_dlt_daemon_applications_save, normal)
{
DltDaemon daemon;
DltGateway gateway;
- const char * apid = "TEST";
+ const char *apid = "TEST";
pid_t pid = 0;
- const char * desc = "HELLO_TEST";
+ const char *desc = "HELLO_TEST";
DltDaemonApplication *app = NULL;
- const char * filename = "/tmp/dlt-runtime.cfg";
+ const char *filename = "/tmp/dlt-runtime.cfg";
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
- app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, fd, ecu, 0);
- EXPECT_LE(0, dlt_daemon_applications_save(&daemon, (char *) filename, 0));
+ app = dlt_daemon_application_add(&daemon, (char *)apid, pid, (char *)desc, fd, ecu, 0);
+ EXPECT_LE(0, dlt_daemon_applications_save(&daemon, (char *)filename, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_applications_save, abnormal)
{
-// DltDaemon daemon;
-// const char * apid = "TEST";
-// pid_t pid = 0;
-// const char * desc = "HELLO_TEST";
-// DltDaemonApplication *app = NULL;
-// const char * filename = "/tmp/dlt-runtime.cfg";
-
- // Uninitialized
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_applications_save(&daemon, (char *) filename, 0));
-
- // Verbose != 1 or 0, expect error
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// EXPECT_GE(-1, dlt_daemon_applications_save(&daemon, (char *) filename, 123456789));
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
- // Wrong path filename
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// EXPECT_GE(-1, dlt_daemon_applications_save(&daemon, (char *) "PATH_DONT_EXIST", 0));
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* const char * apid = "TEST"; */
+/* pid_t pid = 0; */
+/* const char * desc = "HELLO_TEST"; */
+/* DltDaemonApplication *app = NULL; */
+/* const char * filename = "/tmp/dlt-runtime.cfg"; */
+
+ /* Uninitialized */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_applications_save(&daemon, (char *) filename, 0)); */
+
+ /* Verbose != 1 or 0, expect error */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* EXPECT_GE(-1, dlt_daemon_applications_save(&daemon, (char *) filename, 123456789)); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+ /* Wrong path filename */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* EXPECT_GE(-1, dlt_daemon_applications_save(&daemon, (char *) "PATH_DONT_EXIST", 0)); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_applications_save, nullpointer)
{
DltDaemon daemon;
- const char * filename = "/tmp/dlt-runtime.cfg";
+ const char *filename = "/tmp/dlt-runtime.cfg";
- // NULL-Pointer
+ /* NULL-Pointer */
EXPECT_GE(-1, dlt_daemon_applications_save(NULL, NULL, 0));
- EXPECT_GE(-1, dlt_daemon_applications_save(NULL, (char *) filename, 0));
+ EXPECT_GE(-1, dlt_daemon_applications_save(NULL, (char *)filename, 0));
EXPECT_GE(-1, dlt_daemon_applications_save(&daemon, NULL, 0));
}
/* End Method: dlt_daemon_common::dlt_daemon_applications_save */
@@ -627,50 +646,53 @@ TEST(t_dlt_daemon_applications_load, normal)
DltDaemon daemon;
DltGateway gateway;
char ecu[] = "ECU1";
- const char * filename = "/tmp/dlt-runtime.cfg";
+ const char *filename = "/tmp/dlt-runtime.cfg";
- // Normal Use-Case, first execute t_dlt_daemon_applications_save !!
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case, first execute t_dlt_daemon_applications_save !! */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
- EXPECT_LE(0, dlt_daemon_applications_load(&daemon,(char *) filename, 0));
+ EXPECT_LE(0, dlt_daemon_applications_load(&daemon, (char *)filename, 0));
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_applications_load, abnormal)
{
-// DltDaemon daemon;
-// const char * apid = "TEST";
-// pid_t pid = 0;
-// const char * desc = "HELLO_TEST";
-// DltDaemonApplication *app = NULL;
-// const char * filename = "/tmp/dlt-runtime.cfg";
-
- // Uninitialized
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_applications_load(&daemon, (char *) filename, 0));
-
- // Verbose != 1 or 0, expect error
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// EXPECT_GE(-1, dlt_daemon_applications_load(&daemon, (char *) filename, 123456789));
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
- // Wrong path filename
-// app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0);
-// EXPECT_GE(-1, dlt_daemon_applications_load(&daemon, (char *) "PATH_DONT_EXIST", 0));
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* const char * apid = "TEST"; */
+/* pid_t pid = 0; */
+/* const char * desc = "HELLO_TEST"; */
+/* DltDaemonApplication *app = NULL; */
+/* const char * filename = "/tmp/dlt-runtime.cfg"; */
+
+ /* Uninitialized */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_applications_load(&daemon, (char *) filename, 0)); */
+
+ /* Verbose != 1 or 0, expect error */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* EXPECT_GE(-1, dlt_daemon_applications_load(&daemon, (char *) filename, 123456789)); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+ /* Wrong path filename */
+/* app = dlt_daemon_application_add(&daemon,(char *) apid, pid, (char *) desc, 0); */
+/* EXPECT_GE(-1, dlt_daemon_applications_load(&daemon, (char *) "PATH_DONT_EXIST", 0)); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_applications_load, nullpointer)
{
DltDaemon daemon;
- const char * filename = "/tmp/dlt-runtime.cfg";
+ const char *filename = "/tmp/dlt-runtime.cfg";
- // NULL-Pointer
+ /* NULL-Pointer */
EXPECT_GE(-1, dlt_daemon_applications_load(NULL, NULL, 0));
- EXPECT_GE(-1, dlt_daemon_applications_load(NULL, (char *) filename, 0));
+ EXPECT_GE(-1, dlt_daemon_applications_load(NULL, (char *)filename, 0));
EXPECT_GE(-1, dlt_daemon_applications_load(&daemon, NULL, 0));
}
/* End Method: dlt_daemon_common::dlt_daemon_applications_load */
@@ -688,20 +710,20 @@ TEST(t_dlt_daemon_applications_load, nullpointer)
/* Begin Method: dlt_daemon_common::dlt_daemon_context_add */
TEST(t_dlt_daemon_context_add, normal)
{
-// Log Level
-// DLT_LOG_DEFAULT = -1, /**< Default log level */
-// DLT_LOG_OFF = 0x00, /**< Log level off */
-// DLT_LOG_FATAL = 0x01, /**< fatal system error */
-// DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */
-// DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */
-// DLT_LOG_INFO = 0x04, /**< informational */
-// DLT_LOG_DEBUG = 0x05, /**< debug */
-// DLT_LOG_VERBOSE = 0x06 /**< highest grade of information */
-
-// Trace Status
-// DLT_TRACE_STATUS_DEFAULT = -1, /**< Default trace status */
-// DLT_TRACE_STATUS_OFF = 0x00, /**< Trace status: Off */
-// DLT_TRACE_STATUS_ON = 0x01 /**< Trace status: On */
+/* Log Level */
+/* DLT_LOG_DEFAULT = -1, / **< Default log level * / */
+/* DLT_LOG_OFF = 0x00, / **< Log level off * / */
+/* DLT_LOG_FATAL = 0x01, / **< fatal system error * / */
+/* DLT_LOG_ERROR = 0x02, / **< error with impact to correct functionality * / */
+/* DLT_LOG_WARN = 0x03, / **< warning, correct behaviour could not be ensured * / */
+/* DLT_LOG_INFO = 0x04, / **< informational * / */
+/* DLT_LOG_DEBUG = 0x05, / **< debug * / */
+/* DLT_LOG_VERBOSE = 0x06 / **< highest grade of information * / */
+
+/* Trace Status */
+/* DLT_TRACE_STATUS_DEFAULT = -1, / **< Default trace status * / */
+/* DLT_TRACE_STATUS_OFF = 0x00, / **< Trace status: Off * / */
+/* DLT_TRACE_STATUS_ON = 0x01 / **< Trace status: On * / */
DltDaemon daemon;
DltGateway gateway;
@@ -713,15 +735,18 @@ TEST(t_dlt_daemon_context_add, normal)
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
daecontext = dlt_daemon_context_add(&daemon, apid, ctid, DLT_LOG_DEFAULT,
DLT_TRACE_STATUS_DEFAULT, 0, 0, desc, ecu, 0);
- //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid);
+ /*printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid); */
EXPECT_STREQ(apid, daecontext->apid);
EXPECT_STREQ(ctid, daecontext->ctid);
EXPECT_STREQ(desc, daecontext->context_description);
@@ -730,7 +755,7 @@ TEST(t_dlt_daemon_context_add, normal)
EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, ecu, 0));
- EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu,0));
+ EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_context_add, abnormal)
@@ -745,102 +770,123 @@ TEST(t_dlt_daemon_context_add, abnormal)
char ecu[] = "ECU1";
int fd = 42;
- // Log Level dont exists
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Log Level dont exists */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
DltLogLevelType DLT_LOG_NOT_EXIST = (DltLogLevelType) - 100;
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_NOT_EXIST,DLT_TRACE_STATUS_DEFAULT,0,0,desc,ecu,0);
- //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid);
- EXPECT_EQ((DltDaemonContext *) 0, daecontext);
+ daecontext = dlt_daemon_context_add(&daemon,
+ apid,
+ ctid,
+ DLT_LOG_NOT_EXIST,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
+ /*printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid); */
+ EXPECT_EQ((DltDaemonContext *)0, daecontext);
EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
- // Trace Status dont exists
+ /* Trace Status dont exists */
DltTraceStatusType DLT_TRACE_TYPE_NOT_EXIST = (DltTraceStatusType) - 100;
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_TYPE_NOT_EXIST,0,0,desc,ecu,0);
- //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid);
- EXPECT_EQ((DltDaemonContext *) 0, daecontext);
+ daecontext = dlt_daemon_context_add(&daemon,
+ apid,
+ ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_TYPE_NOT_EXIST,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
+ /*printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid); */
+ EXPECT_EQ((DltDaemonContext *)0, daecontext);
EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
- // Apid to long
-// char apid_tl[8] = "TO_LONG";
-// app = dlt_daemon_application_add(&daemon, apid_tl, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid_tl,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid);
-// EXPECT_STREQ(apid_tl, daecontext->apid);
-// EXPECT_STREQ(ctid, daecontext->ctid);
-// EXPECT_STREQ(desc, daecontext->context_description);
-// EXPECT_EQ(DLT_LOG_DEFAULT, daecontext->log_level);
-// EXPECT_EQ(DLT_TRACE_STATUS_DEFAULT, daecontext->trace_status);
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
- // Apid to short
-// char apid_ts[3] = "TS";
-// app = dlt_daemon_application_add(&daemon, apid_ts, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid_ts,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid);
-// EXPECT_STREQ(apid_ts, daecontext->apid);
-// EXPECT_STREQ(ctid, daecontext->ctid);
-// EXPECT_STREQ(desc, daecontext->context_description);
-// EXPECT_EQ(DLT_LOG_DEFAULT, daecontext->log_level);
-// EXPECT_EQ(DLT_TRACE_STATUS_DEFAULT, daecontext->trace_status);
-// //EXPECT_EQ(4, strlen(apid_ts));
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
- // Ctid to long
-// char ctid_tl[8] = "TO_LONG";
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid_tl,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid);
-// EXPECT_STREQ(apid, daecontext->apid);
-// EXPECT_STREQ(ctid_tl, daecontext->ctid);
-// EXPECT_STREQ(desc, daecontext->context_description);
-// EXPECT_EQ(DLT_LOG_DEFAULT, daecontext->log_level);
-// EXPECT_EQ(DLT_TRACE_STATUS_DEFAULT, daecontext->trace_status);
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
- // Ctid to short
-// char ctid_ts[4] = "TS";
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid_ts,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid);
-// EXPECT_STREQ(apid, daecontext->apid);
-// EXPECT_STREQ(ctid_ts, daecontext->ctid);
-// EXPECT_STREQ(desc, daecontext->context_description);
-// EXPECT_EQ(DLT_LOG_DEFAULT, daecontext->log_level);
-// EXPECT_EQ(DLT_TRACE_STATUS_DEFAULT, daecontext->trace_status);
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
- // Verbose != 0 or 1
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,123456789);
-// //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid);
-// EXPECT_EQ((DltDaemonContext *) 0, daecontext);
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
+ /* Apid to long */
+/* char apid_tl[8] = "TO_LONG"; */
+/* app = dlt_daemon_application_add(&daemon, apid_tl, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid_tl,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid); */
+/* EXPECT_STREQ(apid_tl, daecontext->apid); */
+/* EXPECT_STREQ(ctid, daecontext->ctid); */
+/* EXPECT_STREQ(desc, daecontext->context_description); */
+/* EXPECT_EQ(DLT_LOG_DEFAULT, daecontext->log_level); */
+/* EXPECT_EQ(DLT_TRACE_STATUS_DEFAULT, daecontext->trace_status); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+ /* Apid to short */
+/* char apid_ts[3] = "TS"; */
+/* app = dlt_daemon_application_add(&daemon, apid_ts, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid_ts,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid); */
+/* EXPECT_STREQ(apid_ts, daecontext->apid); */
+/* EXPECT_STREQ(ctid, daecontext->ctid); */
+/* EXPECT_STREQ(desc, daecontext->context_description); */
+/* EXPECT_EQ(DLT_LOG_DEFAULT, daecontext->log_level); */
+/* EXPECT_EQ(DLT_TRACE_STATUS_DEFAULT, daecontext->trace_status); */
+/* //EXPECT_EQ(4, strlen(apid_ts)); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+ /* Ctid to long */
+/* char ctid_tl[8] = "TO_LONG"; */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid_tl,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid); */
+/* EXPECT_STREQ(apid, daecontext->apid); */
+/* EXPECT_STREQ(ctid_tl, daecontext->ctid); */
+/* EXPECT_STREQ(desc, daecontext->context_description); */
+/* EXPECT_EQ(DLT_LOG_DEFAULT, daecontext->log_level); */
+/* EXPECT_EQ(DLT_TRACE_STATUS_DEFAULT, daecontext->trace_status); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+ /* Ctid to short */
+/* char ctid_ts[4] = "TS"; */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid_ts,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid); */
+/* EXPECT_STREQ(apid, daecontext->apid); */
+/* EXPECT_STREQ(ctid_ts, daecontext->ctid); */
+/* EXPECT_STREQ(desc, daecontext->context_description); */
+/* EXPECT_EQ(DLT_LOG_DEFAULT, daecontext->log_level); */
+/* EXPECT_EQ(DLT_TRACE_STATUS_DEFAULT, daecontext->trace_status); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+ /* Verbose != 0 or 1 */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,123456789); */
+/* //printf("### CONTEXT: APID=%s\tCTID=%s\n", daecontext->apid,daecontext->ctid); */
+/* EXPECT_EQ((DltDaemonContext *) 0, daecontext); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_context_add, nullpointer)
@@ -852,26 +898,29 @@ TEST(t_dlt_daemon_context_add, nullpointer)
char ecu[] = "ECU1";
char desc[255] = "TEST dlt_daemon_context_add";
- // NULL-Pointer
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* NULL-Pointer */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(NULL,NULL,NULL,0,0,0,0,NULL,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(NULL,NULL,NULL,0,0,0,0,desc,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(NULL,NULL,ctid,0,0,0,0,NULL,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(NULL,NULL,ctid,0,0,0,0,desc,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(NULL,apid,NULL,0,0,0,0,NULL,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(NULL,apid,NULL,0,0,0,0,desc,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(NULL,apid,ctid,0,0,0,0,NULL,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(NULL,apid,ctid,0,0,0,0,desc,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(&daemon,NULL,NULL,0,0,0,0,NULL,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(&daemon,NULL,NULL,0,0,0,0,desc,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(&daemon,NULL,ctid,0,0,0,0,NULL,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(&daemon,NULL,ctid,0,0,0,0,desc,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(&daemon,apid,NULL,0,0,0,0,NULL,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(&daemon,apid,NULL,0,0,0,0,desc,NULL,0));
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_add(&daemon,apid,ctid,0,0,0,0,NULL,NULL,0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(NULL, NULL, NULL, 0, 0, 0, 0, desc, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(NULL, NULL, ctid, 0, 0, 0, 0, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(NULL, NULL, ctid, 0, 0, 0, 0, desc, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(NULL, apid, NULL, 0, 0, 0, 0, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(NULL, apid, NULL, 0, 0, 0, 0, desc, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(NULL, apid, ctid, 0, 0, 0, 0, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(NULL, apid, ctid, 0, 0, 0, 0, desc, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(&daemon, NULL, NULL, 0, 0, 0, 0, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(&daemon, NULL, NULL, 0, 0, 0, 0, desc, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(&daemon, NULL, ctid, 0, 0, 0, 0, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(&daemon, NULL, ctid, 0, 0, 0, 0, desc, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(&daemon, apid, NULL, 0, 0, 0, 0, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(&daemon, apid, NULL, 0, 0, 0, 0, desc, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_add(&daemon, apid, ctid, 0, 0, 0, 0, NULL, NULL, 0));
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
/* End Method: dlt_daemon_common::dlt_daemon_context_add */
@@ -891,13 +940,25 @@ TEST(t_dlt_daemon_context_del, normal)
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,ecu,0);
+ daecontext = dlt_daemon_context_add(&daemon,
+ apid,
+ ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, ecu, 0));
@@ -906,39 +967,39 @@ TEST(t_dlt_daemon_context_del, normal)
}
TEST(t_dlt_daemon_context_del, abnormal)
{
-// DltDaemon daemon;
-// ID4 apid = "TES";
-// ID4 ctid = "CON";
-// char desc[255] = "TEST dlt_daemon_context_add";
-// DltDaemonContext *daecontext;
-// DltDaemonApplication *app;
-
- // Context uninitialized
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, 0));
-
- // No application used
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, 0));
-// EXPECT_GE(-1, dlt_daemon_application_del(&daemon, app, 0));
-// EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 0));
-// EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, 0));
-
- // No contex added
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, 0));
-// EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, 0));
-// EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 0));
-// EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, 0));
-
- // Verbose != 0 or 1
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, 123456789));
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* ID4 apid = "TES"; */
+/* ID4 ctid = "CON"; */
+/* char desc[255] = "TEST dlt_daemon_context_add"; */
+/* DltDaemonContext *daecontext; */
+/* DltDaemonApplication *app; */
+
+ /* Context uninitialized */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, 0)); */
+
+ /* No application used */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, 0)); */
+/* EXPECT_GE(-1, dlt_daemon_application_del(&daemon, app, 0)); */
+/* EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 0)); */
+/* EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, 0)); */
+
+ /* No contex added */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, 0)); */
+/* EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, 0)); */
+/* EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 0)); */
+/* EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, 0)); */
+
+ /* Verbose != 0 or 1 */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, 123456789)); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_context_del, nullpointer)
{
@@ -946,7 +1007,7 @@ TEST(t_dlt_daemon_context_del, nullpointer)
DltDaemonContext daecontext;
char ecu[] = "ECU1";
- //NULL-Pointer
+ /*NULL-Pointer */
EXPECT_GE(-1, dlt_daemon_context_del(NULL, NULL, ecu, 0));
EXPECT_GE(-1, dlt_daemon_context_del(NULL, &daecontext, NULL, 0));
EXPECT_GE(-1, dlt_daemon_context_del(&daemon, NULL, NULL, 0));
@@ -969,13 +1030,25 @@ TEST(t_dlt_daemon_context_find, normal)
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,ecu,0);
+ daecontext = dlt_daemon_context_add(&daemon,
+ apid,
+ ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
EXPECT_STREQ(apid, daecontext->apid);
EXPECT_STREQ(ctid, daecontext->ctid);
EXPECT_STREQ(desc, daecontext->context_description);
@@ -999,48 +1072,78 @@ TEST(t_dlt_daemon_context_find, abnormal)
char ecu[] = "ECU1";
int fd = 42;
- // Uninitialized
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Uninitialized */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(&daemon, apid, ctid, ecu, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(&daemon, apid, ctid, ecu, 0));
- // No apid
+ /* No apid */
char no_apid[1] = "";
app = dlt_daemon_application_add(&daemon, no_apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,no_apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,ecu,0);
- EXPECT_EQ((DltDaemonContext *) 0, dlt_daemon_context_find(&daemon, no_apid, ctid, ecu, 0));
+ daecontext = dlt_daemon_context_add(&daemon,
+ no_apid,
+ ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(&daemon, no_apid, ctid, ecu, 0));
EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_GE(-1, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
- // No ctid
+ /* No ctid */
char no_ctid[1] = "";
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,apid,no_ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,ecu,0);
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(&daemon, apid, no_ctid, ecu, 0));
+ daecontext = dlt_daemon_context_add(&daemon,
+ apid,
+ no_ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(&daemon, apid, no_ctid, ecu, 0));
EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
- // No application added
- daecontext = dlt_daemon_context_add(&daemon,no_apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,ecu,0);
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(&daemon, no_apid, ctid, ecu, 0));
+ /* No application added */
+ daecontext = dlt_daemon_context_add(&daemon,
+ no_apid,
+ ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(&daemon, no_apid, ctid, ecu, 0));
EXPECT_GE(-1, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, ecu, 0));
EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, ecu, 0));
- // Verbose != 0 or 1
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(&daemon, apid, ctid, 123456789));
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
+ /* Verbose != 0 or 1 */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(&daemon, apid, ctid, 123456789)); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_context_find, nullpointer)
@@ -1050,14 +1153,14 @@ TEST(t_dlt_daemon_context_find, nullpointer)
ID4 ctid = "CON";
ID4 ecu = "ECU";
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(NULL, NULL, NULL, NULL, 0));
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(NULL, NULL, ctid, NULL, 0));
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(NULL, apid, NULL, NULL, 0));
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(NULL, apid, ctid, NULL, 0));
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(&daemon, NULL, NULL, NULL, 0));
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(&daemon, NULL, ctid, NULL, 0));
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(&daemon, apid, NULL, NULL, 0));
- EXPECT_EQ((DltDaemonContext *) 0 ,dlt_daemon_context_find(&daemon, NULL, NULL, ecu, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(NULL, NULL, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(NULL, NULL, ctid, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(NULL, apid, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(NULL, apid, ctid, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(&daemon, NULL, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(&daemon, NULL, ctid, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(&daemon, apid, NULL, NULL, 0));
+ EXPECT_EQ((DltDaemonContext *)0, dlt_daemon_context_find(&daemon, NULL, NULL, ecu, 0));
}
/* End Method: dlt_daemon_common::dlt_daemon_context_find */
@@ -1077,13 +1180,25 @@ TEST(t_dlt_daemon_contexts_clear, normal)
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,ecu,0);
+ daecontext = dlt_daemon_context_add(&daemon,
+ apid,
+ ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, ecu, 0));
@@ -1092,29 +1207,29 @@ TEST(t_dlt_daemon_contexts_clear, normal)
}
TEST(t_dlt_daemon_contexts_clear, abnormal)
{
-// DltDaemon daemon;
-// ID4 apid = "TES";
-// ID4 ctid = "CON";
-// char desc[255] = "TEST dlt_daemon_context_add";
-// DltDaemonContext *daecontext = NULL;
-// DltDaemonApplication *app = NULL;
-
- // No context added
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_contexts_clear(&daemon, 0));
-
- // Verbose != 0 or 1
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 123456789));
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* ID4 apid = "TES"; */
+/* ID4 ctid = "CON"; */
+/* char desc[255] = "TEST dlt_daemon_context_add"; */
+/* DltDaemonContext *daecontext = NULL; */
+/* DltDaemonApplication *app = NULL; */
+
+ /* No context added */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_contexts_clear(&daemon, 0)); */
+
+ /* Verbose != 0 or 1 */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 123456789)); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_contexts_clear, nullpointer)
{
- // NULL-Pointer
+ /* NULL-Pointer */
EXPECT_GE(-1, dlt_daemon_contexts_clear(NULL, NULL, 0));
}
/* End Method: dlt_daemon_common::dlt_daemon_contexts_clear */
@@ -1135,13 +1250,25 @@ TEST(t_dlt_daemon_contexts_invalidate_fd, normal)
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,ecu,0);
+ daecontext = dlt_daemon_context_add(&daemon,
+ apid,
+ ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
EXPECT_LE(0, dlt_daemon_contexts_invalidate_fd(&daemon, ecu, app->user_handle, 0));
EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
@@ -1151,30 +1278,30 @@ TEST(t_dlt_daemon_contexts_invalidate_fd, normal)
}
TEST(t_dlt_daemon_contexts_invalidate_fd, abnormal)
{
-// DltDaemon daemon;
-// ID4 apid = "TES";
-// ID4 ctid = "CON";
-// char desc[255] = "TEST dlt_daemon_context_add";
-// DltDaemonContext *daecontext = NULL;
-// DltDaemonApplication *app = NULL;
-
- // Uninitialized
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_contexts_invalidate_fd(&daemon, app->user_handle, 0));
-
- // Verbose != 0 or 1
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_GE(-1, dlt_daemon_contexts_invalidate_fd(&daemon, app->user_handle, 123456789));
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* ID4 apid = "TES"; */
+/* ID4 ctid = "CON"; */
+/* char desc[255] = "TEST dlt_daemon_context_add"; */
+/* DltDaemonContext *daecontext = NULL; */
+/* DltDaemonApplication *app = NULL; */
+
+ /* Uninitialized */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_contexts_invalidate_fd(&daemon, app->user_handle, 0)); */
+
+ /* Verbose != 0 or 1 */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_contexts_invalidate_fd(&daemon, app->user_handle, 123456789)); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_contexts_invalidate_fd, nullpointer)
{
- // NULL-Pointer
+ /* NULL-Pointer */
EXPECT_GE(-1, dlt_daemon_contexts_invalidate_fd(NULL, NULL, 0, 0));
}
/* End Method: dlt_daemon_common::dlt_daemon_contexts_invalidate_fd */
@@ -1192,17 +1319,29 @@ TEST(t_dlt_daemon_contexts_save, normal)
char desc[255] = "TEST dlt_daemon_context_add";
DltDaemonContext *daecontext = NULL;
DltDaemonApplication *app = NULL;
- const char * filename = "/tmp/dlt-runtime-context.cfg";
+ const char *filename = "/tmp/dlt-runtime-context.cfg";
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,ecu,0);
+ daecontext = dlt_daemon_context_add(&daemon,
+ apid,
+ ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
EXPECT_LE(0, dlt_daemon_contexts_save(&daemon, filename, 0));
EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
@@ -1212,43 +1351,43 @@ TEST(t_dlt_daemon_contexts_save, normal)
}
TEST(t_dlt_daemon_contexts_save, abnormal)
{
-// DltDaemon daemon;
-// ID4 apid = "TES";
-// ID4 ctid = "CON";
-// char desc[255] = "TEST dlt_daemon_context_add";
-// DltDaemonContext *daecontext = NULL;
-// DltDaemonApplication *app = NULL;
-// const char * filename = "/tmp/dlt-runtime-context.cfg";
-
- // Uninitialized
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_contexts_save(&daemon, filename, 0));
-
- // Verbose != 1 or 0, expect error
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_GE(-1, dlt_daemon_contexts_save(&daemon, filename, 123456789));
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
- // Wrong path filename
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_GE(-1, dlt_daemon_contexts_save(&daemon, (char *) "PATCH_NOT_EXISTS", 0));
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* ID4 apid = "TES"; */
+/* ID4 ctid = "CON"; */
+/* char desc[255] = "TEST dlt_daemon_context_add"; */
+/* DltDaemonContext *daecontext = NULL; */
+/* DltDaemonApplication *app = NULL; */
+/* const char * filename = "/tmp/dlt-runtime-context.cfg"; */
+
+ /* Uninitialized */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_contexts_save(&daemon, filename, 0)); */
+
+ /* Verbose != 1 or 0, expect error */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_contexts_save(&daemon, filename, 123456789)); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+ /* Wrong path filename */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_contexts_save(&daemon, (char *) "PATCH_NOT_EXISTS", 0)); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_contexts_save, nullpointer)
{
DltDaemon daemon;
- const char * filename = "/tmp/dlt-runtime-context.cfg";
+ const char *filename = "/tmp/dlt-runtime-context.cfg";
- // NULL-Pointer
+ /* NULL-Pointer */
EXPECT_GE(-1, dlt_daemon_contexts_save(NULL, NULL, 0));
EXPECT_GE(-1, dlt_daemon_contexts_save(NULL, filename, 0));
EXPECT_GE(-1, dlt_daemon_contexts_save(&daemon, NULL, 0));
@@ -1268,17 +1407,29 @@ TEST(t_dlt_daemon_contexts_load, normal)
char desc[255] = "TEST dlt_daemon_context_add";
DltDaemonContext *daecontext = NULL;
DltDaemonApplication *app = NULL;
- const char * filename = "/tmp/dlt-runtime-context.cfg";
+ const char *filename = "/tmp/dlt-runtime-context.cfg";
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,ecu,0);
+ daecontext = dlt_daemon_context_add(&daemon,
+ apid,
+ ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 0,
+ desc,
+ ecu,
+ 0);
EXPECT_LE(0, dlt_daemon_contexts_load(&daemon, filename, 0));
EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
@@ -1288,43 +1439,43 @@ TEST(t_dlt_daemon_contexts_load, normal)
}
TEST(t_dlt_daemon_contexts_load, abnormal)
{
-// DltDaemon daemon;
-// ID4 apid = "TES";
-// ID4 ctid = "CON";
-// char desc[255] = "TEST dlt_daemon_context_add";
-// DltDaemonContext *daecontext = NULL;
-// DltDaemonApplication *app = NULL;
-// const char * filename = "/tmp/dlt-runtime-context.cfg";
-
- // Uninitialized
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_contexts_load(&daemon, filename, 0));
-
- // Verbose != 1 or 0, expect error
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_GE(-1, dlt_daemon_contexts_load(&daemon, filename, 123456789));
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-
- // Wrong path filename
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_GE(-1, dlt_daemon_contexts_load(&daemon, (char *) "PATCH_NOT_EXISTS", 0));
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* ID4 apid = "TES"; */
+/* ID4 ctid = "CON"; */
+/* char desc[255] = "TEST dlt_daemon_context_add"; */
+/* DltDaemonContext *daecontext = NULL; */
+/* DltDaemonApplication *app = NULL; */
+/* const char * filename = "/tmp/dlt-runtime-context.cfg"; */
+
+ /* Uninitialized */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_contexts_load(&daemon, filename, 0)); */
+
+ /* Verbose != 1 or 0, expect error */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_contexts_load(&daemon, filename, 123456789)); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+
+ /* Wrong path filename */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_contexts_load(&daemon, (char *) "PATCH_NOT_EXISTS", 0)); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_contexts_load, nullpointer)
{
DltDaemon daemon;
- const char * filename = "/tmp/dlt-runtime-context.cfg";
+ const char *filename = "/tmp/dlt-runtime-context.cfg";
- // NULL-Pointer
+ /* NULL-Pointer */
EXPECT_GE(-1, dlt_daemon_contexts_load(NULL, NULL, 0));
EXPECT_GE(-1, dlt_daemon_contexts_load(NULL, filename, 0));
EXPECT_GE(-1, dlt_daemon_contexts_load(&daemon, NULL, 0));
@@ -1343,15 +1494,18 @@ TEST(t_dlt_daemon_contexts_load, nullpointer)
/* Begin Method: dlt_daemon_common::dlt_daemon_user_send_all_log_state */
-// Can't test this Method, maybe a return value would be a better solution
+/* Can't test this Method, maybe a return value would be a better solution */
TEST(t_dlt_daemon_user_send_all_log_state, normal)
{
DltDaemon daemon;
DltGateway gateway;
char ecu[] = "ECU1";
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
@@ -1359,9 +1513,7 @@ TEST(t_dlt_daemon_user_send_all_log_state, normal)
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_user_send_all_log_state, abnormal)
-{
-
-}
+{}
TEST(t_dlt_daemon_user_send_all_log_state, nullpointer)
{
EXPECT_NO_FATAL_FAILURE(dlt_daemon_user_send_all_log_state(NULL, 0));
@@ -1372,15 +1524,18 @@ TEST(t_dlt_daemon_user_send_all_log_state, nullpointer)
/* Begin Method: dlt_daemon_common::dlt_daemon_user_send_default_update */
-// Can't test this Method, maybe a return value would be a better solution
+/* Can't test this Method, maybe a return value would be a better solution */
TEST(t_dlt_daemon_user_send_default_update, normal)
{
DltDaemon daemon;
DltGateway gateway;
char ecu[] = "ECU1";
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
@@ -1388,9 +1543,7 @@ TEST(t_dlt_daemon_user_send_default_update, normal)
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_user_send_default_update, abnormal)
-{
-
-}
+{}
TEST(t_dlt_daemon_user_send_default_update, nullpointer)
{
EXPECT_NO_FATAL_FAILURE(dlt_daemon_user_send_default_update(NULL, 0));
@@ -1413,13 +1566,25 @@ TEST(t_dlt_daemon_user_send_log_level, normal)
char ecu[] = "ECU1";
int fd = 42;
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
app = dlt_daemon_application_add(&daemon, apid, 0, desc, fd, ecu, 0);
- daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,1,desc,ecu,0);
+ daecontext = dlt_daemon_context_add(&daemon,
+ apid,
+ ctid,
+ DLT_LOG_DEFAULT,
+ DLT_TRACE_STATUS_DEFAULT,
+ 0,
+ 1,
+ desc,
+ ecu,
+ 0);
EXPECT_LE(0, dlt_daemon_user_send_log_level(&daemon, daecontext, 0));
EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, ecu, 0));
EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, ecu, 0));
@@ -1429,42 +1594,42 @@ TEST(t_dlt_daemon_user_send_log_level, normal)
}
TEST(t_dlt_daemon_user_send_log_level, abnormal)
{
-// DltDaemon daemon;
-// ID4 apid = "TES";
-// ID4 ctid = "CON";
-// char desc[255] = "TEST dlt_daemon_context_add";
-// DltDaemonContext *daecontext = NULL;
-// DltDaemonApplication *app = NULL;
-
- // Uninitialized
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_user_send_log_level(&daemon, daecontext, 0));
-
- // File Handler <= 0
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,-1,desc,0);
-// EXPECT_GE(-1, dlt_daemon_user_send_log_level(&daemon, daecontext, 0));
-// EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, 0));
-// EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, 0));
-// EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 0));
-// EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, 0));
-
- // Verbose != 0 or 1
-// app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,1,desc,0);
-// EXPECT_GE(-1, dlt_daemon_user_send_log_level(&daemon, daecontext, 123456789));
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* ID4 apid = "TES"; */
+/* ID4 ctid = "CON"; */
+/* char desc[255] = "TEST dlt_daemon_context_add"; */
+/* DltDaemonContext *daecontext = NULL; */
+/* DltDaemonApplication *app = NULL; */
+
+ /* Uninitialized */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_user_send_log_level(&daemon, daecontext, 0)); */
+
+ /* File Handler <= 0 */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,-1,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_user_send_log_level(&daemon, daecontext, 0)); */
+/* EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, 0)); */
+/* EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, 0)); */
+/* EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 0)); */
+/* EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, 0)); */
+
+ /* Verbose != 0 or 1 */
+/* app = dlt_daemon_application_add(&daemon, apid, 0, desc, 0); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,1,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_user_send_log_level(&daemon, daecontext, 123456789)); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_user_send_log_level, nullpointer)
{
DltDaemon daemon;
DltDaemonContext daecontext;
- // NULL-Pointer
+ /* NULL-Pointer */
EXPECT_GE(-1, dlt_daemon_user_send_log_level(NULL, NULL, 0));
EXPECT_GE(-1, dlt_daemon_user_send_log_level(NULL, &daecontext, 0));
EXPECT_GE(-1, dlt_daemon_user_send_log_level(&daemon, NULL, 0));
@@ -1479,76 +1644,79 @@ TEST(t_dlt_daemon_user_send_log_state, normal)
{
DltDaemon daemon;
DltGateway gateway;
-// ID4 apid = "TES";
-// ID4 ctid = "CON";
-// char desc[255] = "TEST dlt_daemon_context_add";
-// DltDaemonContext *daecontext;
-// DltDaemonApplication *app;
+/* ID4 apid = "TES"; */
+/* ID4 ctid = "CON"; */
+/* char desc[255] = "TEST dlt_daemon_context_add"; */
+/* DltDaemonContext *daecontext; */
+/* DltDaemonApplication *app; */
pid_t pid = 18166;
char ecu[] = "ECU1";
- char filename[DLT_DAEMON_COMMON_TEXTBUFSIZE+1];
- snprintf(filename,DLT_DAEMON_COMMON_TEXTBUFSIZE,"%s/dlt%d",DLT_USER_DIR,pid);
-
- // Normal Use-Case
- EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ char filename[DLT_DAEMON_COMMON_TEXTBUFSIZE + 1];
+ snprintf(filename, DLT_DAEMON_COMMON_TEXTBUFSIZE, "%s/dlt%d", DLT_USER_DIR, pid);
+
+ /* Normal Use-Case */
+ EXPECT_EQ(0,
+ dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE,
+ DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY, DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, strncmp(daemon.ecuid, daemon.user_list[0].ecu, DLT_ID_SIZE));
-// open(filename, O_RDWR |O_NONBLOCK);
-// dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, "",0);
-// app = dlt_daemon_application_add(&daemon, apid, pid, desc, 0);
-// //printf("### USERHANDLE=%i\n", app->user_handle);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_GE(0, dlt_daemon_user_send_log_state(&daemon, app, 0));
-// EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, 0));
-// EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, 0));
-// EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 0));
-// EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, 0));
-// EXPECT_LE(0, close(app->user_handle));
+/* open(filename, O_RDWR |O_NONBLOCK); */
+/* dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, "",0); */
+/* app = dlt_daemon_application_add(&daemon, apid, pid, desc, 0); */
+/* //printf("### USERHANDLE=%i\n", app->user_handle); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_GE(0, dlt_daemon_user_send_log_state(&daemon, app, 0)); */
+/* EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, 0)); */
+/* EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, 0)); */
+/* EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 0)); */
+/* EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, 0)); */
+/* EXPECT_LE(0, close(app->user_handle)); */
EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
}
TEST(t_dlt_daemon_user_send_log_state, abnormal)
{
-// DltDaemon daemon;
-// ID4 apid = "TES";
-// ID4 ctid = "CON";
-// char desc[255] = "TEST dlt_daemon_context_add";
-// DltDaemonContext *daecontext = NULL;
-// DltDaemonApplication *app = NULL;
-// pid_t pid = 18166;
-// char filename[DLT_DAEMON_COMMON_TEXTBUFSIZE+1];
-// snprintf(filename,DLT_DAEMON_COMMON_TEXTBUFSIZE,"%s/dlt%d",DLT_USER_DIR,pid);
-
- //Uninitialized
-// EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
-// EXPECT_GE(-1, dlt_daemon_user_send_log_state(&daemon, app, 0));
-
- // No Pipe open
- //open(filename, O_RDWR |O_NONBLOCK);
-// dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, "",0);
-// app = dlt_daemon_application_add(&daemon, apid, pid, desc, 0);
- //printf("### USERHANDLE=%i\n", app->user_handle);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_GE(-1, dlt_daemon_user_send_log_state(&daemon, app, 0));
-// EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, 0));
-// EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, 0));
-// EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 0));
-// EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, 0));
-// EXPECT_LE(0, close(app->user_handle));
-
- // Verbose != 1 or 0
-// open(filename, O_RDWR |O_NONBLOCK);
-// dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, "",0);
-// app = dlt_daemon_application_add(&daemon, apid, pid, desc, 0);
-// //printf("### USERHANDLE=%i\n", app->user_handle);
-// daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0);
-// EXPECT_GE(-1, dlt_daemon_user_send_log_state(&daemon, app, 123456789));
-// dlt_daemon_context_del(&daemon, daecontext, 0);
-// dlt_daemon_application_del(&daemon, app, 0);
-// dlt_daemon_contexts_clear(&daemon, 0);
-// dlt_daemon_applications_clear(&daemon, 0);
-// close(app->user_handle);
-// EXPECT_EQ(0, dlt_daemon_free(&daemon, 0));
+/* DltDaemon daemon; */
+/* ID4 apid = "TES"; */
+/* ID4 ctid = "CON"; */
+/* char desc[255] = "TEST dlt_daemon_context_add"; */
+/* DltDaemonContext *daecontext = NULL; */
+/* DltDaemonApplication *app = NULL; */
+/* pid_t pid = 18166; */
+/* char filename[DLT_DAEMON_COMMON_TEXTBUFSIZE+1]; */
+/* snprintf(filename,DLT_DAEMON_COMMON_TEXTBUFSIZE,"%s/dlt%d",DLT_USER_DIR,pid); */
+
+ /*Uninitialized */
+/* EXPECT_EQ(0, dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, DLT_RUNTIME_DEFAULT_DIRECTORY,DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0)); */
+/* EXPECT_GE(-1, dlt_daemon_user_send_log_state(&daemon, app, 0)); */
+
+ /* No Pipe open */
+ /*open(filename, O_RDWR |O_NONBLOCK); */
+/* dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, "",0); */
+/* app = dlt_daemon_application_add(&daemon, apid, pid, desc, 0); */
+ /*printf("### USERHANDLE=%i\n", app->user_handle); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_user_send_log_state(&daemon, app, 0)); */
+/* EXPECT_LE(0, dlt_daemon_context_del(&daemon, daecontext, 0)); */
+/* EXPECT_LE(0, dlt_daemon_application_del(&daemon, app, 0)); */
+/* EXPECT_LE(0, dlt_daemon_contexts_clear(&daemon, 0)); */
+/* EXPECT_LE(0, dlt_daemon_applications_clear(&daemon, 0)); */
+/* EXPECT_LE(0, close(app->user_handle)); */
+
+ /* Verbose != 1 or 0 */
+/* open(filename, O_RDWR |O_NONBLOCK); */
+/* dlt_daemon_init(&daemon, DLT_DAEMON_RINGBUFFER_MIN_SIZE, DLT_DAEMON_RINGBUFFER_MAX_SIZE, DLT_DAEMON_RINGBUFFER_STEP_SIZE, "",0); */
+/* app = dlt_daemon_application_add(&daemon, apid, pid, desc, 0); */
+/* //printf("### USERHANDLE=%i\n", app->user_handle); */
+/* daecontext = dlt_daemon_context_add(&daemon,apid,ctid,DLT_LOG_DEFAULT,DLT_TRACE_STATUS_DEFAULT,0,0,desc,0); */
+/* EXPECT_GE(-1, dlt_daemon_user_send_log_state(&daemon, app, 123456789)); */
+/* dlt_daemon_context_del(&daemon, daecontext, 0); */
+/* dlt_daemon_application_del(&daemon, app, 0); */
+/* dlt_daemon_contexts_clear(&daemon, 0); */
+/* dlt_daemon_applications_clear(&daemon, 0); */
+/* close(app->user_handle); */
+/* EXPECT_EQ(0, dlt_daemon_free(&daemon, 0)); */
}
TEST(t_dlt_daemon_user_send_log_state, nullpointer)
{
@@ -1575,7 +1743,7 @@ int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
::testing::FLAGS_gtest_break_on_failure = true;
- //::testing::FLAGS_gtest_filter = "*.normal";
- //::testing::FLAGS_gtest_repeat = 10000;
+ /*::testing::FLAGS_gtest_filter = "*.normal"; */
+ /*::testing::FLAGS_gtest_repeat = 10000; */
return RUN_ALL_TESTS();
}
diff --git a/tests/gtest_dlt_daemon_event_handler.cpp b/tests/gtest_dlt_daemon_event_handler.cpp
index df9caa0..82e01bb 100644
--- a/tests/gtest_dlt_daemon_event_handler.cpp
+++ b/tests/gtest_dlt_daemon_event_handler.cpp
@@ -79,7 +79,7 @@ TEST(t_dlt_daemon_prepare_event_handling, normal)
TEST(t_dlt_daemon_prepare_event_handling, nullpointer)
{
- // NULL-Pointer, expect -1
+ /* NULL-Pointer, expect -1 */
EXPECT_EQ(DLT_RETURN_ERROR, dlt_daemon_prepare_event_handling(NULL));
}
@@ -91,13 +91,13 @@ TEST(t_dlt_daemon_handle_event, normal)
EXPECT_EQ(DLT_RETURN_OK, dlt_daemon_prepare_event_handling(&daemon_local.pEvent));
EXPECT_EQ(DLT_RETURN_OK, dlt_daemon_handle_event(&daemon_local.pEvent,
- &daemon,
- &daemon_local));
+ &daemon,
+ &daemon_local));
}
TEST(t_dlt_daemon_handle_event, nullpointer)
{
- EXPECT_EQ(DLT_RETURN_ERROR, dlt_daemon_handle_event(NULL,NULL,NULL));
+ EXPECT_EQ(DLT_RETURN_ERROR, dlt_daemon_handle_event(NULL, NULL, NULL));
}
/* Begin Method: dlt_daemon_event_handler::dlt_event_handler_find_connection*/
@@ -127,7 +127,7 @@ TEST(t_dlt_daemon_add_connection, normal)
DltReceiver receiver = {};
ev1.connections = (DltConnection *)malloc(sizeof(DltConnection));
- head = (DltConnection*)ev1.connections;
+ head = (DltConnection *)ev1.connections;
memset(ev1.connections, 0, sizeof(DltConnection));
ev1.connections->next = 0;
ev1.connections->type = DLT_CONNECTION_CLIENT_MSG_SERIAL;
@@ -141,7 +141,7 @@ TEST(t_dlt_daemon_add_connection, normal)
EXPECT_EQ(DLT_CONNECTION_CLIENT_MSG_SERIAL, ev1.connections->type);
dlt_daemon_add_connection(&ev1, connections1);
- head = (DltConnection*)ev1.connections->next;
+ head = (DltConnection *)ev1.connections->next;
EXPECT_EQ(DLT_CONNECTION_GATEWAY, head->type);
@@ -157,7 +157,7 @@ TEST(t_dlt_daemon_remove_connection, normal)
DltConnection *connections1 = nullptr;
ev1.connections = (DltConnection *)malloc(sizeof(DltConnection));
- head = (DltConnection*)ev1.connections;
+ head = (DltConnection *)ev1.connections;
memset(ev1.connections, 0, sizeof(DltConnection));
ev1.connections->next = 0;
ev1.connections->type = DLT_CONNECTION_CLIENT_MSG_SERIAL;
@@ -172,7 +172,7 @@ TEST(t_dlt_daemon_remove_connection, normal)
EXPECT_EQ(DLT_CONNECTION_CLIENT_MSG_SERIAL, ev1.connections->type);
dlt_daemon_add_connection(&ev1, connections1);
- head = (DltConnection*)ev1.connections->next;
+ head = (DltConnection *)ev1.connections->next;
EXPECT_EQ(DLT_CONNECTION_GATEWAY, head->type);
@@ -208,7 +208,7 @@ TEST(t_dlt_connection_check_activate, normal)
con.type = DLT_CONNECTION_CLIENT_MSG_TCP;
EXPECT_EQ(DLT_RETURN_OK, dlt_daemon_prepare_event_handling(&evhdl));
-
+
ret = dlt_connection_check_activate(&evhdl, &con, ACTIVATE);
EXPECT_EQ(DLT_RETURN_OK, ret);
@@ -300,7 +300,7 @@ TEST(t_dlt_connection_create, normal)
DltDaemonLocal daemon_local = {};
EXPECT_EQ(DLT_RETURN_OK,
- dlt_daemon_prepare_event_handling(&daemon_local.pEvent));
+ dlt_daemon_prepare_event_handling(&daemon_local.pEvent));
ret = dlt_connection_create(&daemon_local,
&daemon_local.pEvent,
@@ -417,6 +417,7 @@ TEST(t_dlt_connection_send, normal_1)
conn.type = DLT_CONNECTION_CLIENT_MSG_TCP;
daemon_local.msg.databuffer = (uint8_t *)malloc(sizeof(uint8_t));
+
if (daemon_local.msg.databuffer == NULL)
close(receiver.fd);
@@ -447,8 +448,8 @@ TEST(t_dlt_connection_send, normal_2)
conn.type = DLT_CONNECTION_CLIENT_MSG_SERIAL;
ret = dlt_connection_send(&conn,
- (void *)dltSerialHeader,
- sizeof(dltSerialHeader));
+ (void *)dltSerialHeader,
+ sizeof(dltSerialHeader));
EXPECT_EQ(DLT_RETURN_OK, ret);
}
@@ -464,8 +465,8 @@ TEST(t_dlt_connection_send, abnormal)
conn.type = DLT_CONNECTION_TYPE_MAX;
ret = dlt_connection_send(&conn,
- (void *)dltSerialHeader,
- sizeof(dltSerialHeader));
+ (void *)dltSerialHeader,
+ sizeof(dltSerialHeader));
EXPECT_EQ(DLT_RETURN_ERROR, ret);
}
@@ -493,9 +494,9 @@ TEST(t_dlt_connection_send_multiple, normal_1)
conn.type = DLT_CONNECTION_CLIENT_MSG_TCP;
daemon_local.msg.headersize = sizeof(DltStorageHeader) +
- sizeof(DltStandardHeader) +
- sizeof(DltStandardHeaderExtra) +
- sizeof(DltExtendedHeader);
+ sizeof(DltStandardHeader) +
+ sizeof(DltStandardHeaderExtra) +
+ sizeof(DltExtendedHeader);
memset(daemon_local.msg.headerbuffer, 0, daemon_local.msg.headersize);
@@ -503,6 +504,7 @@ TEST(t_dlt_connection_send_multiple, normal_1)
size1 = daemon_local.msg.headersize - sizeof(DltStorageHeader);
daemon_local.msg.databuffer = (uint8_t *)malloc(sizeof(uint8_t));
+
if (daemon_local.msg.databuffer == NULL)
close(receiver.fd);
@@ -515,11 +517,11 @@ TEST(t_dlt_connection_send_multiple, normal_1)
size2 = daemon_local.msg.datasize;
ret = dlt_connection_send_multiple(&conn,
- data1,
- size1,
- data2,
- size2,
- 1);
+ data1,
+ size1,
+ data2,
+ size2,
+ 1);
EXPECT_EQ(DLT_RETURN_OK, ret);
@@ -550,9 +552,9 @@ TEST(t_dlt_connection_send_multiple, normal_2)
conn.type = DLT_CONNECTION_CLIENT_MSG_TCP;
daemon_local.msg.headersize = sizeof(DltStorageHeader) +
- sizeof(DltStandardHeader) +
- sizeof(DltStandardHeaderExtra) +
- sizeof(DltExtendedHeader);
+ sizeof(DltStandardHeader) +
+ sizeof(DltStandardHeaderExtra) +
+ sizeof(DltExtendedHeader);
memset(daemon_local.msg.headerbuffer, 0, daemon_local.msg.headersize);
@@ -560,6 +562,7 @@ TEST(t_dlt_connection_send_multiple, normal_2)
size1 = daemon_local.msg.headersize - sizeof(DltStorageHeader);
daemon_local.msg.databuffer = (uint8_t *)malloc(sizeof(uint8_t));
+
if (daemon_local.msg.databuffer == NULL)
close(receiver.fd);
@@ -572,11 +575,11 @@ TEST(t_dlt_connection_send_multiple, normal_2)
size2 = daemon_local.msg.datasize;
ret = dlt_connection_send_multiple(&conn,
- data1,
- size1,
- data2,
- size2,
- 0);
+ data1,
+ size1,
+ data2,
+ size2,
+ 0);
EXPECT_EQ(DLT_RETURN_OK, ret);
@@ -599,11 +602,11 @@ TEST(t_dlt_connection_send_multiple, nullpointer)
size2 = daemon_local.msg.datasize;
ret = dlt_connection_send_multiple(NULL,
- data1,
- size1,
- data2,
- size2,
- 0);
+ data1,
+ size1,
+ data2,
+ size2,
+ 0);
EXPECT_EQ(DLT_RETURN_ERROR, ret);
}
@@ -617,15 +620,14 @@ int connectServer(void)
portno = 8080;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
server = gethostbyname("127.0.0.1");
- memset((char *) &serv_addr, 0, sizeof(serv_addr));
+ memset((char *)&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
memcpy((char *)&serv_addr.sin_addr.s_addr,
(char *)server->h_addr,
server->h_length);
serv_addr.sin_port = htons(portno);
- if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
- {
+ if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
printf("Error: %s (%d) occured in connect socket\n",
strerror(errno),
errno);
@@ -640,16 +642,14 @@ int connectServer(void)
int main(int argc, char **argv)
{
- pid_t cpid = fork();
+ pid_t cpid = fork();
- if(cpid == -1)
- {
+ if (cpid == -1) {
printf("fork fail\n");
return -1;
}
- if (cpid)
- {
+ if (cpid) {
int i = GTEST_SOCKS_ACCEPTED;
int j = 0, optval = 1;
char buffer[256] = {};
@@ -658,13 +658,12 @@ int main(int argc, char **argv)
struct sockaddr_in serv_addr = {}, cli_addr = {};
sockfd = socket(AF_INET, SOCK_STREAM, 0);
- if(sockfd == -1)
- {
+ if (sockfd == -1) {
printf("Error in creating socket\n");
return -1;
}
- bzero((char *) &serv_addr, sizeof(serv_addr));
+ bzero((char *)&serv_addr, sizeof(serv_addr));
portno = 8080;
serv_addr.sin_family = AF_INET;
@@ -681,24 +680,23 @@ int main(int argc, char **argv)
exit(1);
}
- j = bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
- if(j == -1)
- {
+ j = bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
+
+ if (j == -1) {
perror("Bind Error\n");
close(sockfd);
return -1;
}
listen(sockfd, 5);
- while(i)
- {
+
+ while (i) {
clilen = sizeof(cli_addr);
newsockfd[i - 1] = accept(sockfd,
(struct sockaddr *)&cli_addr,
&clilen);
- if(newsockfd[i - 1] == -1)
- {
+ if (newsockfd[i - 1] == -1) {
printf("Error in accept");
return -1;
}
@@ -708,18 +706,18 @@ int main(int argc, char **argv)
i--;
}
- for(j = 0; j < GTEST_SOCKS_ACCEPTED; j++)
+ for (j = 0; j < GTEST_SOCKS_ACCEPTED; j++)
close(newsockfd[i]);
close(sockfd);
}
- else
- {
+ else {
::testing::InitGoogleTest(&argc, argv);
::testing::FLAGS_gtest_break_on_failure = false;
-// ::testing::FLAGS_gtest_filter = "t_dlt_event_handler_register_connection*";
+/* ::testing::FLAGS_gtest_filter = "t_dlt_event_handler_register_connection*"; */
return RUN_ALL_TESTS();
}
+
return 0;
}
diff --git a/tests/gtest_dlt_daemon_gateway.cpp b/tests/gtest_dlt_daemon_gateway.cpp
index d07c35d..af9d865 100644
--- a/tests/gtest_dlt_daemon_gateway.cpp
+++ b/tests/gtest_dlt_daemon_gateway.cpp
@@ -81,7 +81,7 @@ TEST(t_dlt_gateway_init, normal)
daemon_local.pEvent.max_nfds = 0;
daemon_local.pEvent.connections->receiver = &receiver;
daemon_local.pEvent.connections->next = NULL;
- memset(daemon_local.flags.gatewayConfigFile,0,DLT_DAEMON_FLAG_MAX);
+ memset(daemon_local.flags.gatewayConfigFile, 0, DLT_DAEMON_FLAG_MAX);
strncpy(daemon_local.flags.gatewayConfigFile, "/tmp/dlt_gateway.conf", DLT_DAEMON_FLAG_MAX - 1);
EXPECT_EQ(DLT_RETURN_OK, dlt_gateway_init(&daemon_local, 1));
@@ -109,13 +109,16 @@ TEST(t_dlt_gateway_send_control_message, Normal)
daemon_local.pEvent.nfds = 0;
daemon_local.pEvent.max_nfds = 0;
daemon_local.pEvent.connections->receiver = &receiver1;
- memset(daemon_local.flags.gatewayConfigFile,0,DLT_DAEMON_FLAG_MAX);
+ memset(daemon_local.flags.gatewayConfigFile, 0, DLT_DAEMON_FLAG_MAX);
strncpy(daemon_local.flags.gatewayConfigFile, "/tmp/dlt_gateway.conf", DLT_DAEMON_FLAG_MAX - 1);
ret = dlt_gateway_init(&daemon_local, 0);
EXPECT_EQ(DLT_RETURN_OK, ret);
- dlt_gateway_send_control_message(daemon_local.pGateway.connections, daemon_local.pGateway.connections->p_control_msgs, NULL, 0);
+ dlt_gateway_send_control_message(daemon_local.pGateway.connections,
+ daemon_local.pGateway.connections->p_control_msgs,
+ NULL,
+ 0);
dlt_gateway_deinit(&daemon_local.pGateway, 0);
}
@@ -154,8 +157,8 @@ TEST(t_dlt_gateway_store_connection, nullpointer)
{
DltGateway gateway;
- EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER, dlt_gateway_store_connection(NULL , NULL, 0));
- EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER, dlt_gateway_store_connection(&gateway , NULL, 0));
+ EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER, dlt_gateway_store_connection(NULL, NULL, 0));
+ EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER, dlt_gateway_store_connection(&gateway, NULL, 0));
}
/* Begin Method: dlt_gateway::t_dlt_gateway_check_ip*/
@@ -411,7 +414,7 @@ TEST(t_dlt_gateway_parse_get_log_info, normal)
uint16_t len_app = 0;
uint16_t len_con = 0;
int8_t log_level = -1;
- int8_t trace_status = -1;;
+ int8_t trace_status = -1;
int offset = 0;
memset(&daemon, 0, sizeof(DltDaemon));
@@ -423,11 +426,11 @@ TEST(t_dlt_gateway_parse_get_log_info, normal)
/* create response message */
msg.datasize = sizeof(DltServiceGetLogInfoResponse) +
- sizeof(AppIDsType) +
- sizeof(ContextIDsInfoType) +
- strlen(app_description) +
- strlen(context_description);
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
+ sizeof(AppIDsType) +
+ sizeof(ContextIDsInfoType) +
+ strlen(app_description) +
+ strlen(context_description);
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
msg.databuffersize = msg.datasize;
memset(msg.databuffer, 0, msg.datasize);
@@ -440,13 +443,13 @@ TEST(t_dlt_gateway_parse_get_log_info, normal)
memcpy(msg.databuffer + offset, &count_app_ids, sizeof(uint16_t));
offset += sizeof(uint16_t);
- dlt_set_id((char*)(msg.databuffer + offset), apid);
+ dlt_set_id((char *)(msg.databuffer + offset), apid);
offset += sizeof(ID4);
memcpy(msg.databuffer + offset, &count_context_ids, sizeof(uint16_t));
offset += sizeof(uint16_t);
- dlt_set_id((char*)(msg.databuffer + offset), ctid);
+ dlt_set_id((char *)(msg.databuffer + offset), ctid);
offset += sizeof(ID4);
memcpy(msg.databuffer + offset, &log_level, sizeof(int8_t));
@@ -469,32 +472,32 @@ TEST(t_dlt_gateway_parse_get_log_info, normal)
memcpy(msg.databuffer + offset, app_description, strlen(app_description));
offset += strlen(app_description);
- dlt_set_id((char*)(msg.databuffer + offset), com);
+ dlt_set_id((char *)(msg.databuffer + offset), com);
- msg.storageheader = (DltStorageHeader*)msg.headerbuffer;
+ msg.storageheader = (DltStorageHeader *)msg.headerbuffer;
dlt_set_storageheader(msg.storageheader, "");
- msg.standardheader = (DltStandardHeader*)(msg.headerbuffer + sizeof(DltStorageHeader));
- msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1 ;
+ msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+ msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
msg.standardheader->mcnt = 0;
dlt_set_id(msg.headerextra.ecu, ecuid);
msg.headerextra.tmsp = dlt_uptime();
dlt_message_set_extraparameters(&msg, 0);
- msg.extendedheader = (DltExtendedHeader*)(msg.headerbuffer +
- sizeof(DltStorageHeader) +
- sizeof(DltStandardHeader) +
- DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp) );
+ msg.extendedheader = (DltExtendedHeader *)(msg.headerbuffer +
+ sizeof(DltStorageHeader) +
+ sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
msg.extendedheader->msin = DLT_MSIN_CONTROL_RESPONSE;
msg.extendedheader->noar = 1;
dlt_set_id(msg.extendedheader->apid, "");
dlt_set_id(msg.extendedheader->ctid, "");
msg.headersize = sizeof(DltStorageHeader) +
- sizeof(DltStandardHeader) +
- sizeof(DltExtendedHeader) +
- DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
+ sizeof(DltStandardHeader) +
+ sizeof(DltExtendedHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
len = msg.headersize - sizeof(DltStorageHeader) + msg.datasize;
msg.standardheader->len = DLT_HTOBE_16(len);
@@ -521,7 +524,7 @@ TEST(t_dlt_gateway_process_passive_node_messages, normal)
daemon_local.pGateway.num_connections = 1;
daemon_local.pGateway.connections->status = DLT_GATEWAY_CONNECTED;
- EXPECT_EQ(DLT_RETURN_OK, dlt_gateway_process_passive_node_messages(&daemon,&daemon_local,&receiver,1));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_gateway_process_passive_node_messages(&daemon, &daemon_local, &receiver, 1));
}
TEST(t_dlt_gateway_process_passive_node_messages, nullpointer)
@@ -550,7 +553,8 @@ TEST(t_dlt_gateway_process_gateway_timer, normal)
daemon.storage_handle = &storage_handle;
daemon_local.pEvent.connections->receiver->fd = -1;
- EXPECT_EQ(DLT_RETURN_OK, dlt_gateway_process_gateway_timer(&daemon,&daemon_local,daemon_local.pEvent.connections->receiver,1));
+ EXPECT_EQ(DLT_RETURN_OK,
+ dlt_gateway_process_gateway_timer(&daemon, &daemon_local, daemon_local.pEvent.connections->receiver, 1));
}
TEST(t_dlt_gateway_process_gateway_timer, nullpointer)
@@ -572,10 +576,10 @@ TEST(t_dlt_gateway_process_on_demand_request, normal)
connections.ecuid = node_id;
EXPECT_EQ(DLT_RETURN_OK, dlt_gateway_process_on_demand_request(&daemon_local.pGateway,
- &daemon_local,
- node_id,
- connection_status,
- 1));
+ &daemon_local,
+ node_id,
+ connection_status,
+ 1));
}
TEST(t_dlt_gateway_process_on_demand_request, abnormal)
@@ -590,10 +594,10 @@ TEST(t_dlt_gateway_process_on_demand_request, abnormal)
connections.ecuid = node_id;
EXPECT_EQ(DLT_RETURN_ERROR, dlt_gateway_process_on_demand_request(&daemon_local.pGateway,
- &daemon_local,
- node_id,
- connection_status,
- 0));
+ &daemon_local,
+ node_id,
+ connection_status,
+ 0));
}
TEST(t_dlt_gateway_process_on_demand_request, nullpointer)
@@ -612,14 +616,14 @@ TEST(t_dlt_gateway_check_param, normal)
gateway.connections = &tmp;
EXPECT_EQ(DLT_RETURN_OK, dlt_gateway_check_param(&gateway,
- &tmp,
- GW_CONF_IP_ADDRESS,
- value_1));
+ &tmp,
+ GW_CONF_IP_ADDRESS,
+ value_1));
EXPECT_EQ(DLT_RETURN_OK, dlt_gateway_check_param(&gateway,
- &tmp,
- GW_CONF_PORT,
- value_2));
+ &tmp,
+ GW_CONF_PORT,
+ value_2));
}
TEST(t_dlt_gateway_check_param, abnormal)
@@ -630,9 +634,9 @@ TEST(t_dlt_gateway_check_param, abnormal)
gateway.connections = &tmp;
EXPECT_EQ(DLT_RETURN_ERROR, dlt_gateway_check_param(&gateway,
- &tmp,
- GW_CONF_PORT,
- value_1));
+ &tmp,
+ GW_CONF_PORT,
+ value_1));
}
TEST(t_dlt_gateway_check_param, nullpointer)
@@ -661,7 +665,7 @@ TEST(t_dlt_gateway_configure, nullpointer)
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
-// ::testing::FLAGS_gtest_break_on_failure = true;
-// ::testing::FLAGS_gtest_filter = "t_dlt_gateway_process_passive_node_messages*";
+/* ::testing::FLAGS_gtest_break_on_failure = true; */
+/* ::testing::FLAGS_gtest_filter = "t_dlt_gateway_process_passive_node_messages*"; */
return RUN_ALL_TESTS();
}
diff --git a/tests/gtest_dlt_daemon_offline_log.cpp b/tests/gtest_dlt_daemon_offline_log.cpp
index 2563e3d..549ac5c 100644
--- a/tests/gtest_dlt_daemon_offline_log.cpp
+++ b/tests/gtest_dlt_daemon_offline_log.cpp
@@ -8,7 +8,7 @@
* Email : onkar.palkar@wipro.com
*
* History : 30-Jun-2016
-*/
+ */
#include <gtest/gtest.h>
int connectServer(void);
@@ -29,7 +29,7 @@ extern "C"
}
#ifndef DLT_DAEMON_BLOCKING_TEST
-#define DLT_DAEMON_BLOCKING_TEST 1
+# define DLT_DAEMON_BLOCKING_TEST 1
#endif
/* Begin Method: dlt_logstorage::t_dlt_logstorage_list_add*/
@@ -39,10 +39,9 @@ TEST(t_dlt_logstorage_list_add, normal)
DltLogStorageFilterConfig *data = NULL;
char key = 1;
- data = (DltLogStorageFilterConfig *) calloc(1, sizeof(DltLogStorageFilterConfig));
+ data = (DltLogStorageFilterConfig *)calloc(1, sizeof(DltLogStorageFilterConfig));
- if (data != NULL)
- {
+ if (data != NULL) {
dlt_logstorage_filter_set_strategy(data, DLT_LOGSTORAGE_SYNC_ON_MSG);
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_list_add(&key, data, &list));
@@ -56,11 +55,10 @@ TEST(t_dlt_logstorage_list_add_config, normal)
DltLogStorageFilterConfig *data = NULL;
DltLogStorageFilterConfig *listdata = NULL;
- data = (DltLogStorageFilterConfig *) calloc(1, sizeof(DltLogStorageFilterConfig));
- listdata = (DltLogStorageFilterConfig *) calloc(1, sizeof(DltLogStorageFilterConfig));
+ data = (DltLogStorageFilterConfig *)calloc(1, sizeof(DltLogStorageFilterConfig));
+ listdata = (DltLogStorageFilterConfig *)calloc(1, sizeof(DltLogStorageFilterConfig));
- if ((data != NULL) && (listdata != NULL))
- {
+ if ((data != NULL) && (listdata != NULL)) {
dlt_logstorage_list_add_config(data, &listdata);
free(data);
free(listdata);
@@ -74,10 +72,9 @@ TEST(t_dlt_logstorage_list_destroy, normal)
DltLogStorageFilterConfig *data = NULL;
char key = 1;
- data = (DltLogStorageFilterConfig *) calloc(1, sizeof(DltLogStorageFilterConfig));
+ data = (DltLogStorageFilterConfig *)calloc(1, sizeof(DltLogStorageFilterConfig));
- if (data != NULL)
- {
+ if (data != NULL) {
dlt_logstorage_filter_set_strategy(data, DLT_LOGSTORAGE_SYNC_ON_MSG);
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_list_add(&key, data, &list));
@@ -95,24 +92,23 @@ TEST(t_dlt_logstorage_list_find, normal)
char apid[] = "1234";
char ctid[] = "5678";
- data = (DltLogStorageFilterConfig *) calloc(1, sizeof(DltLogStorageFilterConfig));
+ data = (DltLogStorageFilterConfig *)calloc(1, sizeof(DltLogStorageFilterConfig));
- if (data != NULL)
- {
+ if (data != NULL) {
data->apids = strdup(apid);
data->ctids = strdup(ctid);
dlt_logstorage_filter_set_strategy(data, DLT_LOGSTORAGE_SYNC_ON_MSG);
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_list_add(key, data, &list));
- retData = (DltLogStorageFilterConfig*)dlt_logstorage_list_find(key, &list);
+ retData = (DltLogStorageFilterConfig *)dlt_logstorage_list_find(key, &list);
EXPECT_NE((DltLogStorageFilterConfig *)NULL, retData);
- if (retData != NULL)
- {
+ if (retData != NULL) {
EXPECT_STREQ(apid, retData->apids);
EXPECT_STREQ(ctid, retData->ctids);
}
+
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_list_destroy(&list, 0));
}
}
@@ -127,10 +123,9 @@ TEST(t_dlt_logstorage_free, normal)
handle.num_configs = 0;
handle.config_list = NULL;
- data = (DltLogStorageFilterConfig *) calloc(1, sizeof(DltLogStorageFilterConfig));
+ data = (DltLogStorageFilterConfig *)calloc(1, sizeof(DltLogStorageFilterConfig));
- if(data != NULL)
- {
+ if (data != NULL) {
dlt_logstorage_filter_set_strategy(data, DLT_LOGSTORAGE_SYNC_ON_MSG);
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_list_add(&key, data, &handle.config_list));
@@ -244,8 +239,8 @@ TEST(t_dlt_logstorage_read_list_of_names, normal)
char value[] = "a,b,c,d";
namesPtr = (char *)calloc (1, sizeof(char));
- if(namesPtr != NULL)
- {
+
+ if (namesPtr != NULL) {
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_read_list_of_names(&namesPtr, value));
free(namesPtr);
@@ -263,8 +258,8 @@ TEST(t_dlt_logstorage_check_apids, normal)
char value[] = "a,b,c,d";
DltLogStorageFilterConfig config;
config.apids = (char *)calloc (1, sizeof(char));
- if(config.apids != NULL)
- {
+
+ if (config.apids != NULL) {
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_check_apids(&config, value));
free(config.apids);
@@ -282,8 +277,8 @@ TEST(t_dlt_logstorage_check_ctids, normal)
char value[] = "a,b,c,d";
DltLogStorageFilterConfig config;
config.ctids = (char *)calloc (1, sizeof(char));
- if(config.ctids != NULL)
- {
+
+ if (config.ctids != NULL) {
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_check_ctids(&config, value));
free(config.ctids);
@@ -316,8 +311,8 @@ TEST(t_dlt_logstorage_check_filename, normal)
char value[] = "file_name";
DltLogStorageFilterConfig config;
config.file_name = (char *)calloc (1, sizeof(char));
- if(config.file_name != NULL)
- {
+
+ if (config.file_name != NULL) {
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_check_filename(&config, value));
free(config.file_name);
@@ -329,8 +324,8 @@ TEST(t_dlt_logstorage_check_filename, abnormal)
char value[] = "../file_name";
DltLogStorageFilterConfig config;
config.file_name = (char *)calloc (1, sizeof(char));
- if(config.file_name != NULL)
- {
+
+ if (config.file_name != NULL) {
EXPECT_EQ(DLT_RETURN_ERROR, dlt_logstorage_check_filename(&config, value));
free(config.file_name);
@@ -404,12 +399,12 @@ TEST(t_dlt_logstorage_check_ecuid, normal)
char value[] = "213";
DltLogStorageFilterConfig config;
config.ecuid = (char *)calloc (1, sizeof(char));
- if(config.ecuid != NULL)
- {
+
+ if (config.ecuid != NULL) {
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_check_ecuid(&config, value));
EXPECT_EQ('2', *config.ecuid);
- EXPECT_EQ('1', *(config.ecuid+1));
- EXPECT_EQ('3', *(config.ecuid+2));
+ EXPECT_EQ('1', *(config.ecuid + 1));
+ EXPECT_EQ('3', *(config.ecuid + 2));
free(config.ecuid);
}
@@ -426,7 +421,7 @@ TEST(t_dlt_logstorage_check_param, normal)
char value[] = "100";
DltLogStorageFilterConfig config;
- EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_check_param(&config, DLT_LOGSTORAGE_FILTER_CONF_FILESIZE, value));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_check_param(&config, DLT_LOGSTORAGE_FILTER_CONF_FILESIZE, value));
EXPECT_EQ(100, config.file_size);
}
@@ -514,17 +509,16 @@ TEST(t_dlt_logstorage_get_loglevel_by_key, normal)
{
char arr[] = "abc";
char *key = arr;
- DltLogStorageFilterConfig* config = NULL;
+ DltLogStorageFilterConfig *config = NULL;
DltLogStorage handle;
handle.config_status = 0;
handle.connection_type = DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED;
handle.config_status = DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE;
handle.config_list = NULL;
- config = (DltLogStorageFilterConfig *) calloc(1, sizeof(DltLogStorageFilterConfig));
+ config = (DltLogStorageFilterConfig *)calloc(1, sizeof(DltLogStorageFilterConfig));
- if (config != NULL)
- {
+ if (config != NULL) {
config->log_level = DLT_LOG_ERROR;
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_list_add(key, config, &(handle.config_list)));
@@ -556,7 +550,7 @@ TEST(t_dlt_logstorage_get_config, normal)
char key0[] = ":1234:\000\000\000\000";
char key1[] = "::5678\000\000\000\000";
char key2[] = ":1234:5678";
- DltLogStorageFilterConfig *config[3] = {0};
+ DltLogStorageFilterConfig *config[3] = { 0 };
DltLogStorage handle;
handle.connection_type = DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED;
handle.config_status = DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE;
@@ -596,7 +590,7 @@ TEST(t_dlt_logstorage_filter, normal)
char key0[] = ":1234:\000\000\000\000";
char key1[] = "::5678\000\000\000\000";
char key2[] = ":1234:5678";
- DltLogStorageFilterConfig *config[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS] = {0};
+ DltLogStorageFilterConfig *config[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS] = { 0 };
DltLogStorage handle;
handle.connection_type = DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED;
handle.config_status = DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE;
@@ -613,7 +607,7 @@ TEST(t_dlt_logstorage_filter, normal)
TEST(t_dlt_logstorage_filter, null)
{
- DltLogStorageFilterConfig *config[3] = {0};
+ DltLogStorageFilterConfig *config[3] = { 0 };
int num = dlt_logstorage_filter(NULL, config, NULL, NULL, NULL, 0);
EXPECT_EQ(DLT_RETURN_ERROR, num);
}
@@ -681,7 +675,7 @@ TEST(t_dlt_logstorage_sync_caches, normal)
/* Begin Method: dlt_logstorage::t_dlt_logstorage_log_file_name*/
TEST(t_dlt_logstorage_log_file_name, normal)
{
- char log_file_name[DLT_MOUNT_PATH_MAX] = {'\0'};
+ char log_file_name[DLT_MOUNT_PATH_MAX] = { '\0' };
DltLogStorageUserConfig file_config;
file_config.logfile_delimiter = '/';
file_config.logfile_maxcounter = 0;
@@ -704,13 +698,13 @@ TEST(t_dlt_logstorage_log_file_name, null)
/* Begin Method: dlt_logstorage::t_dlt_logstorage_sort_file_name*/
TEST(t_dlt_logstorage_sort_file_name, normal)
{
- DltLogStorageFileList *node1, *node2, *node3;;
+ DltLogStorageFileList *node1, *node2, *node3;
DltLogStorageFileList **head;
node1 = (DltLogStorageFileList *)calloc (1, sizeof(DltLogStorageFileList));
node2 = (DltLogStorageFileList *)calloc (1, sizeof(DltLogStorageFileList));
node3 = (DltLogStorageFileList *)calloc (1, sizeof(DltLogStorageFileList));
- if(node1 != NULL && node2 != NULL && node3 != NULL)
- {
+
+ if ((node1 != NULL) && (node2 != NULL) && (node3 != NULL)) {
node1->next = node2;
node2->next = node3;
node3->next = NULL;
@@ -736,18 +730,15 @@ TEST(t_dlt_logstorage_sort_file_name, normal)
node2 = NULL;
node3 = NULL;
}
- if(node1 != NULL)
- {
+
+ if (node1 != NULL)
free(node1);
- }
- if(node2 != NULL)
- {
+
+ if (node2 != NULL)
free(node2);
- }
- if(node3 != NULL)
- {
+
+ if (node3 != NULL)
free(node3);
- }
}
TEST(t_dlt_logstorage_sort_file_name, null)
@@ -758,13 +749,13 @@ TEST(t_dlt_logstorage_sort_file_name, null)
/* Begin Method: dlt_logstorage::t_dlt_logstorage_rearrange_file_name*/
TEST(t_dlt_logstorage_rearrange_file_name, normal)
{
- DltLogStorageFileList *node1, *node2, *node3;;
+ DltLogStorageFileList *node1, *node2, *node3;
DltLogStorageFileList **head;
node1 = (DltLogStorageFileList *)calloc (1, sizeof(DltLogStorageFileList));
node2 = (DltLogStorageFileList *)calloc (1, sizeof(DltLogStorageFileList));
node3 = (DltLogStorageFileList *)calloc (1, sizeof(DltLogStorageFileList));
- if((node1 != NULL) && (node2 != NULL) && (node3 != NULL))
- {
+
+ if ((node1 != NULL) && (node2 != NULL) && (node3 != NULL)) {
node1->next = node2;
node2->next = node3;
@@ -792,18 +783,15 @@ TEST(t_dlt_logstorage_rearrange_file_name, normal)
node2 = NULL;
node3 = NULL;
}
- if(node1 != NULL)
- {
+
+ if (node1 != NULL)
free(node1);
- }
- if(node2 != NULL)
- {
+
+ if (node2 != NULL)
free(node2);
- }
- if(node3 != NULL)
- {
+
+ if (node3 != NULL)
free(node3);
- }
}
TEST(t_dlt_logstorage_rearrange_file_name, null)
@@ -815,11 +803,11 @@ TEST(t_dlt_logstorage_rearrange_file_name, null)
TEST(t_dlt_logstorage_get_idx_of_log_file, normal)
{
DltLogStorageUserConfig file_config;
- file_config.logfile_timestamp =191132;
- file_config.logfile_delimiter = {'_'};
+ file_config.logfile_timestamp = 191132;
+ file_config.logfile_delimiter = { '_' };
file_config.logfile_maxcounter = 2;
file_config.logfile_counteridxlen = 2;
- char *file = (char*)"Test_002_20160509_191132.dlt";
+ char *file = (char *)"Test_002_20160509_191132.dlt";
EXPECT_EQ(2, dlt_logstorage_get_idx_of_log_file(&file_config, file));
}
@@ -832,17 +820,17 @@ TEST(t_dlt_logstorage_get_idx_of_log_file, null)
TEST(t_dlt_logstorage_storage_dir_info, normal)
{
DltLogStorageUserConfig file_config;
- file_config.logfile_timestamp =191132;
- file_config.logfile_delimiter = {'_'};
+ file_config.logfile_timestamp = 191132;
+ file_config.logfile_delimiter = { '_' };
file_config.logfile_maxcounter = 2;
file_config.logfile_counteridxlen = 2;
- char *path = (char*)"/tmp";
+ char *path = (char *)"/tmp";
DltLogStorageFilterConfig config;
char apids;
char ctids;
config.apids = &apids;
config.ctids = &ctids;
- config.file_name = (char*)"Test_002_20160509_191132.dlt";
+ config.file_name = (char *)"Test_002_20160509_191132.dlt";
config.records = NULL;
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_storage_dir_info(&file_config, path, &config));
@@ -856,17 +844,17 @@ TEST(t_dlt_logstorage_storage_dir_info, null)
TEST(t_dlt_logstorage_open_log_file, normal)
{
DltLogStorageUserConfig file_config;
- file_config.logfile_timestamp =191132;
- file_config.logfile_delimiter = {'_'};
+ file_config.logfile_timestamp = 191132;
+ file_config.logfile_delimiter = { '_' };
file_config.logfile_maxcounter = 2;
file_config.logfile_counteridxlen = 2;
- char *path = (char*)"/tmp";
+ char *path = (char *)"/tmp";
DltLogStorageFilterConfig config;
char apids;
char ctids;
config.apids = &apids;
config.ctids = &ctids;
- config.file_name = (char*)"Test";
+ config.file_name = (char *)"Test";
config.records = NULL;
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_open_log_file(&config, &file_config, path, 1));
@@ -880,17 +868,17 @@ TEST(t_dlt_logstorage_open_log_file, null)
TEST(t_dlt_logstorage_prepare_on_msg, normal)
{
DltLogStorageUserConfig file_config;
- file_config.logfile_timestamp =191132;
- file_config.logfile_delimiter = {'_'};
+ file_config.logfile_timestamp = 191132;
+ file_config.logfile_delimiter = { '_' };
file_config.logfile_maxcounter = 2;
file_config.logfile_counteridxlen = 2;
- char *path = (char*)"/tmp";
+ char *path = (char *)"/tmp";
DltLogStorageFilterConfig config;
char apids;
char ctids;
config.apids = &apids;
config.ctids = &ctids;
- config.file_name = (char*)"Test";
+ config.file_name = (char *)"Test";
config.records = NULL;
config.log = NULL;
@@ -906,17 +894,17 @@ TEST(t_dlt_logstorage_prepare_on_msg, null)
TEST(t_dlt_logstorage_write_on_msg, normal)
{
DltLogStorageUserConfig file_config;
- file_config.logfile_timestamp =191132;
- file_config.logfile_delimiter = {'_'};
+ file_config.logfile_timestamp = 191132;
+ file_config.logfile_delimiter = { '_' };
file_config.logfile_maxcounter = 2;
file_config.logfile_counteridxlen = 2;
- char *path = (char*)"/tmp";
+ char *path = (char *)"/tmp";
DltLogStorageFilterConfig config;
char apids;
char ctids;
config.apids = &apids;
config.ctids = &ctids;
- config.file_name = (char*)"Test";
+ config.file_name = (char *)"Test";
config.records = NULL;
config.log = NULL;
unsigned int size = 8;
@@ -943,7 +931,7 @@ TEST(t_dlt_logstorage_sync_on_msg, normal)
memset(&config, 0, sizeof(DltLogStorageFilterConfig));
config.apids = &apids;
config.ctids = &ctids;
- config.file_name = (char*)"Test";
+ config.file_name = (char *)"Test";
config.records = NULL;
config.log = NULL;
char *path = NULL;
@@ -960,17 +948,17 @@ TEST(t_dlt_logstorage_sync_on_msg, null)
TEST(t_dlt_logstorage_prepare_msg_cache, normal)
{
DltLogStorageUserConfig file_config;
- file_config.logfile_timestamp =191132;
- file_config.logfile_delimiter = {'_'};
+ file_config.logfile_timestamp = 191132;
+ file_config.logfile_delimiter = { '_' };
file_config.logfile_maxcounter = 2;
file_config.logfile_counteridxlen = 2;
- char *path = (char*)"/tmp";
+ char *path = (char *)"/tmp";
DltLogStorageFilterConfig config;
char apids;
char ctids;
config.apids = &apids;
config.ctids = &ctids;
- config.file_name = (char*)"Test";
+ config.file_name = (char *)"Test";
config.records = NULL;
config.log = NULL;
config.cache = NULL;
@@ -999,8 +987,8 @@ TEST(t_dlt_logstorage_write_msg_cache, normal)
memset(&config, 0, sizeof(DltLogStorageFilterConfig));
config.cache = calloc(1, 50 + sizeof(DltLogStorageCacheFooter));
- if(config.cache != NULL)
- {
+
+ if (config.cache != NULL) {
config.file_size = 50;
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_write_msg_cache(&config, data1, size, data2, size, data3, size));
@@ -1057,7 +1045,7 @@ TEST(t_dlt_logstorage_update_all_contexts, normal)
daemon_local.RingbufferMaxSize,
daemon_local.RingbufferStepSize,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &daemon_local.pGateway, 0, 0));
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_update_all_contexts(&daemon, &daemon_local, apid, 1, 1, ecu, 0));
@@ -1097,13 +1085,13 @@ TEST(t_dlt_logstorage_update_context, normal)
daemon_local.RingbufferMaxSize,
daemon_local.RingbufferStepSize,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &daemon_local.pGateway, 0, 0));
- app = dlt_daemon_application_add(&daemon, apid, getpid() , desc, fd, ecu, 0);
+ app = dlt_daemon_application_add(&daemon, apid, getpid(), desc, fd, ecu, 0);
daecontext = dlt_daemon_context_add(&daemon, apid, ctid, DLT_LOG_DEFAULT,
- DLT_TRACE_STATUS_DEFAULT, 0, app->user_handle, desc, daemon.ecuid, 0);
- EXPECT_NE((DltDaemonContext*)(NULL), daecontext);
+ DLT_TRACE_STATUS_DEFAULT, 0, app->user_handle, desc, daemon.ecuid, 0);
+ EXPECT_NE((DltDaemonContext *)(NULL), daecontext);
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_update_context(&daemon, &daemon_local, apid, ctid, ecu, 1, 0));
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_update_context(&daemon, &daemon_local, apid, ctid, ecu, 0, 0));
}
@@ -1142,15 +1130,15 @@ TEST(t_dlt_logstorage_update_context_loglevel, normal)
daemon_local.RingbufferMaxSize,
daemon_local.RingbufferStepSize,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &daemon_local.pGateway, 0, 0));
app = dlt_daemon_application_add(&daemon, apid, getpid(), desc, fd, ecu, 0);
daecontext = dlt_daemon_context_add(&daemon, apid, ctid, DLT_LOG_DEFAULT,
- DLT_TRACE_STATUS_DEFAULT, 0, app->user_handle, desc, daemon.ecuid, 0);
- EXPECT_NE((DltDaemonContext*)(NULL), daecontext);
+ DLT_TRACE_STATUS_DEFAULT, 0, app->user_handle, desc, daemon.ecuid, 0);
+ EXPECT_NE((DltDaemonContext *)(NULL), daecontext);
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_update_context_loglevel
- (&daemon, &daemon_local, key, 1, 0));
+ (&daemon, &daemon_local, key, 1, 0));
}
TEST(t_dlt_logstorage_update_context_loglevel, null)
@@ -1179,7 +1167,7 @@ TEST(t_dlt_daemon_logstorage_reset_application_loglevel, normal)
daemon_local.RingbufferMaxSize,
daemon_local.RingbufferStepSize,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &daemon_local.pGateway, 0, 0));
EXPECT_NO_THROW(dlt_daemon_logstorage_reset_application_loglevel(&daemon, &daemon_local, device_index, 1, 0));
@@ -1221,7 +1209,7 @@ TEST(t_dlt_daemon_logstorage_get_loglevel, normal)
daemon_local.RingbufferMaxSize,
daemon_local.RingbufferStepSize,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &daemon_local.pGateway, 0, 0));
@@ -1273,7 +1261,7 @@ TEST(t_dlt_daemon_logstorage_update_application_loglevel, normal)
daemon_local.RingbufferMaxSize,
daemon_local.RingbufferStepSize,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &daemon_local.pGateway, 0, 0));
@@ -1307,7 +1295,7 @@ TEST(t_dlt_daemon_logstorage_write, normal)
DLT_DAEMON_RINGBUFFER_MAX_SIZE,
DLT_DAEMON_RINGBUFFER_STEP_SIZE,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &gateway, 0, 0));
daemon.storage_handle = &storage_handle;
@@ -1324,7 +1312,7 @@ TEST(t_dlt_daemon_logstorage_write, normal)
unsigned char data1[] = "123";
unsigned char data2[] = "123";
unsigned char data3[] = "123";
- int size = 10 * sizeof(uint32_t);;
+ int size = 10 * sizeof(uint32_t);
daemon.storage_handle->connection_type = DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED;
daemon.storage_handle->config_status = DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE;
daemon.storage_handle->config_list = NULL;
@@ -1345,7 +1333,7 @@ TEST(t_dlt_daemon_logstorage_write, normal)
TEST(t_dlt_daemon_logstorage_write, null)
{
- EXPECT_NO_THROW(dlt_daemon_logstorage_write(NULL, NULL, NULL, 0, NULL, 0,NULL, 0));
+ EXPECT_NO_THROW(dlt_daemon_logstorage_write(NULL, NULL, NULL, 0, NULL, 0, NULL, 0));
}
/* Begin Method: dlt_logstorage::t_dlt_daemon_logstorage_setup_internal_storage*/
@@ -1368,7 +1356,7 @@ TEST(t_dlt_daemon_logstorage_setup_internal_storage, normal)
daemon_local.RingbufferMaxSize,
daemon_local.RingbufferStepSize,
DLT_RUNTIME_DEFAULT_DIRECTORY,
- DLT_LOG_INFO, DLT_TRACE_STATUS_OFF,0,0));
+ DLT_LOG_INFO, DLT_TRACE_STATUS_OFF, 0, 0));
dlt_set_id(daemon.ecuid, ecu);
EXPECT_EQ(0, dlt_daemon_init_user_information(&daemon, &daemon_local.pGateway, 0, 0));
@@ -1465,30 +1453,30 @@ TEST(t_dlt_daemon_logstorage_get_device, null)
/* Begin Method: dlt_logstorage::t_dlt_logstorage_find_dlt_header*/
TEST(t_dlt_logstorage_find_dlt_header, normal)
{
- char data[] = {'a','b','D','L','T',0x01};
+ char data[] = { 'a', 'b', 'D', 'L', 'T', 0x01 };
DltLogStorageFilterConfig config;
memset(&config, 0, sizeof(DltLogStorageFilterConfig));
config.cache = calloc(1, sizeof(data));
- if (config.cache != NULL)
- {
+
+ if (config.cache != NULL) {
strncpy((char *)config.cache, data, sizeof(data));
/* DLT header starts from index 2 */
- EXPECT_EQ(2, dlt_logstorage_find_dlt_header(config.cache, 0,sizeof(data)));
+ EXPECT_EQ(2, dlt_logstorage_find_dlt_header(config.cache, 0, sizeof(data)));
free(config.cache);
}
}
TEST(t_dlt_logstorage_find_dlt_header, null)
{
- char data[] = {'N','o','H','e','a','d','e','r'};
+ char data[] = { 'N', 'o', 'H', 'e', 'a', 'd', 'e', 'r' };
DltLogStorageFilterConfig config;
memset(&config, 0, sizeof(DltLogStorageFilterConfig));
config.cache = calloc(1, sizeof(data));
- if (config.cache != NULL)
- {
+
+ if (config.cache != NULL) {
/* config.cache =(void *) "a,b,D,L,T,0x01"; */
strncpy((char *)config.cache, data, sizeof(data));
- EXPECT_EQ(DLT_RETURN_ERROR, dlt_logstorage_find_dlt_header(config.cache, 0,sizeof(data)));
+ EXPECT_EQ(DLT_RETURN_ERROR, dlt_logstorage_find_dlt_header(config.cache, 0, sizeof(data)));
free(config.cache);
}
}
@@ -1498,18 +1486,18 @@ TEST(t_dlt_logstorage_sync_create_new_file, normal)
{
DltLogStorageUserConfig file_config;
memset(&file_config, 0, sizeof(DltLogStorageUserConfig));
- file_config.logfile_timestamp =191132;
- file_config.logfile_delimiter = {'_'};
+ file_config.logfile_timestamp = 191132;
+ file_config.logfile_delimiter = { '_' };
file_config.logfile_maxcounter = 5;
file_config.logfile_counteridxlen = 2;
- char *path = (char*)"/tmp";
+ char *path = (char *)"/tmp";
DltLogStorageFilterConfig config;
memset(&config, 0, sizeof(DltLogStorageFilterConfig));
char apids;
char ctids;
config.apids = &apids;
config.ctids = &ctids;
- config.file_name = (char*)"Test";
+ config.file_name = (char *)"Test";
config.records = NULL;
config.log = NULL;
config.cache = NULL;
@@ -1524,11 +1512,11 @@ TEST(t_dlt_logstorage_sync_create_new_file, normal)
DltLogStorageCacheFooter *footer = NULL;
config.cache = calloc(1, 50 + sizeof(DltLogStorageCacheFooter));
- if(config.cache != NULL)
- {
+
+ if (config.cache != NULL) {
footer = (DltLogStorageCacheFooter *)((unsigned char *)config.cache + 50);
- if (footer != NULL)
- {
+
+ if (footer != NULL) {
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_prepare_msg_cache(&config, &file_config, path, 1));
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_write_msg_cache(&config, data1, size, data2, size, data3, size));
footer->offset = 0;
@@ -1537,7 +1525,6 @@ TEST(t_dlt_logstorage_sync_create_new_file, normal)
config.cache = NULL;
}
}
-
}
TEST(t_dlt_logstorage_sync_create_new_file, null)
@@ -1550,18 +1537,18 @@ TEST(t_dlt_logstorage_sync_to_file, normal)
{
DltLogStorageUserConfig file_config;
memset(&file_config, 0, sizeof(DltLogStorageUserConfig));
- file_config.logfile_timestamp =191132;
- file_config.logfile_delimiter = {'_'};
+ file_config.logfile_timestamp = 191132;
+ file_config.logfile_delimiter = { '_' };
file_config.logfile_maxcounter = 6;
file_config.logfile_counteridxlen = 2;
- char *path = (char*)"/tmp";
+ char *path = (char *)"/tmp";
DltLogStorageFilterConfig config;
memset(&config, 0, sizeof(DltLogStorageFilterConfig));
char apids;
char ctids;
config.apids = &apids;
config.ctids = &ctids;
- config.file_name = (char*)"Test";
+ config.file_name = (char *)"Test";
config.records = NULL;
config.log = NULL;
config.cache = NULL;
@@ -1576,8 +1563,8 @@ TEST(t_dlt_logstorage_sync_to_file, normal)
unsigned char data3[10] = "dlt_data2";
config.cache = calloc(1, 50 + sizeof(DltLogStorageCacheFooter));
- if(config.cache != NULL)
- {
+
+ if (config.cache != NULL) {
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_prepare_msg_cache(&config, &file_config, path, 1));
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_write_msg_cache(&config, data1, size, data2, size, data3, size));
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_sync_to_file(&config, &file_config, path));
@@ -1596,18 +1583,18 @@ TEST(t_dlt_logstorage_sync_capable_data_to_file, normal)
{
DltLogStorageUserConfig file_config;
memset(&file_config, 0, sizeof(DltLogStorageUserConfig));
- file_config.logfile_timestamp =191132;
- file_config.logfile_delimiter = {'_'};
+ file_config.logfile_timestamp = 191132;
+ file_config.logfile_delimiter = { '_' };
file_config.logfile_maxcounter = 7;
file_config.logfile_counteridxlen = 2;
- char *path = (char*)"/tmp";
+ char *path = (char *)"/tmp";
DltLogStorageFilterConfig config;
memset(&config, 0, sizeof(DltLogStorageFilterConfig));
char apids;
char ctids;
config.apids = &apids;
config.ctids = &ctids;
- config.file_name = (char*)"Test";
+ config.file_name = (char *)"Test";
config.records = NULL;
config.log = NULL;
config.cache = NULL;
@@ -1622,13 +1609,13 @@ TEST(t_dlt_logstorage_sync_capable_data_to_file, normal)
unsigned char data3[10] = "Dlt_data2";
config.cache = calloc(1, 50 + sizeof(DltLogStorageCacheFooter));
- if(config.cache != NULL)
- {
- EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_prepare_msg_cache(&config, &file_config, path, 1));
- EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_write_msg_cache(&config, data1, size, data2, size, data3, size));
- EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_sync_capable_data_to_file(&config, 0));
- free(config.cache);
- config.cache = NULL;
+
+ if (config.cache != NULL) {
+ EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_prepare_msg_cache(&config, &file_config, path, 1));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_write_msg_cache(&config, data1, size, data2, size, data3, size));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_sync_capable_data_to_file(&config, 0));
+ free(config.cache);
+ config.cache = NULL;
}
}
@@ -1642,11 +1629,11 @@ TEST(t_dlt_logstorage_sync_msg_cache, normal)
{
DltLogStorageUserConfig file_config;
memset(&file_config, 0, sizeof(DltLogStorageUserConfig));
- file_config.logfile_timestamp =191132;
- file_config.logfile_delimiter = {'_'};
+ file_config.logfile_timestamp = 191132;
+ file_config.logfile_delimiter = { '_' };
file_config.logfile_maxcounter = 8;
file_config.logfile_counteridxlen = 2;
- char *path = (char*)"/tmp";
+ char *path = (char *)"/tmp";
DltLogStorageFilterConfig config;
memset(&config, 0, sizeof(DltLogStorageFilterConfig));
@@ -1654,7 +1641,7 @@ TEST(t_dlt_logstorage_sync_msg_cache, normal)
char ctids;
config.apids = &apids;
config.ctids = &ctids;
- config.file_name = (char*)"Test";
+ config.file_name = (char *)"Test";
config.records = NULL;
config.log = NULL;
config.cache = NULL;
@@ -1669,11 +1656,12 @@ TEST(t_dlt_logstorage_sync_msg_cache, normal)
unsigned char data3[10] = "dlt_dataC";
config.cache = calloc(1, 50 + sizeof(DltLogStorageCacheFooter));
- if(config.cache != NULL)
- {
+
+ if (config.cache != NULL) {
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_prepare_msg_cache(&config, &file_config, path, 1));
EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_write_msg_cache(&config, data1, size, data2, size, data3, size));
- EXPECT_EQ(DLT_RETURN_OK, dlt_logstorage_sync_msg_cache(&config, &file_config, path, DLT_LOGSTORAGE_SYNC_ON_DEMAND));
+ EXPECT_EQ(DLT_RETURN_OK,
+ dlt_logstorage_sync_msg_cache(&config, &file_config, path, DLT_LOGSTORAGE_SYNC_ON_DEMAND));
free(config.cache);
config.cache = NULL;
}
@@ -1692,18 +1680,19 @@ int connectServer(void)
portno = 8080;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
server = gethostbyname("127.0.0.1");
- bzero((char *) &serv_addr, sizeof(serv_addr));
+ bzero((char *)&serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
memcpy((char *)&serv_addr.sin_addr.s_addr,
(char *)server->h_addr,
server->h_length);
serv_addr.sin_port = htons(portno);
- if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
- {
+
+ if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
printf("Error: %s (%d) occured in connect socket\n", strerror(errno), errno);
close(sockfd);
return -1;
}
+
return sockfd;
}
@@ -1713,13 +1702,13 @@ int main(int argc, char **argv)
{
pid_t cpid;
cpid = fork();
- if(cpid == -1)
- {
+
+ if (cpid == -1) {
printf("fork fail\n");
return -1;
}
- if (cpid)
- {
+
+ if (cpid) {
int i = GTEST_SOCKS_ACCEPTED;
int j, optval = 1;
char buffer[256];
@@ -1727,12 +1716,13 @@ int main(int argc, char **argv)
socklen_t clilen;
struct sockaddr_in serv_addr, cli_addr;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
- if(sockfd == -1)
- {
+
+ if (sockfd == -1) {
printf("Error in creating socket\n");
return -1;
}
- bzero((char *) &serv_addr, sizeof(serv_addr));
+
+ bzero((char *)&serv_addr, sizeof(serv_addr));
portno = 8080;
serv_addr.sin_family = AF_INET;
@@ -1745,40 +1735,42 @@ int main(int argc, char **argv)
exit(1);
}
- j = bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
- if(j == -1)
- {
+ j = bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
+
+ if (j == -1) {
perror("Bind Error\n");
close(sockfd);
return -1;
}
+
listen(sockfd, 5);
- while(i)
- {
+
+ while (i) {
clilen = sizeof(cli_addr);
- newsockfd[i-1] = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
- if(newsockfd[i-1] == -1)
- {
+ newsockfd[i - 1] = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
+
+ if (newsockfd[i - 1] == -1) {
printf("Error in accept");
return -1;
}
+
memset(buffer, 0, 256);
- (void)(read(newsockfd[i-1], buffer, 255) + 1); /* just ignore result */
+ (void)(read(newsockfd[i - 1], buffer, 255) + 1); /* just ignore result */
i--;
}
- for(j = 0; j < GTEST_SOCKS_ACCEPTED; j++)
+ for (j = 0; j < GTEST_SOCKS_ACCEPTED; j++)
close(newsockfd[i]);
close(sockfd);
}
- else
- {
+ else {
::testing::InitGoogleTest(&argc, argv);
::testing::FLAGS_gtest_break_on_failure = false;
-// ::testing::FLAGS_gtest_filter = "t_dlt_event_handler_register_connection*";
+/* ::testing::FLAGS_gtest_filter = "t_dlt_event_handler_register_connection*"; */
return RUN_ALL_TESTS();
}
+
return 0;
}
diff --git a/tests/gtest_dlt_user.cpp b/tests/gtest_dlt_user.cpp
index c8bf2de..91cc69c 100644
--- a/tests/gtest_dlt_user.cpp
+++ b/tests/gtest_dlt_user.cpp
@@ -23,7 +23,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file gtest_dlt_common.cpp
-*/
+ */
#include <stdio.h>
#include "gtest/gtest.h"
@@ -35,199 +35,199 @@ extern "C" {
-// TEST COMMENTED OUT WITH
-// TODO:
-// DO FAIL!
+/* TEST COMMENTED OUT WITH */
+/* TODO: */
+/* DO FAIL! */
-// tested functions
+/* tested functions */
/*
-int dlt_user_log_write_start(DltContext *handle, DltContextData *log, DltLogLevelType loglevel);
-int dlt_user_log_write_start_id(DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid);
-int dlt_user_log_write_finish(DltContextData *log);
-int dlt_user_log_write_bool(DltContextData *log, uint8_t data);
-int dlt_user_log_write_float32(DltContextData *log, float32_t data);
-int dlt_user_log_write_float64(DltContextData *log, double data);
-int dlt_user_log_write_uint(DltContextData *log, unsigned int data);
-int dlt_user_log_write_uint8(DltContextData *log, uint8_t data);
-int dlt_user_log_write_uint16(DltContextData *log, uint16_t data);
-int dlt_user_log_write_uint32(DltContextData *log, uint32_t data);
-int dlt_user_log_write_uint64(DltContextData *log, uint64_t data);
-int dlt_user_log_write_uint8_formatted(DltContextData *log, uint8_t data, DltFormatType type);
-int dlt_user_log_write_uint16_formatted(DltContextData *log, uint16_t data, DltFormatType type);
-int dlt_user_log_write_uint32_formatted(DltContextData *log, uint32_t data, DltFormatType type);
-int dlt_user_log_write_uint64_formatted(DltContextData *log, uint64_t data, DltFormatType type);
-int dlt_user_log_write_int(DltContextData *log, int data);
-int dlt_user_log_write_int8(DltContextData *log, int8_t data);
-int dlt_user_log_write_int16(DltContextData *log, int16_t data);
-int dlt_user_log_write_int32(DltContextData *log, int32_t data);
-int dlt_user_log_write_int64(DltContextData *log, int64_t data);
-int dlt_user_log_write_string( DltContextData *log, const char *text);
-int dlt_user_log_write_constant_string( DltContextData *log, const char *text);
-int dlt_user_log_write_utf8_string(DltContextData *log, const char *text);
-int dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t length);
-int dlt_user_log_write_raw_formatted(DltContextData *log,void *data,uint16_t length,DltFormatType type);
-*/
+ * int dlt_user_log_write_start(DltContext *handle, DltContextData *log, DltLogLevelType loglevel);
+ * int dlt_user_log_write_start_id(DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid);
+ * int dlt_user_log_write_finish(DltContextData *log);
+ * int dlt_user_log_write_bool(DltContextData *log, uint8_t data);
+ * int dlt_user_log_write_float32(DltContextData *log, float32_t data);
+ * int dlt_user_log_write_float64(DltContextData *log, double data);
+ * int dlt_user_log_write_uint(DltContextData *log, unsigned int data);
+ * int dlt_user_log_write_uint8(DltContextData *log, uint8_t data);
+ * int dlt_user_log_write_uint16(DltContextData *log, uint16_t data);
+ * int dlt_user_log_write_uint32(DltContextData *log, uint32_t data);
+ * int dlt_user_log_write_uint64(DltContextData *log, uint64_t data);
+ * int dlt_user_log_write_uint8_formatted(DltContextData *log, uint8_t data, DltFormatType type);
+ * int dlt_user_log_write_uint16_formatted(DltContextData *log, uint16_t data, DltFormatType type);
+ * int dlt_user_log_write_uint32_formatted(DltContextData *log, uint32_t data, DltFormatType type);
+ * int dlt_user_log_write_uint64_formatted(DltContextData *log, uint64_t data, DltFormatType type);
+ * int dlt_user_log_write_int(DltContextData *log, int data);
+ * int dlt_user_log_write_int8(DltContextData *log, int8_t data);
+ * int dlt_user_log_write_int16(DltContextData *log, int16_t data);
+ * int dlt_user_log_write_int32(DltContextData *log, int32_t data);
+ * int dlt_user_log_write_int64(DltContextData *log, int64_t data);
+ * int dlt_user_log_write_string( DltContextData *log, const char *text);
+ * int dlt_user_log_write_constant_string( DltContextData *log, const char *text);
+ * int dlt_user_log_write_utf8_string(DltContextData *log, const char *text);
+ * int dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t length);
+ * int dlt_user_log_write_raw_formatted(DltContextData *log,void *data,uint16_t length,DltFormatType type);
+ */
/*
-int dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const char *text);
-int dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, const char *text, int data);
-int dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel, const char *text, unsigned int data);
-int dlt_log_int(DltContext *handle,DltLogLevelType loglevel, int data);
-int dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigned int data);
-int dlt_log_raw(DltContext *handle,DltLogLevelType loglevel, void *data,uint16_t length);
-int dlt_log_marker();
-*/
+ * int dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const char *text);
+ * int dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, const char *text, int data);
+ * int dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel, const char *text, unsigned int data);
+ * int dlt_log_int(DltContext *handle,DltLogLevelType loglevel, int data);
+ * int dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigned int data);
+ * int dlt_log_raw(DltContext *handle,DltLogLevelType loglevel, void *data,uint16_t length);
+ * int dlt_log_marker();
+ */
/*
-int dlt_register_app(const char *appid, const char * description);
-int dlt_unregister_app(void);
-int dlt_register_context(DltContext *handle, const char *contextid, const char * description);
-int dlt_register_context_ll_ts(DltContext *handle, const char *contextid, const char * description, int loglevel, int tracestatus);
-int dlt_unregister_context(DltContext *handle);
-int dlt_register_injection_callback(DltContext *handle, uint32_t service_id, int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length));
-int dlt_register_log_level_changed_callback(DltContext *handle, void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],uint8_t log_level, uint8_t trace_status));
-*/
+ * int dlt_register_app(const char *appid, const char * description);
+ * int dlt_unregister_app(void);
+ * int dlt_register_context(DltContext *handle, const char *contextid, const char * description);
+ * int dlt_register_context_ll_ts(DltContext *handle, const char *contextid, const char * description, int loglevel, int tracestatus);
+ * int dlt_unregister_context(DltContext *handle);
+ * int dlt_register_injection_callback(DltContext *handle, uint32_t service_id, int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length));
+ * int dlt_register_log_level_changed_callback(DltContext *handle, void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],uint8_t log_level, uint8_t trace_status));
+ */
/*
-int dlt_user_trace_network(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
-int dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload, int allow_truncate);
-int dlt_user_trace_network_segmented(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
-*/
+ * int dlt_user_trace_network(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
+ * int dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload, int allow_truncate);
+ * int dlt_user_trace_network_segmented(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
+ */
/*
-int dlt_set_log_mode(DltUserLogMode mode);
-int dlt_get_log_state();
-*/
+ * int dlt_set_log_mode(DltUserLogMode mode);
+ * int dlt_get_log_state();
+ */
/*
-int dlt_verbose_mode(void);
-int dlt_nonverbose_mode(void);
-*/
+ * int dlt_verbose_mode(void);
+ * int dlt_nonverbose_mode(void);
+ */
-// define some min and max values (if not present in <limits.h>)
+/* define some min and max values (if not present in <limits.h>) */
#ifndef UINT8_MIN
-#define UINT8_MIN 0
+# define UINT8_MIN 0
#endif
#ifndef UINT16_MIN
-#define UINT16_MIN 0
+# define UINT16_MIN 0
#endif
#ifndef UINT32_MIN
-#define UINT32_MIN 0
+# define UINT32_MIN 0
#endif
#ifndef UINT64_MIN
-#define UINT64_MIN 0
+# define UINT64_MIN 0
#endif
#ifndef UINT8_MAX
-#define UINT8_MAX 255
+# define UINT8_MAX 255
#endif
#ifndef UINT16_MAX
-#define UINT16_MAX 65535
+# define UINT16_MAX 65535
#endif
#ifndef UINT32_MAX
-#define UINT32_MAX 4294967295
+# define UINT32_MAX 4294967295
#endif
#ifndef UINT64_MAX
-#define UINT64_MAX 18446744073709551615UL
+# define UINT64_MAX 18446744073709551615UL
#endif
#ifndef INT8_MIN
-#define INT8_MIN -128
+# define INT8_MIN -128
#endif
#ifndef INT16_MIN
-#define INT16_MIN -32768
+# define INT16_MIN -32768
#endif
#ifndef INT32_MIN
-#define INT32_MIN -2147483648
+# define INT32_MIN -2147483648
#endif
#ifndef INT64_MIN
-#define INT64_MIN -9223372036854775807
+# define INT64_MIN -9223372036854775807
#endif
#ifndef INT8_MAX
-#define INT8_MAX 127
+# define INT8_MAX 127
#endif
#ifndef INT16_MAX
-#define INT16_MAX 32767
+# define INT16_MAX 32767
#endif
#ifndef INT32_MAX
-#define INT32_MAX 2147483647
+# define INT32_MAX 2147483647
#endif
#ifndef INT64_MAX
-#define INT64_MAX 9223372036854775807
+# define INT64_MAX 9223372036854775807
#endif
#ifndef UINT_MIN
-#define UINT_MIN UINT32_MIN
+# define UINT_MIN UINT32_MIN
#endif
#ifndef UINT_MAX
-#define UINT_MAX UINT32_MAX
+# define UINT_MAX UINT32_MAX
#endif
#ifndef INT_MIN
-#define INT_MIN INT32_MIN
+# define INT_MIN INT32_MIN
#endif
#ifndef INT_MAX
-#define INT_MAX INT32_MAX
+# define INT_MAX INT32_MAX
#endif
-/////////////////////////////////////////
-// start initial dlt
+/*/////////////////////////////////////// */
+/* start initial dlt */
TEST(t_dlt_init, onetime)
{
EXPECT_EQ(DLT_RETURN_OK, dlt_init());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_start
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_start */
TEST(t_dlt_user_log_write_start, normal)
{
DltContext context;
DltContextData contextData;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start normal"));
- // the defined enum values for log level
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_FATAL));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_ERROR));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_WARN));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_INFO));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEBUG));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_VERBOSE));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ /* the defined enum values for log level */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_OFF));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_FATAL));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_ERROR));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_WARN));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_INFO));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEBUG));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_VERBOSE));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_start, abnormal)
@@ -237,18 +237,18 @@ TEST(t_dlt_user_log_write_start, abnormal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start abnormal"));
- // undefined values for DltLogLevelType
- // shouldn't it return -1?
- EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,dlt_user_log_write_start(&context, &contextData, (DltLogLevelType)-100));
- EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,dlt_user_log_write_start(&context, &contextData, (DltLogLevelType)-10));
- EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,dlt_user_log_write_start(&context, &contextData, (DltLogLevelType)10));
- EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,dlt_user_log_write_start(&context, &contextData, (DltLogLevelType)100));
+ /* undefined values for DltLogLevelType */
+ /* shouldn't it return -1? */
+ EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER, dlt_user_log_write_start(&context, &contextData, (DltLogLevelType) - 100));
+ EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER, dlt_user_log_write_start(&context, &contextData, (DltLogLevelType) - 10));
+ EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER, dlt_user_log_write_start(&context, &contextData, (DltLogLevelType)10));
+ EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER, dlt_user_log_write_start(&context, &contextData, (DltLogLevelType)100));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_start, startstartfinish)
@@ -258,15 +258,16 @@ TEST(t_dlt_user_log_write_start, startstartfinish)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start startstartfinish"));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- // shouldn't it return -1, because it is already started?
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start startstartfinish"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* shouldn't it return -1, because it is already started? */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_start, nullpointer)
@@ -275,21 +276,22 @@ TEST(t_dlt_user_log_write_start, nullpointer)
DltContextData contextData;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start nullpointer"));
- // NULL's
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start(NULL, &contextData, DLT_LOG_DEFAULT));
- //EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start(NULL, NULL, DLT_LOG_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start(&context, NULL, DLT_LOG_DEFAULT));
- //EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start nullpointer"));
+ /* NULL's */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_start(NULL, &contextData, DLT_LOG_DEFAULT));
+ /*EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData)); */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_start(NULL, NULL, DLT_LOG_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_start(&context, NULL, DLT_LOG_DEFAULT));
+ /*EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData)); */
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_start_id
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_start_id */
TEST(t_dlt_user_log_write_start_id, normal)
{
DltContext context;
@@ -298,71 +300,72 @@ TEST(t_dlt_user_log_write_start_id, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start_id normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start_id normal"));
- // the defined enum values for log level
+ /* the defined enum values for log level */
messageid = UINT32_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEFAULT, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_OFF, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_FATAL, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_ERROR, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_WARN, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_INFO, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEBUG, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_VERBOSE, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEFAULT, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_OFF, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_FATAL, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_ERROR, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_WARN, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_INFO, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEBUG, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_VERBOSE, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
messageid = UINT32_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEFAULT, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_OFF, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_FATAL, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_ERROR, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_WARN, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_INFO, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEBUG, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_VERBOSE, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
-
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEFAULT, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_OFF, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_FATAL, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_ERROR, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_WARN, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_INFO, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEBUG, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_VERBOSE, messageid));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_start_id, abnormal)
{
DltContext context;
- // TODO: DltContextData contextData;
- // TODO: uint32_t messageid;
+ /* TODO: DltContextData contextData; */
+ /* TODO: uint32_t messageid; */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start_id abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start_id abnormal"));
- // undefined values for DltLogLevelType
- // shouldn't it return -1?
- // TODO: messageid = UINT32_MIN;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, &contextData, (DltLogLevelType)-100, messageid));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, &contextData, (DltLogLevelType)-10, messageid));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, &contextData, (DltLogLevelType)10, messageid));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, &contextData, (DltLogLevelType)100, messageid));
+ /* undefined values for DltLogLevelType */
+ /* shouldn't it return -1? */
+ /* TODO: messageid = UINT32_MIN; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, &contextData, (DltLogLevelType)-100, messageid)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, &contextData, (DltLogLevelType)-10, messageid)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, &contextData, (DltLogLevelType)10, messageid)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, &contextData, (DltLogLevelType)100, messageid)); */
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_start_id, startstartfinish)
@@ -373,17 +376,18 @@ TEST(t_dlt_user_log_write_start_id, startstartfinish)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start_id startstartfinish"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start_id startstartfinish"));
messageid = UINT32_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEFAULT, messageid));
- // shouldn't it return -1, because it is already started?
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEFAULT, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEFAULT, messageid));
+ /* shouldn't it return -1, because it is already started? */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEFAULT, messageid)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_start_id, nullpointer)
@@ -394,22 +398,23 @@ TEST(t_dlt_user_log_write_start_id, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start_id nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start_id nullpointer"));
- // NULL's
+ /* NULL's */
messageid = UINT32_MIN;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(NULL, &contextData, DLT_LOG_DEFAULT, messageid));
- //EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(NULL, NULL, DLT_LOG_DEFAULT, messageid));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_start_id(&context, NULL, DLT_LOG_DEFAULT, messageid));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_start_id(NULL, &contextData, DLT_LOG_DEFAULT, messageid));
+ /*EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData)); */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_start_id(NULL, NULL, DLT_LOG_DEFAULT, messageid));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_start_id(&context, NULL, DLT_LOG_DEFAULT, messageid));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_finish
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_finish */
TEST(t_dlt_user_log_write_finish, finish)
{
DltContext context;
@@ -417,32 +422,32 @@ TEST(t_dlt_user_log_write_finish, finish)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start finish"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start finish"));
- // finish without start
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(NULL));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData));
+ /* finish without start */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(NULL)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData)); */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_finish finish"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_finish finish"));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData)); */
- // finish with start and initialized context
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ /* finish with start and initialized context */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- // 2nd finish
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData));
+ /* 2nd finish */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_finish(&contextData)); */
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_bool
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_bool */
TEST(t_dlt_user_log_write_bool, normal)
{
DltContext context;
@@ -451,44 +456,44 @@ TEST(t_dlt_user_log_write_bool, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_bool normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_bool normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = true;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_bool(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_bool(&contextData, data));
data = false;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_bool(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_bool(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_bool, abnormal)
{
DltContext context;
DltContextData contextData;
- // TODO: uint8_t data;
+ /* TODO: uint8_t data; */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_bool abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_bool abnormal"));
- // abnormal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- // TODO: data = 2;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_bool(&contextData, data));
- // TODO: data = 100;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_bool(&contextData, data));
- // TODO: data = UINT8_MAX;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_bool(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ /* abnormal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* TODO: data = 2; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_bool(&contextData, data)); */
+ /* TODO: data = 100; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_bool(&contextData, data)); */
+ /* TODO: data = UINT8_MAX; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_bool(&contextData, data)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_bool, nullpointer)
@@ -498,19 +503,20 @@ TEST(t_dlt_user_log_write_bool, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_bool nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_bool nullpointer"));
- // NULL
+ /* NULL */
data = true;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_bool(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_bool(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_float32
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_float32 */
TEST(t_dlt_user_log_write_float32, normal)
{
DltContext context;
@@ -519,27 +525,27 @@ TEST(t_dlt_user_log_write_float32, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_float32 normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_float32 normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = 3.141592653589793238;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float32(&contextData, data));
data = -3.141592653589793238;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float32(&contextData, data));
data = 0.;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float32(&contextData, data));
data = -0.;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float32(&contextData, data));
data = FLT_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float32(&contextData, data));
data = FLT_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float32(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_float32, nullpointer)
@@ -549,19 +555,20 @@ TEST(t_dlt_user_log_write_float32, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_float32 nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_float32 nullpointer"));
- // NULL
+ /* NULL */
data = 1.;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_float32(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_float32(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_float64
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_float64 */
TEST(t_dlt_user_log_write_float64, normal)
{
DltContext context;
@@ -570,27 +577,27 @@ TEST(t_dlt_user_log_write_float64, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_float64 normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_float64 normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = 3.14159265358979323846;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float64(&contextData, data));
data = -3.14159265358979323846;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float64(&contextData, data));
data = 0.;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float64(&contextData, data));
data = -0.;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float64(&contextData, data));
data = DBL_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float64(&contextData, data));
data = DBL_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_float64(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_float64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_float64, nullpointer)
@@ -600,19 +607,20 @@ TEST(t_dlt_user_log_write_float64, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_float64 nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_float64 nullpointer"));
- // NULL
+ /* NULL */
data = 1.;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_float64(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_float64(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_uint
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_uint */
TEST(t_dlt_user_log_write_uint, normal)
{
DltContext context;
@@ -621,42 +629,42 @@ TEST(t_dlt_user_log_write_uint, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = UINT_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint(&contextData, data));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint(&contextData, data));
data = UINT_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint, abnormal)
{
DltContext context;
DltContextData contextData;
- // TODO: unsigned int data;
+ /* TODO: unsigned int data; */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint abnormal"));
- // abnormal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- // TODO: data = -1;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ /* abnormal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* TODO: data = -1; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint(&contextData, data)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint, nullpointer)
@@ -666,19 +674,20 @@ TEST(t_dlt_user_log_write_uint, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_uint8
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_uint8 */
TEST(t_dlt_user_log_write_uint8, normal)
{
DltContext context;
@@ -687,21 +696,21 @@ TEST(t_dlt_user_log_write_uint8, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint8 normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint8 normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = UINT8_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8(&contextData, data));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8(&contextData, data));
data = UINT8_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint8, nullpointer)
@@ -711,19 +720,20 @@ TEST(t_dlt_user_log_write_uint8, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint8 nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint8 nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint8(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_uint16
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_uint16 */
TEST(t_dlt_user_log_write_uint16, normal)
{
DltContext context;
@@ -732,21 +742,21 @@ TEST(t_dlt_user_log_write_uint16, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint16 normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint16 normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = UINT16_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16(&contextData, data));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16(&contextData, data));
data = UINT16_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint16, nullpointer)
@@ -756,19 +766,20 @@ TEST(t_dlt_user_log_write_uint16, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint16 nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint16 nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint16(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_uint32
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_uint32 */
TEST(t_dlt_user_log_write_uint32, normal)
{
DltContext context;
@@ -777,21 +788,21 @@ TEST(t_dlt_user_log_write_uint32, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint32 normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint32 normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = UINT32_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32(&contextData, data));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32(&contextData, data));
data = UINT32_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint32, nullpointer)
@@ -801,19 +812,20 @@ TEST(t_dlt_user_log_write_uint32, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint32 nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint32 nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint32(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_uint64
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_uint64 */
TEST(t_dlt_user_log_write_uint64, normal)
{
DltContext context;
@@ -822,21 +834,21 @@ TEST(t_dlt_user_log_write_uint64, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint64 normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint64 normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = UINT64_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64(&contextData, data));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64(&contextData, data));
data = UINT64_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint64, nullpointer)
@@ -846,19 +858,20 @@ TEST(t_dlt_user_log_write_uint64, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint64 nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint64 nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint64(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_uint8_formatted
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_uint8_formatted */
TEST(t_dlt_user_log_write_uint8_formatted, normal)
{
DltContext context;
@@ -867,63 +880,65 @@ TEST(t_dlt_user_log_write_uint8_formatted, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint8_formatted normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint8_formatted normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = UINT8_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN16));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN16));
data = UINT8_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint8_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint8_formatted, abnormal)
{
DltContext context;
DltContextData contextData;
- // TODO: uint8_t data;
+ /* TODO: uint8_t data; */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint8_formatted abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint8_formatted abnormal"));
- // abnormal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- // TODO: data = 1;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(&contextData, data, (DltFormatType)-100));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(&contextData, data, (DltFormatType)-10));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(&contextData, data, (DltFormatType)10));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(&contextData, data, (DltFormatType)100));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ /* abnormal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* TODO: data = 1; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(&contextData, data, (DltFormatType)-100)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(&contextData, data, (DltFormatType)-10)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(&contextData, data, (DltFormatType)10)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(&contextData, data, (DltFormatType)100)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint8_formatted, nullpointer)
@@ -933,25 +948,26 @@ TEST(t_dlt_user_log_write_uint8_formatted, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint8_formatted nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint8_formatted nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_HEX8));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_HEX16));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_HEX32));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_HEX64));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_BIN8));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_BIN16));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_HEX8));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_HEX16));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_HEX32));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_HEX64));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_BIN8));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint8_formatted(NULL, data, DLT_FORMAT_BIN16));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_uint16_formatted
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_uint16_formatted */
TEST(t_dlt_user_log_write_uint16_formatted, normal)
{
DltContext context;
@@ -960,63 +976,65 @@ TEST(t_dlt_user_log_write_uint16_formatted, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint16_formatted normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint16_formatted normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = UINT16_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN16));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN16));
data = UINT16_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint16_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint16_formatted, abnormal)
{
DltContext context;
DltContextData contextData;
- // TODO: uint16_t data;
+ /* TODO: uint16_t data; */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint16_formatted abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint16_formatted abnormal"));
- // abnormal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- // TODO: data = 1;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(&contextData, data, (DltFormatType)-100));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(&contextData, data, (DltFormatType)-10));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(&contextData, data, (DltFormatType)10));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(&contextData, data, (DltFormatType)100));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ /* abnormal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* TODO: data = 1; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(&contextData, data, (DltFormatType)-100)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(&contextData, data, (DltFormatType)-10)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(&contextData, data, (DltFormatType)10)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(&contextData, data, (DltFormatType)100)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint16_formatted, nullpointer)
@@ -1026,25 +1044,26 @@ TEST(t_dlt_user_log_write_uint16_formatted, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint16_formatted nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint16_formatted nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_HEX8));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_HEX16));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_HEX32));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_HEX64));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_BIN8));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_BIN16));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_HEX8));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_HEX16));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_HEX32));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_HEX64));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_BIN8));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint16_formatted(NULL, data, DLT_FORMAT_BIN16));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_uint32_formatted
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_uint32_formatted */
TEST(t_dlt_user_log_write_uint32_formatted, normal)
{
DltContext context;
@@ -1053,63 +1072,65 @@ TEST(t_dlt_user_log_write_uint32_formatted, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint32_formatted normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint32_formatted normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = UINT32_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN16));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN16));
data = UINT32_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint32_formatted, abnormal)
{
DltContext context;
DltContextData contextData;
- // TODO: uint32_t data;
+ /* TODO: uint32_t data; */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint32_formatted abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint32_formatted abnormal"));
- // abnormal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- // TODO: data = 1;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(&contextData, data, (DltFormatType)-100));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(&contextData, data, (DltFormatType)-10));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(&contextData, data, (DltFormatType)10));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(&contextData, data, (DltFormatType)100));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ /* abnormal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* TODO: data = 1; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(&contextData, data, (DltFormatType)-100)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(&contextData, data, (DltFormatType)-10)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(&contextData, data, (DltFormatType)10)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(&contextData, data, (DltFormatType)100)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint32_formatted, nullpointer)
@@ -1119,25 +1140,26 @@ TEST(t_dlt_user_log_write_uint32_formatted, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint32_formatted nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint32_formatted nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_HEX8));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_HEX16));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_HEX32));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_HEX64));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_BIN8));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_BIN16));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_HEX8));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_HEX16));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_HEX32));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_HEX64));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_BIN8));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint32_formatted(NULL, data, DLT_FORMAT_BIN16));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_uint64_formatted
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_uint64_formatted */
TEST(t_dlt_user_log_write_uint64_formatted, normal)
{
DltContext context;
@@ -1146,63 +1168,65 @@ TEST(t_dlt_user_log_write_uint64_formatted, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint64_formatted normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint64_formatted normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = UINT64_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN16));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN16));
data = UINT64_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint64_formatted(&contextData, data, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint64_formatted, abnormal)
{
DltContext context;
DltContextData contextData;
- // TODO: uint64_t data;
+ /* TODO: uint64_t data; */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint64_formatted abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint64_formatted abnormal"));
- // abnormal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- // TODO: data = 1;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(&contextData, data, (DltFormatType)-100));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(&contextData, data, (DltFormatType)-10));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(&contextData, data, (DltFormatType)10));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(&contextData, data, (DltFormatType)100));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ /* abnormal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* TODO: data = 1; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(&contextData, data, (DltFormatType)-100)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(&contextData, data, (DltFormatType)-10)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(&contextData, data, (DltFormatType)10)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(&contextData, data, (DltFormatType)100)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_uint64_formatted, nullpointer)
@@ -1212,25 +1236,26 @@ TEST(t_dlt_user_log_write_uint64_formatted, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint64_formatted nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_uint64_formatted nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_HEX8));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_HEX16));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_HEX32));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_HEX64));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_BIN8));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_BIN16));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_HEX8));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_HEX16));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_HEX32));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_HEX64));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_BIN8));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_uint64_formatted(NULL, data, DLT_FORMAT_BIN16));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_int
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_int */
TEST(t_dlt_user_log_write_int, normal)
{
DltContext context;
@@ -1239,25 +1264,25 @@ TEST(t_dlt_user_log_write_int, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = -1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int(&contextData, data));
data = 0;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int(&contextData, data));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int(&contextData, data));
data = INT_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int(&contextData, data));
data = INT_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_int, nullpointer)
@@ -1267,19 +1292,19 @@ TEST(t_dlt_user_log_write_int, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_int(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_int(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_int8
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_int8 */
TEST(t_dlt_user_log_write_int8, normal)
{
DltContext context;
@@ -1288,25 +1313,25 @@ TEST(t_dlt_user_log_write_int8, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int8 normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int8 normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = -1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int8(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int8(&contextData, data));
data = 0;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int8(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int8(&contextData, data));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int8(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int8(&contextData, data));
data = INT8_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int8(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int8(&contextData, data));
data = INT8_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int8(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int8(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_int8, nullpointer)
@@ -1316,19 +1341,20 @@ TEST(t_dlt_user_log_write_int8, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int8 nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int8 nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_int8(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_int8(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_int16
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_int16 */
TEST(t_dlt_user_log_write_int16, normal)
{
DltContext context;
@@ -1337,25 +1363,25 @@ TEST(t_dlt_user_log_write_int16, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int16 normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int16 normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = -1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int16(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int16(&contextData, data));
data = 0;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int16(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int16(&contextData, data));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int16(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int16(&contextData, data));
data = INT16_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int16(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int16(&contextData, data));
data = INT16_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int16(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int16(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_int16, nullpointer)
@@ -1365,19 +1391,20 @@ TEST(t_dlt_user_log_write_int16, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int16 nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int16 nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_int16(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_int16(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_int32
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_int32 */
TEST(t_dlt_user_log_write_int32, normal)
{
DltContext context;
@@ -1386,25 +1413,25 @@ TEST(t_dlt_user_log_write_int32, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int32 normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int32 normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = -1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int32(&contextData, data));
data = 0;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int32(&contextData, data));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int32(&contextData, data));
data = INT32_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int32(&contextData, data));
data = INT32_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int32(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int32(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_int32, nullpointer)
@@ -1414,19 +1441,20 @@ TEST(t_dlt_user_log_write_int32, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int32 nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int32 nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_int32(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_int32(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_int64
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_int64 */
TEST(t_dlt_user_log_write_int64, normal)
{
DltContext context;
@@ -1435,25 +1463,25 @@ TEST(t_dlt_user_log_write_int64, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int64 normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int64 normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
data = -1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int64(&contextData, data));
data = 0;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int64(&contextData, data));
data = 1;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int64(&contextData, data));
data = INT64_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int64(&contextData, data));
data = INT64_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_int64(&contextData, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_int64(&contextData, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_int64, nullpointer)
@@ -1463,19 +1491,20 @@ TEST(t_dlt_user_log_write_int64, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int64 nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_int64 nullpointer"));
- // NULL
+ /* NULL */
data = 1;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_int64(NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_int64(NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_string
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_string */
TEST(t_dlt_user_log_write_string, normal)
{
DltContext context;
@@ -1483,19 +1512,19 @@ TEST(t_dlt_user_log_write_string, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_string normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_string normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
const char *text1 = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_string(&contextData, text1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_string(&contextData, text1));
const char *text2 = "";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_string(&contextData, text2));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_string(&contextData, text2));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_string, nullpointer)
@@ -1505,23 +1534,24 @@ TEST(t_dlt_user_log_write_string, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_string nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_string nullpointer"));
- // NULL
+ /* NULL */
const char *text1 = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_string(NULL, text1));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_string(NULL, NULL));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_string(&contextData, NULL));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_string(NULL, text1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_string(NULL, NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_string(&contextData, NULL));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_constant_string
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_constant_string */
TEST(t_dlt_user_log_write_constant_string, normal)
{
DltContext context;
@@ -1529,19 +1559,20 @@ TEST(t_dlt_user_log_write_constant_string, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_constant_string normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_constant_string normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
const char *text1 = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_constant_string(&contextData, text1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_constant_string(&contextData, text1));
const char *text2 = "";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_constant_string(&contextData, text2));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_constant_string(&contextData, text2));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_constant_string, nullpointer)
@@ -1551,23 +1582,24 @@ TEST(t_dlt_user_log_write_constant_string, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_constant_string nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_constant_string nullpointer"));
- // NULL
+ /* NULL */
const char *text1 = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_constant_string(NULL, text1));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_constant_string(NULL, NULL));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_constant_string(&contextData, NULL));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_constant_string(NULL, text1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_constant_string(NULL, NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_constant_string(&contextData, NULL));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_utf8_string
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_utf8_string */
TEST(t_dlt_user_log_write_utf8_string, normal)
{
DltContext context;
@@ -1575,19 +1607,20 @@ TEST(t_dlt_user_log_write_utf8_string, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_utf8_string normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_utf8_string normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
const char *text1 = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_utf8_string(&contextData, text1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_utf8_string(&contextData, text1));
const char *text2 = "";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_utf8_string(&contextData, text2));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_utf8_string(&contextData, text2));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_utf8_string, nullpointer)
@@ -1597,23 +1630,24 @@ TEST(t_dlt_user_log_write_utf8_string, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_utf8_string nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_utf8_string nullpointer"));
- // NULL
+ /* NULL */
const char *text1 = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_utf8_string(NULL, text1));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_utf8_string(NULL, NULL));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_utf8_string(&contextData, NULL));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_utf8_string(NULL, text1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_utf8_string(NULL, NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_utf8_string(&contextData, NULL));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_raw
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_raw */
TEST(t_dlt_user_log_write_raw, normal)
{
DltContext context;
@@ -1621,19 +1655,19 @@ TEST(t_dlt_user_log_write_raw, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_raw normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_raw normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
char text1[6] = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw(&contextData, text1, 6));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw(&contextData, text1, 6));
char text2[1] = "";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw(&contextData, text2, 0));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw(&contextData, text2, 0));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_raw, nullpointer)
@@ -1643,24 +1677,24 @@ TEST(t_dlt_user_log_write_raw, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_raw nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_raw nullpointer"));
- // NULL
+ /* NULL */
char text1[6] = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw(NULL, text1, 6));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw(NULL, NULL, 0));
- EXPECT_GE(DLT_RETURN_OK,dlt_user_log_write_raw(&contextData, NULL, 0));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw(&contextData, NULL, 1));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_raw(NULL, text1, 6));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_raw(NULL, NULL, 0));
+ EXPECT_GE(DLT_RETURN_OK, dlt_user_log_write_raw(&contextData, NULL, 0));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_raw(&contextData, NULL, 1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_log_write_raw_formatted
+/*/////////////////////////////////////// */
+/* t_dlt_user_log_write_raw_formatted */
TEST(t_dlt_user_log_write_raw_formatted, normal)
{
DltContext context;
@@ -1668,31 +1702,32 @@ TEST(t_dlt_user_log_write_raw_formatted, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_raw_formatted normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_raw_formatted normal"));
- // normal values
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ /* normal values */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
char text1[6] = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text1, 6, DLT_FORMAT_BIN16));
char text2[1] = "";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_HEX8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_HEX16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_HEX32));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_HEX64));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_BIN8));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_BIN16));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_HEX8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_HEX16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_HEX32));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_HEX64));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_BIN8));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, text2, 0, DLT_FORMAT_BIN16));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_raw_formatted, abnormal)
@@ -1705,24 +1740,26 @@ TEST(t_dlt_user_log_write_raw_formatted, abnormal)
char buffer[length];
memset(buffer, '\000', length);
- for(int i = 0; i < length; i++)
+ for (int i = 0; i < length; i++)
buffer[i] = 'X';
- EXPECT_EQ(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_EQ(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_raw_formatted abnormal"));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_EQ(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_raw_formatted abnormal"));
- EXPECT_EQ(DLT_RETURN_USER_BUFFER_FULL,dlt_user_log_write_raw_formatted(&contextData, buffer, length, DLT_FORMAT_DEFAULT));
+ EXPECT_EQ(DLT_RETURN_USER_BUFFER_FULL,
+ dlt_user_log_write_raw_formatted(&contextData, buffer, length, DLT_FORMAT_DEFAULT));
-// undefined values for DltFormatType
-// shouldn't it return -1?
-// char text1[6] = "test1";
-// EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(&contextData, text1, 6, (DltFormatType)-100));
-// EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(&contextData, text1, 6, (DltFormatType)-10));
-// EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(&contextData, text1, 6, (DltFormatType)10));
-// EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(&contextData, text1, 6, (DltFormatType)100));
+/* undefined values for DltFormatType */
+/* shouldn't it return -1? */
+/* char text1[6] = "test1"; */
+/* EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(&contextData, text1, 6, (DltFormatType)-100)); */
+/* EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(&contextData, text1, 6, (DltFormatType)-10)); */
+/* EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(&contextData, text1, 6, (DltFormatType)10)); */
+/* EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(&contextData, text1, 6, (DltFormatType)100)); */
- EXPECT_EQ(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_EQ(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_EQ(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_log_write_raw_formatted, nullpointer)
@@ -1732,91 +1769,92 @@ TEST(t_dlt_user_log_write_raw_formatted, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_raw_formatted nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_raw_formatted nullpointer"));
- // NULL
+ /* NULL */
char text1[6] = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(NULL, text1, 6, DLT_FORMAT_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(NULL, NULL, 0, DLT_FORMAT_DEFAULT));
- EXPECT_GE(DLT_RETURN_OK,dlt_user_log_write_raw_formatted(&contextData, NULL, 0, DLT_FORMAT_DEFAULT));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_user_log_write_raw_formatted(&contextData, NULL, 1, DLT_FORMAT_DEFAULT));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_log_write_finish(&contextData));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_raw_formatted(NULL, text1, 6, DLT_FORMAT_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_raw_formatted(NULL, NULL, 0, DLT_FORMAT_DEFAULT));
+ EXPECT_GE(DLT_RETURN_OK, dlt_user_log_write_raw_formatted(&contextData, NULL, 0, DLT_FORMAT_DEFAULT));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_user_log_write_raw_formatted(&contextData, NULL, 1, DLT_FORMAT_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
/*
-int dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const char *text);
-int dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, const char *text, int data);
-int dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel, const char *text, unsigned int data);
-int dlt_log_int(DltContext *handle,DltLogLevelType loglevel, int data);
-int dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigned int data);
-int dlt_log_raw(DltContext *handle,DltLogLevelType loglevel, void *data,uint16_t length);
-int dlt_log_marker();
-*/
-
-/////////////////////////////////////////
-// t_dlt_log_string
+ * int dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const char *text);
+ * int dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, const char *text, int data);
+ * int dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel, const char *text, unsigned int data);
+ * int dlt_log_int(DltContext *handle,DltLogLevelType loglevel, int data);
+ * int dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigned int data);
+ * int dlt_log_raw(DltContext *handle,DltLogLevelType loglevel, void *data,uint16_t length);
+ * int dlt_log_marker();
+ */
+
+/*/////////////////////////////////////// */
+/* t_dlt_log_string */
TEST(t_dlt_log_string, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string normal"));
- // normal values
+ /* normal values */
const char text1[6] = "test1";
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_DEFAULT, text1));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_OFF, text1));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_FATAL, text1));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_ERROR, text1));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_WARN, text1));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_INFO, text1));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_VERBOSE, text1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_DEFAULT, text1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_OFF, text1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_FATAL, text1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_ERROR, text1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_WARN, text1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_INFO, text1));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_VERBOSE, text1));
const char text2[1] = "";
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_DEFAULT, text2));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_OFF, text2));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_FATAL, text2));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_ERROR, text2));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_WARN, text2));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_INFO, text2));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string(&context, DLT_LOG_VERBOSE, text2));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_DEFAULT, text2));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_OFF, text2));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_FATAL, text2));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_ERROR, text2));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_WARN, text2));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_INFO, text2));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string(&context, DLT_LOG_VERBOSE, text2));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_string, abnormal)
{
DltContext context;
- EXPECT_EQ(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_EQ(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string abnormal"));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string abnormal"));
uint16_t length = DLT_USER_BUF_MAX_SIZE + 10;
char buffer[length];
memset(buffer, '\000', length);
- for(int i = 0; i < length - 1; i++)
+ for (int i = 0; i < length - 1; i++)
buffer[i] = 'X';
EXPECT_EQ(DLT_RETURN_USER_BUFFER_FULL, dlt_log_string(&context, DLT_LOG_INFO, buffer));
- // undefined values for DltLogLevelType
- // shouldn't it return -1?
- // TODO: const char text1[6] = "test1";
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(&context, (DltLogLevelType)-100, text1));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(&context, (DltLogLevelType)-10, text1));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(&context, (DltLogLevelType)10, text1));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(&context, (DltLogLevelType)100, text1));
+ /* undefined values for DltLogLevelType */
+ /* shouldn't it return -1? */
+ /* TODO: const char text1[6] = "test1"; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(&context, (DltLogLevelType)-100, text1)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(&context, (DltLogLevelType)-10, text1)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(&context, (DltLogLevelType)10, text1)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(&context, (DltLogLevelType)100, text1)); */
- EXPECT_EQ(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_EQ(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_EQ(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_string, nullpointer)
@@ -1825,89 +1863,89 @@ TEST(t_dlt_log_string, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string nullpointer"));
- // NULL
+ /* NULL */
char text1[6] = "test1";
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(NULL, DLT_LOG_DEFAULT, text1));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(NULL, DLT_LOG_DEFAULT, NULL));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string(&context, DLT_LOG_DEFAULT, NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_string(NULL, DLT_LOG_DEFAULT, text1));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_string(NULL, DLT_LOG_DEFAULT, NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_string(&context, DLT_LOG_DEFAULT, NULL));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_log_string_int
+/*/////////////////////////////////////// */
+/* t_dlt_log_string_int */
TEST(t_dlt_log_string_int, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_int normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_int normal"));
- // normal values
+ /* normal values */
const char text1[6] = "test1";
int data = INT_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_DEFAULT, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_OFF, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_FATAL, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_ERROR, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_WARN, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_INFO, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_VERBOSE, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_DEFAULT, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_OFF, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_FATAL, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_ERROR, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_WARN, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_INFO, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_VERBOSE, text1, data));
const char text2[1] = "";
data = 0;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_DEFAULT, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_OFF, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_FATAL, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_ERROR, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_WARN, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_INFO, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_VERBOSE, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_DEFAULT, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_OFF, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_FATAL, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_ERROR, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_WARN, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_INFO, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_VERBOSE, text2, data));
data = INT_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_DEFAULT, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_OFF, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_FATAL, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_ERROR, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_WARN, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_INFO, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_int(&context, DLT_LOG_VERBOSE, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_DEFAULT, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_OFF, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_FATAL, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_ERROR, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_WARN, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_INFO, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_int(&context, DLT_LOG_VERBOSE, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_string_int, abnormal)
{
DltContext context;
- EXPECT_EQ(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_EQ(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_int abnormal"));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_int abnormal"));
uint16_t length = DLT_USER_BUF_MAX_SIZE + 10;
char buffer[length];
memset(buffer, '\000', length);
- for(int i = 0; i < length - 1; i++)
+ for (int i = 0; i < length - 1; i++)
buffer[i] = 'X';
- EXPECT_EQ(DLT_RETURN_USER_BUFFER_FULL,dlt_log_string_int(&context, DLT_LOG_INFO, buffer, 1));
+ EXPECT_EQ(DLT_RETURN_USER_BUFFER_FULL, dlt_log_string_int(&context, DLT_LOG_INFO, buffer, 1));
- // undefined values for DltLogLevelType
- // shouldn't it return -1?
- // TODO: const char text1[6] = "test1";
- // TODO: int data = 1;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(&context, (DltLogLevelType)-100, text1, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(&context, (DltLogLevelType)-10, text1, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(&context, (DltLogLevelType)10, text1, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(&context, (DltLogLevelType)100, text1, data));
+ /* undefined values for DltLogLevelType */
+ /* shouldn't it return -1? */
+ /* TODO: const char text1[6] = "test1"; */
+ /* TODO: int data = 1; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(&context, (DltLogLevelType)-100, text1, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(&context, (DltLogLevelType)-10, text1, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(&context, (DltLogLevelType)10, text1, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(&context, (DltLogLevelType)100, text1, data)); */
- EXPECT_EQ(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_EQ(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_EQ(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_string_int, nullpointer)
@@ -1916,90 +1954,90 @@ TEST(t_dlt_log_string_int, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_int nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_int nullpointer"));
- // NULL
+ /* NULL */
char text1[6] = "test1";
int data = 0;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(NULL, DLT_LOG_DEFAULT, text1, data));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(NULL, DLT_LOG_DEFAULT, NULL, data));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_int(&context, DLT_LOG_DEFAULT, NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_string_int(NULL, DLT_LOG_DEFAULT, text1, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_string_int(NULL, DLT_LOG_DEFAULT, NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_string_int(&context, DLT_LOG_DEFAULT, NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_log_string_uint
+/*/////////////////////////////////////// */
+/* t_dlt_log_string_uint */
TEST(t_dlt_log_string_uint, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_uint normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_uint normal"));
- // normal values
+ /* normal values */
const char text1[6] = "test1";
unsigned int data = UINT_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_DEFAULT, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_OFF, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_FATAL, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_ERROR, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_WARN, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_INFO, text1, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_VERBOSE, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_DEFAULT, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_OFF, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_FATAL, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_ERROR, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_WARN, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_INFO, text1, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_VERBOSE, text1, data));
const char text2[1] = "";
data = 0;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_DEFAULT, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_OFF, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_FATAL, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_ERROR, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_WARN, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_INFO, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_VERBOSE, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_DEFAULT, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_OFF, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_FATAL, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_ERROR, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_WARN, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_INFO, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_VERBOSE, text2, data));
data = UINT_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_DEFAULT, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_OFF, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_FATAL, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_ERROR, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_WARN, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_INFO, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_string_uint(&context, DLT_LOG_VERBOSE, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_DEFAULT, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_OFF, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_FATAL, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_ERROR, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_WARN, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_INFO, text2, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_string_uint(&context, DLT_LOG_VERBOSE, text2, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_string_uint, abnormal)
{
DltContext context;
- EXPECT_EQ(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_EQ(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_uint abnormal"));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_uint abnormal"));
uint16_t length = DLT_USER_BUF_MAX_SIZE + 10;
char buffer[length];
- memset(buffer, '\000', DLT_USER_BUF_MAX_SIZE+10);
+ memset(buffer, '\000', DLT_USER_BUF_MAX_SIZE + 10);
- for(int i = 0; i < length - 1; i++)
+ for (int i = 0; i < length - 1; i++)
buffer[i] = 'X';
- EXPECT_EQ(DLT_RETURN_USER_BUFFER_FULL,dlt_log_string_uint(&context, DLT_LOG_INFO, buffer, 1));
+ EXPECT_EQ(DLT_RETURN_USER_BUFFER_FULL, dlt_log_string_uint(&context, DLT_LOG_INFO, buffer, 1));
- // undefined values for DltLogLevelType
- // shouldn't it return -1?
- // TODO: const char text1[6] = "test1";
- // TODO: unsigned int data = 1;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(&context, (DltLogLevelType)-100, text1, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(&context, (DltLogLevelType)-10, text1, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(&context, (DltLogLevelType)10, text1, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(&context, (DltLogLevelType)100, text1, data));
+ /* undefined values for DltLogLevelType */
+ /* shouldn't it return -1? */
+ /* TODO: const char text1[6] = "test1"; */
+ /* TODO: unsigned int data = 1; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(&context, (DltLogLevelType)-100, text1, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(&context, (DltLogLevelType)-10, text1, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(&context, (DltLogLevelType)10, text1, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(&context, (DltLogLevelType)100, text1, data)); */
- EXPECT_EQ(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_EQ(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_EQ(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_string_uint, nullpointer)
@@ -2008,59 +2046,59 @@ TEST(t_dlt_log_string_uint, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_uint nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_string_uint nullpointer"));
- // NULL
+ /* NULL */
char text1[6] = "test1";
unsigned int data = 0;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(NULL, DLT_LOG_DEFAULT, text1, data));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(NULL, DLT_LOG_DEFAULT, NULL, data));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_string_uint(&context, DLT_LOG_DEFAULT, NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_string_uint(NULL, DLT_LOG_DEFAULT, text1, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_string_uint(NULL, DLT_LOG_DEFAULT, NULL, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_string_uint(&context, DLT_LOG_DEFAULT, NULL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_log_int
+/*/////////////////////////////////////// */
+/* t_dlt_log_int */
TEST(t_dlt_log_int, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_int normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_int normal"));
- // normal values
+ /* normal values */
int data = INT_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_DEFAULT, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_OFF, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_FATAL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_ERROR, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_WARN, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_INFO, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_VERBOSE, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_DEFAULT, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_OFF, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_FATAL, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_ERROR, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_WARN, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_INFO, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_VERBOSE, data));
data = 0;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_DEFAULT, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_OFF, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_FATAL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_ERROR, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_WARN, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_INFO, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_VERBOSE, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_DEFAULT, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_OFF, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_FATAL, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_ERROR, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_WARN, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_INFO, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_VERBOSE, data));
data = INT_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_DEFAULT, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_OFF, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_FATAL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_ERROR, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_WARN, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_INFO, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_int(&context, DLT_LOG_VERBOSE, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_DEFAULT, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_OFF, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_FATAL, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_ERROR, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_WARN, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_INFO, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_int(&context, DLT_LOG_VERBOSE, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_int, abnormal)
@@ -2069,19 +2107,19 @@ TEST(t_dlt_log_int, abnormal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_int abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_int abnormal"));
- // undefined values for DltLogLevelType
- // shouldn't it return -1?
- // TODO: int data = 1;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_int(&context, (DltLogLevelType)-100, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_int(&context, (DltLogLevelType)-10, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_int(&context, (DltLogLevelType)10, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_int(&context, (DltLogLevelType)100, data));
+ /* undefined values for DltLogLevelType */
+ /* shouldn't it return -1? */
+ /* TODO: int data = 1; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_int(&context, (DltLogLevelType)-100, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_int(&context, (DltLogLevelType)-10, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_int(&context, (DltLogLevelType)10, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_int(&context, (DltLogLevelType)100, data)); */
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_int, nullpointer)
@@ -2090,56 +2128,56 @@ TEST(t_dlt_log_int, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_int nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_int nullpointer"));
- // NULL
+ /* NULL */
int data = 0;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_int(NULL, DLT_LOG_DEFAULT, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_int(NULL, DLT_LOG_DEFAULT, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_log_uint
+/*/////////////////////////////////////// */
+/* t_dlt_log_uint */
TEST(t_dlt_log_uint, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_uint normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_uint normal"));
- // normal values
+ /* normal values */
unsigned int data = UINT_MIN;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_DEFAULT, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_OFF, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_FATAL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_ERROR, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_WARN, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_INFO, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_VERBOSE, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_DEFAULT, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_OFF, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_FATAL, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_ERROR, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_WARN, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_INFO, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_VERBOSE, data));
data = 0;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_DEFAULT, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_OFF, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_FATAL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_ERROR, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_WARN, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_INFO, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_VERBOSE, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_DEFAULT, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_OFF, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_FATAL, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_ERROR, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_WARN, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_INFO, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_VERBOSE, data));
data = UINT_MAX;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_DEFAULT, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_OFF, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_FATAL, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_ERROR, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_WARN, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_INFO, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_uint(&context, DLT_LOG_VERBOSE, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_DEFAULT, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_OFF, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_FATAL, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_ERROR, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_WARN, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_INFO, data));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_uint(&context, DLT_LOG_VERBOSE, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_uint, abnormal)
@@ -2148,19 +2186,19 @@ TEST(t_dlt_log_uint, abnormal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_uint abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_uint abnormal"));
- // undefined values for DltLogLevelType
- // shouldn't it return -1?
- // TODO: unsigned int data = 1;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_uint(&context, (DltLogLevelType)-100, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_uint(&context, (DltLogLevelType)-10, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_uint(&context, (DltLogLevelType)10, data));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_uint(&context, (DltLogLevelType)100, data));
+ /* undefined values for DltLogLevelType */
+ /* shouldn't it return -1? */
+ /* TODO: unsigned int data = 1; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_uint(&context, (DltLogLevelType)-100, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_uint(&context, (DltLogLevelType)-10, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_uint(&context, (DltLogLevelType)10, data)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_uint(&context, (DltLogLevelType)100, data)); */
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_uint, nullpointer)
@@ -2169,41 +2207,41 @@ TEST(t_dlt_log_uint, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_uint nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_uint nullpointer"));
- // NULL
+ /* NULL */
unsigned int data = 0;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_uint(NULL, DLT_LOG_DEFAULT, data));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_uint(NULL, DLT_LOG_DEFAULT, data));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_log_raw
+/*/////////////////////////////////////// */
+/* t_dlt_log_raw */
TEST(t_dlt_log_raw, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_raw normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_raw normal"));
- // normal values
+ /* normal values */
char data[5] = "test";
uint16_t length = 4;
- EXPECT_LE(DLT_RETURN_OK,dlt_log_raw(&context, DLT_LOG_DEFAULT, data, length));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_raw(&context, DLT_LOG_OFF, data, length));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_raw(&context, DLT_LOG_FATAL, data, length));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_raw(&context, DLT_LOG_ERROR, data, length));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_raw(&context, DLT_LOG_WARN, data, length));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_raw(&context, DLT_LOG_INFO, data, length));
- EXPECT_LE(DLT_RETURN_OK,dlt_log_raw(&context, DLT_LOG_VERBOSE, data, length));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_raw(&context, DLT_LOG_DEFAULT, data, length));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_raw(&context, DLT_LOG_OFF, data, length));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_raw(&context, DLT_LOG_FATAL, data, length));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_raw(&context, DLT_LOG_ERROR, data, length));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_raw(&context, DLT_LOG_WARN, data, length));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_raw(&context, DLT_LOG_INFO, data, length));
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_raw(&context, DLT_LOG_VERBOSE, data, length));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_raw, abnormal)
@@ -2212,37 +2250,37 @@ TEST(t_dlt_log_raw, abnormal)
- EXPECT_EQ(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_EQ(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_raw abnormal"));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_raw abnormal"));
uint16_t length = DLT_USER_BUF_MAX_SIZE + 10;
char buffer[length];
memset(buffer, '\000', length);
- for(int i = 0; i < length; i++)
+ for (int i = 0; i < length; i++)
buffer[i] = 'X';
EXPECT_EQ(DLT_RETURN_USER_BUFFER_FULL, dlt_log_raw(&context, DLT_LOG_INFO, buffer, length));
- // undefined values for DltLogLevelType
- // shouldn't it return -1?
-// char data[5] = "test";
- // TODO: uint16_t length = 4;
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, (DltLogLevelType)-100, data, length));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, (DltLogLevelType)-10, data, length));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, (DltLogLevelType)10, data, length));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, (DltLogLevelType)100, data, length));
+ /* undefined values for DltLogLevelType */
+ /* shouldn't it return -1? */
+/* char data[5] = "test"; */
+ /* TODO: uint16_t length = 4; */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, (DltLogLevelType)-100, data, length)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, (DltLogLevelType)-10, data, length)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, (DltLogLevelType)10, data, length)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, (DltLogLevelType)100, data, length)); */
- // zero length
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, DLT_LOG_DEFAULT, data, 0));
+ /* zero length */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, DLT_LOG_DEFAULT, data, 0)); */
- // negative length
-// EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, DLT_LOG_DEFAULT, data, -1));
-// EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, DLT_LOG_DEFAULT, data, -100));
+ /* negative length */
+/* EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, DLT_LOG_DEFAULT, data, -1)); */
+/* EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, DLT_LOG_DEFAULT, data, -100)); */
- EXPECT_EQ(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_EQ(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_EQ(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_EQ(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_log_raw, nullpointer)
@@ -2251,123 +2289,123 @@ TEST(t_dlt_log_raw, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_raw nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_raw nullpointer"));
- // NULL
+ /* NULL */
char data[5] = "test";
uint16_t length = 4;
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(NULL, DLT_LOG_DEFAULT, data, length));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(NULL, DLT_LOG_DEFAULT, NULL, length));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_log_raw(&context, DLT_LOG_DEFAULT, NULL, length));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_raw(NULL, DLT_LOG_DEFAULT, data, length));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_raw(NULL, DLT_LOG_DEFAULT, NULL, length));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_log_raw(&context, DLT_LOG_DEFAULT, NULL, length));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_log_marker
+/*/////////////////////////////////////// */
+/* t_dlt_log_marker */
TEST(t_dlt_log_marker, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_marker normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_log_marker normal"));
- // normal
- EXPECT_LE(DLT_RETURN_OK,dlt_log_marker());
+ /* normal */
+ EXPECT_LE(DLT_RETURN_OK, dlt_log_marker());
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_register_app
+/*/////////////////////////////////////// */
+/* t_dlt_register_app */
TEST(t_dlt_register_app, normal)
{
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("T", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TU", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUS", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("T", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TU", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUS", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_register_app, abnormal)
{
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("", "dlt_user.c tests"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app());
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR1", "dlt_user.c tests"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app());
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR123445667", "dlt_user.c tests"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app());
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR", ""));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app());
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR", NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_app("", "dlt_user.c tests"));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_unregister_app());
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR1", "dlt_user.c tests")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app()); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR123445667", "dlt_user.c tests")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app()); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR", "")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app()); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR", NULL)); */
}
TEST(t_dlt_register_app, nullpointer)
{
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app(NULL, NULL));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app(NULL, "dlt_user.c tests"));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_app(NULL, NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_app(NULL, "dlt_user.c tests"));
}
-/////////////////////////////////////////
-// t_dlt_unregister_app
+/*/////////////////////////////////////// */
+/* t_dlt_unregister_app */
TEST(t_dlt_unregister_app, normal)
{
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("T", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TU", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUS", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("T", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TU", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUS", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_unregister_app, abnormal)
{
- EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app());
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("", "dlt_user.c tests"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app());
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR1", "dlt_user.c tests"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app());
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR123445667", "dlt_user.c tests"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app());
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR", ""));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app());
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_unregister_app());
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_app("", "dlt_user.c tests"));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_unregister_app());
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR1", "dlt_user.c tests")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app()); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR123445667", "dlt_user.c tests")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app()); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_app("TUSR", "")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_app()); */
}
-/////////////////////////////////////////
-// t_dlt_register_context
+/*/////////////////////////////////////// */
+/* t_dlt_register_context */
TEST(t_dlt_register_context, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal"));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_register_context, abnormal)
@@ -2376,31 +2414,31 @@ TEST(t_dlt_register_context, abnormal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "", "d"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "T", ""));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "", ""));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1", ""));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1", "1"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1234567890", ""));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1234567890", "1"));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(&context, "", "d"));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "T", "")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(&context, "", ""));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1", "")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1", "1")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1234567890", "")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1234567890", "1")); */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", NULL));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal"));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_context normal")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", NULL)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_register_context, nullpointer)
@@ -2408,58 +2446,100 @@ TEST(t_dlt_register_context, nullpointer)
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, NULL, "dlt_user.c t_dlt_register_context normal"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, NULL, NULL));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(NULL, "TEST", NULL));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(NULL, NULL, "dlt_user.c t_dlt_register_context normal"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(NULL, NULL, NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(&context, NULL, "dlt_user.c t_dlt_register_context normal"));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(&context, NULL, NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(NULL, "TEST", NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(NULL, NULL, "dlt_user.c t_dlt_register_context normal"));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(NULL, NULL, NULL));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_register_context_ll_ts
+/*/////////////////////////////////////// */
+/* t_dlt_register_context_ll_ts */
TEST(t_dlt_register_context_ll_ts, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
-
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_FATAL, DLT_TRACE_STATUS_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_ERROR, DLT_TRACE_STATUS_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_WARN, DLT_TRACE_STATUS_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_INFO, DLT_TRACE_STATUS_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_DEBUG, DLT_TRACE_STATUS_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_VERBOSE, DLT_TRACE_STATUS_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
-
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_FATAL, DLT_TRACE_STATUS_ON));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_ERROR, DLT_TRACE_STATUS_ON));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_WARN, DLT_TRACE_STATUS_ON));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_INFO, DLT_TRACE_STATUS_ON));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_DEBUG, DLT_TRACE_STATUS_ON));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_OFF,
+ DLT_TRACE_STATUS_OFF));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_FATAL,
+ DLT_TRACE_STATUS_OFF));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_ERROR,
+ DLT_TRACE_STATUS_OFF));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_WARN,
+ DLT_TRACE_STATUS_OFF));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_INFO,
+ DLT_TRACE_STATUS_OFF));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_DEBUG,
+ DLT_TRACE_STATUS_OFF));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_VERBOSE,
+ DLT_TRACE_STATUS_OFF));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_OFF,
+ DLT_TRACE_STATUS_ON));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_FATAL,
+ DLT_TRACE_STATUS_ON));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_ERROR,
+ DLT_TRACE_STATUS_ON));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_WARN,
+ DLT_TRACE_STATUS_ON));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_INFO,
+ DLT_TRACE_STATUS_ON));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_DEBUG,
+ DLT_TRACE_STATUS_ON));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_VERBOSE,
+ DLT_TRACE_STATUS_ON));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_register_context_ll_ts, abnormal)
@@ -2468,50 +2548,61 @@ TEST(t_dlt_register_context_ll_ts, abnormal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
-
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "", "d", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "T", "", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "", "", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST1", "", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST1", "1", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST1234567890", "", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST1234567890", "1", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
-
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
-
- // DLT_LOG_DEFAULT and DLT_TRACE_STATUS_DEFAULT not allowed
- // TODO: Why not?
-// EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_DEFAULT, DLT_TRACE_STATUS_OFF));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
-// EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
-// EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_DEFAULT));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
-
- // abnormal values for loglevel and tracestatus
- EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", -3, DLT_TRACE_STATUS_OFF));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", 100, DLT_TRACE_STATUS_OFF));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, -3));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, 100));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", NULL, DLT_LOG_OFF, DLT_TRACE_STATUS_OFF));
-
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context_ll_ts(&context, "", "d", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "T", "", DLT_LOG_OFF, DLT_TRACE_STATUS_ON)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context_ll_ts(&context, "", "", DLT_LOG_OFF, DLT_TRACE_STATUS_ON));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST1", "", DLT_LOG_OFF, DLT_TRACE_STATUS_ON)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST1", "1", DLT_LOG_OFF, DLT_TRACE_STATUS_ON)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST1234567890", "", DLT_LOG_OFF, DLT_TRACE_STATUS_ON)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST1234567890", "1", DLT_LOG_OFF, DLT_TRACE_STATUS_ON)); */
+
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_OFF,
+ DLT_TRACE_STATUS_ON));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_ON)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_ON)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_ON)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_ON)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+
+ /* DLT_LOG_DEFAULT and DLT_TRACE_STATUS_DEFAULT not allowed */
+ /* TODO: Why not? */
+/* EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_DEFAULT, DLT_TRACE_STATUS_OFF)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+/* EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+/* EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_DEFAULT)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+
+ /* abnormal values for loglevel and tracestatus */
+ EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", -3,
+ DLT_TRACE_STATUS_OFF));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal", 100,
+ DLT_TRACE_STATUS_OFF));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_OFF, -3));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ EXPECT_EQ(DLT_RETURN_WRONG_PARAMETER,
+ dlt_register_context_ll_ts(&context, "TEST", "dlt_user.c t_dlt_register_context_ll_ts normal",
+ DLT_LOG_OFF, 100));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, "TEST", NULL, DLT_LOG_OFF, DLT_TRACE_STATUS_OFF)); */
+
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_register_context_ll_ts, nullpointer)
@@ -2520,31 +2611,35 @@ TEST(t_dlt_register_context_ll_ts, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, NULL, "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_OFF));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(&context, NULL, NULL, DLT_LOG_OFF, DLT_TRACE_STATUS_OFF));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(NULL, "TEST", NULL, DLT_LOG_OFF, DLT_TRACE_STATUS_OFF));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(NULL, NULL, "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF, DLT_TRACE_STATUS_OFF));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context_ll_ts(NULL, NULL, NULL, DLT_LOG_OFF, DLT_TRACE_STATUS_OFF));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_register_context_ll_ts(&context, NULL, "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF,
+ DLT_TRACE_STATUS_OFF));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context_ll_ts(&context, NULL, NULL, DLT_LOG_OFF, DLT_TRACE_STATUS_OFF));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context_ll_ts(NULL, "TEST", NULL, DLT_LOG_OFF, DLT_TRACE_STATUS_OFF));
+ EXPECT_GE(DLT_RETURN_ERROR,
+ dlt_register_context_ll_ts(NULL, NULL, "dlt_user.c t_dlt_register_context_ll_ts normal", DLT_LOG_OFF,
+ DLT_TRACE_STATUS_OFF));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context_ll_ts(NULL, NULL, NULL, DLT_LOG_OFF, DLT_TRACE_STATUS_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_unregister_context
+/*/////////////////////////////////////// */
+/* t_dlt_unregister_context */
TEST(t_dlt_unregister_context, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal"));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_unregister_context, abnormal)
@@ -2553,31 +2648,31 @@ TEST(t_dlt_unregister_context, abnormal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "", "d"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "T", ""));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "", ""));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1", ""));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1", "1"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1234567890", ""));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1234567890", "1"));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(&context, "", "d"));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "T", "")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(&context, "", ""));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1", "")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1", "1")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1234567890", "")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_unregister_context(&context)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST1234567890", "1")); */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal"));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", NULL));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal"));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_unregister_context normal")); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, "TEST", NULL)); */
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_unregister_context, nullpointer)
@@ -2586,20 +2681,20 @@ TEST(t_dlt_unregister_context, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, NULL, "dlt_user.c t_dlt_unregister_context normal"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(&context, NULL, NULL));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(NULL, "TEST", NULL));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(NULL, NULL, "dlt_user.c t_dlt_unregister_context normal"));
- EXPECT_GE(DLT_RETURN_ERROR,dlt_register_context(NULL, NULL, NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(&context, NULL, "dlt_user.c t_dlt_unregister_context normal"));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(&context, NULL, NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(NULL, "TEST", NULL));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(NULL, NULL, "dlt_user.c t_dlt_unregister_context normal"));
+ EXPECT_GE(DLT_RETURN_ERROR, dlt_register_context(NULL, NULL, NULL));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_register_injection_callback
+/*/////////////////////////////////////// */
+/* t_dlt_register_injection_callback */
int dlt_user_injection_callback(uint32_t /*service_id*/, void */*data*/, uint32_t /*length*/)
{
return 0;
@@ -2608,28 +2703,28 @@ int dlt_user_injection_callback(uint32_t /*service_id*/, void */*data*/, uint32_
TEST(t_dlt_register_injection_callback, normal)
{
DltContext context;
- // TODO: uint32_t service_id;
+ /* TODO: uint32_t service_id; */
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_injection_callback normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_injection_callback normal"));
- // TODO: service_id = 0x123;
- // TODO: EXPECT_LE(DLT_RETURN_OK,dlt_register_injection_callback(&context, service_id, dlt_user_injection_callback));
+ /* TODO: service_id = 0x123; */
+ /* TODO: EXPECT_LE(DLT_RETURN_OK,dlt_register_injection_callback(&context, service_id, dlt_user_injection_callback)); */
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_register_log_level_changed_callback
-void dlt_user_log_level_changed_callback(char /*context_id*/[DLT_ID_SIZE], uint8_t /*log_level*/, uint8_t /*trace_status*/)
-{
-
-}
+/*/////////////////////////////////////// */
+/* t_dlt_register_log_level_changed_callback */
+void dlt_user_log_level_changed_callback(char /*context_id*/[DLT_ID_SIZE], uint8_t /*log_level*/,
+ uint8_t /*trace_status*/)
+{}
TEST(t_dlt_register_log_level_changed_callback, normal)
{
@@ -2637,46 +2732,46 @@ TEST(t_dlt_register_log_level_changed_callback, normal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_log_level_changed_callback normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_register_log_level_changed_callback normal"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_log_level_changed_callback(&context, dlt_user_log_level_changed_callback));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_log_level_changed_callback(&context, dlt_user_log_level_changed_callback));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_trace_network
+/*/////////////////////////////////////// */
+/* t_dlt_user_trace_network */
TEST(t_dlt_user_trace_network, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network normal"));
char header[16];
- for(char i = 0; i < 16; ++i)
- {
+
+ for (char i = 0; i < 16; ++i)
header[(int)i] = i;
- }
+
char payload[32];
- for(char i = 0; i < 32; ++i)
- {
+
+ for (char i = 0; i < 32; ++i)
payload[(int)i] = i;
- }
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network(&context, DLT_NW_TRACE_IPC, 16, header, 32, payload));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network(&context, DLT_NW_TRACE_CAN, 16, header, 32, payload));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 32, payload));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network(&context, DLT_NW_TRACE_MOST, 16, header, 32, payload));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network(&context, DLT_NW_TRACE_IPC, 16, header, 32, payload));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network(&context, DLT_NW_TRACE_CAN, 16, header, 32, payload));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 32, payload));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network(&context, DLT_NW_TRACE_MOST, 16, header, 32, payload));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_trace_network, abnormal)
@@ -2685,33 +2780,33 @@ TEST(t_dlt_user_trace_network, abnormal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network abnormal"));
- // TODO: char header[16];
- // TODO: for(char i = 0; i < 16; ++i)
- // TODO: {
- // TODO: header[(int)i] = i;
- // TODO: }
- // TODO: char payload[32];
- // TODO: for(char i = 0; i < 32; ++i)
- // TODO: {
- // TODO: payload[(int)i] = i;
- // TODO: }
+ /* TODO: char header[16]; */
+ /* TODO: for(char i = 0; i < 16; ++i) */
+ /* TODO: { */
+ /* TODO: header[(int)i] = i; */
+ /* TODO: } */
+ /* TODO: char payload[32]; */
+ /* TODO: for(char i = 0; i < 32; ++i) */
+ /* TODO: { */
+ /* TODO: payload[(int)i] = i; */
+ /* TODO: } */
- // data length = 0. Does this make sense?
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, DLT_NW_TRACE_IPC, 0, header, 32, payload));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, DLT_NW_TRACE_CAN, 0, header, 0, payload));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 0, payload));
+ /* data length = 0. Does this make sense? */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, DLT_NW_TRACE_IPC, 0, header, 32, payload)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, DLT_NW_TRACE_CAN, 0, header, 0, payload)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 0, payload)); */
- // invalid DltNetworkTraceType value
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, (DltNetworkTraceType)-100, 16, header, 32, payload));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, (DltNetworkTraceType)-10, 16, header, 32, payload));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, (DltNetworkTraceType)10, 16, header, 32, payload));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, (DltNetworkTraceType)100, 16, header, 32, payload));
+ /* invalid DltNetworkTraceType value */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, (DltNetworkTraceType)-100, 16, header, 32, payload)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, (DltNetworkTraceType)-10, 16, header, 32, payload)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, (DltNetworkTraceType)10, 16, header, 32, payload)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network(&context, (DltNetworkTraceType)100, 16, header, 32, payload)); */
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_trace_network, nullpointer)
@@ -2720,59 +2815,60 @@ TEST(t_dlt_user_trace_network, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network nullpointer"));
char header[16];
- for(char i = 0; i < 16; ++i)
- {
+
+ for (char i = 0; i < 16; ++i)
header[(int)i] = i;
- }
+
char payload[32];
- for(char i = 0; i < 32; ++i)
- {
+
+ for (char i = 0; i < 32; ++i)
payload[(int)i] = i;
- }
- // what to expect when giving in NULL pointer?
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network(&context, DLT_NW_TRACE_IPC, 16, NULL, 32, payload));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER,dlt_user_trace_network(&context, DLT_NW_TRACE_CAN, 16, header, 32, NULL));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER,dlt_user_trace_network(&context, DLT_NW_TRACE_FLEXRAY, 16, NULL, 32, NULL));
+ /* what to expect when giving in NULL pointer? */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network(&context, DLT_NW_TRACE_IPC, 16, NULL, 32, payload));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_user_trace_network(&context, DLT_NW_TRACE_CAN, 16, header, 32, NULL));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_user_trace_network(&context, DLT_NW_TRACE_FLEXRAY, 16, NULL, 32, NULL));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_trace_network_truncated
+/*/////////////////////////////////////// */
+/* t_dlt_user_trace_network_truncated */
TEST(t_dlt_user_trace_network_truncated, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_truncated normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_truncated normal"));
char header[16];
- for(char i = 0; i < 16; ++i)
- {
+
+ for (char i = 0; i < 16; ++i)
header[(int)i] = i;
- }
+
char payload[32];
- for(char i = 0; i < 32; ++i)
- {
+
+ for (char i = 0; i < 32; ++i)
payload[(int)i] = i;
- }
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_IPC, 16, header, 32, payload, 0));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_CAN, 16, header, 32, payload, 1));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 32, payload, -1));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_MOST, 16, header, 32, payload, 10));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_IPC, 16, header, 32, payload, 0));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_CAN, 16, header, 32, payload, 1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 32, payload, -1));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_MOST, 16, header, 32, payload, 10));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_trace_network_truncated, abnormal)
@@ -2781,33 +2877,34 @@ TEST(t_dlt_user_trace_network_truncated, abnormal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_truncated abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_truncated abnormal"));
- // TODO: char header[16];
- // TODO: for(char i = 0; i < 16; ++i)
- // TODO: {
- // TODO: header[(int)i] = i;
- // TODO: }
- // TODO: char payload[32];
- // TODO: for(char i = 0; i < 32; ++i)
- // TODO: {
- // TODO: payload[(int)i] = i;
- // TODO: }
+ /* TODO: char header[16]; */
+ /* TODO: for(char i = 0; i < 16; ++i) */
+ /* TODO: { */
+ /* TODO: header[(int)i] = i; */
+ /* TODO: } */
+ /* TODO: char payload[32]; */
+ /* TODO: for(char i = 0; i < 32; ++i) */
+ /* TODO: { */
+ /* TODO: payload[(int)i] = i; */
+ /* TODO: } */
- // data length = 0. Does this make sense?
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_IPC, 0, header, 32, payload, 0));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_CAN, 0, header, 0, payload, 0));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 0, payload, 0));
+ /* data length = 0. Does this make sense? */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_IPC, 0, header, 32, payload, 0)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_CAN, 0, header, 0, payload, 0)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 0, payload, 0)); */
- // invalid DltNetworkTraceType value
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, (DltNetworkTraceType)-100, 16, header, 32, payload, 0));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, (DltNetworkTraceType)-10, 16, header, 32, payload, 0));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, (DltNetworkTraceType)10, 16, header, 32, payload, 0));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, (DltNetworkTraceType)100, 16, header, 32, payload, 0));
+ /* invalid DltNetworkTraceType value */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, (DltNetworkTraceType)-100, 16, header, 32, payload, 0)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, (DltNetworkTraceType)-10, 16, header, 32, payload, 0)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, (DltNetworkTraceType)10, 16, header, 32, payload, 0)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_truncated(&context, (DltNetworkTraceType)100, 16, header, 32, payload, 0)); */
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_trace_network_truncated, nullpointer)
@@ -2816,59 +2913,61 @@ TEST(t_dlt_user_trace_network_truncated, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_truncated nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_truncated nullpointer"));
char header[16];
- for(char i = 0; i < 16; ++i)
- {
+
+ for (char i = 0; i < 16; ++i)
header[(int)i] = i;
- }
+
char payload[32];
- for(char i = 0; i < 32; ++i)
- {
+
+ for (char i = 0; i < 32; ++i)
payload[(int)i] = i;
- }
- // what to expect when giving in NULL pointer?
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_IPC, 16, NULL, 32, payload, 0));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_CAN, 16, header, 32, NULL, 0));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER,dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_FLEXRAY, 16, NULL, 32, NULL, 0));
+ /* what to expect when giving in NULL pointer? */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_IPC, 16, NULL, 32, payload, 0));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER,
+ dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_CAN, 16, header, 32, NULL, 0));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER,
+ dlt_user_trace_network_truncated(&context, DLT_NW_TRACE_FLEXRAY, 16, NULL, 32, NULL, 0));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_user_trace_network_segmented
+/*/////////////////////////////////////// */
+/* t_dlt_user_trace_network_segmented */
TEST(t_dlt_user_trace_network_segmented, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_segmented normal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_segmented normal"));
char header[16];
- for(char i = 0; i < 16; ++i)
- {
+
+ for (char i = 0; i < 16; ++i)
header[(int)i] = i;
- }
+
char payload[32];
- for(char i = 0; i < 32; ++i)
- {
+
+ for (char i = 0; i < 32; ++i)
payload[(int)i] = i;
- }
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_IPC, 16, header, 32, payload));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_CAN, 16, header, 32, payload));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 32, payload));
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_MOST, 16, header, 32, payload));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_IPC, 16, header, 32, payload));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_CAN, 16, header, 32, payload));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 32, payload));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_MOST, 16, header, 32, payload));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_trace_network_segmented, abnormal)
@@ -2877,33 +2976,34 @@ TEST(t_dlt_user_trace_network_segmented, abnormal)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_segmented abnormal"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_segmented abnormal"));
- // TODO: char header[16];
- // TODO: for(char i = 0; i < 16; ++i)
- // TODO: {
- // TODO: header[(int)i] = i;
- // TODO: }
- // TODO: char payload[32];
- // TODO: for(char i = 0; i < 32; ++i)
- // TODO: {
- // TODO: payload[(int)i] = i;
- // TODO: }
+ /* TODO: char header[16]; */
+ /* TODO: for(char i = 0; i < 16; ++i) */
+ /* TODO: { */
+ /* TODO: header[(int)i] = i; */
+ /* TODO: } */
+ /* TODO: char payload[32]; */
+ /* TODO: for(char i = 0; i < 32; ++i) */
+ /* TODO: { */
+ /* TODO: payload[(int)i] = i; */
+ /* TODO: } */
- // data length = 0. Does this make sense?
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_IPC, 0, header, 32, payload));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_CAN, 0, header, 0, payload));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 0, payload));
+ /* data length = 0. Does this make sense? */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_IPC, 0, header, 32, payload)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_CAN, 0, header, 0, payload)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_FLEXRAY, 16, header, 0, payload)); */
- // invalid DltNetworkTraceType value
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, (DltNetworkTraceType)-100, 16, header, 32, payload));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, (DltNetworkTraceType)-10, 16, header, 32, payload));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, (DltNetworkTraceType)10, 16, header, 32, payload));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, (DltNetworkTraceType)100, 16, header, 32, payload));
+ /* invalid DltNetworkTraceType value */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, (DltNetworkTraceType)-100, 16, header, 32, payload)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, (DltNetworkTraceType)-10, 16, header, 32, payload)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, (DltNetworkTraceType)10, 16, header, 32, payload)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_user_trace_network_segmented(&context, (DltNetworkTraceType)100, 16, header, 32, payload)); */
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_trace_network_segmented, nullpointer)
@@ -2912,41 +3012,43 @@ TEST(t_dlt_user_trace_network_segmented, nullpointer)
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_segmented nullpointer"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK,
+ dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_trace_network_segmented nullpointer"));
char header[16];
- for(char i = 0; i < 16; ++i)
- {
- header[(int)i] = i;
- }
+
+ for (char i = 0; i < 16; ++i)
+ header[(int)i] = i;
+
char payload[32];
- for(char i = 0; i < 32; ++i)
- {
+
+ for (char i = 0; i < 32; ++i)
payload[(int)i] = i;
- }
- // what to expect when giving in NULL pointer?
- EXPECT_LE(DLT_RETURN_OK,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_IPC, 16, NULL, 32, payload));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_CAN, 16, header, 32, NULL));
- EXPECT_LE(DLT_RETURN_WRONG_PARAMETER,dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_FLEXRAY, 16, NULL, 32, NULL));
+ /* what to expect when giving in NULL pointer? */
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_IPC, 16, NULL, 32, payload));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER,
+ dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_CAN, 16, header, 32, NULL));
+ EXPECT_LE(DLT_RETURN_WRONG_PARAMETER,
+ dlt_user_trace_network_segmented(&context, DLT_NW_TRACE_FLEXRAY, 16, NULL, 32, NULL));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
-/////////////////////////////////////////
-// t_dlt_set_log_mode
+/*/////////////////////////////////////// */
+/* t_dlt_set_log_mode */
TEST(t_dlt_set_log_mode, normal)
{
- EXPECT_LE(DLT_RETURN_OK,dlt_set_log_mode(DLT_USER_MODE_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_set_log_mode(DLT_USER_MODE_EXTERNAL));
- EXPECT_LE(DLT_RETURN_OK,dlt_set_log_mode(DLT_USER_MODE_INTERNAL));
- EXPECT_LE(DLT_RETURN_OK,dlt_set_log_mode(DLT_USER_MODE_BOTH));
+ EXPECT_LE(DLT_RETURN_OK, dlt_set_log_mode(DLT_USER_MODE_OFF));
+ EXPECT_LE(DLT_RETURN_OK, dlt_set_log_mode(DLT_USER_MODE_EXTERNAL));
+ EXPECT_LE(DLT_RETURN_OK, dlt_set_log_mode(DLT_USER_MODE_INTERNAL));
+ EXPECT_LE(DLT_RETURN_OK, dlt_set_log_mode(DLT_USER_MODE_BOTH));
}
@@ -2955,68 +3057,68 @@ TEST(t_dlt_set_log_mode, abnormal)
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_set_log_mode(DLT_USER_MODE_UNDEFINED));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_set_log_mode((DltUserLogMode)-100));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_set_log_mode((DltUserLogMode)-10));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_set_log_mode((DltUserLogMode)10));
- // TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_set_log_mode((DltUserLogMode)100));
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_set_log_mode(DLT_USER_MODE_UNDEFINED)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_set_log_mode((DltUserLogMode)-100)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_set_log_mode((DltUserLogMode)-10)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_set_log_mode((DltUserLogMode)10)); */
+ /* TODO: EXPECT_GE(DLT_RETURN_ERROR,dlt_set_log_mode((DltUserLogMode)100)); */
}
-/////////////////////////////////////////
-// t_dlt_get_log_state
+/*/////////////////////////////////////// */
+/* t_dlt_get_log_state */
TEST(t_dlt_get_log_state, normal)
{
sleep(1);
dlt_init_common();
- EXPECT_EQ(-1,dlt_get_log_state());
+ EXPECT_EQ(-1, dlt_get_log_state());
}
-/////////////////////////////////////////
-// t_dlt_verbose_mode
+/*/////////////////////////////////////// */
+/* t_dlt_verbose_mode */
TEST(t_dlt_verbose_mode, normal)
{
- EXPECT_LE(DLT_RETURN_OK,dlt_verbose_mode());
+ EXPECT_LE(DLT_RETURN_OK, dlt_verbose_mode());
}
-/////////////////////////////////////////
-// t_dlt_nonverbose_mode
+/*/////////////////////////////////////// */
+/* t_dlt_nonverbose_mode */
TEST(t_dlt_nonverbose_mode, normal)
{
- EXPECT_LE(DLT_RETURN_OK,dlt_nonverbose_mode());
+ EXPECT_LE(DLT_RETURN_OK, dlt_nonverbose_mode());
}
-/////////////////////////////////////////
-// free dlt
+/*/////////////////////////////////////// */
+/* free dlt */
TEST(t_dlt_free, onetime)
{
EXPECT_EQ(DLT_RETURN_OK, dlt_free());
}
-/////////////////////////////////////////
-// dlt_user_is_logLevel_enabled
+/*/////////////////////////////////////// */
+/* dlt_user_is_logLevel_enabled */
TEST(t_dlt_user_is_logLevel_enabled, normal)
{
DltContext context;
- EXPECT_LE(DLT_RETURN_OK,dlt_register_app("TUSR", "dlt_user.c tests"));
- EXPECT_LE(DLT_RETURN_OK,dlt_register_context_ll_ts(&context, "ILLE",
- "t_dlt_user_is_logLevel_enabled context",
- DLT_LOG_INFO,
- -2)); /* DLT_USER_TRACE_STATUS_NOT_SET */
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context_ll_ts(&context, "ILLE",
+ "t_dlt_user_is_logLevel_enabled context",
+ DLT_LOG_INFO,
+ -2)); /* DLT_USER_TRACE_STATUS_NOT_SET */
EXPECT_LE(DLT_RETURN_TRUE, dlt_user_is_logLevel_enabled(&context, DLT_LOG_FATAL));
EXPECT_LE(DLT_RETURN_TRUE, dlt_user_is_logLevel_enabled(&context, DLT_LOG_ERROR));
@@ -3026,8 +3128,8 @@ TEST(t_dlt_user_is_logLevel_enabled, normal)
EXPECT_LE(DLT_RETURN_LOGGING_DISABLED, dlt_user_is_logLevel_enabled(&context, DLT_LOG_VERBOSE));
EXPECT_LE(DLT_RETURN_LOGGING_DISABLED, dlt_user_is_logLevel_enabled(&context, DLT_LOG_OFF));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_context(&context));
- EXPECT_LE(DLT_RETURN_OK,dlt_unregister_app());
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
}
TEST(t_dlt_user_is_logLevel_enabled, nullpointer)
@@ -3035,8 +3137,8 @@ TEST(t_dlt_user_is_logLevel_enabled, nullpointer)
EXPECT_LE(DLT_RETURN_WRONG_PARAMETER, dlt_user_is_logLevel_enabled(NULL, DLT_LOG_FATAL));
}
-/////////////////////////////////////////
-// main
+/*/////////////////////////////////////// */
+/* main */
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
diff --git a/tests/mod_system_logger/mod_system_logger.c b/tests/mod_system_logger/mod_system_logger.c
index 1d31fdb..61c732c 100644
--- a/tests/mod_system_logger/mod_system_logger.c
+++ b/tests/mod_system_logger/mod_system_logger.c
@@ -4,31 +4,36 @@
int i;
-static int system_proc_show(struct seq_file *m, void *v) {
- for(i=0; i<1000; i++)
- seq_printf(m, "Test Systemlogger %i\n",i);
- return 0;
+static int system_proc_show(struct seq_file *m, void *v)
+{
+ for (i = 0; i < 1000; i++)
+ seq_printf(m, "Test Systemlogger %i\n", i);
+
+ return 0;
}
-static int system_proc_open(struct inode *inode, struct file *file) {
- return single_open(file, system_proc_show, NULL);
+static int system_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, system_proc_show, NULL);
}
static const struct file_operations system_proc_fops = {
- .owner = THIS_MODULE,
- .open = system_proc_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
+ .owner = THIS_MODULE,
+ .open = system_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
};
-static int __init system_proc_init(void) {
- proc_create("systemlogger", 0, NULL, &system_proc_fops);
- return 0;
+static int __init system_proc_init(void)
+{
+ proc_create("systemlogger", 0, NULL, &system_proc_fops);
+ return 0;
}
-static void __exit system_proc_exit(void) {
- remove_proc_entry("systemlogger", NULL);
+static void __exit system_proc_exit(void)
+{
+ remove_proc_entry("systemlogger", NULL);
}
MODULE_LICENSE("GPL");
diff --git a/util/uncrustify.cfg b/util/uncrustify.cfg
new file mode 100644
index 0000000..cb6761a
--- /dev/null
+++ b/util/uncrustify.cfg
@@ -0,0 +1,2736 @@
+# Uncrustify-0.68_f
+
+#
+# General options
+#
+
+# The type of line endings.
+#
+# Default: auto
+newlines = auto # lf/crlf/cr/auto
+
+# The original size of tabs in the input.
+#
+# Default: 8
+input_tab_size = 4 # unsigned number
+
+# The size of tabs in the output (only used if align_with_tabs=true).
+#
+# Default: 8
+output_tab_size = 4 # unsigned number
+
+# The ASCII value of the string escape char, usually 92 (\) or (Pawn) 94 (^).
+#
+# Default: 92
+string_escape_char = 92 # unsigned number
+
+# Alternate string escape char (usually only used for Pawn).
+# Only works right before the quote char.
+string_escape_char2 = 0 # unsigned number
+
+# Replace tab characters found in string literals with the escape sequence \t
+# instead.
+string_replace_tab_chars = false # true/false
+
+# Allow interpreting '>=' and '>>=' as part of a template in code like
+# 'void f(list<list<B>>=val);'. If true, 'assert(x<0 && y>=3)' will be broken.
+# Improvements to template detection may make this option obsolete.
+tok_split_gte = false # true/false
+
+# Specify the marker used in comments to disable processing of part of the
+# file.
+#
+# Default: *INDENT-OFF*
+disable_processing_cmt = "" # string
+
+# Specify the marker used in comments to (re)enable processing in a file.
+#
+# Default: *INDENT-ON*
+enable_processing_cmt = "" # string
+
+# Enable parsing of digraphs.
+enable_digraphs = false # true/false
+
+# Add or remove the UTF-8 BOM (recommend 'remove').
+utf8_bom = ignore # ignore/add/remove/force
+
+# If the file contains bytes with values between 128 and 255, but is not
+# UTF-8, then output as UTF-8.
+utf8_byte = false # true/false
+
+# Force the output encoding to UTF-8.
+utf8_force = false # true/false
+
+#
+# Spacing options
+#
+
+# Add or remove space around non-assignment symbolic operators ('+', '/', '%',
+# '<<', and so forth).
+sp_arith = force # ignore/add/remove/force
+
+# Add or remove space around arithmetic operators '+' and '-'.
+#
+# Overrides sp_arith.
+sp_arith_additive = ignore # ignore/add/remove/force
+
+# Add or remove space around assignment operator '=', '+=', etc.
+sp_assign = force # ignore/add/remove/force
+
+# Add or remove space around '=' in C++11 lambda capture specifications.
+#
+# Overrides sp_assign.
+sp_cpp_lambda_assign = ignore # ignore/add/remove/force
+
+# Add or remove space after the capture specification in C++11 lambda.
+sp_cpp_lambda_paren = ignore # ignore/add/remove/force
+
+# Add or remove space around assignment operator '=' in a prototype.
+sp_assign_default = ignore # ignore/add/remove/force
+
+# Add or remove space before assignment operator '=', '+=', etc.
+#
+# Overrides sp_assign.
+sp_before_assign = ignore # ignore/add/remove/force
+
+# Add or remove space after assignment operator '=', '+=', etc.
+#
+# Overrides sp_assign.
+sp_after_assign = ignore # ignore/add/remove/force
+
+# Add or remove space in 'NS_ENUM ('.
+sp_enum_paren = ignore # ignore/add/remove/force
+
+# Add or remove space around assignment '=' in enum.
+sp_enum_assign = force # ignore/add/remove/force
+
+# Add or remove space before assignment '=' in enum.
+#
+# Overrides sp_enum_assign.
+sp_enum_before_assign = ignore # ignore/add/remove/force
+
+# Add or remove space after assignment '=' in enum.
+#
+# Overrides sp_enum_assign.
+sp_enum_after_assign = ignore # ignore/add/remove/force
+
+# Add or remove space around assignment ':' in enum.
+sp_enum_colon = ignore # ignore/add/remove/force
+
+# Add or remove space around preprocessor '##' concatenation operator.
+#
+# Default: add
+sp_pp_concat = ignore # ignore/add/remove/force
+
+# Add or remove space after preprocessor '#' stringify operator.
+# Also affects the '#@' charizing operator.
+sp_pp_stringify = ignore # ignore/add/remove/force
+
+# Add or remove space before preprocessor '#' stringify operator
+# as in '#define x(y) L#y'.
+sp_before_pp_stringify = ignore # ignore/add/remove/force
+
+# Add or remove space around boolean operators '&&' and '||'.
+sp_bool = force # ignore/add/remove/force
+
+# Add or remove space around compare operator '<', '>', '==', etc.
+sp_compare = force # ignore/add/remove/force
+
+# Add or remove space inside '(' and ')'.
+sp_inside_paren = remove # ignore/add/remove/force
+
+# Add or remove space between nested parentheses, i.e. '((' vs. ') )'.
+sp_paren_paren = remove # ignore/add/remove/force
+
+# Add or remove space between back-to-back parentheses, i.e. ')(' vs. ') ('.
+sp_cparen_oparen = ignore # ignore/add/remove/force
+
+# Whether to balance spaces inside nested parentheses.
+sp_balance_nested_parens = false # true/false
+
+# Add or remove space between ')' and '{'.
+sp_paren_brace = force # ignore/add/remove/force
+
+# Add or remove space between nested braces, i.e. '{{' vs '{ {'.
+sp_brace_brace = ignore # ignore/add/remove/force
+
+# Add or remove space before pointer star '*'.
+sp_before_ptr_star = force # ignore/add/remove/force
+
+# Add or remove space before pointer star '*' that isn't followed by a
+# variable name. If set to 'ignore', sp_before_ptr_star is used instead.
+sp_before_unnamed_ptr_star = force # ignore/add/remove/force
+
+# Add or remove space between pointer stars '*'.
+sp_between_ptr_star = remove # ignore/add/remove/force
+
+# Add or remove space after pointer star '*', if followed by a word.
+sp_after_ptr_star = remove # ignore/add/remove/force
+
+# Add or remove space after pointer caret '^', if followed by a word.
+sp_after_ptr_block_caret = ignore # ignore/add/remove/force
+
+# Add or remove space after pointer star '*', if followed by a qualifier.
+sp_after_ptr_star_qualifier = ignore # ignore/add/remove/force
+
+# Add or remove space after a pointer star '*', if followed by a function
+# prototype or function definition.
+sp_after_ptr_star_func = remove # ignore/add/remove/force
+
+# Add or remove space after a pointer star '*', if followed by an open
+# parenthesis, as in 'void* (*)().
+sp_ptr_star_paren = ignore # ignore/add/remove/force
+
+# Add or remove space before a pointer star '*', if followed by a function
+# prototype or function definition.
+sp_before_ptr_star_func = add # ignore/add/remove/force
+
+# Add or remove space before a reference sign '&'.
+sp_before_byref = add # ignore/add/remove/force
+
+# Add or remove space before a reference sign '&' that isn't followed by a
+# variable name. If set to 'ignore', sp_before_byref is used instead.
+sp_before_unnamed_byref = add # ignore/add/remove/force
+
+# Add or remove space after reference sign '&', if followed by a word.
+sp_after_byref = remove # ignore/add/remove/force
+
+# Add or remove space after a reference sign '&', if followed by a function
+# prototype or function definition.
+sp_after_byref_func = remove # ignore/add/remove/force
+
+# Add or remove space before a reference sign '&', if followed by a function
+# prototype or function definition.
+sp_before_byref_func = add # ignore/add/remove/force
+
+# Add or remove space between type and word.
+#
+# Default: force
+sp_after_type = force # ignore/add/remove/force
+
+# Add or remove space between 'decltype(...)' and word.
+sp_after_decltype = ignore # ignore/add/remove/force
+
+# (D) Add or remove space before the parenthesis in the D constructs
+# 'template Foo(' and 'class Foo('.
+sp_before_template_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'template' and '<'.
+# If set to ignore, sp_before_angle is used.
+sp_template_angle = ignore # ignore/add/remove/force
+
+# Add or remove space before '<'.
+sp_before_angle = ignore # ignore/add/remove/force
+
+# Add or remove space inside '<' and '>'.
+sp_inside_angle = ignore # ignore/add/remove/force
+
+# Add or remove space between '>' and ':'.
+sp_angle_colon = ignore # ignore/add/remove/force
+
+# Add or remove space after '<>'.
+sp_after_angle = ignore # ignore/add/remove/force
+
+# Add or remove space between '>' and '(' as found in 'new List<byte>(foo);'.
+sp_angle_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between '>' and '()' as found in 'new List<byte>();'.
+sp_angle_paren_empty = ignore # ignore/add/remove/force
+
+# Add or remove space between '>' and a word as in 'List<byte> m;' or
+# 'template <typename T> static ...'.
+sp_angle_word = ignore # ignore/add/remove/force
+
+# Add or remove space between '>' and '>' in '>>' (template stuff).
+#
+# Default: add
+sp_angle_shift = add # ignore/add/remove/force
+
+# (C++11) Permit removal of the space between '>>' in 'foo<bar<int> >'. Note
+# that sp_angle_shift cannot remove the space without this option.
+sp_permit_cpp11_shift = false # true/false
+
+# Add or remove space before '(' of control statements ('if', 'for', 'switch',
+# 'while', etc.).
+sp_before_sparen = force # ignore/add/remove/force
+
+# Add or remove space inside '(' and ')' of control statements.
+sp_inside_sparen = remove # ignore/add/remove/force
+
+# Add or remove space after '(' of control statements.
+#
+# Overrides sp_inside_sparen.
+sp_inside_sparen_open = ignore # ignore/add/remove/force
+
+# Add or remove space before ')' of control statements.
+#
+# Overrides sp_inside_sparen.
+sp_inside_sparen_close = ignore # ignore/add/remove/force
+
+# Add or remove space after ')' of control statements.
+sp_after_sparen = force # ignore/add/remove/force
+
+# Add or remove space between ')' and '{' of of control statements.
+sp_sparen_brace = force # ignore/add/remove/force
+
+# (D) Add or remove space between 'invariant' and '('.
+sp_invariant_paren = ignore # ignore/add/remove/force
+
+# (D) Add or remove space after the ')' in 'invariant (C) c'.
+sp_after_invariant_paren = ignore # ignore/add/remove/force
+
+# Add or remove space before empty statement ';' on 'if', 'for' and 'while'.
+sp_special_semi = remove # ignore/add/remove/force
+
+# Add or remove space before ';'.
+#
+# Default: remove
+sp_before_semi = remove # ignore/add/remove/force
+
+# Add or remove space before ';' in non-empty 'for' statements.
+sp_before_semi_for = remove # ignore/add/remove/force
+
+# Add or remove space before a semicolon of an empty part of a for statement.
+sp_before_semi_for_empty = ignore # ignore/add/remove/force
+
+# Add or remove space after ';', except when followed by a comment.
+#
+# Default: add
+sp_after_semi = add # ignore/add/remove/force
+
+# Add or remove space after ';' in non-empty 'for' statements.
+#
+# Default: force
+sp_after_semi_for = force # ignore/add/remove/force
+
+# Add or remove space after the final semicolon of an empty part of a for
+# statement, as in 'for ( ; ; <here> )'.
+sp_after_semi_for_empty = ignore # ignore/add/remove/force
+
+# Add or remove space before '[' (except '[]').
+sp_before_square = ignore # ignore/add/remove/force
+
+# Add or remove space before '[]'.
+sp_before_squares = remove # ignore/add/remove/force
+
+# Add or remove space before C++17 structured bindings.
+sp_cpp_before_struct_binding = ignore # ignore/add/remove/force
+
+# Add or remove space inside a non-empty '[' and ']'.
+sp_inside_square = remove # ignore/add/remove/force
+
+# (OC) Add or remove space inside a non-empty Objective-C boxed array '@[' and
+# ']'. If set to ignore, sp_inside_square is used.
+sp_inside_square_oc_array = ignore # ignore/add/remove/force
+
+# Add or remove space after ',', i.e. 'a,b' vs. 'a, b'.
+sp_after_comma = force # ignore/add/remove/force
+
+# Add or remove space before ','.
+#
+# Default: remove
+sp_before_comma = remove # ignore/add/remove/force
+
+# (C#) Add or remove space between ',' and ']' in multidimensional array type
+# like 'int[,,]'.
+sp_after_mdatype_commas = ignore # ignore/add/remove/force
+
+# (C#) Add or remove space between '[' and ',' in multidimensional array type
+# like 'int[,,]'.
+sp_before_mdatype_commas = ignore # ignore/add/remove/force
+
+# (C#) Add or remove space between ',' in multidimensional array type
+# like 'int[,,]'.
+sp_between_mdatype_commas = ignore # ignore/add/remove/force
+
+# Add or remove space between an open parenthesis and comma,
+# i.e. '(,' vs. '( ,'.
+#
+# Default: force
+sp_paren_comma = force # ignore/add/remove/force
+
+# Add or remove space before the variadic '...' when preceded by a
+# non-punctuator.
+sp_before_ellipsis = ignore # ignore/add/remove/force
+
+# Add or remove space between a type and '...'.
+sp_type_ellipsis = ignore # ignore/add/remove/force
+
+# Add or remove space between ')' and '...'.
+sp_paren_ellipsis = ignore # ignore/add/remove/force
+
+# Add or remove space after class ':'.
+sp_after_class_colon = ignore # ignore/add/remove/force
+
+# Add or remove space before class ':'.
+sp_before_class_colon = ignore # ignore/add/remove/force
+
+# Add or remove space after class constructor ':'.
+sp_after_constr_colon = ignore # ignore/add/remove/force
+
+# Add or remove space before class constructor ':'.
+sp_before_constr_colon = ignore # ignore/add/remove/force
+
+# Add or remove space before case ':'.
+#
+# Default: remove
+sp_before_case_colon = remove # ignore/add/remove/force
+
+# Add or remove space between 'operator' and operator sign.
+sp_after_operator = ignore # ignore/add/remove/force
+
+# Add or remove space between the operator symbol and the open parenthesis, as
+# in 'operator ++('.
+sp_after_operator_sym = ignore # ignore/add/remove/force
+
+# Overrides sp_after_operator_sym when the operator has no arguments, as in
+# 'operator *()'.
+sp_after_operator_sym_empty = ignore # ignore/add/remove/force
+
+# Add or remove space after C/D cast, i.e. 'cast(int)a' vs. 'cast(int) a' or
+# '(int)a' vs. '(int) a'.
+sp_after_cast = remove # ignore/add/remove/force
+
+# Add or remove spaces inside cast parentheses.
+sp_inside_paren_cast = remove # ignore/add/remove/force
+
+# Add or remove space between the type and open parenthesis in a C++ cast,
+# i.e. 'int(exp)' vs. 'int (exp)'.
+sp_cpp_cast_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'sizeof' and '('.
+sp_sizeof_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'sizeof' and '...'.
+sp_sizeof_ellipsis = ignore # ignore/add/remove/force
+
+# Add or remove space between 'sizeof...' and '('.
+sp_sizeof_ellipsis_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'decltype' and '('.
+sp_decltype_paren = ignore # ignore/add/remove/force
+
+# (Pawn) Add or remove space after the tag keyword.
+sp_after_tag = ignore # ignore/add/remove/force
+
+# Add or remove space inside enum '{' and '}'.
+sp_inside_braces_enum = ignore # ignore/add/remove/force
+
+# Add or remove space inside struct/union '{' and '}'.
+sp_inside_braces_struct = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space inside Objective-C boxed dictionary '{' and '}'
+sp_inside_braces_oc_dict = ignore # ignore/add/remove/force
+
+# Add or remove space after open brace in an unnamed temporary
+# direct-list-initialization.
+sp_after_type_brace_init_lst_open = ignore # ignore/add/remove/force
+
+# Add or remove space before close brace in an unnamed temporary
+# direct-list-initialization.
+sp_before_type_brace_init_lst_close = ignore # ignore/add/remove/force
+
+# Add or remove space inside an unnamed temporary direct-list-initialization.
+sp_inside_type_brace_init_lst = ignore # ignore/add/remove/force
+
+# Add or remove space inside '{' and '}'.
+sp_inside_braces = force # ignore/add/remove/force
+
+# Add or remove space inside '{}'.
+sp_inside_braces_empty = remove # ignore/add/remove/force
+
+# Add or remove space between return type and function name. A minimum of 1
+# is forced except for pointer return types.
+sp_type_func = ignore # ignore/add/remove/force
+
+# Add or remove space between type and open brace of an unnamed temporary
+# direct-list-initialization.
+sp_type_brace_init_lst = ignore # ignore/add/remove/force
+
+# Add or remove space between function name and '(' on function declaration.
+sp_func_proto_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between function name and '()' on function declaration
+# without parameters.
+sp_func_proto_paren_empty = ignore # ignore/add/remove/force
+
+# Add or remove space between function name and '(' on function definition.
+sp_func_def_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between function name and '()' on function definition
+# without parameters.
+sp_func_def_paren_empty = ignore # ignore/add/remove/force
+
+# Add or remove space inside empty function '()'.
+sp_inside_fparens = remove # ignore/add/remove/force
+
+# Add or remove space inside function '(' and ')'.
+sp_inside_fparen = remove # ignore/add/remove/force
+
+# Add or remove space inside the first parentheses in a function type, as in
+# 'void (*x)(...)'.
+sp_inside_tparen = ignore # ignore/add/remove/force
+
+# Add or remove space between the ')' and '(' in a function type, as in
+# 'void (*x)(...)'.
+sp_after_tparen_close = ignore # ignore/add/remove/force
+
+# Add or remove space between ']' and '(' when part of a function call.
+sp_square_fparen = ignore # ignore/add/remove/force
+
+# Add or remove space between ')' and '{' of function.
+sp_fparen_brace = force # ignore/add/remove/force
+
+# Add or remove space between ')' and '{' of s function call in object
+# initialization.
+#
+# Overrides sp_fparen_brace.
+sp_fparen_brace_initializer = ignore # ignore/add/remove/force
+
+# (Java) Add or remove space between ')' and '{{' of double brace initializer.
+sp_fparen_dbrace = ignore # ignore/add/remove/force
+
+# Add or remove space between function name and '(' on function calls.
+sp_func_call_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between function name and '()' on function calls without
+# parameters. If set to 'ignore' (the default), sp_func_call_paren is used.
+sp_func_call_paren_empty = ignore # ignore/add/remove/force
+
+# Add or remove space between the user function name and '(' on function
+# calls. You need to set a keyword to be a user function in the config file,
+# like:
+# set func_call_user tr _ i18n
+sp_func_call_user_paren = ignore # ignore/add/remove/force
+
+# Add or remove space inside user function '(' and ')'.
+sp_func_call_user_inside_fparen = ignore # ignore/add/remove/force
+
+# Add or remove space between nested parentheses with user functions,
+# i.e. '((' vs. '( ('.
+sp_func_call_user_paren_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between a constructor/destructor and the open
+# parenthesis.
+sp_func_class_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between a constructor without parameters or destructor
+# and '()'.
+sp_func_class_paren_empty = ignore # ignore/add/remove/force
+
+# Add or remove space between 'return' and '('.
+sp_return_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'return' and '{'.
+sp_return_brace = ignore # ignore/add/remove/force
+
+# Add or remove space between '__attribute__' and '('.
+sp_attribute_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'defined' and '(' in '#if defined (FOO)'.
+sp_defined_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'throw' and '(' in 'throw (something)'.
+sp_throw_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'throw' and anything other than '(' as in
+# '@throw [...];'.
+sp_after_throw = ignore # ignore/add/remove/force
+
+# Add or remove space between 'catch' and '(' in 'catch (something) { }'.
+# If set to ignore, sp_before_sparen is used.
+sp_catch_paren = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space between '@catch' and '('
+# in '@catch (something) { }'. If set to ignore, sp_catch_paren is used.
+sp_oc_catch_paren = ignore # ignore/add/remove/force
+
+# (D) Add or remove space between 'version' and '('
+# in 'version (something) { }'. If set to ignore, sp_before_sparen is used.
+sp_version_paren = ignore # ignore/add/remove/force
+
+# (D) Add or remove space between 'scope' and '('
+# in 'scope (something) { }'. If set to ignore, sp_before_sparen is used.
+sp_scope_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between 'super' and '(' in 'super (something)'.
+#
+# Default: remove
+sp_super_paren = remove # ignore/add/remove/force
+
+# Add or remove space between 'this' and '(' in 'this (something)'.
+#
+# Default: remove
+sp_this_paren = remove # ignore/add/remove/force
+
+# Add or remove space between a macro name and its definition.
+sp_macro = ignore # ignore/add/remove/force
+
+# Add or remove space between a macro function ')' and its definition.
+sp_macro_func = ignore # ignore/add/remove/force
+
+# Add or remove space between 'else' and '{' if on the same line.
+sp_else_brace = force # ignore/add/remove/force
+
+# Add or remove space between '}' and 'else' if on the same line.
+sp_brace_else = force # ignore/add/remove/force
+
+# Add or remove space between '}' and the name of a typedef on the same line.
+sp_brace_typedef = force # ignore/add/remove/force
+
+# Add or remove space before the '{' of a 'catch' statement, if the '{' and
+# 'catch' are on the same line, as in 'catch (decl) <here> {'.
+sp_catch_brace = force # ignore/add/remove/force
+
+# (OC) Add or remove space before the '{' of a '@catch' statement, if the '{'
+# and '@catch' are on the same line, as in '@catch (decl) <here> {'.
+# If set to ignore, sp_catch_brace is used.
+sp_oc_catch_brace = ignore # ignore/add/remove/force
+
+# Add or remove space between '}' and 'catch' if on the same line.
+sp_brace_catch = force # ignore/add/remove/force
+
+# (OC) Add or remove space between '}' and '@catch' if on the same line.
+# If set to ignore, sp_brace_catch is used.
+sp_oc_brace_catch = ignore # ignore/add/remove/force
+
+# Add or remove space between 'finally' and '{' if on the same line.
+sp_finally_brace = ignore # ignore/add/remove/force
+
+# Add or remove space between '}' and 'finally' if on the same line.
+sp_brace_finally = ignore # ignore/add/remove/force
+
+# Add or remove space between 'try' and '{' if on the same line.
+sp_try_brace = ignore # ignore/add/remove/force
+
+# Add or remove space between get/set and '{' if on the same line.
+sp_getset_brace = ignore # ignore/add/remove/force
+
+# Add or remove space between a variable and '{' for C++ uniform
+# initialization.
+#
+# Default: add
+sp_word_brace = add # ignore/add/remove/force
+
+# Add or remove space between a variable and '{' for a namespace.
+#
+# Default: add
+sp_word_brace_ns = add # ignore/add/remove/force
+
+# Add or remove space before the '::' operator.
+sp_before_dc = ignore # ignore/add/remove/force
+
+# Add or remove space after the '::' operator.
+sp_after_dc = ignore # ignore/add/remove/force
+
+# (D) Add or remove around the D named array initializer ':' operator.
+sp_d_array_colon = ignore # ignore/add/remove/force
+
+# Add or remove space after the '!' (not) unary operator.
+#
+# Default: remove
+sp_not = remove # ignore/add/remove/force
+
+# Add or remove space after the '~' (invert) unary operator.
+#
+# Default: remove
+sp_inv = remove # ignore/add/remove/force
+
+# Add or remove space after the '&' (address-of) unary operator. This does not
+# affect the spacing after a '&' that is part of a type.
+#
+# Default: remove
+sp_addr = remove # ignore/add/remove/force
+
+# Add or remove space around the '.' or '->' operators.
+#
+# Default: remove
+sp_member = remove # ignore/add/remove/force
+
+# Add or remove space after the '*' (dereference) unary operator. This does
+# not affect the spacing after a '*' that is part of a type.
+#
+# Default: remove
+sp_deref = remove # ignore/add/remove/force
+
+# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'.
+#
+# Default: remove
+sp_sign = remove # ignore/add/remove/force
+
+# Add or remove space between '++' and '--' the word to which it is being
+# applied, as in '(--x)' or 'y++;'.
+#
+# Default: remove
+sp_incdec = remove # ignore/add/remove/force
+
+# Add or remove space before a backslash-newline at the end of a line.
+#
+# Default: add
+sp_before_nl_cont = add # ignore/add/remove/force
+
+# (OC) Add or remove space after the scope '+' or '-', as in '-(void) foo;'
+# or '+(int) bar;'.
+sp_after_oc_scope = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space after the colon in message specs,
+# i.e. '-(int) f:(int) x;' vs. '-(int) f: (int) x;'.
+sp_after_oc_colon = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space before the colon in message specs,
+# i.e. '-(int) f: (int) x;' vs. '-(int) f : (int) x;'.
+sp_before_oc_colon = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space after the colon in immutable dictionary expression
+# 'NSDictionary *test = @{@"foo" :@"bar"};'.
+sp_after_oc_dict_colon = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space before the colon in immutable dictionary expression
+# 'NSDictionary *test = @{@"foo" :@"bar"};'.
+sp_before_oc_dict_colon = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space after the colon in message specs,
+# i.e. '[object setValue:1];' vs. '[object setValue: 1];'.
+sp_after_send_oc_colon = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space before the colon in message specs,
+# i.e. '[object setValue:1];' vs. '[object setValue :1];'.
+sp_before_send_oc_colon = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space after the (type) in message specs,
+# i.e. '-(int)f: (int) x;' vs. '-(int)f: (int)x;'.
+sp_after_oc_type = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space after the first (type) in message specs,
+# i.e. '-(int) f:(int)x;' vs. '-(int)f:(int)x;'.
+sp_after_oc_return_type = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space between '@selector' and '(',
+# i.e. '@selector(msgName)' vs. '@selector (msgName)'.
+# Also applies to '@protocol()' constructs.
+sp_after_oc_at_sel = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space between '@selector(x)' and the following word,
+# i.e. '@selector(foo) a:' vs. '@selector(foo)a:'.
+sp_after_oc_at_sel_parens = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space inside '@selector' parentheses,
+# i.e. '@selector(foo)' vs. '@selector( foo )'.
+# Also applies to '@protocol()' constructs.
+sp_inside_oc_at_sel_parens = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space before a block pointer caret,
+# i.e. '^int (int arg){...}' vs. ' ^int (int arg){...}'.
+sp_before_oc_block_caret = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space after a block pointer caret,
+# i.e. '^int (int arg){...}' vs. '^ int (int arg){...}'.
+sp_after_oc_block_caret = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space between the receiver and selector in a message,
+# as in '[receiver selector ...]'.
+sp_after_oc_msg_receiver = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space after '@property'.
+sp_after_oc_property = ignore # ignore/add/remove/force
+
+# (OC) Add or remove space between '@synchronized' and the open parenthesis,
+# i.e. '@synchronized(foo)' vs. '@synchronized (foo)'.
+sp_after_oc_synchronized = ignore # ignore/add/remove/force
+
+# Add or remove space around the ':' in 'b ? t : f'.
+sp_cond_colon = ignore # ignore/add/remove/force
+
+# Add or remove space before the ':' in 'b ? t : f'.
+#
+# Overrides sp_cond_colon.
+sp_cond_colon_before = ignore # ignore/add/remove/force
+
+# Add or remove space after the ':' in 'b ? t : f'.
+#
+# Overrides sp_cond_colon.
+sp_cond_colon_after = ignore # ignore/add/remove/force
+
+# Add or remove space around the '?' in 'b ? t : f'.
+sp_cond_question = ignore # ignore/add/remove/force
+
+# Add or remove space before the '?' in 'b ? t : f'.
+#
+# Overrides sp_cond_question.
+sp_cond_question_before = ignore # ignore/add/remove/force
+
+# Add or remove space after the '?' in 'b ? t : f'.
+#
+# Overrides sp_cond_question.
+sp_cond_question_after = ignore # ignore/add/remove/force
+
+# In the abbreviated ternary form '(a ?: b)', add or remove space between '?'
+# and ':'.
+#
+# Overrides all other sp_cond_* options.
+sp_cond_ternary_short = ignore # ignore/add/remove/force
+
+# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make
+# sense here.
+sp_case_label = ignore # ignore/add/remove/force
+
+# (D) Add or remove space around the D '..' operator.
+sp_range = ignore # ignore/add/remove/force
+
+# Add or remove space after ':' in a Java/C++11 range-based 'for',
+# as in 'for (Type var : expr)'.
+sp_after_for_colon = ignore # ignore/add/remove/force
+
+# Add or remove space before ':' in a Java/C++11 range-based 'for',
+# as in 'for (Type var : expr)'.
+sp_before_for_colon = ignore # ignore/add/remove/force
+
+# (D) Add or remove space between 'extern' and '(' as in 'extern (C)'.
+sp_extern_paren = ignore # ignore/add/remove/force
+
+# Add or remove space after the opening of a C++ comment,
+# i.e. '// A' vs. '//A'.
+sp_cmt_cpp_start = ignore # ignore/add/remove/force
+
+# If true, space is added with sp_cmt_cpp_start will be added after doxygen
+# sequences like '///', '///<', '//!' and '//!<'.
+sp_cmt_cpp_doxygen = false # true/false
+
+# If true, space is added with sp_cmt_cpp_start will be added after Qt
+# translator or meta-data comments like '//:', '//=', and '//~'.
+sp_cmt_cpp_qttr = false # true/false
+
+# Add or remove space between #else or #endif and a trailing comment.
+sp_endif_cmt = ignore # ignore/add/remove/force
+
+# Add or remove space after 'new', 'delete' and 'delete[]'.
+sp_after_new = ignore # ignore/add/remove/force
+
+# Add or remove space between 'new' and '(' in 'new()'.
+sp_between_new_paren = ignore # ignore/add/remove/force
+
+# Add or remove space between ')' and type in 'new(foo) BAR'.
+sp_after_newop_paren = ignore # ignore/add/remove/force
+
+# Add or remove space inside parenthesis of the new operator
+# as in 'new(foo) BAR'.
+sp_inside_newop_paren = ignore # ignore/add/remove/force
+
+# Add or remove space after the open parenthesis of the new operator,
+# as in 'new(foo) BAR'.
+#
+# Overrides sp_inside_newop_paren.
+sp_inside_newop_paren_open = ignore # ignore/add/remove/force
+
+# Add or remove space before the close parenthesis of the new operator,
+# as in 'new(foo) BAR'.
+#
+# Overrides sp_inside_newop_paren.
+sp_inside_newop_paren_close = ignore # ignore/add/remove/force
+
+# Add or remove space before a trailing or embedded comment.
+sp_before_tr_emb_cmt = ignore # ignore/add/remove/force
+
+# Number of spaces before a trailing or embedded comment.
+sp_num_before_tr_emb_cmt = 0 # unsigned number
+
+# (Java) Add or remove space between an annotation and the open parenthesis.
+sp_annotation_paren = ignore # ignore/add/remove/force
+
+# If true, vbrace tokens are dropped to the previous token and skipped.
+sp_skip_vbrace_tokens = false # true/false
+
+# Add or remove space after 'noexcept'.
+sp_after_noexcept = ignore # ignore/add/remove/force
+
+# If true, a <TAB> is inserted after #define.
+force_tab_after_define = false # true/false
+
+#
+# Indenting options
+#
+
+# The number of columns to indent per level. Usually 2, 3, 4, or 8.
+#
+# Default: 8
+indent_columns = 4 # unsigned number
+
+# The continuation indent. If non-zero, this overrides the indent of '(' and
+# '=' continuation indents. Negative values are OK; negative value is absolute
+# and not increased for each '(' level.
+#
+# For FreeBSD, this is set to 4.
+indent_continue = 0 # number
+
+# The continuation indent, only for class header line(s). If non-zero, this
+# overrides the indent of 'class' continuation indents.
+indent_continue_class_head = 0 # unsigned number
+
+# Whether to indent empty lines (i.e. lines which contain only spaces before
+# the newline character).
+indent_single_newlines = false # true/false
+
+# The continuation indent for func_*_param if they are true. If non-zero, this
+# overrides the indent.
+indent_param = 0 # unsigned number
+
+# How to use tabs when indenting code.
+#
+# 0: Spaces only
+# 1: Indent with tabs to brace level, align with spaces (default)
+# 2: Indent and align with tabs, using spaces when not on a tabstop
+#
+# Default: 1
+indent_with_tabs = 0 # unsigned number
+
+# Whether to indent comments that are not at a brace level with tabs on a
+# tabstop. Requires indent_with_tabs=2. If false, will use spaces.
+indent_cmt_with_tabs = false # true/false
+
+# Whether to indent strings broken by '\' so that they line up.
+indent_align_string = false # true/false
+
+# The number of spaces to indent multi-line XML strings.
+# Requires indent_align_string=true.
+indent_xml_string = 0 # unsigned number
+
+# Spaces to indent '{' from level.
+indent_brace = 0 # unsigned number
+
+# Whether braces are indented to the body level.
+indent_braces = false # true/false
+
+# Whether to disable indenting function braces if indent_braces=true.
+indent_braces_no_func = false # true/false
+
+# Whether to disable indenting class braces if indent_braces=true.
+indent_braces_no_class = false # true/false
+
+# Whether to disable indenting struct braces if indent_braces=true.
+indent_braces_no_struct = false # true/false
+
+# Whether to indent based on the size of the brace parent,
+# i.e. 'if' → 3 spaces, 'for' → 4 spaces, etc.
+indent_brace_parent = false # true/false
+
+# Whether to indent based on the open parenthesis instead of the open brace
+# in '({\n'.
+indent_paren_open_brace = false # true/false
+
+# (C#) Whether to indent the brace of a C# delegate by another level.
+indent_cs_delegate_brace = false # true/false
+
+# (C#) Whether to indent a C# delegate (to handle delegates with no brace) by
+# another level.
+indent_cs_delegate_body = false # true/false
+
+# Whether to indent the body of a 'namespace'.
+indent_namespace = false # true/false
+
+# Whether to indent only the first namespace, and not any nested namespaces.
+# Requires indent_namespace=true.
+indent_namespace_single_indent = false # true/false
+
+# The number of spaces to indent a namespace block.
+indent_namespace_level = 0 # unsigned number
+
+# If the body of the namespace is longer than this number, it won't be
+# indented. Requires indent_namespace=true. 0 means no limit.
+indent_namespace_limit = 0 # unsigned number
+
+# Whether the 'extern "C"' body is indented.
+indent_extern = false # true/false
+
+# Whether the 'class' body is indented.
+indent_class = false # true/false
+
+# Whether to indent the stuff after a leading base class colon.
+indent_class_colon = false # true/false
+
+# Whether to indent based on a class colon instead of the stuff after the
+# colon. Requires indent_class_colon=true.
+indent_class_on_colon = false # true/false
+
+# Whether to indent the stuff after a leading class initializer colon.
+indent_constr_colon = false # true/false
+
+# Virtual indent from the ':' for member initializers.
+#
+# Default: 2
+indent_ctor_init_leading = 2 # unsigned number
+
+# Additional indent for constructor initializer list.
+# Negative values decrease indent down to the first column.
+indent_ctor_init = 0 # number
+
+# Whether to indent 'if' following 'else' as a new block under the 'else'.
+# If false, 'else\nif' is treated as 'else if' for indenting purposes.
+indent_else_if = false # true/false
+
+# Amount to indent variable declarations after a open brace.
+#
+# <0: Relative
+# ≥0: Absolute
+indent_var_def_blk = 0 # number
+
+# Whether to indent continued variable declarations instead of aligning.
+indent_var_def_cont = false # true/false
+
+# Whether to indent continued shift expressions ('<<' and '>>') instead of
+# aligning. Set align_left_shift=false when enabling this.
+indent_shift = false # true/false
+
+# Whether to force indentation of function definitions to start in column 1.
+indent_func_def_force_col1 = false # true/false
+
+# Whether to indent continued function call parameters one indent level,
+# rather than aligning parameters under the open parenthesis.
+indent_func_call_param = false # true/false
+
+# Same as indent_func_call_param, but for function definitions.
+indent_func_def_param = false # true/false
+
+# Same as indent_func_call_param, but for function prototypes.
+indent_func_proto_param = false # true/false
+
+# Same as indent_func_call_param, but for class declarations.
+indent_func_class_param = false # true/false
+
+# Same as indent_func_call_param, but for class variable constructors.
+indent_func_ctor_var_param = false # true/false
+
+# Same as indent_func_call_param, but for template parameter lists.
+indent_template_param = false # true/false
+
+# Double the indent for indent_func_xxx_param options.
+# Use both values of the options indent_columns and indent_param.
+indent_func_param_double = false # true/false
+
+# Indentation column for standalone 'const' qualifier on a function
+# prototype.
+indent_func_const = 0 # unsigned number
+
+# Indentation column for standalone 'throw' qualifier on a function
+# prototype.
+indent_func_throw = 0 # unsigned number
+
+# The number of spaces to indent a continued '->' or '.'.
+# Usually set to 0, 1, or indent_columns.
+indent_member = 0 # unsigned number
+
+# Whether lines broken at '.' or '->' should be indented by a single indent.
+# The indent_member option will not be effective if this is set to true.
+indent_member_single = false # true/false
+
+# Spaces to indent single line ('//') comments on lines before code.
+indent_sing_line_comments = 0 # unsigned number
+
+# Whether to indent trailing single line ('//') comments relative to the code
+# instead of trying to keep the same absolute column.
+indent_relative_single_line_comments = false # true/false
+
+# Spaces to indent 'case' from 'switch'. Usually 0 or indent_columns.
+indent_switch_case = 0 # unsigned number
+
+# Whether to indent preprocessor statements inside of switch statements.
+#
+# Default: true
+indent_switch_pp = true # true/false
+
+# Spaces to shift the 'case' line, without affecting any other lines.
+# Usually 0.
+indent_case_shift = 0 # unsigned number
+
+# Spaces to indent '{' from 'case'. By default, the brace will appear under
+# the 'c' in case. Usually set to 0 or indent_columns. Negative values are OK.
+indent_case_brace = 0 # number
+
+# Whether to indent comments found in first column.
+indent_col1_comment = false # true/false
+
+# How to indent goto labels.
+#
+# >0: Absolute column where 1 is the leftmost column
+# ≤0: Subtract from brace indent
+#
+# Default: 1
+indent_label = 1 # number
+
+# Same as indent_label, but for access specifiers that are followed by a
+# colon.
+#
+# Default: 1
+indent_access_spec = 1 # number
+
+# Whether to indent the code after an access specifier by one level.
+# If true, this option forces 'indent_access_spec=0'.
+indent_access_spec_body = false # true/false
+
+# If an open parenthesis is followed by a newline, whether to indent the next
+# line so that it lines up after the open parenthesis (not recommended).
+indent_paren_nl = false # true/false
+
+# How to indent a close parenthesis after a newline.
+#
+# 0: Indent to body level (default)
+# 1: Align under the open parenthesis
+# 2: Indent to the brace level
+indent_paren_close = 0 # unsigned number
+
+# Whether to indent the open parenthesis of a function definition,
+# if the parenthesis is on its own line.
+indent_paren_after_func_def = false # true/false
+
+# Whether to indent the open parenthesis of a function declaration,
+# if the parenthesis is on its own line.
+indent_paren_after_func_decl = false # true/false
+
+# Whether to indent the open parenthesis of a function call,
+# if the parenthesis is on its own line.
+indent_paren_after_func_call = false # true/false
+
+# Whether to indent a comma when inside a parenthesis.
+# If true, aligns under the open parenthesis.
+indent_comma_paren = false # true/false
+
+# Whether to indent a Boolean operator when inside a parenthesis.
+# If true, aligns under the open parenthesis.
+indent_bool_paren = false # true/false
+
+# Whether to indent a semicolon when inside a for parenthesis.
+# If true, aligns under the open for parenthesis.
+indent_semicolon_for_paren = false # true/false
+
+# Whether to align the first expression to following ones
+# if indent_bool_paren=true.
+indent_first_bool_expr = false # true/false
+
+# Whether to align the first expression to following ones
+# if indent_semicolon_for_paren=true.
+indent_first_for_expr = false # true/false
+
+# If an open square is followed by a newline, whether to indent the next line
+# so that it lines up after the open square (not recommended).
+indent_square_nl = false # true/false
+
+# (ESQL/C) Whether to preserve the relative indent of 'EXEC SQL' bodies.
+indent_preserve_sql = false # true/false
+
+# Whether to align continued statements at the '='. If false or if the '=' is
+# followed by a newline, the next line is indent one tab.
+#
+# Default: true
+indent_align_assign = false # true/false
+
+# Whether to align continued statements at the '('. If false or the '(' is not
+# followed by a newline, the next line indent is one tab.
+#
+# Default: true
+indent_align_paren = true # true/false
+
+# (OC) Whether to indent Objective-C blocks at brace level instead of usual
+# rules.
+indent_oc_block = false # true/false
+
+# (OC) Indent for Objective-C blocks in a message relative to the parameter
+# name.
+#
+# =0: Use indent_oc_block rules
+# >0: Use specified number of spaces to indent
+indent_oc_block_msg = 0 # unsigned number
+
+# (OC) Minimum indent for subsequent parameters
+indent_oc_msg_colon = 0 # unsigned number
+
+# (OC) Whether to prioritize aligning with initial colon (and stripping spaces
+# from lines, if necessary).
+#
+# Default: true
+indent_oc_msg_prioritize_first_colon = true # true/false
+
+# (OC) Whether to indent blocks the way that Xcode does by default
+# (from the keyword if the parameter is on its own line; otherwise, from the
+# previous indentation level). Requires indent_oc_block_msg=true.
+indent_oc_block_msg_xcode_style = false # true/false
+
+# (OC) Whether to indent blocks from where the brace is, relative to a
+# message keyword. Requires indent_oc_block_msg=true.
+indent_oc_block_msg_from_keyword = false # true/false
+
+# (OC) Whether to indent blocks from where the brace is, relative to a message
+# colon. Requires indent_oc_block_msg=true.
+indent_oc_block_msg_from_colon = false # true/false
+
+# (OC) Whether to indent blocks from where the block caret is.
+# Requires indent_oc_block_msg=true.
+indent_oc_block_msg_from_caret = false # true/false
+
+# (OC) Whether to indent blocks from where the brace caret is.
+# Requires indent_oc_block_msg=true.
+indent_oc_block_msg_from_brace = false # true/false
+
+# When indenting after virtual brace open and newline add further spaces to
+# reach this minimum indent.
+indent_min_vbrace_open = 0 # unsigned number
+
+# Whether to add further spaces after regular indent to reach next tabstop
+# when identing after virtual brace open and newline.
+indent_vbrace_open_on_tabstop = false # true/false
+
+# How to indent after a brace followed by another token (not a newline).
+# true: indent all contained lines to match the token
+# false: indent all contained lines to match the brace
+#
+# Default: true
+indent_token_after_brace = true # true/false
+
+# Whether to indent the body of a C++11 lambda.
+indent_cpp_lambda_body = false # true/false
+
+# (C#) Whether to indent a 'using' block if no braces are used.
+#
+# Default: true
+indent_using_block = true # true/false
+
+# How to indent the continuation of ternary operator.
+#
+# 0: Off (default)
+# 1: When the `if_false` is a continuation, indent it under `if_false`
+# 2: When the `:` is a continuation, indent it under `?`
+indent_ternary_operator = 0 # unsigned number
+
+# If true, the indentation of the chunks after a `return new` sequence will be set at return indentation column.
+indent_off_after_return_new = false # true/false
+
+# If true, the tokens after return are indented with regular single indentation. By default (false) the indentation is after the return token.
+indent_single_after_return = false # true/false
+
+# Whether to ignore indent and alignment for 'asm' blocks (i.e. assume they
+# have their own indentation).
+indent_ignore_asm_block = false # true/false
+
+#
+# Newline adding and removing options
+#
+
+# Whether to collapse empty blocks between '{' and '}'.
+nl_collapse_empty_body = true # true/false
+
+# Don't split one-line braced assignments, as in 'foo_t f = { 1, 2 };'.
+nl_assign_leave_one_liners = false # true/false
+
+# Don't split one-line braced statements inside a 'class xx { }' body.
+nl_class_leave_one_liners = false # true/false
+
+# Don't split one-line enums, as in 'enum foo { BAR = 15 };'
+nl_enum_leave_one_liners = false # true/false
+
+# Don't split one-line get or set functions.
+nl_getset_leave_one_liners = false # true/false
+
+# (C#) Don't split one-line property get or set functions.
+nl_cs_property_leave_one_liners = false # true/false
+
+# Don't split one-line function definitions, as in 'int foo() { return 0; }'.
+nl_func_leave_one_liners = false # true/false
+
+# Don't split one-line C++11 lambdas, as in '[]() { return 0; }'.
+nl_cpp_lambda_leave_one_liners = false # true/false
+
+# Don't split one-line if/else statements, as in 'if(...) b++;'.
+nl_if_leave_one_liners = false # true/false
+
+# Don't split one-line while statements, as in 'while(...) b++;'.
+nl_while_leave_one_liners = false # true/false
+
+# Don't split one-line for statements, as in 'for(...) b++;'.
+nl_for_leave_one_liners = false # true/false
+
+# (OC) Don't split one-line Objective-C messages.
+nl_oc_msg_leave_one_liner = false # true/false
+
+# (OC) Add or remove newline between method declaration and '{'.
+nl_oc_mdef_brace = ignore # ignore/add/remove/force
+
+# (OC) Add or remove newline between Objective-C block signature and '{'.
+nl_oc_block_brace = ignore # ignore/add/remove/force
+
+# (OC) Add or remove newline between '@interface' and '{'.
+nl_oc_interface_brace = ignore # ignore/add/remove/force
+
+# (OC) Add or remove newline between '@implementation' and '{'.
+nl_oc_implementation_brace = ignore # ignore/add/remove/force
+
+# Add or remove newlines at the start of the file.
+nl_start_of_file = ignore # ignore/add/remove/force
+
+# The minimum number of newlines at the start of the file (only used if
+# nl_start_of_file is 'add' or 'force').
+nl_start_of_file_min = 0 # unsigned number
+
+# Add or remove newline at the end of the file.
+nl_end_of_file = ignore # ignore/add/remove/force
+
+# The minimum number of newlines at the end of the file (only used if
+# nl_end_of_file is 'add' or 'force').
+nl_end_of_file_min = 0 # unsigned number
+
+# Add or remove newline between '=' and '{'.
+nl_assign_brace = remove # ignore/add/remove/force
+
+# (D) Add or remove newline between '=' and '['.
+nl_assign_square = ignore # ignore/add/remove/force
+
+# Add or remove newline between '[]' and '{'.
+nl_tsquare_brace = ignore # ignore/add/remove/force
+
+# (D) Add or remove newline after '= ['. Will also affect the newline before
+# the ']'.
+nl_after_square_assign = ignore # ignore/add/remove/force
+
+# The number of blank lines after a block of variable definitions at the top
+# of a function body.
+#
+# 0 = No change (default).
+nl_func_var_def_blk = 0 # unsigned number
+
+# The number of newlines before a block of typedefs. If nl_after_access_spec
+# is non-zero, that option takes precedence.
+#
+# 0 = No change (default).
+nl_typedef_blk_start = 0 # unsigned number
+
+# The number of newlines after a block of typedefs.
+#
+# 0 = No change (default).
+nl_typedef_blk_end = 0 # unsigned number
+
+# The maximum number of consecutive newlines within a block of typedefs.
+#
+# 0 = No change (default).
+nl_typedef_blk_in = 0 # unsigned number
+
+# The number of newlines before a block of variable definitions not at the top
+# of a function body. If nl_after_access_spec is non-zero, that option takes
+# precedence.
+#
+# 0 = No change (default).
+nl_var_def_blk_start = 0 # unsigned number
+
+# The number of newlines after a block of variable definitions not at the top
+# of a function body.
+#
+# 0 = No change (default).
+nl_var_def_blk_end = 0 # unsigned number
+
+# The maximum number of consecutive newlines within a block of variable
+# definitions.
+#
+# 0 = No change (default).
+nl_var_def_blk_in = 0 # unsigned number
+
+# Add or remove newline between a function call's ')' and '{', as in
+# 'list_for_each(item, &list) { }'.
+nl_fcall_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'enum' and '{'.
+nl_enum_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'enum' and 'class'.
+nl_enum_class = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'enum class' and the identifier.
+nl_enum_class_identifier = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'enum class' type and ':'.
+nl_enum_identifier_colon = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'enum class identifier :' and type.
+nl_enum_colon_type = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'struct and '{'.
+nl_struct_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'union' and '{'.
+nl_union_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'if' and '{'.
+nl_if_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'else'.
+nl_brace_else = add # ignore/add/remove/force
+
+# Add or remove newline between 'else if' and '{'. If set to ignore,
+# nl_if_brace is used instead.
+nl_elseif_brace = add # ignore/add/remove/force
+
+# Add or remove newline between 'else' and '{'.
+nl_else_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between 'else' and 'if'.
+nl_else_if = ignore # ignore/add/remove/force
+
+# Add or remove newline before 'if'/'else if' closing parenthesis.
+nl_before_if_closing_paren = ignore # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'finally'.
+nl_brace_finally = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'finally' and '{'.
+nl_finally_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'try' and '{'.
+nl_try_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between get/set and '{'.
+nl_getset_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'for' and '{'.
+nl_for_brace = remove # ignore/add/remove/force
+
+# Add or remove newline before the '{' of a 'catch' statement, as in
+# 'catch (decl) <here> {'.
+nl_catch_brace = ignore # ignore/add/remove/force
+
+# (OC) Add or remove newline before the '{' of a '@catch' statement, as in
+# '@catch (decl) <here> {'. If set to ignore, nl_catch_brace is used.
+nl_oc_catch_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'catch'.
+nl_brace_catch = ignore # ignore/add/remove/force
+
+# (OC) Add or remove newline between '}' and '@catch'. If set to ignore,
+# nl_brace_catch is used.
+nl_oc_brace_catch = ignore # ignore/add/remove/force
+
+# Add or remove newline between '}' and ']'.
+nl_brace_square = ignore # ignore/add/remove/force
+
+# Add or remove newline between '}' and ')' in a function invocation.
+nl_brace_fparen = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'while' and '{'.
+nl_while_brace = remove # ignore/add/remove/force
+
+# (D) Add or remove newline between 'scope (x)' and '{'.
+nl_scope_brace = ignore # ignore/add/remove/force
+
+# (D) Add or remove newline between 'unittest' and '{'.
+nl_unittest_brace = ignore # ignore/add/remove/force
+
+# (D) Add or remove newline between 'version (x)' and '{'.
+nl_version_brace = ignore # ignore/add/remove/force
+
+# (C#) Add or remove newline between 'using' and '{'.
+nl_using_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between two open or close braces. Due to general
+# newline/brace handling, REMOVE may not work.
+nl_brace_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'do' and '{'.
+nl_do_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'while' of 'do' statement.
+nl_brace_while = remove # ignore/add/remove/force
+
+# Add or remove newline between 'switch' and '{'.
+nl_switch_brace = remove # ignore/add/remove/force
+
+# Add or remove newline between 'synchronized' and '{'.
+nl_synchronized_brace = ignore # ignore/add/remove/force
+
+# Add a newline between ')' and '{' if the ')' is on a different line than the
+# if/for/etc.
+#
+# Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch and
+# nl_catch_brace.
+nl_multi_line_cond = false # true/false
+
+# Force a newline in a define after the macro name for multi-line defines.
+nl_multi_line_define = false # true/false
+
+# Whether to add a newline before 'case', and a blank line before a 'case'
+# statement that follows a ';' or '}'.
+nl_before_case = false # true/false
+
+# Whether to add a newline after a 'case' statement.
+nl_after_case = false # true/false
+
+# Add or remove newline between a case ':' and '{'.
+#
+# Overrides nl_after_case.
+nl_case_colon_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between ')' and 'throw'.
+nl_before_throw = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'namespace' and '{'.
+nl_namespace_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'template<>' and whatever follows.
+nl_template_class = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'class' and '{'.
+nl_class_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline before or after (depending on pos_class_comma) each
+# ',' in the base class list.
+nl_class_init_args = ignore # ignore/add/remove/force
+
+# Add or remove newline after each ',' in the constructor member
+# initialization. Related to nl_constr_colon, pos_constr_colon and
+# pos_constr_comma.
+nl_constr_init_args = ignore # ignore/add/remove/force
+
+# Add or remove newline before first element, after comma, and after last
+# element, in 'enum'.
+nl_enum_own_lines = ignore # ignore/add/remove/force
+
+# Add or remove newline between return type and function name in a function
+# definition.
+nl_func_type_name = ignore # ignore/add/remove/force
+
+# Add or remove newline between return type and function name inside a class
+# definition. If set to ignore, nl_func_type_name or nl_func_proto_type_name
+# is used instead.
+nl_func_type_name_class = ignore # ignore/add/remove/force
+
+# Add or remove newline between class specification and '::'
+# in 'void A::f() { }'. Only appears in separate member implementation (does
+# not appear with in-line implementation).
+nl_func_class_scope = ignore # ignore/add/remove/force
+
+# Add or remove newline between function scope and name, as in
+# 'void A :: <here> f() { }'.
+nl_func_scope_name = ignore # ignore/add/remove/force
+
+# Add or remove newline between return type and function name in a prototype.
+nl_func_proto_type_name = ignore # ignore/add/remove/force
+
+# Add or remove newline between a function name and the opening '(' in the
+# declaration.
+nl_func_paren = ignore # ignore/add/remove/force
+
+# Overrides nl_func_paren for functions with no parameters.
+nl_func_paren_empty = ignore # ignore/add/remove/force
+
+# Add or remove newline between a function name and the opening '(' in the
+# definition.
+nl_func_def_paren = ignore # ignore/add/remove/force
+
+# Overrides nl_func_def_paren for functions with no parameters.
+nl_func_def_paren_empty = ignore # ignore/add/remove/force
+
+# Add or remove newline between a function name and the opening '(' in the
+# call.
+nl_func_call_paren = ignore # ignore/add/remove/force
+
+# Overrides nl_func_call_paren for functions with no parameters.
+nl_func_call_paren_empty = ignore # ignore/add/remove/force
+
+# Add or remove newline after '(' in a function declaration.
+nl_func_decl_start = ignore # ignore/add/remove/force
+
+# Add or remove newline after '(' in a function definition.
+nl_func_def_start = ignore # ignore/add/remove/force
+
+# Overrides nl_func_decl_start when there is only one parameter.
+nl_func_decl_start_single = ignore # ignore/add/remove/force
+
+# Overrides nl_func_def_start when there is only one parameter.
+nl_func_def_start_single = ignore # ignore/add/remove/force
+
+# Whether to add a newline after '(' in a function declaration if '(' and ')'
+# are in different lines. If false, nl_func_decl_start is used instead.
+nl_func_decl_start_multi_line = false # true/false
+
+# Whether to add a newline after '(' in a function definition if '(' and ')'
+# are in different lines. If false, nl_func_def_start is used instead.
+nl_func_def_start_multi_line = false # true/false
+
+# Add or remove newline after each ',' in a function declaration.
+nl_func_decl_args = ignore # ignore/add/remove/force
+
+# Add or remove newline after each ',' in a function definition.
+nl_func_def_args = ignore # ignore/add/remove/force
+
+# Whether to add a newline after each ',' in a function declaration if '('
+# and ')' are in different lines. If false, nl_func_decl_args is used instead.
+nl_func_decl_args_multi_line = false # true/false
+
+# Whether to add a newline after each ',' in a function definition if '('
+# and ')' are in different lines. If false, nl_func_def_args is used instead.
+nl_func_def_args_multi_line = false # true/false
+
+# Add or remove newline before the ')' in a function declaration.
+nl_func_decl_end = ignore # ignore/add/remove/force
+
+# Add or remove newline before the ')' in a function definition.
+nl_func_def_end = ignore # ignore/add/remove/force
+
+# Overrides nl_func_decl_end when there is only one parameter.
+nl_func_decl_end_single = ignore # ignore/add/remove/force
+
+# Overrides nl_func_def_end when there is only one parameter.
+nl_func_def_end_single = ignore # ignore/add/remove/force
+
+# Whether to add a newline before ')' in a function declaration if '(' and ')'
+# are in different lines. If false, nl_func_decl_end is used instead.
+nl_func_decl_end_multi_line = false # true/false
+
+# Whether to add a newline before ')' in a function definition if '(' and ')'
+# are in different lines. If false, nl_func_def_end is used instead.
+nl_func_def_end_multi_line = false # true/false
+
+# Add or remove newline between '()' in a function declaration.
+nl_func_decl_empty = ignore # ignore/add/remove/force
+
+# Add or remove newline between '()' in a function definition.
+nl_func_def_empty = ignore # ignore/add/remove/force
+
+# Add or remove newline between '()' in a function call.
+nl_func_call_empty = ignore # ignore/add/remove/force
+
+# Whether to add a newline after '(' in a function call if '(' and ')' are in
+# different lines.
+nl_func_call_start_multi_line = false # true/false
+
+# Whether to add a newline after each ',' in a function call if '(' and ')'
+# are in different lines.
+nl_func_call_args_multi_line = false # true/false
+
+# Whether to add a newline before ')' in a function call if '(' and ')' are in
+# different lines.
+nl_func_call_end_multi_line = false # true/false
+
+# (OC) Whether to put each Objective-C message parameter on a separate line.
+# See nl_oc_msg_leave_one_liner.
+nl_oc_msg_args = false # true/false
+
+# Add or remove newline between function signature and '{'.
+nl_fdef_brace = force # ignore/add/remove/force
+
+# Add or remove newline between C++11 lambda signature and '{'.
+nl_cpp_ldef_brace = ignore # ignore/add/remove/force
+
+# Add or remove newline between 'return' and the return expression.
+nl_return_expr = ignore # ignore/add/remove/force
+
+# Whether to add a newline after semicolons, except in 'for' statements.
+nl_after_semicolon = false # true/false
+
+# (Java) Add or remove newline between the ')' and '{{' of the double brace
+# initializer.
+nl_paren_dbrace_open = ignore # ignore/add/remove/force
+
+# Whether to add a newline after the type in an unnamed temporary
+# direct-list-initialization.
+nl_type_brace_init_lst = ignore # ignore/add/remove/force
+
+# Whether to add a newline after the open brace in an unnamed temporary
+# direct-list-initialization.
+nl_type_brace_init_lst_open = ignore # ignore/add/remove/force
+
+# Whether to add a newline before the close brace in an unnamed temporary
+# direct-list-initialization.
+nl_type_brace_init_lst_close = ignore # ignore/add/remove/force
+
+# Whether to add a newline after '{'. This also adds a newline before the
+# matching '}'.
+nl_after_brace_open = false # true/false
+
+# Whether to add a newline between the open brace and a trailing single-line
+# comment. Requires nl_after_brace_open=true.
+nl_after_brace_open_cmt = false # true/false
+
+# Whether to add a newline after a virtual brace open with a non-empty body.
+# These occur in un-braced if/while/do/for statement bodies.
+nl_after_vbrace_open = false # true/false
+
+# Whether to add a newline after a virtual brace open with an empty body.
+# These occur in un-braced if/while/do/for statement bodies.
+nl_after_vbrace_open_empty = false # true/false
+
+# Whether to add a newline after '}'. Does not apply if followed by a
+# necessary ';'.
+nl_after_brace_close = false # true/false
+
+# Whether to add a newline after a virtual brace close,
+# as in 'if (foo) a++; <here> return;'.
+nl_after_vbrace_close = false # true/false
+
+# Add or remove newline between the close brace and identifier,
+# as in 'struct { int a; } <here> b;'. Affects enumerations, unions and
+# structures. If set to ignore, uses nl_after_brace_close.
+nl_brace_struct_var = ignore # ignore/add/remove/force
+
+# Whether to alter newlines in '#define' macros.
+nl_define_macro = false # true/false
+
+# Whether to alter newlines between consecutive parenthesis closes. The number
+# of closing parentheses in a line will depend on respective open parenthesis
+# lines.
+nl_squeeze_paren_close = false # true/false
+
+# Whether to remove blanks after '#ifxx' and '#elxx', or before '#elxx' and
+# '#endif'. Does not affect top-level #ifdefs.
+nl_squeeze_ifdef = false # true/false
+
+# Makes the nl_squeeze_ifdef option affect the top-level #ifdefs as well.
+nl_squeeze_ifdef_top_level = false # true/false
+
+# Add or remove blank line before 'if'.
+nl_before_if = force # ignore/add/remove/force
+
+# Add or remove blank line after 'if' statement. Add/Force work only if the
+# next token is not a closing brace.
+nl_after_if = force # ignore/add/remove/force
+
+# Add or remove blank line before 'for'.
+nl_before_for = force # ignore/add/remove/force
+
+# Add or remove blank line after 'for' statement.
+nl_after_for = force # ignore/add/remove/force
+
+# Add or remove blank line before 'while'.
+nl_before_while = force # ignore/add/remove/force
+
+# Add or remove blank line after 'while' statement.
+nl_after_while = force # ignore/add/remove/force
+
+# Add or remove blank line before 'switch'.
+nl_before_switch = force # ignore/add/remove/force
+
+# Add or remove blank line after 'switch' statement.
+nl_after_switch = force # ignore/add/remove/force
+
+# Add or remove blank line before 'synchronized'.
+nl_before_synchronized = ignore # ignore/add/remove/force
+
+# Add or remove blank line after 'synchronized' statement.
+nl_after_synchronized = ignore # ignore/add/remove/force
+
+# Add or remove blank line before 'do'.
+nl_before_do = force # ignore/add/remove/force
+
+# Add or remove blank line after 'do/while' statement.
+nl_after_do = force # ignore/add/remove/force
+
+# Whether to double-space commented-entries in 'struct'/'union'/'enum'.
+nl_ds_struct_enum_cmt = false # true/false
+
+# Whether to force a newline before '}' of a 'struct'/'union'/'enum'.
+# (Lower priority than eat_blanks_before_close_brace.)
+nl_ds_struct_enum_close_brace = false # true/false
+
+# Add or remove newline before or after (depending on pos_class_colon) a class
+# colon, as in 'class Foo <here> : <or here> public Bar'.
+nl_class_colon = ignore # ignore/add/remove/force
+
+# Add or remove newline around a class constructor colon. The exact position
+# depends on nl_constr_init_args, pos_constr_colon and pos_constr_comma.
+nl_constr_colon = ignore # ignore/add/remove/force
+
+# Whether to collapse a two-line namespace, like 'namespace foo\n{ decl; }'
+# into a single line. If true, prevents other brace newline rules from turning
+# such code into four lines.
+nl_namespace_two_to_one_liner = false # true/false
+
+# Whether to remove a newline in simple unbraced if statements, turning them
+# into one-liners, as in 'if(b)\n i++;' → 'if(b) i++;'.
+nl_create_if_one_liner = false # true/false
+
+# Whether to remove a newline in simple unbraced for statements, turning them
+# into one-liners, as in 'for (...)\n stmt;' → 'for (...) stmt;'.
+nl_create_for_one_liner = false # true/false
+
+# Whether to remove a newline in simple unbraced while statements, turning
+# them into one-liners, as in 'while (expr)\n stmt;' → 'while (expr) stmt;'.
+nl_create_while_one_liner = false # true/false
+
+# Whether to collapse a function definition whose body (not counting braces)
+# is only one line so that the entire definition (prototype, braces, body) is
+# a single line.
+nl_create_func_def_one_liner = false # true/false
+
+# Whether to split one-line simple unbraced if statements into two lines by
+# adding a newline, as in 'if(b) <here> i++;'.
+nl_split_if_one_liner = false # true/false
+
+# Whether to split one-line simple unbraced for statements into two lines by
+# adding a newline, as in 'for (...) <here> stmt;'.
+nl_split_for_one_liner = false # true/false
+
+# Whether to split one-line simple unbraced while statements into two lines by
+# adding a newline, as in 'while (expr) <here> stmt;'.
+nl_split_while_one_liner = false # true/false
+
+#
+# Blank line options
+#
+
+# The maximum number of consecutive newlines (3 = 2 blank lines).
+nl_max = 0 # unsigned number
+
+# The maximum number of consecutive newlines in a function.
+nl_max_blank_in_func = 0 # unsigned number
+
+# The number of newlines before a function prototype.
+nl_before_func_body_proto = 0 # unsigned number
+
+# The number of newlines before a multi-line function definition.
+nl_before_func_body_def = 0 # unsigned number
+
+# The number of newlines before a class constructor/destructor prototype.
+nl_before_func_class_proto = 0 # unsigned number
+
+# The number of newlines before a class constructor/destructor definition.
+nl_before_func_class_def = 0 # unsigned number
+
+# The number of newlines after a function prototype.
+nl_after_func_proto = 0 # unsigned number
+
+# The number of newlines after a function prototype, if not followed by
+# another function prototype.
+nl_after_func_proto_group = 0 # unsigned number
+
+# The number of newlines after a class constructor/destructor prototype.
+nl_after_func_class_proto = 0 # unsigned number
+
+# The number of newlines after a class constructor/destructor prototype,
+# if not followed by another constructor/destructor prototype.
+nl_after_func_class_proto_group = 0 # unsigned number
+
+# Whether one-line method definitions inside a class body should be treated
+# as if they were prototypes for the purposes of adding newlines.
+#
+# Requires nl_class_leave_one_liners=true. Overrides nl_before_func_body_def
+# and nl_before_func_class_def for one-liners.
+nl_class_leave_one_liner_groups = false # true/false
+
+# The number of newlines after '}' of a multi-line function body.
+nl_after_func_body = 0 # unsigned number
+
+# The number of newlines after '}' of a multi-line function body in a class
+# declaration. Also affects class constructors/destructors.
+#
+# Overrides nl_after_func_body.
+nl_after_func_body_class = 0 # unsigned number
+
+# The number of newlines after '}' of a single line function body. Also
+# affects class constructors/destructors.
+#
+# Overrides nl_after_func_body and nl_after_func_body_class.
+nl_after_func_body_one_liner = 0 # unsigned number
+
+# The minimum number of newlines before a multi-line comment.
+# Doesn't apply if after a brace open or another multi-line comment.
+nl_before_block_comment = 0 # unsigned number
+
+# The minimum number of newlines before a single-line C comment.
+# Doesn't apply if after a brace open or other single-line C comments.
+nl_before_c_comment = 0 # unsigned number
+
+# The minimum number of newlines before a CPP comment.
+# Doesn't apply if after a brace open or other CPP comments.
+nl_before_cpp_comment = 0 # unsigned number
+
+# Whether to force a newline after a multi-line comment.
+nl_after_multiline_comment = false # true/false
+
+# Whether to force a newline after a label's colon.
+nl_after_label_colon = false # true/false
+
+# The number of newlines after '}' or ';' of a struct/enum/union definition.
+nl_after_struct = 0 # unsigned number
+
+# The number of newlines before a class definition.
+nl_before_class = 0 # unsigned number
+
+# The number of newlines after '}' or ';' of a class definition.
+nl_after_class = 0 # unsigned number
+
+# The number of newlines before an access specifier label. This also includes
+# the Qt-specific 'signals:' and 'slots:'. Will not change the newline count
+# if after a brace open.
+#
+# 0 = No change (default).
+nl_before_access_spec = 0 # unsigned number
+
+# The number of newlines after an access specifier label. This also includes
+# the Qt-specific 'signals:' and 'slots:'. Will not change the newline count
+# if after a brace open.
+#
+# 0 = No change (default).
+#
+# Overrides nl_typedef_blk_start and nl_var_def_blk_start.
+nl_after_access_spec = 0 # unsigned number
+
+# The number of newlines between a function definition and the function
+# comment, as in '// comment\n <here> void foo() {...}'.
+#
+# 0 = No change (default).
+nl_comment_func_def = 0 # unsigned number
+
+# The number of newlines after a try-catch-finally block that isn't followed
+# by a brace close.
+#
+# 0 = No change (default).
+nl_after_try_catch_finally = 0 # unsigned number
+
+# (C#) The number of newlines before and after a property, indexer or event
+# declaration.
+#
+# 0 = No change (default).
+nl_around_cs_property = 0 # unsigned number
+
+# (C#) The number of newlines between the get/set/add/remove handlers.
+#
+# 0 = No change (default).
+nl_between_get_set = 0 # unsigned number
+
+# (C#) Add or remove newline between property and the '{'.
+nl_property_brace = ignore # ignore/add/remove/force
+
+# The number of newlines after '{' of a namespace. This also adds newlines
+# before the matching '}'.
+#
+# 0 = Apply eat_blanks_after_open_brace or eat_blanks_before_close_brace if
+# applicable, otherwise no change.
+#
+# Overrides eat_blanks_after_open_brace and eat_blanks_before_close_brace.
+nl_inside_namespace = 0 # unsigned number
+
+# Whether to remove blank lines after '{'.
+eat_blanks_after_open_brace = false # true/false
+
+# Whether to remove blank lines before '}'.
+eat_blanks_before_close_brace = false # true/false
+
+# How aggressively to remove extra newlines not in preprocessor.
+#
+# 0: No change (default)
+# 1: Remove most newlines not handled by other config
+# 2: Remove all newlines and reformat completely by config
+nl_remove_extra_newlines = 0 # unsigned number
+
+# Whether to put a blank line before 'return' statements, unless after an open
+# brace.
+nl_before_return = false # true/false
+
+# Whether to put a blank line after 'return' statements, unless followed by a
+# close brace.
+nl_after_return = false # true/false
+
+# (Java) Add or remove newline after an annotation statement. Only affects
+# annotations that are after a newline.
+nl_after_annotation = ignore # ignore/add/remove/force
+
+# (Java) Add or remove newline between two annotations.
+nl_between_annotation = ignore # ignore/add/remove/force
+
+#
+# Positioning options
+#
+
+# The position of arithmetic operators in wrapped expressions.
+pos_arith = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of assignment in wrapped expressions. Do not affect '='
+# followed by '{'.
+pos_assign = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of Boolean operators in wrapped expressions.
+pos_bool = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of comparison operators in wrapped expressions.
+pos_compare = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of conditional operators, as in the '?' and ':' of
+# 'expr ? stmt : stmt', in wrapped expressions.
+pos_conditional = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of the comma in wrapped expressions.
+pos_comma = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of the comma in enum entries.
+pos_enum_comma = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of the comma in the base class list if there is more than one
+# line. Affects nl_class_init_args.
+pos_class_comma = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of the comma in the constructor initialization list.
+# Related to nl_constr_colon, nl_constr_init_args and pos_constr_colon.
+pos_constr_comma = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of trailing/leading class colon, between class and base class
+# list. Affects nl_class_colon.
+pos_class_colon = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of colons between constructor and member initialization.
+# Related to nl_constr_colon, nl_constr_init_args and pos_constr_comma.
+pos_constr_colon = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+#
+# Line splitting options
+#
+
+# Try to limit code width to N columns.
+code_width = 120 # unsigned number
+
+# Whether to fully split long 'for' statements at semi-colons.
+ls_for_split_full = true # true/false
+
+# Whether to fully split long function prototypes/calls at commas.
+ls_func_split_full = true # true/false
+
+# Whether to split lines as close to code_width as possible and ignore some
+# groupings.
+ls_code_width = false # true/false
+
+#
+# Code alignment options (not left column spaces/tabs)
+#
+
+# Whether to keep non-indenting tabs.
+align_keep_tabs = false # true/false
+
+# Whether to use tabs for aligning.
+align_with_tabs = false # true/false
+
+# Whether to bump out to the next tab when aligning.
+align_on_tabstop = false # true/false
+
+# Whether to right-align numbers.
+align_number_right = false # true/false
+
+# Whether to keep whitespace not required for alignment.
+align_keep_extra_space = false # true/false
+
+# Whether to align variable definitions in prototypes and functions.
+align_func_params = false # true/false
+
+# The span for aligning parameter definitions in function on parameter name.
+#
+# 0 = Don't align (default).
+align_func_params_span = 0 # unsigned number
+
+# The threshold for aligning function parameter definitions.
+#
+# 0 = No limit (default).
+align_func_params_thresh = 0 # unsigned number
+
+# The gap for aligning function parameter definitions.
+align_func_params_gap = 0 # unsigned number
+
+# Whether to align parameters in single-line functions that have the same
+# name. The function names must already be aligned with each other.
+align_same_func_call_params = false # true/false
+
+# The span for aligning function-call parameters for single line functions.
+#
+# 0 = Don't align (default).
+align_same_func_call_params_span = 0 # unsigned number
+
+# The threshold for aligning function-call parameters for single line
+# functions.
+#
+# 0 = No limit (default).
+align_same_func_call_params_thresh = 0 # unsigned number
+
+# The span for aligning variable definitions.
+#
+# 0 = Don't align (default).
+align_var_def_span = 0 # unsigned number
+
+# How to align the '*' in variable definitions.
+#
+# 0: Part of the type 'void * foo;' (default)
+# 1: Part of the variable 'void *foo;'
+# 2: Dangling 'void *foo;'
+align_var_def_star_style = 0 # unsigned number
+
+# How to align the '&' in variable definitions.
+#
+# 0: Part of the type 'long & foo;' (default)
+# 1: Part of the variable 'long &foo;'
+# 2: Dangling 'long &foo;'
+align_var_def_amp_style = 0 # unsigned number
+
+# The threshold for aligning variable definitions.
+#
+# 0 = No limit (default).
+align_var_def_thresh = 0 # unsigned number
+
+# The gap for aligning variable definitions.
+align_var_def_gap = 0 # unsigned number
+
+# Whether to align the colon in struct bit fields.
+align_var_def_colon = false # true/false
+
+# The gap for aligning the colon in struct bit fields.
+align_var_def_colon_gap = 0 # unsigned number
+
+# Whether to align any attribute after the variable name.
+align_var_def_attribute = false # true/false
+
+# Whether to align inline struct/enum/union variable definitions.
+align_var_def_inline = false # true/false
+
+# The span for aligning on '=' in assignments.
+#
+# 0 = Don't align (default).
+align_assign_span = 0 # unsigned number
+
+# The threshold for aligning on '=' in assignments.
+#
+# 0 = No limit (default).
+align_assign_thresh = 0 # unsigned number
+
+# How to apply align_assign_span to function declaration "assignments", i.e.
+# 'virtual void foo() = 0' or '~foo() = {default|delete}'.
+#
+# 0: Align with other assignments (default)
+# 1: Align with each other, ignoring regular assignments
+# 2: Don't align
+align_assign_decl_func = 0 # unsigned number
+
+# The span for aligning on '=' in enums.
+#
+# 0 = Don't align (default).
+align_enum_equ_span = 0 # unsigned number
+
+# The threshold for aligning on '=' in enums.
+#
+# 0 = no limit (default).
+align_enum_equ_thresh = 0 # unsigned number
+
+# The span for aligning class member definitions.
+#
+# 0 = Don't align (default).
+align_var_class_span = 0 # unsigned number
+
+# The threshold for aligning class member definitions.
+#
+# 0 = No limit (default).
+align_var_class_thresh = 0 # unsigned number
+
+# The gap for aligning class member definitions.
+align_var_class_gap = 0 # unsigned number
+
+# The span for aligning struct/union member definitions.
+#
+# 0 = Don't align (default).
+align_var_struct_span = 0 # unsigned number
+
+# The threshold for aligning struct/union member definitions.
+#
+# 0 = No limit (default).
+align_var_struct_thresh = 0 # unsigned number
+
+# The gap for aligning struct/union member definitions.
+align_var_struct_gap = 0 # unsigned number
+
+# The span for aligning struct initializer values.
+#
+# 0 = Don't align (default).
+align_struct_init_span = 0 # unsigned number
+
+# The minimum space between the type and the synonym of a typedef.
+align_typedef_gap = 0 # unsigned number
+
+# The span for aligning single-line typedefs.
+#
+# 0 = Don't align (default).
+align_typedef_span = 0 # unsigned number
+
+# How to align typedef'd functions with other typedefs.
+#
+# 0: Don't mix them at all (default)
+# 1: Align the open parenthesis with the types
+# 2: Align the function type name with the other type names
+align_typedef_func = 0 # unsigned number
+
+# How to align the '*' in typedefs.
+#
+# 0: Align on typedef type, ignore '*' (default)
+# 1: The '*' is part of type name: 'typedef int *pint;'
+# 2: The '*' is part of the type, but dangling: 'typedef int *pint;'
+align_typedef_star_style = 0 # unsigned number
+
+# How to align the '&' in typedefs.
+#
+# 0: Align on typedef type, ignore '&' (default)
+# 1: The '&' is part of type name: 'typedef int &pint;'
+# 2: The '&' is part of the type, but dangling: 'typedef int &pint;'
+align_typedef_amp_style = 0 # unsigned number
+
+# The span for aligning comments that end lines.
+#
+# 0 = Don't align (default).
+align_right_cmt_span = 0 # unsigned number
+
+# If aligning comments, whether to mix with comments after '}' and #endif with
+# less than three spaces before the comment.
+align_right_cmt_mix = false # true/false
+
+# Whether to only align trailing comments that are at the same brace level.
+align_right_cmt_same_level = false # true/false
+
+# Minimum number of columns between preceding text and a trailing comment in
+# order for the comment to qualify for being aligned. Must be non-zero to have
+# an effect.
+align_right_cmt_gap = 0 # unsigned number
+
+# Minimum column at which to align trailing comments. Comments which are
+# aligned beyond this column, but which can be aligned in a lesser column,
+# may be "pulled in".
+#
+# 0 = Ignore (default).
+align_right_cmt_at_col = 0 # unsigned number
+
+# The span for aligning function prototypes.
+#
+# 0 = Don't align (default).
+align_func_proto_span = 0 # unsigned number
+
+# Minimum gap between the return type and the function name.
+align_func_proto_gap = 0 # unsigned number
+
+# Whether to align function prototypes on the 'operator' keyword instead of
+# what follows.
+align_on_operator = false # true/false
+
+# Whether to mix aligning prototype and variable declarations. If true,
+# align_var_def_XXX options are used instead of align_func_proto_XXX options.
+align_mix_var_proto = false # true/false
+
+# Whether to align single-line functions with function prototypes.
+# Uses align_func_proto_span.
+align_single_line_func = false # true/false
+
+# Whether to align the open brace of single-line functions.
+# Requires align_single_line_func=true. Uses align_func_proto_span.
+align_single_line_brace = false # true/false
+
+# Gap for align_single_line_brace.
+align_single_line_brace_gap = 0 # unsigned number
+
+# (OC) The span for aligning Objective-C message specifications.
+#
+# 0 = Don't align (default).
+align_oc_msg_spec_span = 0 # unsigned number
+
+# Whether to align macros wrapped with a backslash and a newline. This will
+# not work right if the macro contains a multi-line comment.
+align_nl_cont = false # true/false
+
+# Whether to align macro functions and variables together.
+align_pp_define_together = false # true/false
+
+# The minimum space between label and value of a preprocessor define.
+align_pp_define_gap = 0 # unsigned number
+
+# The span for aligning on '#define' bodies.
+#
+# =0: Don't align (default)
+# >0: Number of lines (including comments) between blocks
+align_pp_define_span = 0 # unsigned number
+
+# Whether to align lines that start with '<<' with previous '<<'.
+#
+# Default: true
+align_left_shift = true # true/false
+
+# Whether to align text after 'asm volatile ()' colons.
+align_asm_colon = false # true/false
+
+# (OC) Span for aligning parameters in an Objective-C message call
+# on the ':'.
+#
+# 0 = Don't align.
+align_oc_msg_colon_span = 0 # unsigned number
+
+# (OC) Whether to always align with the first parameter, even if it is too
+# short.
+align_oc_msg_colon_first = false # true/false
+
+# (OC) Whether to align parameters in an Objective-C '+' or '-' declaration
+# on the ':'.
+align_oc_decl_colon = false # true/false
+
+#
+# Comment modification options
+#
+
+# Try to wrap comments at N columns.
+cmt_width = 0 # unsigned number
+
+# How to reflow comments.
+#
+# 0: No reflowing (apart from the line wrapping due to cmt_width) (default)
+# 1: No touching at all
+# 2: Full reflow
+cmt_reflow_mode = 0 # unsigned number
+
+# Whether to convert all tabs to spaces in comments. If false, tabs in
+# comments are left alone, unless used for indenting.
+cmt_convert_tab_to_spaces = true # true/false
+
+# Whether to apply changes to multi-line comments, including cmt_width,
+# keyword substitution and leading chars.
+#
+# Default: true
+cmt_indent_multi = true # true/false
+
+# Whether to group c-comments that look like they are in a block.
+cmt_c_group = false # true/false
+
+# Whether to put an empty '/*' on the first line of the combined c-comment.
+cmt_c_nl_start = false # true/false
+
+# Whether to add a newline before the closing '*/' of the combined c-comment.
+cmt_c_nl_end = false # true/false
+
+# Whether to change cpp-comments into c-comments.
+cmt_cpp_to_c = true # true/false
+
+# Whether to group cpp-comments that look like they are in a block. Only
+# meaningful if cmt_cpp_to_c=true.
+cmt_cpp_group = false # true/false
+
+# Whether to put an empty '/*' on the first line of the combined cpp-comment
+# when converting to a c-comment.
+#
+# Requires cmt_cpp_to_c=true and cmt_cpp_group=true.
+cmt_cpp_nl_start = false # true/false
+
+# Whether to add a newline before the closing '*/' of the combined cpp-comment
+# when converting to a c-comment.
+#
+# Requires cmt_cpp_to_c=true and cmt_cpp_group=true.
+cmt_cpp_nl_end = false # true/false
+
+# Whether to put a star on subsequent comment lines.
+cmt_star_cont = true # true/false
+
+# The number of spaces to insert at the start of subsequent comment lines.
+cmt_sp_before_star_cont = 0 # unsigned number
+
+# The number of spaces to insert after the star on subsequent comment lines.
+cmt_sp_after_star_cont = 0 # unsigned number
+
+# For multi-line comments with a '*' lead, remove leading spaces if the first
+# and last lines of the comment are the same length.
+#
+# Default: true
+cmt_multi_check_last = true # true/false
+
+# For multi-line comments with a '*' lead, remove leading spaces if the first
+# and last lines of the comment are the same length AND if the length is
+# bigger as the first_len minimum.
+#
+# Default: 4
+cmt_multi_first_len_minimum = 4 # unsigned number
+
+# Path to a file that contains text to insert at the beginning of a file if
+# the file doesn't start with a C/C++ comment. If the inserted text contains
+# '$(filename)', that will be replaced with the current file's name.
+cmt_insert_file_header = "" # string
+
+# Path to a file that contains text to insert at the end of a file if the
+# file doesn't end with a C/C++ comment. If the inserted text contains
+# '$(filename)', that will be replaced with the current file's name.
+cmt_insert_file_footer = "" # string
+
+# Path to a file that contains text to insert before a function definition if
+# the function isn't preceded by a C/C++ comment. If the inserted text
+# contains '$(function)', '$(javaparam)' or '$(fclass)', these will be
+# replaced with, respectively, the name of the function, the javadoc '@param'
+# and '@return' stuff, or the name of the class to which the member function
+# belongs.
+cmt_insert_func_header = "" # string
+
+# Path to a file that contains text to insert before a class if the class
+# isn't preceded by a C/C++ comment. If the inserted text contains '$(class)',
+# that will be replaced with the class name.
+cmt_insert_class_header = "" # string
+
+# Path to a file that contains text to insert before an Objective-C message
+# specification, if the method isn't preceded by a C/C++ comment. If the
+# inserted text contains '$(message)' or '$(javaparam)', these will be
+# replaced with, respectively, the name of the function, or the javadoc
+# '@param' and '@return' stuff.
+cmt_insert_oc_msg_header = "" # string
+
+# Whether a comment should be inserted if a preprocessor is encountered when
+# stepping backwards from a function name.
+#
+# Applies to cmt_insert_oc_msg_header, cmt_insert_func_header and
+# cmt_insert_class_header.
+cmt_insert_before_preproc = false # true/false
+
+# Whether a comment should be inserted if a function is declared inline to a
+# class definition.
+#
+# Applies to cmt_insert_func_header.
+#
+# Default: true
+cmt_insert_before_inlines = true # true/false
+
+# Whether a comment should be inserted if the function is a class constructor
+# or destructor.
+#
+# Applies to cmt_insert_func_header.
+cmt_insert_before_ctor_dtor = false # true/false
+
+#
+# Code modifying options (non-whitespace)
+#
+
+# Add or remove braces on a single-line 'do' statement.
+mod_full_brace_do = remove # ignore/add/remove/force
+
+# Add or remove braces on a single-line 'for' statement.
+mod_full_brace_for = remove # ignore/add/remove/force
+
+# (Pawn) Add or remove braces on a single-line function definition.
+mod_full_brace_function = force # ignore/add/remove/force
+
+# Add or remove braces on a single-line 'if' statement. Braces will not be
+# removed if the braced statement contains an 'else'.
+mod_full_brace_if = remove # ignore/add/remove/force
+
+# Whether to enforce that all blocks of an 'if'/'else if'/'else' chain either
+# have, or do not have, braces. If true, braces will be added if any block
+# needs braces, and will only be removed if they can be removed from all
+# blocks.
+#
+# Overrides mod_full_brace_if.
+mod_full_brace_if_chain = true # true/false
+
+# Whether to add braces to all blocks of an 'if'/'else if'/'else' chain.
+# If true, mod_full_brace_if_chain will only remove braces from an 'if' that
+# does not have an 'else if' or 'else'.
+mod_full_brace_if_chain_only = false # true/false
+
+# Add or remove braces on single-line 'while' statement.
+mod_full_brace_while = remove # ignore/add/remove/force
+
+# Add or remove braces on single-line 'using ()' statement.
+mod_full_brace_using = ignore # ignore/add/remove/force
+
+# Don't remove braces around statements that span N newlines
+mod_full_brace_nl = 0 # unsigned number
+
+# Whether to prevent removal of braces from 'if'/'for'/'while'/etc. blocks
+# which span multiple lines.
+#
+# Affects:
+# mod_full_brace_for
+# mod_full_brace_if
+# mod_full_brace_if_chain
+# mod_full_brace_if_chain_only
+# mod_full_brace_while
+# mod_full_brace_using
+#
+# Does not affect:
+# mod_full_brace_do
+# mod_full_brace_function
+mod_full_brace_nl_block_rem_mlcond = false # true/false
+
+# Add or remove unnecessary parenthesis on 'return' statement.
+mod_paren_on_return = remove # ignore/add/remove/force
+
+# (Pawn) Whether to change optional semicolons to real semicolons.
+mod_pawn_semicolon = false # true/false
+
+# Whether to fully parenthesize Boolean expressions in 'while' and 'if'
+# statement, as in 'if (a && b > c)' → 'if (a && (b > c))'.
+mod_full_paren_if_bool = true # true/false
+
+# Whether to remove superfluous semicolons.
+mod_remove_extra_semicolon = true # true/false
+
+# If a function body exceeds the specified number of newlines and doesn't have
+# a comment after the close brace, a comment will be added.
+mod_add_long_function_closebrace_comment = 0 # unsigned number
+
+# If a namespace body exceeds the specified number of newlines and doesn't
+# have a comment after the close brace, a comment will be added.
+mod_add_long_namespace_closebrace_comment = 0 # unsigned number
+
+# If a class body exceeds the specified number of newlines and doesn't have a
+# comment after the close brace, a comment will be added.
+mod_add_long_class_closebrace_comment = 0 # unsigned number
+
+# If a switch body exceeds the specified number of newlines and doesn't have a
+# comment after the close brace, a comment will be added.
+mod_add_long_switch_closebrace_comment = 0 # unsigned number
+
+# If an #ifdef body exceeds the specified number of newlines and doesn't have
+# a comment after the #endif, a comment will be added.
+mod_add_long_ifdef_endif_comment = 0 # unsigned number
+
+# If an #ifdef or #else body exceeds the specified number of newlines and
+# doesn't have a comment after the #else, a comment will be added.
+mod_add_long_ifdef_else_comment = 0 # unsigned number
+
+# Whether to sort consecutive single-line 'import' statements.
+mod_sort_import = false # true/false
+
+# (C#) Whether to sort consecutive single-line 'using' statements.
+mod_sort_using = false # true/false
+
+# Whether to sort consecutive single-line '#include' statements (C/C++) and
+# '#import' statements (Objective-C). Be aware that this has the potential to
+# break your code if your includes/imports have ordering dependencies.
+mod_sort_include = false # true/false
+
+# Whether to move a 'break' that appears after a fully braced 'case' before
+# the close brace, as in 'case X: { ... } break;' → 'case X: { ... break; }'.
+mod_move_case_break = false # true/false
+
+# Add or remove braces around a fully braced case statement. Will only remove
+# braces if there are no variable declarations in the block.
+mod_case_brace = ignore # ignore/add/remove/force
+
+# Whether to remove a void 'return;' that appears as the last statement in a
+# function.
+mod_remove_empty_return = false # true/false
+
+# Add or remove the comma after the last value of an enumeration.
+mod_enum_last_comma = ignore # ignore/add/remove/force
+
+# (OC) Whether to organize the properties. If true, properties will be
+# rearranged according to the mod_sort_oc_property_*_weight factors.
+mod_sort_oc_properties = false # true/false
+
+# (OC) Weight of a class property modifier.
+mod_sort_oc_property_class_weight = 0 # number
+
+# (OC) Weight of 'atomic' and 'nonatomic'.
+mod_sort_oc_property_thread_safe_weight = 0 # number
+
+# (OC) Weight of 'readwrite' when organizing properties.
+mod_sort_oc_property_readwrite_weight = 0 # number
+
+# (OC) Weight of a reference type specifier ('retain', 'copy', 'assign',
+# 'weak', 'strong') when organizing properties.
+mod_sort_oc_property_reference_weight = 0 # number
+
+# (OC) Weight of getter type ('getter=') when organizing properties.
+mod_sort_oc_property_getter_weight = 0 # number
+
+# (OC) Weight of setter type ('setter=') when organizing properties.
+mod_sort_oc_property_setter_weight = 0 # number
+
+# (OC) Weight of nullability type ('nullable', 'nonnull', 'null_unspecified',
+# 'null_resettable') when organizing properties.
+mod_sort_oc_property_nullability_weight = 0 # number
+
+#
+# Preprocessor options
+#
+
+# Add or remove indentation of preprocessor directives inside #if blocks
+# at brace level 0 (file-level).
+pp_indent = ignore # ignore/add/remove/force
+
+# Whether to indent #if/#else/#endif at the brace level. If false, these are
+# indented from column 1.
+pp_indent_at_level = false # true/false
+
+# Specifies the number of columns to indent preprocessors per level
+# at brace level 0 (file-level). If pp_indent_at_level=false, also specifies
+# the number of columns to indent preprocessors per level
+# at brace level > 0 (function-level).
+#
+# Default: 1
+pp_indent_count = 1 # unsigned number
+
+# Add or remove space after # based on pp_level of #if blocks.
+pp_space = force # ignore/add/remove/force
+
+# Sets the number of spaces per level added with pp_space.
+pp_space_count = 3 # unsigned number
+
+# The indent for '#region' and '#endregion' in C# and '#pragma region' in
+# C/C++. Negative values decrease indent down to the first column.
+pp_indent_region = 0 # number
+
+# Whether to indent the code between #region and #endregion.
+pp_region_indent_code = false # true/false
+
+# If pp_indent_at_level=true, sets the indent for #if, #else and #endif when
+# not at file-level. Negative values decrease indent down to the first column.
+#
+# =0: Indent preprocessors using output_tab_size
+# >0: Column at which all preprocessors will be indented
+pp_indent_if = 0 # number
+
+# Whether to indent the code between #if, #else and #endif.
+pp_if_indent_code = false # true/false
+
+# Whether to indent '#define' at the brace level. If false, these are
+# indented from column 1.
+pp_define_at_level = false # true/false
+
+# Whether to ignore the '#define' body while formatting.
+pp_ignore_define_body = false # true/false
+
+# Whether to indent case statements between #if, #else, and #endif.
+# Only applies to the indent of the preprocesser that the case statements
+# directly inside of.
+#
+# Default: true
+pp_indent_case = true # true/false
+
+# Whether to indent whole function definitions between #if, #else, and #endif.
+# Only applies to the indent of the preprocesser that the function definition
+# is directly inside of.
+#
+# Default: true
+pp_indent_func_def = true # true/false
+
+# Whether to indent extern C blocks between #if, #else, and #endif.
+# Only applies to the indent of the preprocesser that the extern block is
+# directly inside of.
+#
+# Default: true
+pp_indent_extern = true # true/false
+
+# Whether to indent braces directly inside #if, #else, and #endif.
+# Only applies to the indent of the preprocesser that the braces are directly
+# inside of.
+#
+# Default: true
+pp_indent_brace = true # true/false
+
+#
+# Sort includes options
+#
+
+# The regex for include category with priority 0.
+include_category_0 = "" # string
+
+# The regex for include category with priority 1.
+include_category_1 = "" # string
+
+# The regex for include category with priority 2.
+include_category_2 = "" # string
+
+#
+# Use or Do not Use options
+#
+
+# true: indent_func_call_param will be used (default)
+# false: indent_func_call_param will NOT be used
+#
+# Default: true
+use_indent_func_call_param = true # true/false
+
+# The value of the indentation for a continuation line is calculated
+# differently if the statement is:
+# - a declaration: your case with QString fileName ...
+# - an assignment: your case with pSettings = new QSettings( ...
+#
+# At the second case the indentation value might be used twice:
+# - at the assignment
+# - at the function call (if present)
+#
+# To prevent the double use of the indentation value, use this option with the
+# value 'true'.
+#
+# true: indent_continue will be used only once
+# false: indent_continue will be used every time (default)
+use_indent_continue_only_once = false # true/false
+
+# The value might be used twice:
+# - at the assignment
+# - at the opening brace
+#
+# To prevent the double use of the indentation value, use this option with the
+# value 'true'.
+#
+# true: indentation will be used only once
+# false: indentation will be used every time (default)
+indent_cpp_lambda_only_once = false # true/false
+
+# Whether to apply special formatting for Qt SIGNAL/SLOT macros. Essentially,
+# this tries to format these so that they match Qt's normalized form (i.e. the
+# result of QMetaObject::normalizedSignature), which can slightly improve the
+# performance of the QObject::connect call, rather than how they would
+# otherwise be formatted.
+#
+# See options_for_QT.cpp for details.
+#
+# Default: true
+use_options_overriding_for_qt_macros = true # true/false
+
+#
+# Warn levels - 1: error, 2: warning (default), 3: note
+#
+
+# (C#) Warning is given if doing tab-to-\t replacement and we have found one
+# in a C# verbatim string literal.
+#
+# Default: 2
+warn_level_tabs_found_in_verbatim_string_literals = 2 # unsigned number
+
+# Meaning of the settings:
+# Ignore - do not do any changes
+# Add - makes sure there is 1 or more space/brace/newline/etc
+# Force - makes sure there is exactly 1 space/brace/newline/etc,
+# behaves like Add in some contexts
+# Remove - removes space/brace/newline/etc
+#
+#
+# - Token(s) can be treated as specific type(s) with the 'set' option:
+# `set tokenType tokenString [tokenString...]`
+#
+# Example:
+# `set BOOL __AND__ __OR__`
+#
+# tokenTypes are defined in src/token_enum.h, use them without the
+# 'CT_' prefix: 'CT_BOOL' → 'BOOL'
+#
+#
+# - Token(s) can be treated as type(s) with the 'type' option.
+# `type tokenString [tokenString...]`
+#
+# Example:
+# `type int c_uint_8 Rectangle`
+#
+# This can also be achieved with `set TYPE int c_uint_8 Rectangle`
+#
+#
+# To embed whitespace in tokenStrings use the '\' escape character, or quote
+# the tokenStrings. These quotes are supported: "'`
+#
+#
+# - Support for the auto detection of languages through the file ending can be
+# added using the 'file_ext' command.
+# `file_ext langType langString [langString..]`
+#
+# Example:
+# `file_ext CPP .ch .cxx .cpp.in`
+#
+# langTypes are defined in uncrusify_types.h in the lang_flag_e enum, use
+# them without the 'LANG_' prefix: 'LANG_CPP' → 'CPP'
+#
+#
+# - Custom macro-based indentation can be set up using 'macro-open',
+# 'macro-else' and 'macro-close'.
+# `(macro-open | macro-else | macro-close) tokenString`
+#
+# Example:
+# `macro-open BEGIN_TEMPLATE_MESSAGE_MAP`
+# `macro-open BEGIN_MESSAGE_MAP`
+# `macro-close END_MESSAGE_MAP`
+#
+#
+# option(s) with 'not default' value: 87
+#