Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

vlogfile.h

00001 
00002 
00003 #ifndef VLOGFILE_H
00004 #define VLOGFILE_H
00005 
00006 #include <stdlib.h>
00007 #include <stdio.h>
00008 
00009 #ifdef __cplusplus
00010 extern "C" {
00011 #endif /* __cplusplus */
00012 
00013 
00014 typedef struct {
00015         const char * name;
00016         unsigned long n_lines;
00017         unsigned long n_chars;
00018         FILE * lines;
00019         FILE * dir;
00020         void *(*malloc) (size_t);
00021         void (*free) (void*);
00022 } vlogfile_t;
00023 
00024 
00025 vlogfile_t* new_vlogfile(
00026         const char * log_file_name,
00027         void *(*vlogfile_malloc) (size_t),
00028         void (*vlogfile_free) (void *));
00029 
00030 void delete_vlogfile( 
00031         vlogfile_t* vlogfile); 
00032 
00033 void vlogfile_add_line( 
00034         vlogfile_t* vlogfile, 
00035         const char * line,
00036         size_t line_length);
00037 
00038 const char * vlogfile_get_line(
00039         vlogfile_t* vlogfile,
00040         unsigned long line_number,
00041         unsigned long * line_length);
00042 
00043 void vlogfile_free_line(
00044         vlogfile_t* vlogfile,
00045         const char * line);
00046 
00047 void vlogfile_clear_log(
00048         vlogfile_t* v);
00049 
00050 FILE * vlogfile_open_snapshot(
00051         vlogfile_t* v,
00052         const char * filename);
00053 
00054 void vlogfile_dump_snapshot(
00055         vlogfile_t* v,
00056         FILE * snapshot_file);
00057 
00058 void vlogfile_close_snapshot(
00059         vlogfile_t* v,
00060         FILE * snapshot_file);
00061 
00062 
00063 /*DEBUG LOG*/
00064 
00065 extern FILE * debug_log_file_handle;
00066 extern char * debug_log_current_time;
00067 
00068 #define FPRINTF_HEX_BUFFER(file_handle,data,length) { \
00069         unsigned int iiiii; \
00070         for(iiiii=0;iiiii<(length);iiiii++) { \
00071                 const char * HEX = "0123456789ABCDEF"; \
00072                 char t[16]; \
00073                 unsigned char c = (data)[iiiii]; \
00074                 sprintf(t,"<%c%c>", HEX[(((unsigned char)c)>>4)], HEX[(((unsigned char)c)&0x000F)]); \
00075                 fprintf(file_handle, "%s", t); \
00076                 fflush(file_handle); \
00077         } \
00078 }
00079 
00080 #if defined(DEBUG_PRINTS)
00081 
00082 #define DEBUG_LOG_PRINT_HEX_BUFFER(data,length) { \
00083         unsigned int iiiii; \
00084         for(iiiii=0;iiiii<(length);iiiii++) { \
00085                 const char * HEX = "0123456789ABCDEF"; \
00086                 char t[16]; \
00087                 unsigned char c = (data)[iiiii]; \
00088                 if(c==0x0D || c==0x0A){ \
00089                         sprintf(t,"%c", c); \
00090                 }else \
00091                 if(c<=0x1F){ \
00092                         sprintf(t,"<%c%c>", HEX[(((unsigned char)c)>>4)], HEX[(((unsigned char)c)&0x000F)]); \
00093                 }else \
00094                 if(c>=0x7F){ \
00095                         sprintf(t,"<%c%c>", HEX[(((unsigned char)c)>>4)], HEX[(((unsigned char)c)&0x000F)]); \
00096                 }else \
00097                         sprintf(t,"%c", c); \
00098                 DEBUG_LOG_PRINT_NOTIME(t); \
00099         } \
00100 }
00101 
00102 #define DEBUG_LOG_PRINT_1(item) do { \
00103         if(debug_log_file_handle != NULL) { \
00104                 fprintf(debug_log_file_handle, "%s ", debug_log_current_time); \
00105                 fprintf(debug_log_file_handle, (item)); \
00106                 fflush(debug_log_file_handle); \
00107         } \
00108 } while (0)
00109 
00110 #define DEBUG_LOG_PRINT_2(format, item) do { \
00111         if(debug_log_file_handle != NULL) { \
00112                 fprintf(debug_log_file_handle, "%s ", debug_log_current_time); \
00113                 fprintf(debug_log_file_handle, (format), (item)); \
00114                 fflush(debug_log_file_handle); \
00115         } \
00116 } while (0)
00117 
00118 #define DEBUG_LOG_PRINT_3(format, item1, item2) do { \
00119         if(debug_log_file_handle != NULL) { \
00120                 fprintf(debug_log_file_handle, "%s ", debug_log_current_time); \
00121                 fprintf(debug_log_file_handle, (format), (item1), (item2)); \
00122                 fflush(debug_log_file_handle); \
00123         } \
00124 } while (0)
00125 
00126 #define DEBUG_LOG_PRINT_4(format, item1, item2, item3) do { \
00127         if(debug_log_file_handle != NULL) { \
00128                 fprintf(debug_log_file_handle, "%s ", debug_log_current_time); \
00129                 fprintf(debug_log_file_handle, (format), (item1), (item2), (item3)); \
00130                 fflush(debug_log_file_handle); \
00131         } \
00132 } while (0)
00133 
00134 #define DEBUG_LOG_PRINT_5(format, item1, item2, item3, item4) do { \
00135         if(debug_log_file_handle != NULL) { \
00136                 fprintf(debug_log_file_handle, "%s ", debug_log_current_time); \
00137                 fprintf(debug_log_file_handle, (format), (item1), (item2), (item3), (item4)); \
00138                 fflush(debug_log_file_handle); \
00139         } \
00140 } while (0)
00141 
00142 #define DEBUG_LOG_PRINT_6(format, item1, item2, item3, item4, item5) do { \
00143         if(debug_log_file_handle != NULL) { \
00144                 fprintf(debug_log_file_handle, "%s ", debug_log_current_time); \
00145                 fprintf(debug_log_file_handle, (format), (item1), (item2), (item3), (item4), (item5)); \
00146                 fflush(debug_log_file_handle); \
00147         } \
00148 } while (0)
00149 
00150 #define DEBUG_LOG_PRINT_TODO(item) do { \
00151         if(debug_log_file_handle != NULL) { \
00152                 fprintf(debug_log_file_handle, "%s ", debug_log_current_time); \
00153                 fprintf(debug_log_file_handle, "TODO %s %d : %s\n", __FILE__, __LINE__, (item)); \
00154                 fflush(debug_log_file_handle); \
00155         } \
00156 } while (0)
00157 
00158 #define DEBUG_LOG_PRINT_HCS_BUFFER(message, prefix) do { \
00159         if(debug_log_file_handle != NULL) { \
00160                 fprintf(debug_log_file_handle, "%s %s", debug_log_current_time, prefix); \
00161                 hcs_apro_fprint_hcs_buffer(debug_log_file_handle, message); \
00162                 fflush(debug_log_file_handle); \
00163         } \
00164 } while (0)
00165 
00166 #define DEBUG_LOG_PRINT_NOTIME(item) do { \
00167         if(debug_log_file_handle != NULL) { \
00168                 fprintf(debug_log_file_handle, "%s",(item)); \
00169                 fflush(debug_log_file_handle); \
00170         } \
00171 } while (0)
00172 
00173 #define UPDATE_DEBUG_LOG_TIME() do { \
00174         time_t tmp_time; \
00175         time(&tmp_time); \
00176         strcpy(debug_log_current_time,ctime((const time_t*)&tmp_time)); \
00177         debug_log_current_time[strlen(debug_log_current_time)-strlen("\n")] = '\0'; \
00178 } while (0)
00179 
00180 #else 
00181 
00182 #define DEBUG_LOG_PRINT_HEX_BUFFER(data,length) do { (void)(data); (void)(length); } while (0);
00183 #define DEBUG_LOG_PRINT_1(item) do { ((void)(item)); } while (0)
00184 #define DEBUG_LOG_PRINT_2(format, item) do { ((void)(format)); ((void)(item));} while (0)
00185 #define DEBUG_LOG_PRINT_3(format, item1, item2) do { ((void)(format)); ((void)(item1)); ((void)(item2));} while (0)
00186 #define DEBUG_LOG_PRINT_4(format, item1, item2, item3) do { ((void)(format)); ((void)(item1)); ((void)(item2)); ((void)(item3));} while (0)
00187 #define DEBUG_LOG_PRINT_5(format, item1, item2, item3, item4) do { ((void)(format)); ((void)(item1)); ((void)(item2)); ((void)(item3)); ((void)(item4)); } while (0)
00188 #define DEBUG_LOG_PRINT_6(format, item1, item2, item3, item4, item5) do { ((void)(format)); ((void)(item1)); ((void)(item2)); ((void)(item3)); ((void)(item4)); ((void)(item5)); } while (0)
00189 #define DEBUG_LOG_PRINT_TODO(item) do { void item } while (0)
00190 #define DEBUG_LOG_PRINT_HCS_BUFFER(item, prefix) do { ((void)(item));((void)(prefix));} while (0)
00191 #define DEBUG_LOG_PRINT_NOTIME(item) do { ((void)(item)); } while (0)
00192 
00193 #define UPDATE_DEBUG_LOG_TIME() do { ; } while (0);
00194 
00195 #endif
00196 
00197 
00198 
00199 #ifdef __cplusplus
00200 } /* extern "C" */
00201 #endif /* __cplusplus */
00202 
00203 #endif /*VLOGFILE_H*/
00204 
00205 

Generated on Tue May 17 12:06:00 2005 for Autodesk DWF 3D Toolkit by  doxygen 1.4.1