ec_debug.c
上传用户:nilegod
上传日期:2007-01-08
资源大小:220k
文件大小:3k
- /*
- ettercap -- debug module
- Copyright (C) 2001 ALoR <alor@users.sourceforge.net>, NaGA <crwm@freemail.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.
- */
- #include "include/ec_main.h"
- #ifdef DEBUG
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdarg.h>
- #ifdef HAVE_SYS_UTSNAME_H
- #include <sys/utsname.h>
- #ifdef LINUX
- #include <features.h>
- #endif
- #endif
- #ifndef DEBUG_FILE
- #define DEBUG_FILE "ettercap_debug.log"
- #endif
- FILE *debug_dev;
- void Debug_Init(void);
- void Debug_Close(void);
- void Debug_msg(char *message, ...);
- //----------------------------
- void Debug_Init(void)
- {
- struct utsname buf;
- if ((debug_dev = fopen (DEBUG_FILE, "a")) < 0)
- {
- printf ("Couldn't open DEBUG FILE!n");
- exit (0);
- }
- else
- {
- #ifdef HAVE_SYS_UTSNAME_H
- uname(&buf);
- #ifdef LINUX
- fprintf (debug_dev, "nn-> %s %s running on %s %s glibc %d.%dnn", PROGRAM, VERSION, buf.sysname, buf.release, __GLIBC__, __GLIBC_MINOR__);
- #else
- fprintf (debug_dev, "nn-> %s %s running on %s %snn", PROGRAM, VERSION, buf.sysname, buf.release);
- #endif
- #endif
- fprintf (debug_dev, "DEVICE OPENED FOR %s DEBUGGINGnn", PROGRAM);
- fflush(debug_dev);
- exit_func(Debug_Close);
- }
- }
- void Debug_Close(void)
- {
- fprintf (debug_dev, "nnDEBUGGING DEVICE FOR %s WAS CLOSEDnn", program_argv0);
- fclose (debug_dev);
- }
- void Debug_msg(char *message, ...)
- {
- va_list ap;
- char debug_message[strlen(message)+2];
- fprintf (debug_dev, "%st", program_argv0);
- strcpy(debug_message, message); // for backward compatibility
- strcat(debug_message, "n");
- #ifndef HAVE_VPRINTF
- #errors "Must have vfprintf()."
- #endif
- va_start(ap, message);
- vfprintf(debug_dev, debug_message, ap);
- va_end(ap);
- fflush(debug_dev);
- }
- #endif
- /* EOF */