Main Page | Data Structures | File List | Data Fields | Globals

debug.c

Go to the documentation of this file.
00001 /**
00002  * This file is part of alarmd
00003  *
00004  * Contact Person: David Weinehall <david.weinehall@nokia.com>
00005  *
00006  * Copyright (C) 2006 Nokia Corporation
00007  * alarmd and libalarm are free software; you can redistribute them
00008  * and/or modify them under the terms of the GNU Lesser General Public
00009  * License version 2.1 as published by the Free Software Foundation.
00010  *
00011  * alarmd and libalarm are distributed in the hope that they 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 software; if not, write to the Free
00018  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00019  * 02110-1301 USA
00020  */
00021 
00022 #include <glib/gtypes.h>
00023 #include <stdio.h>
00024 #include <stdarg.h>
00025 #include "debug.h"
00026 
00027 static guint depth = 0;
00028 
00029 void enter_func(const char *name)
00030 {
00031         guint i;
00032         for (i = 0; i < depth; i++) {
00033                 fprintf(stderr, " ");
00034         }
00035         fprintf(stderr, "Entering %s\n", name);
00036         depth++;
00037 }
00038 
00039 void leave_func(const char *name)
00040 {
00041         guint i;
00042         depth--;
00043         for (i = 0; i < depth; i++) {
00044                 fprintf(stderr, " ");
00045         }
00046         fprintf(stderr, "Leaving %s\n", name);
00047 }
00048 
00049 void dbg(const char *func, const char *format, ...)
00050 {
00051         guint i;
00052         va_list args;
00053         for (i = 0; i < depth; i++) {
00054                 fprintf(stderr, " ");
00055         }
00056         fprintf(stderr, "*** %s: ", func);
00057         va_start(args, format);
00058         vfprintf(stderr, format, args);
00059         va_end(args);
00060         fprintf(stderr, "\n");
00061 }

Generated on Thu Dec 21 18:23:30 2006 for Alarmd by  doxygen 1.4.2