From f8f80a07afd45d60c2975bfd7e4b859fb8c10a96 Mon Sep 17 00:00:00 2001 From: Lassi Marttala Date: Wed, 16 May 2012 10:10:12 +0200 Subject: [GDLT-67] dlt-system v2.0, check full commit message for rebase details [GDLT-67] Prepare build system. [GDLT-67] Config parsing, structure for thread handling [GDLT-67] Finalize configuration reading. [GDLT-67] Reimplementation of syslog, logfile, logprocess, shell. [GDLT-67] First complete version of the new dlt-system. [GDLT-67] Fixed header comments. authors, file names. [GDLT-67] Final touches. [GDLT-67] Fixed a problem with thread creation in optimized release binary. [GDLT-67] New configuration file. [GDLT-67] Added dlt debug output Signed-off-by: Christian Muck --- src/system/dlt-system-shell.c | 104 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/system/dlt-system-shell.c (limited to 'src/system/dlt-system-shell.c') diff --git a/src/system/dlt-system-shell.c b/src/system/dlt-system-shell.c new file mode 100644 index 0000000..758f5fc --- /dev/null +++ b/src/system/dlt-system-shell.c @@ -0,0 +1,104 @@ +/** + * @licence app begin@ + * Copyright (C) 2012 BMW AG + * + * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps. + * + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Lassi Marttala BMW 2012 + * + * \file dlt-system-logfile.c + * For further information see http://www.genivi.org/. + * @licence end@ + */ + +/******************************************************************************* +** ** +** SRC-MODULE: dlt-system-shell.c ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Lassi Marttala ** +** Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** +** ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ + +/******************************************************************************* +** Author Identity ** +******************************************************************************** +** ** +** Initials Name Company ** +** -------- ------------------------- ---------------------------------- ** +** lm Lassi Marttala BMW ** +*******************************************************************************/ +#include "dlt.h" +#include "dlt-system.h" + +#include +#include + +DLT_IMPORT_CONTEXT(dltsystem) +DLT_DECLARE_CONTEXT(shellContext) + +int dlt_shell_injection_callback(uint32_t service_id, void *data, uint32_t length) +{ + DLT_LOG(dltsystem,DLT_LOG_DEBUG, + DLT_STRING("dlt-system-shell, injection callback")); + char text[1024]; + int syserr = 0; + + strncpy(text,data,length); + + DLT_LOG(dltsystem,DLT_LOG_DEBUG, + DLT_STRING("dlt-system-shell, injection injection id:"), + DLT_UINT32(service_id)); + DLT_LOG(dltsystem,DLT_LOG_DEBUG, + DLT_STRING("dlt-system-shell, injection data:"), + DLT_STRING(text)); + + switch(service_id) + { + case 0x1001: + if((syserr = system(text)) != 0) + { + DLT_LOG(dltsystem,DLT_LOG_ERROR, + DLT_STRING("dlt-system-shell, abnormal exit status."), + DLT_STRING(text), + DLT_INT(syserr)); + } + break; + default: + DLT_LOG(dltsystem,DLT_LOG_ERROR, + DLT_STRING("dlt-system-shell, unknown command received."), + DLT_UINT32(service_id), + DLT_STRING(text)); + break; + } + return 0; +} + +void init_shell() +{ + DLT_LOG(dltsystem,DLT_LOG_DEBUG, + DLT_STRING("dlt-system-shell, register callback")); + DLT_REGISTER_CONTEXT(shellContext,"CMD","Execute Shell commands"); + DLT_REGISTER_INJECTION_CALLBACK(shellContext, 0x1001, dlt_shell_injection_callback); +} -- cgit v1.2.1