~ubuntu-branches/ubuntu/precise/ettercap/precise

« back to all changes in this revision

Viewing changes to src/ec_debug.c

  • Committer: Bazaar Package Importer
  • Author(s): Murat Demirten
  • Date: 2003-06-21 19:57:18 UTC
  • Revision ID: james.westby@ubuntu.com-20030621195718-qqbbfk18e1djchd9
Tags: upstream-0.6.b
ImportĀ upstreamĀ versionĀ 0.6.b

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    ettercap -- debug module
 
3
 
 
4
    Copyright (C) 2001  ALoR <alor@users.sourceforge.net>, NaGA <crwm@freemail.it>
 
5
 
 
6
    This program is free software; you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License as published by
 
8
    the Free Software Foundation; either version 2 of the License, or
 
9
    (at your option) any later version.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with this program; if not, write to the Free Software
 
18
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
 
 
20
    $Id: ec_debug.c,v 1.17 2002/07/20 09:41:25 alor Exp $
 
21
*/
 
22
 
 
23
#include <ec_main.h>
 
24
 
 
25
#ifdef DEBUG
 
26
 
 
27
#include <stdarg.h>
 
28
#ifdef HAVE_SYS_UTSNAME_H
 
29
   #include <sys/utsname.h>
 
30
   #ifdef LINUX
 
31
      #include <features.h>
 
32
   #endif
 
33
#endif
 
34
 
 
35
#ifdef HAVE_NCURSES
 
36
   #ifdef HAVE_NCURSES_H
 
37
      #include <ncurses.h>
 
38
   #else
 
39
      #include <curses.h>
 
40
   #endif
 
41
#endif
 
42
 
 
43
#ifdef CYGWIN
 
44
        #include <Packet32.h>
 
45
#endif
 
46
 
 
47
#ifndef DEBUG_FILE
 
48
   #define DEBUG_FILE "ettercap_debug.log"
 
49
#endif
 
50
 
 
51
#include <ec_version.h>
 
52
#include <ec_thread.h>
 
53
#include <ec_debug_info.h>
 
54
 
 
55
FILE *debug_dev;
 
56
 
 
57
void debug_init(void);
 
58
void debug_close(void);
 
59
 
 
60
#ifdef MACOSX
 
61
void DEBUG_MSG(char *message, ...);
 
62
#else
 
63
void debug_msg(char *message, ...);
 
64
#endif
 
65
 
 
66
//----------------------------
 
67
 
 
68
void debug_init(void)
 
69
{
 
70
#ifdef HAVE_SYS_UTSNAME_H
 
71
   struct utsname buf;
 
72
#endif
 
73
 
 
74
   if ((debug_dev = fopen (DEBUG_FILE, "w")) == NULL) {
 
75
      ERROR_MSG("Couldn't open DEBUG FILE!");
 
76
   }
 
77
   
 
78
   fprintf (debug_dev, "\n==============================================================\n\n");
 
79
   fprintf (debug_dev, "Configured with  :  %s \n\n", configure_line);
 
80
   fprintf (debug_dev, "Detected options :  NCURSES  %s \n", configure_ncurses);
 
81
   fprintf (debug_dev, "                    FORM     %s \n", configure_form);
 
82
   fprintf (debug_dev, "                    GTK+     %s \n", configure_gtk);
 
83
   fprintf (debug_dev, "                    PLUGINS  %s \n", configure_plugins);
 
84
   fprintf (debug_dev, "                    SSH      %s \n", configure_ssh);
 
85
   fprintf (debug_dev, "                    HTTPS    %s \n\n", configure_https);
 
86
   fprintf (debug_dev, "Programs path    :  wget     %s \n", WGET_PATH);
 
87
   fprintf (debug_dev, "                    openssl  %s \n", OPENSSL_PATH);
 
88
   fprintf (debug_dev, "\n==============================================================\n");
 
89
                   
 
90
   #if DEVEL_RELEASE == 1
 
91
        fprintf (debug_dev, "\n-> %s %s beta %s\n\n", PROGRAM, VERSION, RELEASE_DATE);
 
92
   #else
 
93
        fprintf (debug_dev, "\n-> %s %s\n\n", PROGRAM, VERSION);
 
94
   #endif
 
95
   #ifdef HAVE_SYS_UTSNAME_H
 
96
      uname(&buf);
 
97
      fprintf (debug_dev, "-> running on %s %s %s\n", buf.sysname, buf.release, buf.machine);
 
98
   #endif
 
99
   #if defined (__GLIBC__) && defined (__GLIBC_MINOR__)
 
100
      fprintf (debug_dev, "-> glibc version %d.%d\n", __GLIBC__, __GLIBC_MINOR__);
 
101
   #endif
 
102
   #ifdef CYGWIN
 
103
        fprintf (debug_dev, "-> packet driver version %s\n", PacketGetVersion());
 
104
   #endif
 
105
   #if defined (__GNUC__) && defined (__GNUC_MINOR__)
 
106
      fprintf (debug_dev, "-> compiled with gcc %d.%d\n", __GNUC__, __GNUC_MINOR__);
 
107
   #endif
 
108
   #ifdef HAVE_NCURSES
 
109
        #ifdef CYGWIN
 
110
                fprintf (debug_dev, "-> pdcurses %d \n", PDC_BUILD);
 
111
        #else
 
112
                fprintf (debug_dev, "-> %s\n", curses_version());
 
113
        #endif
 
114
   #endif
 
115
   fprintf (debug_dev, "\n\nDEVICE OPENED FOR %s DEBUGGING\n\n", PROGRAM);
 
116
   fflush(debug_dev);
 
117
   atexit(debug_close);
 
118
}
 
119
 
 
120
 
 
121
 
 
122
void debug_close(void)
 
123
{
 
124
   fprintf (debug_dev, "\n\nDEBUGGING DEVICE FOR %s WAS CLOSED\n\n", ECThread_getname(pthread_self()));
 
125
   fclose (debug_dev);
 
126
}
 
127
 
 
128
 
 
129
 
 
130
#ifdef MACOSX
 
131
void DEBUG_MSG(char *message, ...)
 
132
#else
 
133
void debug_msg(char *message, ...)
 
134
#endif
 
135
{
 
136
   va_list ap;
 
137
   char debug_message[strlen(message)+2];
 
138
 
 
139
   fprintf (debug_dev, "%-10s\t", ECThread_getname(pthread_self()));
 
140
 
 
141
   strlcpy(debug_message, message, sizeof(debug_message));
 
142
   strlcat(debug_message, "\n", sizeof(debug_message));
 
143
 
 
144
   va_start(ap, message);
 
145
   vfprintf(debug_dev, debug_message, ap);
 
146
   va_end(ap);
 
147
 
 
148
   fflush(debug_dev);
 
149
 
 
150
}
 
151
 
 
152
#else /* not defined DEBUG */
 
153
 
 
154
#ifdef MACOSX
 
155
   /*
 
156
    * damned MACOSX  cc compiler !!
 
157
    * it doesn't support our macro DEBUG_MSG(x, args...)
 
158
    */
 
159
 
 
160
   void DEBUG_MSG(char *message, ...);
 
161
 
 
162
   void DEBUG_MSG(char *message, ...)
 
163
   {
 
164
      return;
 
165
   }
 
166
#endif
 
167
 
 
168
#endif /* DEBUG */
 
169
 
 
170
/* EOF */
 
171
 
 
172
// vim:ts=3:expandtab
 
173