⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.c

📁 * A ncurses user interface. * Network statistics to view the amount of packets and data in many
💻 C
字号:
/*  This file is part of sniffer, a packet capture utility and  network moniter  The author can be contacted at <mistral@stev.org>  the lastest version is avilable from   http://stev.org  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., 675 Mass Ave, Cambridge, MA 02139, USA.*/#include <stdio.h>#include <stdarg.h>#include <string.h>#include <unistd.h>#include <errno.h>#include <pthread.h>#include <curses.h>#include <fcntl.h>#include <sys/stat.h>#include "config.h"#include "locks.h"#include "gui_main.h"#include "log.h"#ifdef FTP#include "ftp.h"#endif#ifdef HTTP#include "http.h"#endif#ifdef POP3#include "pop3.h"#endif/* global file descriptors */int log_fd;pthread_mutex_t log_mutex =  PTHREAD_MUTEX_INITIALIZER;/******************************************************* Log Error *************************************************************************//* we log any errors to the log file */void log_error(const char *fmt, ...) {	char buff[1024];	int len;	va_list ap;	va_start(ap, fmt);	len = vsprintf( &buff[0], fmt, ap);	SLOCK(&log_mutex);	write(log_fd, buff, len);	SUNLOCK(&log_mutex);	va_end(ap);	return;}void log_error_nolock(const char *fmt, ...) {	char buff[1024];	int len;	va_list ap;	va_start(ap, fmt);	len = vsprintf( &buff[0], fmt, ap);	write(log_fd, buff, len);	va_end(ap);	return;}/* below here are all init functions *//******************************************************* Log start *************************************************************************//* this sets up the loggin files */void log_start( void ) {	SLOCK(&log_mutex);	if (mkdir("output", S_IRWXU) < 0)		if (errno != EEXIST) /* dont dump an error if its already there */			log_errno_nolock("mkdir: output/ ");	if (mkdir("output/tcp", S_IRWXU) < 0)		if (errno != EEXIST)			log_errno_nolock("mkdir: output/tcp ");#ifdef DEBUG	log_fd = open("output/log",O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR);	if (log_fd < 0)		log_errno_nolock("(output/log) open: ");#else	/* if we are not in debug mode we append to the file not tuncate it */	log_fd = open("output/log", O_CREAT|O_APPEND|O_WRONLY, S_IRUSR|S_IWUSR);	if (log_fd < 0)		log_errno_nolock("(output/log) open: ");#endif	SUNLOCK(&log_mutex);#ifdef FTP	ftp_open();#endif#ifdef HTTP	http_open();#endif#ifdef POP3	pop3_open();#endif	return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -