~ubuntu-branches/ubuntu/lucid/gco/lucid

« back to all changes in this revision

Viewing changes to src/debug.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar (Debian packages)
  • Date: 2006-08-31 12:35:42 UTC
  • mfrom: (3.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20060831123542-mc4q70vmhci7jkx7
Tags: 0.5.0-6
Update package to the last python policy, courtesy of Pierre Habouzit
(Closes: #380807).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  GNOME Comics Organizer
3
 
  Copyright (C) 1999-2000 Maxximum Software
4
 
   
5
 
  This program is free software; you can redistribute it and/or modify
6
 
  it under the terms of the GNU General Public License as published by
7
 
  the Free Software Foundation; either version 2 of the License, or
8
 
  (at your option) any later version.
9
 
  
10
 
  This program is distributed in the hope that it will be useful,
11
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
  GNU General Public License for more details.
14
 
  
15
 
  You should have received a copy of the GNU General Public License
16
 
  along with this program; if not, write to the Free Software
17
 
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
 
*/
19
 
 
20
 
#include <stdio.h>
21
 
#include <stdarg.h>
22
 
 
23
 
void dprintf(const char *format, ...)
24
 
{
25
 
#if DEBUG
26
 
  va_list ap;
27
 
  int d;
28
 
  unsigned int i;
29
 
  char c, *s;
30
 
 
31
 
  fprintf(stderr, "*** debug : ");
32
 
  
33
 
  va_start(ap, format);
34
 
  while (*format){
35
 
 
36
 
    if (*format=='%'){
37
 
      format++;
38
 
      switch(*format++){
39
 
      case 's':           // string
40
 
        s = va_arg(ap, char *);
41
 
        fprintf(stderr, "%s", s);
42
 
        break;
43
 
      case 'x':
44
 
        i = va_arg(ap, unsigned int);
45
 
        fprintf(stderr, "%x", i);
46
 
        break;
47
 
      case 'i':
48
 
        i = va_arg(ap, unsigned int);
49
 
        fprintf(stderr, "%i", i);
50
 
        break;
51
 
      case 'd':           // int
52
 
        d = va_arg(ap, int);
53
 
        fprintf(stderr, "%d", d);
54
 
        break;
55
 
      case 'c': // char
56
 
        // need a cast here since va_arg only
57
 
        // takes fully promoted types
58
 
        c = (char) va_arg(ap, int);
59
 
        fprintf(stderr, "%c", c);
60
 
        break;
61
 
      }
62
 
    }
63
 
    else{
64
 
      putc(*format++, stderr);
65
 
    }
66
 
  }
67
 
  va_end(ap);
68
 
 
69
 
  fflush(stderr);
70
 
 
71
 
#endif
72
 
}