00001 /******************************************************************** 00002 00003 Copyright 2006, ACCESS Systems Americas, Inc. All rights reserved. 00004 00005 The contents of this file are subject to the Mozilla Public License Version 00006 1.1 (the "License"); you may not use this file except in compliance with 00007 the License. You may obtain a copy of the License at 00008 http://www.mozilla.org/MPL/ 00009 00010 Software distributed under the License is distributed on an "AS IS" basis, 00011 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00012 for the specific language governing rights and limitations under the 00013 License. 00014 00015 The Original Code is the entire contents of this file. 00016 00017 The Initial Developer of the Original Code is ACCESS Systems Americas, Inc. 00018 00019 Portions created by ACCESS Systems Americas, Inc. are Copyright © 2006. All 00020 Rights Reserved. 00021 00022 Contributor(s): none. 00023 00024 ********************************************************************/ 00032 #ifndef _TRACES_HELPER_H 00033 #define _TRACES_HELPER_H 00034 00035 /* ------------------------------------------------------------------- */ 00036 #include "traces_main.h" 00037 00038 /* ------------------------------------------------------------------- */ 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif /* __cplusplus */ 00042 00043 /* ------------------------------------------------------------------- */ 00044 typedef unsigned short TraceModule; 00045 typedef unsigned short TraceCode; 00046 typedef unsigned long TraceIdent; 00047 00048 typedef unsigned char TraceKind; 00049 #define TraceKind_Normal 0 00050 #define TraceKind_EOL 1 00051 #define TraceKind_Binary 2 00052 00053 #define OutputKind_HumanReadable 0 00054 #define OutputKind_Binary 1 00055 00056 typedef unsigned short TraceOpcode; 00057 #define TraceOpcode_End 0 00058 00059 #define TraceOpcode_Attributes 1 00060 #define TraceOpcode_IndentLevel 2 00061 #define TraceOpcode_ProcessID 3 00062 #define TraceOpcode_ThreadID 4 00063 #define TraceOpcode_Data 5 00064 #define TraceOpcode_TimeStamp 6 00065 #define TraceOpcode_AppName 128 00066 00067 /* ------------------------------------------------------------------- */ 00068 #define SPRINTF_BUFFER_SIZE 4096 00069 00070 /* ------------------------------------------------------------------- */ 00071 typedef struct _TTraceSendParams 00072 { 00073 TraceKind itsKind; 00074 TraceIdent itsIdent; 00075 unsigned char* itsData; 00076 size_t itsDataLen; 00077 unsigned char itsIndentLevel; 00078 unsigned long itsTimeStamp; 00079 } TTraceSendParams; 00080 00081 /* ------------------------------------------------------------------- */ 00082 typedef struct _TTracer 00083 { 00084 int itsfOpened; 00085 int itsfFirstTrace; 00086 /* 00087 itsOutputKind must be set to: 00088 OutputKind_HumanReadable if this tracer does not need binary marshalling. 00089 OutputKind_BinaryPaquet if this tracer needs binary marshalling. 00090 */ 00091 int itsOutputKind; 00092 int (*itsOpenProc)(struct _TTracer* aTracer, const char* config); 00093 void (*itsCloseProc)(struct _TTracer* aTracer); 00094 void (*itsSendProc)(struct _TTracer* aTracer, TTraceSendParams* aParams); 00095 long (*itsDisconnectedProc)(struct _TTracer* aTracer); 00096 void (*itsDestroyProc)(struct _TTracer* aTracer); 00097 } TTracer; 00098 00099 /* ------------------------------------------------------------------- */ 00100 extern TTracer* gTracer; 00101 extern int gfTracesActivated; 00102 extern int gTracesInited; 00103 extern CRITICAL_SECTION gSendCS; 00104 00105 /* ------------------------------------------------------------------- */ 00106 void Trace_SendText(TTraceSendParams* aParams, const char* aFormat, va_list anArgs); 00107 00108 /* ------------------------------------------------------------------- */ 00109 void Trace_Send(TTraceSendParams* aParams); 00110 void Trace_Close(TTracer* aTracer); 00111 00112 /* ------------------------------------------------------------------- */ 00113 #ifdef __cplusplus 00114 } 00115 #endif /* __cplusplus */ 00116 00117 /* ------------------------------------------------------------------- */ 00118 #endif /* TrHelp_h */