summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lipka <clipka@de.adit-jv.com>2018-12-20 14:58:19 +0100
committerChristoph Lipka <clipka@de.adit-jv.com>2018-12-21 10:23:41 +0100
commitdca8ab254aa0a687c32009079d85e4d8f960b213 (patch)
treee63b6a552fd9f61873892110a56a89ef354864cd
parent0d0c74640c8b792db37cb9f884f89f7561ea551f (diff)
downloadDLT-daemon-dca8ab254aa0a687c32009079d85e4d8f960b213.tar.gz
Code beautification using uncrustify
Signed-off-by: Christoph Lipka <clipka@de.adit-jv.com>
-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;