[prev in list] [next in list] [prev in thread] [next in thread] 

List:       klik-devel
Subject:    [klik-devel] [klikclient commit] r1649 - in
From:       codesite-noreply () google ! com
Date:       2008-08-21 14:28:25
Message-ID: 001636417a853fc3870454f922d0 () google ! com
[Download RAW message or body]

Author: cristian.debian
Date: Thu Aug 21 07:28:10 2008
New Revision: 1649

Added:
    branches/cristian/fusioniso/fusioniso/src/debug.c
    branches/cristian/fusioniso/fusioniso/src/debug.h
Modified:
    branches/cristian/fusioniso/fusioniso/configure.ac
    branches/cristian/fusioniso/fusioniso/src/Makefile.am
    branches/cristian/fusioniso/fusioniso/src/fusemain.c

Log:
new debug files and functions:
   - debug.c and debug.h
   - FSDEBUG(...) print debug info to stderr or file
   - FSWARNING(...) print a single message to stderr

option '-t' changed behavior:
   - debug is disabled by default
   - use ./configure --enable-debug to enable print debug messages to stderr
   - if you enable debug at configure time, '-t file' option will print all
     debug messages to file instead of stderr


Modified: branches/cristian/fusioniso/fusioniso/configure.ac
==============================================================================
--- branches/cristian/fusioniso/fusioniso/configure.ac	(original)
+++ branches/cristian/fusioniso/fusioniso/configure.ac	Thu Aug 21 07:28:10  
2008
@@ -68,6 +68,14 @@
  AC_FUNC_UTIME_NULL
  AC_CHECK_FUNCS([atexit ftruncate getmntent memset mkdir nl_langinfo  
realpath rmdir setlocale strdup strerror strstr utime])

+AC_ARG_ENABLE(
+	[debug],
+	AS_HELP_STRING([--enable-debug], [Enable debug functionalities]),
+	[if test x$enableval != "xno"; then enable_debug=yes ; else  
enable_debug=no; fi],
+	[enable_debug=no]
+)
+AM_CONDITIONAL([ENABLE_DEBUG], [test x$enable_debug = "xyes"])
+
  AC_CONFIG_FILES([Makefile
  		 linux/Makefile
                   man/Makefile

Modified: branches/cristian/fusioniso/fusioniso/src/Makefile.am
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/Makefile.am	(original)
+++ branches/cristian/fusioniso/fusioniso/src/Makefile.am	Thu Aug 21  
07:28:10 2008
@@ -2,7 +2,11 @@

  DEVELFLAGS =

-COMMONSOURCES = fusemain.c fs.c isofs.c
+if ENABLE_DEBUG
+DEVELFLAGS += -D_DEBUG
+endif
+
+COMMONSOURCES = fusemain.c fs.c isofs.c debug.c

  AM_CFLAGS = $(GLIB2_CFLAGS) $(FUSE_CFLAGS) -Wall #-ggdb
  AM_LDFLAGS = -module -avoid-version -export-dynamic
@@ -12,7 +16,7 @@
  bin_PROGRAMS = fusioniso
  mod_LTLIBRARIES = umfuse_fusioniso.la

-noinst_HEADERS = fs.h isofs.h
+noinst_HEADERS = fs.h isofs.h debug.h

  fusioniso_SOURCES = $(COMMONSOURCES)
  fusioniso_LDFLAGS = $(GLIB2_LIBS) $(FUSE_LIBS) -lz -lpthread

Added: branches/cristian/fusioniso/fusioniso/src/debug.c
==============================================================================
--- (empty file)
+++ branches/cristian/fusioniso/fusioniso/src/debug.c	Thu Aug 21 07:28:10  
2008
@@ -0,0 +1,51 @@
+/*
+ *  
-----------------------------------------------------------------------------
+ *
+ *   Copyright (C) 2008 by Cristian Greco <cgreco at cs.unibo.it>
+ *
+ *  
-----------------------------------------------------------------------------
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program 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 General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ *  
-----------------------------------------------------------------------------
+ */
+
+#ifndef _DEBUG_C_
+#define _DEBUG_C_
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include "debug.h"
+
+
+FILE *outfile=NULL;
+
+int debug_outfile(const char *path)
+{
+	outfile=fopen(path,"w");
+	if (!outfile) {
+		fprintf(stderr,"%s: cannot open output file %s (%s)",
+					PACKAGE_NAME,path,strerror(errno));
+		return -1;
+	} else {
+		return 0;
+	}
+}
+
+
+
+#endif /* _DEBUG_C_  */

Added: branches/cristian/fusioniso/fusioniso/src/debug.h
==============================================================================
--- (empty file)
+++ branches/cristian/fusioniso/fusioniso/src/debug.h	Thu Aug 21 07:28:10  
2008
@@ -0,0 +1,63 @@
+/*
+ *  
-----------------------------------------------------------------------------
+ *
+ *   Copyright (C) 2008 by Cristian Greco <cgreco at cs.unibo.it>
+ *
+ *  
-----------------------------------------------------------------------------
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program 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 General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ *  
-----------------------------------------------------------------------------
+ */
+
+#ifndef _DEBUG_H_
+#define _DEBUG_H_
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+extern FILE *outfile;
+#define OUTFILE (outfile ? outfile : stderr)
+
+
+#ifdef _DEBUG
+
+#define FSDEBUG(...) \
+	do { \
+		 
fprintf(OUTFILE,"[%d] %s:%d %s(): ",getpid(),__FILE__,__LINE__,__func__); \
+		fprintf(OUTFILE,__VA_ARGS__); \
+		fprintf(OUTFILE,"\n"); \
+	} while (0);
+
+#define FSWARNING(...) \
+	do { \
+		fprintf(stderr,"%s: ",PACKAGE_NAME); \
+		fprintf(stderr,__VA_ARGS__); \
+		fprintf(stderr,"\n"); \
+	} while (0);
+
+#else /* !_DEBUG */
+
+#define FSDEBUG(...)
+#define FSWARNING(...)
+
+#endif
+
+
+int debug_outfile(const char *path);
+
+#endif /* _DEBUG_H_ */

Modified: branches/cristian/fusioniso/fusioniso/src/fusemain.c
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/fusemain.c	(original)
+++ branches/cristian/fusioniso/fusioniso/src/fusemain.c	Thu Aug 21  
07:28:10 2008
@@ -61,6 +61,7 @@

  #include "fs.h"
  #include "isofs.h"
+#include "debug.h"

  #ifdef __GNUC__
  # define UNUSED(x) x __attribute__((unused))
@@ -534,18 +535,21 @@
      }

      char c;
-    while ((c = getopt(argc, argv, "+npuhtgc:b:B:d:")) > 0)
+    while ((c = getopt(argc, argv, "+npuht:gc:b:B:d:")) > 0)
      {
          switch (c)
          {
              case 'g':
                  extern_glibc = true;
                  break;
-
+#ifdef _DEBUG
              case 't':
-                extern_debug = true;
+                //extern_debug = true;
+		if (optarg)
+			if (debug_outfile(optarg)<0)
+				exit(EXIT_FAILURE);
                  break;
-
+#endif
              case 'n':
                  maintain_mtab = 0;
                  break;
_______________________________________________
klik-devel mailing list
klik-devel@kde.org
https://mail.kde.org/mailman/listinfo/klik-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic