3 * Copyright (C) 2012 BMW AG
5 * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
7 * Contributions are licensed to the GENIVI Alliance under one or more
8 * Contribution License Agreements.
11 * This Source Code Form is subject to the terms of the
12 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
13 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
16 * \author Lassi Marttala <lassi.lm.marttala@partner.bmw.de> BMW 2012
18 * \file dlt-system-logfile.c
19 * For further information see http://www.genivi.org/.
23 /*******************************************************************************
25 ** SRC-MODULE: dlt-system-shell.c **
31 ** AUTHOR : Lassi Marttala <lassi.lm.marttala@partner.bmw.de> **
32 ** Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
38 ** PLATFORM DEPENDANT [yes/no]: yes **
40 ** TO BE CHANGED BY USER [yes/no]: no **
42 *******************************************************************************/
44 /*******************************************************************************
46 ********************************************************************************
48 ** Initials Name Company **
49 ** -------- ------------------------- ---------------------------------- **
50 ** lm Lassi Marttala BMW **
51 *******************************************************************************/
53 #include "dlt-system.h"
58 DLT_IMPORT_CONTEXT(dltsystem)
59 DLT_DECLARE_CONTEXT(shellContext)
61 int dlt_shell_injection_callback(uint32_t service_id, void *data, uint32_t length)
63 DLT_LOG(shellContext,DLT_LOG_DEBUG,
64 DLT_STRING("dlt-system-shell, injection callback"));
68 strncpy(text,data,length);
70 DLT_LOG(shellContext,DLT_LOG_DEBUG,
71 DLT_STRING("dlt-system-shell, injection injection id:"),
72 DLT_UINT32(service_id));
73 DLT_LOG(shellContext,DLT_LOG_DEBUG,
74 DLT_STRING("dlt-system-shell, injection data:"),
80 if((syserr = system(text)) != 0)
82 DLT_LOG(shellContext,DLT_LOG_ERROR,
83 DLT_STRING("dlt-system-shell, abnormal exit status."),
89 DLT_LOG(shellContext,DLT_LOG_INFO,
90 DLT_STRING("Shell command executed:"),
95 DLT_LOG(shellContext,DLT_LOG_ERROR,
96 DLT_STRING("dlt-system-shell, unknown command received."),
97 DLT_UINT32(service_id),
106 DLT_LOG(dltsystem,DLT_LOG_DEBUG,
107 DLT_STRING("dlt-system-shell, register callback"));
108 DLT_REGISTER_CONTEXT(shellContext,"CMD","Execute Shell commands");
109 DLT_REGISTER_INJECTION_CALLBACK(shellContext, 0x1001, dlt_shell_injection_callback);