forked from UnitexGramLab/unitex-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActivityLoggerPlugCallback.h
184 lines (130 loc) · 6.89 KB
/
ActivityLoggerPlugCallback.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
* Unitex
*
* Copyright (C) 2001-2018 Université Paris-Est Marne-la-Vallée <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*
*/
/*
* File created and contributed by Gilles Vollant (Ergonotics SAS)
* as part of an UNITEX optimization and reliability effort
*
* additional information: http://www.ergonotics.com/unitex-contribution/
* contact : [email protected]
*
*/
#ifndef _ACTIVITY_LOGGER_PLUG_CALLBACK_INCLUDED
#define _ACTIVITY_LOGGER_PLUG_CALLBACK_INCLUDED 1
#include "AbstractCallbackFuncModifier.h"
#include "ActivityLogger.h"
#include "Af_stdio.h"
#include "UnitexTool.h"
#ifdef __cplusplus
#ifndef HAS_UNITEX_NAMESPACE
#define HAS_UNITEX_NAMESPACE 1
#endif
namespace unitex {
extern "C" {
#endif
/* use this header to define an Unitex logger
Reading and understanding AbstractFilePlugCallback.h before
this using this file is suggested
An logger is a set of callback called before and after starting an UnitexTool,
and before and after opening or closing file.
There is also a callback to capture standard output (stdout and stderr)
*/
/* there fopen callback are called when an Unitex tool open a file
* In the Unitex context, MODE is one of these value :
* - "rb" : open the file in read only mode
* - "wb" : open the file in write only mode (the previous file is erased, if exist)
* - "r+b" or "ab" : open the file in read and write mode ("ab" mean append)
*/
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_before_af_fopen)(const char* name,const char* MODE,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_after_af_fopen)(const char* name,const char* MODE,ABSTRACTFILE*,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_before_af_fclose)(ABSTRACTFILE*,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_after_af_fclose)(ABSTRACTFILE*,int,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_before_af_rename)(const char* name1,const char* name2,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_after_af_rename)(const char* name1,const char* name2,int,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_before_af_copy)(const char* name1,const char* name2,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_after_af_copy)(const char* name1,const char* name2,int,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_before_af_remove)(const char* name,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_after_af_remove)(const char* name,int,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_before_af_remove_folder)(const char* name, void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_after_af_remove_folder)(const char* name, int, void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_before_calling_tool)(mainFunc*,int argc,char* const argv[],void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_after_calling_tool)(mainFunc*,int argc,char* const argv[],int,void* privateLoggerPtr);
/* two optional (can be just NULL) callbacks to initialize and uninitialize the logger */
typedef int (ABSTRACT_CALLBACK_UNITEX* t_fnc_Init_Logger)(void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX* t_fnc_Uninit_Logger)(void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_LogOutWrite)(const void*Buf, size_t size,void* privateLoggerPtr);
typedef void (ABSTRACT_CALLBACK_UNITEX *t_fnc_LogErrWrite)(const void*Buf, size_t size,void* privateLoggerPtr);
typedef struct
{
unsigned int size_struct;
t_fnc_Init_Logger fnc_Init_Logger;
t_fnc_Uninit_Logger fnc_Uninit_Logger;
t_fnc_before_af_fopen fnc_before_af_fopen;
t_fnc_after_af_fopen fnc_after_af_fopen;
t_fnc_before_af_fclose fnc_before_af_fclose;
t_fnc_after_af_fclose fnc_after_af_fclose;
t_fnc_before_af_rename fnc_before_af_rename;
t_fnc_after_af_rename fnc_after_af_rename;
t_fnc_before_af_copy fnc_before_af_copy;
t_fnc_after_af_copy fnc_after_af_copy;
t_fnc_before_af_remove fnc_before_af_remove;
t_fnc_after_af_remove fnc_after_af_remove;
t_fnc_before_calling_tool fnc_before_calling_tool;
t_fnc_after_calling_tool fnc_after_calling_tool;
t_fnc_LogOutWrite fnc_LogOutWrite;
t_fnc_LogErrWrite fnc_LogErrWrite;
} t_logger_func_array;
typedef struct
{
unsigned int size_struct;
t_fnc_Init_Logger fnc_Init_Logger;
t_fnc_Uninit_Logger fnc_Uninit_Logger;
t_fnc_before_af_fopen fnc_before_af_fopen;
t_fnc_after_af_fopen fnc_after_af_fopen;
t_fnc_before_af_fclose fnc_before_af_fclose;
t_fnc_after_af_fclose fnc_after_af_fclose;
t_fnc_before_af_rename fnc_before_af_rename;
t_fnc_after_af_rename fnc_after_af_rename;
t_fnc_before_af_copy fnc_before_af_copy;
t_fnc_after_af_copy fnc_after_af_copy;
t_fnc_before_af_remove fnc_before_af_remove;
t_fnc_after_af_remove fnc_after_af_remove;
t_fnc_before_calling_tool fnc_before_calling_tool;
t_fnc_after_calling_tool fnc_after_calling_tool;
t_fnc_LogOutWrite fnc_LogOutWrite;
t_fnc_LogErrWrite fnc_LogErrWrite;
t_fnc_before_af_remove_folder fnc_before_af_remove_folder;
t_fnc_after_af_remove_folder fnc_after_af_remove_folder;
} t_logger_func_array_ex_1;
/* these functions respectively add and remove logger.
you can add several logger with the same func_array callback set, but with different privateLoggerPtr
privateLoggerPtr is the parameters which can be set as the last parameter of each callback */
UNITEX_FUNC int UNITEX_CALL AddLoggerInfo(const t_logger_func_array* func_array,void* privateLoggerPtr);
UNITEX_FUNC int UNITEX_CALL RemoveLoggerInfo(const t_logger_func_array* func_array,void* privateLoggerPtr);
UNITEX_FUNC int UNITEX_CALL AddLoggerInfoEx1(const t_logger_func_array_ex_1* func_array, void* privateLoggerPtr);
UNITEX_FUNC int UNITEX_CALL RemoveLoggerInfoEx1(const t_logger_func_array_ex_1* func_array, void* privateLoggerPtr);
/* just return the number of Logger Installed */
UNITEX_FUNC int UNITEX_CALL GetNbLoggerInfoInstalled();
/**********************************************************************/
#ifdef __cplusplus
} // extern "C"
} // namespace unitex
#endif
#endif