DLT_CSTRING implementation non verbose mode.
[profile/ivi/dlt-daemon.git] / include / dlt / dlt_filetransfer.h
1 /**
2  * @licence app begin@
3  * Copyright (C) 2012  BMW AG
4  *
5  * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
6  *
7  * Contributions are licensed to the GENIVI Alliance under one or more
8  * Contribution License Agreements.
9  *
10  * \copyright
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/.
14  *
15  * \file dlt_filetransfer.h
16  * For further information see http://www.genivi.org/.
17  * @licence end@
18  */
19
20 #include <limits.h>                     /* Needed for LONG_MAX */
21 #include <sys/stat.h>           /* Needed for struct stat st*/
22 #include "dlt.h"                /* Needed for DLT Logs */
23 #include <signal.h>     /* Signal handling */
24 #include "errno.h"
25
26
27 //! Error code for dlt_user_log_file_complete
28 #define DLT_FILETRANSFER_ERROR_FILE_COMPLETE -300
29 //! Error code for dlt_user_log_file_complete
30 #define DLT_FILETRANSFER_ERROR_FILE_COMPLETE1 -301
31 //! Error code for dlt_user_log_file_complete
32 #define DLT_FILETRANSFER_ERROR_FILE_COMPLETE2 -302
33 //! Error code for dlt_user_log_file_complete
34 #define DLT_FILETRANSFER_ERROR_FILE_COMPLETE3 -303
35 //! Error code for dlt_user_log_file_head
36 #define DLT_FILETRANSFER_ERROR_FILE_HEAD -400
37 //! Error code for dlt_user_log_file_data
38 #define DLT_FILETRANSFER_ERROR_FILE_DATA -500
39 //! Error code for dlt_user_log_file_data
40 #define DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED -501
41 //! Error code for dlt_user_log_file_end
42 #define DLT_FILETRANSFER_ERROR_FILE_END -600
43 //! Error code for dlt_user_log_file_infoAbout
44 #define DLT_FILETRANSFER_ERROR_INFO_ABOUT -700
45 //! Error code for dlt_user_log_file_packagesCount
46 #define DLT_FILETRANSFER_ERROR_PACKAGE_COUNT -800
47
48
49 //!Transfer the complete file as several dlt logs.
50 /**This method transfer the complete file as several dlt logs. At first it will be checked that the file exist.
51  * In the next step some generic informations about the file will be logged to dlt.
52  * Now the header will be logged to dlt. See the method dlt_user_log_file_header for more informations.
53  * Then the method dlt_user_log_data will be called with the parameter to log all packages in a loop with some timeout.
54  * At last dlt_user_log_end is called to signal that the complete file transfer was okey. This is important for the plugin of the dlt viewer. 
55  * @param fileContext Specific context to log the file to dlt
56  * @param filename Absolute file path
57  * @param deleteFlag Flag if the file will be deleted after transfer. 1->delete, 0->notDelete
58  * @param timeout Timeout in ms to wait between some logs. Important that the FIFO of dlt will not be flooded with to many messages in a short period of time.
59  * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
60  */
61 extern int dlt_user_log_file_complete(DltContext *fileContext, const char *filename, int deleteFlag, int timeout);
62
63
64 //!This method gives information about the number of packages the file have
65 /**Every file will be divided into several packages. Every package will be logged as a single dlt log.
66  * The number of packages depends on the BUFFER_SIZE.
67  * At first it will be checked if the file exist. Then the file will be divided into
68  * several packages depending on the buffer size.
69  * @param fileContext Specific context to log the file to dlt
70  * @param filename Absolute file path
71  * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
72  */
73 extern int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filename);
74
75
76 //!Logs specific file inforamtions to dlt
77 /**The filename, file size, file serial number and the number of packages will be logged to dlt.
78  * @param fileContext Specific context
79  * @param filename Absolute file path
80  * @return Returns 0 if everything was okey.If there was a failure value < 0 will be returned.
81  */
82  extern int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename);
83
84
85  //!Transfer the head of the file as a dlt logs.
86  /**The head of the file must be logged to dlt because the head contains inforamtion about the file serial number,
87   * the file name, the file size, package number the file have and the buffer size.
88   * All these informations are needed from the plugin of the dlt viewer.
89   * See the Mainpages.c for more informations.
90   * @param fileContext Specific context to log the file to dlt
91   * @param filename Absolute file path
92   * @param alias Alias for the file. An alternative name to show in the receiving end
93   * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
94   */
95  extern int dlt_user_log_file_header_alias(DltContext *fileContext, const char *filename, const char *alias);
96
97  //!Transfer the head of the file as a dlt logs.
98  /**The head of the file must be logged to dlt because the head contains inforamtion about the file serial number,
99   * the file name, the file size, package number the file have and the buffer size.
100   * All these informations are needed from the plugin of the dlt viewer.
101   * See the Mainpages.c for more informations.
102   * @param fileContext Specific context to log the file to dlt
103   * @param filename Absolute file path
104   * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
105   */
106  extern int dlt_user_log_file_header(DltContext *fileContext, const char *filename);
107
108
109 //!Transfer the content data of a file.
110 /**See the Mainpages.c for more informations.
111  * @param fileContext Specific context to log the file to dlt
112  * @param filename Absolute file path
113  * @param packageToTransfer Package number to transfer. If this param is LONG_MAX, the whole file will be transferred with a specific timeout
114  * @param timeout Timeout to wait between dlt logs. Important because the dlt FIFO should not be flooded. Default is defined by MIN_TIMEOUT. The given timeout in ms can not be smaller than MIN_TIMEOUT.
115  * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
116  */
117 extern int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int packageToTransfer, int timeout);
118
119
120
121 //!Transfer the end of the file as a dlt logs.
122 /**The end of the file must be logged to dlt because the end contains inforamtion about the file serial number.
123  * This informations is needed from the plugin of the dlt viewer.
124  * See the Mainpages.c for more informations.
125  * @param fileContext Specific context to log the file to dlt
126  * @param filename Absolute file path
127  * @param deleteFlag Flag to delete the file after the whole file is transferred (logged to dlt).1->delete,0->NotDelete
128  * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
129  */
130 extern int dlt_user_log_file_end(DltContext *fileContext, const char *filename,int deleteFlag);