00001 /********************************************************************************** 00002 * DWLB - Debug wrapper library * 00003 * Copyright (C) 2006 Julien Dumont < ju.dumont at free.fr > * 00004 * Website : http://dwlib.free.fr * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the Free Software * 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00019 * * 00020 * http://www.gnu.org/licenses/lgpl.txt * 00021 * * 00022 * $Id: dwlib.h 12 2006-11-14 17:35:03Z julien_dumont $ * 00023 * * 00024 **********************************************************************************/ 00025 #ifndef __traceio_h 00026 #define __traceio_h 00027 00028 #include <stdio.h> 00029 #include <stdlib.h> 00030 #include <string.h> 00031 #include <sys/param.h> // use for define PATH_MAX 00032 00033 // Define the max array size for keep trace of opened files 00034 #ifndef DWLIB_MAX_FILE 00035 #define DWLIB_MAX_FILE 2048 00036 #endif 00037 00041 class DWlibTraceIO { 00042 private : 00047 typedef struct TraceIO { 00048 int id; 00049 char filename[PATH_MAX+1]; 00050 }TraceIO; 00051 00055 TraceIO traceIOarray[DWLIB_MAX_FILE]; 00056 00060 bool _check_init; 00061 00065 bool _open_abort; 00066 00070 bool _debug; 00071 00075 bool _debug_abort; 00076 00080 bool _verbose; 00081 00085 bool _close_abort; 00086 00090 bool _unlink_abort; 00091 00095 bool _check_error; 00096 00100 int _max_fd_opened; 00101 00102 public: 00108 DWlibTraceIO(); 00109 00113 ~DWlibTraceIO(); 00114 00119 void report(void); 00120 00128 void trace(int fileid, char *file); 00129 00134 void removetrace(int fileid); 00135 00142 bool check_opentrace(char *file); 00143 00148 void check_env(void); 00149 00154 int count_current_fd(void); 00155 00156 }; 00157 00158 #endif