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

📄 debug_switch.c

📁 在SCO UNIX制定界面程序 可根据文件配制菜单,而不必修改源程序,非常方便
💻 C
字号:
#include <stdio.h>
#include <curses.h>
#include <varargs.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/timeb.h>
#include <fcntl.h>
#include <errno.h>

#include "all.h"
#include "tool.h"
#include "macro_def.h"

#define	DEBUG_CONFIG_FILE	"DEBUG_CONFIG"

int DebugSwitch()
{
	WINDOW *wMyWin;
	char	sScreen[128];
	FILE	*fp;
	struct	termio stdin_term;
	struct	termio stdout_term;
	char	sDebugFile[128];

	sprintf( sDebugFile, "%s/etc/%s", getenv( "HOME" ), DEBUG_CONFIG_FILE );
	sprintf(sScreen, "/tmp/.debug_switch.%d", getpid());
	scr_dump(sScreen);

	DispBelow("日志开关");
	clear_wline(stdscr, LINES-1);
	wMyWin = newwin(18, 80, 3, 0);
	mvwprintw(wMyWin, 0, 0, "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
	wrefresh(wMyWin);

	ioctl(0, TCGETA, &stdin_term);
	ioctl(1, TCGETA, &stdout_term);

	if ( yorn( wMyWin, 4, "是否打开系统日志跟踪开关?", "1.是", "2,否", 0, 0 ) ) {
		if ( tConfig_SetConfValue( sDebugFile, 0, "DEBUG_SWITCH", "HEAD", "0" ) < 0 ){
			h_prompt( LINES - 1, 1, "关闭系统日志跟踪开关失败, 按任意键继续...", 1, 2 );
			return ( -1 );
		}

		h_prompt( LINES - 1, 1, "关闭系统日志跟踪开关成功, 按任意键继续...", 1, 2 );
	}

	else {
		if ( tConfig_SetConfValue( sDebugFile, 0, "DEBUG_SWITCH", "HEAD", "1" ) < 0 ){
			h_prompt( LINES - 1, 1, "打开系统日志跟踪开关失败, 按任意键继续...", 1, 2 );
			return( -1 );
		}

		h_prompt( LINES - 1, 1, "打开系统日志跟踪开关成功, 按任意键继续...", 1, 2 );
	}
	
	ioctl(0, TCSETAW, &stdin_term);
	ioctl(1, TCSETAW, &stdout_term);

	scr_restore(sScreen);
	unlink(sScreen);
	touchwin(curscr);
	wrefresh(curscr);
	return(0);
}

⌨️ 快捷键说明

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