亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? apmd.c

?? 電源管理程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* apmd.c -- APM event-monitoring daemon * Created: Mon Jan  8 14:29:18 1996 by faith@acm.org * Revised: Fri Dec 26 21:38:28 1997 by faith@acm.org * Copyright 1996, 1997 Rickard E. Faith (faith@acm.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, 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. * * Changes to support pre_suspend, post_resume and low_battery commands * based on patches from Bjoern Kriews (bkr@cut.de), 1996/12/24. * *//* * Changes to support ac_offline, ac_online commands to * execute when the power status changes. * 1999/2/24  J.D. Smith - comments to jdsmith@alum.mit.edu. * This is useful to set hard drive spindown rates and other * configureable power saving options when the ac cord is  * inserted or removed.   * * New options:                              long form: *  -a ac_online_cmd                         ac_online *  -b ac_offline_cmd                        ac_offline *//* * Changes to support centralized dispatch routines, generalized logging, * general code cleanup, add support for apm_reject and APM_CAPABILITY_CHANGE. * Craig Markwardt, craigm@lheamail.gsfc.nasa.gov, 1999 May 21 *//* * Reduced spurious and repeated syslog messages, as well as the number of * times the proxy gets called during charging/discharging.  Minor cleanup and * commenting.  Documentation updated.  Power status reporting now goes by AC * status only. * - David Brownell, db@post.harvard.edu, 14 June 1999 */#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <getopt.h>#include <time.h>#include <syslog.h>#include <signal.h>#include <paths.h>#include <sys/ioctl.h>#include <sys/stat.h>#include "apm.h"#include <errno.h>#include <string.h>#include <sys/wait.h>#include <errno.h>#include <fcntl.h>#define APM_TRACE 1	/* enable to compile in debug tracing */#ifdef APM_TRACE#define ADEBUG(lev,args...) \    if (APM_TRACE>=lev) syslog(LOG_DEBUG, __FUNCTION__ ": " args)#else#define ADEBUG(args...)#endif#define PID_FILE _PATH_VARRUN "apmd.pid"#define MAX_EVENTS   8		/* Maximum events we accept from BIOS driver */#define RESUME_HOURS 6		/* If resuming after N hours, show as days *//* These are "synthetic" APM events generated by APMD itself.  The * benefit is that we can do a simple lookup into the event dispatch * table.  (We're trusting that the APM BIOS spec doesn't get updated * to use these particular "reserved" codes for anything...) */#define APMD_START		0xad00	/* Daemon startup */#define APMD_STOP		0xad01	/* Daemon shutdown */#define APMD_BATTERY		0xad02	/* Battery charging update */#define APMD_SYNTHETIC_CHECK	0xad03	/* Check power */#define APMD_INVALID		0xad0f	/* A non-event for completeness *//* This table defines how events are handled.  For each event type, as * listed on the left, there are two entries, one for "proxy" and one * for "log".  If a proxy entry is 1, then the corresponding event * causes the user proxy program to run (zero prevents the program * from running).  Similarly, if a log entry is 1 then the * corresponding event is logged. */static int apmd_action[][3] ={				/* proxy  log */    {APM_SYS_STANDBY, 1, 1},	/* potentially too frequent */    {APM_SYS_SUSPEND, 1, 1},    {APM_NORMAL_RESUME, 1, 1},    {APM_CRITICAL_RESUME, 1, 1},    {APM_LOW_BATTERY, 1, 1},    {APM_POWER_STATUS_CHANGE, 1, 1},	/* update time -- handled by recent APM BIOS drivers, and	 * may happen too often to fork processes or log in any case */    {APM_UPDATE_TIME, 0, 0},	/* critical suspend -- no time to do anything except suspend! */    {APM_CRITICAL_SUSPEND, 0, 0},    {APM_USER_STANDBY, 1, 1},    {APM_USER_SUSPEND, 1, 1},    {APM_STANDBY_RESUME, 1, 1},	/* potentially too frequent */#ifdef APM_CAPABILITY_CHANGE    {APM_CAPABILITY_CHANGE, 1, 1},#endif    /* These are synthesized by apmd */    {APMD_START, 1, 1},    {APMD_STOP, 1, 1},    {APMD_BATTERY, 1, 1},    {APMD_SYNTHETIC_CHECK, 0, 0}};#define apmd_num_actions (sizeof(apmd_action)/(3*sizeof(int)))/* From parsing the command line: */static int verbose = 0;static int quiet = 0;static int wall = 0;static int percent_change = 5;		/* lot every 5% change */static int warn_level = 10;		/* start warning at 10% remaining */static int check_power_time = -1;	/* seconds between /proc/apm checks */static char *apmd_proxy = APMD_PROXY_NAME;/* From initialization: */static uid_t apmd_uid = 0;static int apmd_fd = -1;/* State collected during daemon operation: */static time_t pre_suspend_time = 0;	/* Time at onset of suspend/standby */static time_t post_suspend_time = 0;	/* Time upon resume suspend/standby */static int pre_suspend_percentage = 0;	/* Battery level before suspend *//* A question of notation: * MINOR CHECKPOINT - occurs whenever a notification is passed to * the daemon and a message is printed here. * The minor checkpoint reflects the last time * a log entry was printed. * Time and battery percentage are recorded. * MAJOR CHECKPOINT - occurs upon startup and APM resume functions, * or when charging/discharging is complete. * Reflects the last time a major power-related * status change occurred, especially when the time * has been disrupted by a standby or suspend. */static time_t major_checkpoint = 0;	/* Updated at init/resume/full/... */static time_t minor_checkpoint = 0;	/* Updated at power status logging */static int major_percentage = -1;static int minor_percentage = -1;static int last_charging_status = -1;#ifndef abs#define abs(a) ((a)<0?(-(a)):(a))#endif#define IS_CHARGING(i) ( ((i).battery_status == 3) || ((i).battery_flags & 8) )static void usage(void){    fprintf(stderr,	    "usage: apmd [-c seconds] [-P apmd_proxy] [-p percent] [-qVvW] "					"[-w percent] [-?]\n"					);    exit(1);}static void warn(const char *message){    FILE *str;    syslog(LOG_ALERT, "%s", message);    if (wall)    {	str = popen("wall", "w");	fprintf(str, "%s\n", message);	pclose(str);    }}static char *ac_descr (int code){    if (code == 0)	return "Battery";    else if (code == 1)	return "AC";    else if (code == 2)	return "Backup";    else	return "???";}/* Generic logging function.  Depending on the event type and dispatch * table, it may or may not be logged. */static void apmd_log(apm_event_t event, char *msg){    int i;    /* Scan through dispatch table looking for this event type */    for (i = 0; i < apmd_num_actions; i++)	if ((apm_event_t) apmd_action[i][0] == event)	    break;    /* Event is not found */    if (i == apmd_num_actions || !apmd_action[i][2])	return;    /* Success.  Log it. */    syslog(LOG_INFO, "%s", msg);}/* apmd_call_proxy() is a generic outcalling dispatcher.  It calls a * proxy program, defined by apmd_proxy, which can do further event * processing.  When the kernel APM BIOS driver supports rejection of * suspend and standby events from userland, the return code from * apmd_proxy can be used as well.  */static int apmd_call_proxy(apm_event_t event, apm_info * apmi){    const char *argv[4] = {NULL, NULL, NULL, NULL};    int i, fds[2];    pid_t pid;    char line[256];    ADEBUG(4, "0x%04x\n", event);    /* If the proxy flag is not set, then return 0 indicating that     * the event is acceptable     */    for (i = 0; i < apmd_num_actions; i++)	if ((apm_event_t) apmd_action[i][0] == event)	    break;    /* Event is not found or proxy shouldn't be called */    if (i == apmd_num_actions || !apmd_action[i][1])	return 0;    /* Check that the proxy file actually exists */    if (access(apmd_proxy, X_OK))	    return 0;	    argv[0] = apmd_proxy;        /* Add the arguments depending on event type */    switch (event)    {    case APM_SYS_STANDBY:	argv[1] = "standby";	argv[2] = "system";	break;    case APM_USER_STANDBY:	argv[1] = "standby";	argv[2] = "user";	break;    case APM_SYS_SUSPEND:	argv[1] = "suspend";	argv[2] = "system";	break;    case APM_USER_SUSPEND:	argv[1] = "suspend";	argv[2] = "user";	break;    case APM_CRITICAL_SUSPEND:	argv[1] = "suspend";	argv[2] = "critical";	break;    case APM_NORMAL_RESUME:	argv[1] = "resume";	argv[2] = "suspend";	break;    case APM_STANDBY_RESUME:	argv[1] = "resume";	argv[2] = "standby";	break;    case APM_CRITICAL_RESUME:	argv[1] = "resume";	argv[2] = "critical";	break;    case APM_LOW_BATTERY:	argv[1] = "change";	argv[2] = "battery";	break;    case APM_POWER_STATUS_CHANGE:	argv[1] = "change";	argv[2] = "power";	break;    case APM_UPDATE_TIME:	argv[1] = "change";	argv[2] = "time";	break;    case APMD_START:	argv[1] = "start";	break;    case APMD_STOP:	argv[1] = "stop";	break;#ifdef APM_CAPABILITY_CHANGE    case APM_CAPABILITY_CHANGE:	argv[1] = "change";	argv[2] = "capability";	break;#endif    default:	// should never happen !!	return 0;    }    if (pipe(fds))    {	ADEBUG(0, "can't open fds for apmd_proxy: %s", strerror(errno));	return 2;    }        ADEBUG(1, "executing: '%s' '%s'", argv[0], argv[1]);    pid = fork();    if (pid == 0) /* child */    {	close(fds[0]);		/* don't let them inherit stdin.  Use /dev/null instead. */	close(0);	open("/dev/null", O_RDONLY);		/* stdout/stderr are the pipe */	dup2(fds[1], 1);	dup2(fds[1], 2);		/* don't close-on-exec */	fcntl(0, F_SETFD, 0);	fcntl(1, F_SETFD, 0);	fcntl(2, F_SETFD, 0);		execvp(argv[0], (char **)argv);	_exit(142); /* we only do this if the execvp fails */    }    else if (pid < 0) /* can't fork */    {	ADEBUG(0, "can't fork for apmd_proxy: %s", strerror(errno));	return 1;    }    else if (pid > 0) /* parent */    {	int status, retval;	ssize_t len;		close(fds[1]);	fcntl(fds[0], F_SETFL, O_RDONLY|O_NONBLOCK);		/* capture the child's output, if any, but only until they terminate */	for (;;)	{	    while ((len = read(fds[0], line, sizeof(line)-1)) > 0)	    {		line[len] = 0;		ADEBUG(1, "+ %s", line);	    }	    	    retval = waitpid(pid, &status, WNOHANG);	    if (retval == pid)		break; // finished okay	    if (retval == -1 && errno != EINTR)	    {		ADEBUG(0, "waitpid failed: %s", strerror(errno));		status = 143;		break;	    }	    	    sleep(1);	}		/* flush any remaining data */	while ((len = read(fds[0], line, sizeof(line)-1)) > 0)	{	    line[len] = 0;	    ADEBUG(1, "+ %s", line);	}		close(fds[0]);	    	/* Collect the exit code */	if (WIFEXITED(status))	{	    ADEBUG(3, "%s exited with status %d", apmd_proxy,		   WEXITSTATUS(status));	    /* Return the exit status of the program */	    return WEXITSTATUS(status);	}	else	    ADEBUG(3, "%s exited on signal %d", apmd_proxy, WTERMSIG(status));    }        return 0;}static inline int apmd_time(apm_info * apmi){    return (apmi->battery_time * (apmi->using_minutes ? 60 : 1));}/* "reset" power means that we totally reinitialize our state variables * concerning power status */static void apmd_power_reset(apm_event_t event, apm_info * apmi){    char msg[512];    ADEBUG(4, "0x%04x\n", event);    if (last_charging_status == apmi->battery_status)	return;    /* Establish a major (and minor) checkpoint */    time(&major_checkpoint);    major_percentage = apmi->battery_percentage;    minor_checkpoint = major_checkpoint;    minor_percentage = major_percentage;    last_charging_status = apmi->battery_status;    sprintf(msg, "%s: * * * (%d%% %s)",	    last_charging_status ? "Charge" : "Battery",	    apmi->battery_percentage, apm_time_nosec(apmd_time(apmi)));    apmd_log(APMD_BATTERY, msg);}/* apmd_init occurs once when the daemon starts up */static void apmd_init(apm_info * apmi){    syslog(LOG_INFO, "Version %s (APM BIOS %d.%d, Linux driver %s)",	   VERSION,	   apmi->apm_version_major, apmi->apm_version_minor,	   apmi->driver_version);    /* Call the proxy */    apmd_call_proxy(APMD_START, apmi);    /* Print battery status at beginning of run */    apmd_power_reset(APMD_START, apmi);}/* Suspend handler.  It calls the dispatcher.  The dispatcher may reject * a suspend, in which case we must reply to the kernel driver anyway. */static int apmd_suspend(apm_event_t event, apm_info * apmi){    ADEBUG(4, "0x%04x\n", event);    if (apmd_call_proxy(event, apmi))    {#ifdef APM_REJECT_ENABLED	/* If kernel rejection enabled */	ADEBUG(5, "Suspend rejected\n");	return apm_reject(apmd_fd);#endif    }    /* Record current time and battery status */    time(&pre_suspend_time);    pre_suspend_percentage = apmi->battery_percentage;    /* Logging is okay here since the sync() happens afterward */    switch (event)    {    case APM_SYS_SUSPEND:	apmd_log(event, "System Suspend");	break;    case APM_USER_SUSPEND:	apmd_log(event, "User Suspend");	break;    }    sync();    sleep(0);			/* let syslogd write the message */    sync();    return apm_suspend(apmd_fd);}/* Standby handler.  It calls the dispatcher.  The dispatcher may reject * a standby, in which case we must reply to the kernel driver anyway. */static int apmd_standby(apm_event_t event, apm_info * apmi){    ADEBUG(4, "0x%04x\n", event);    if (apmd_call_proxy(event, apmi))    {#ifdef APM_REJECT_ENABLED	ADEBUG(5, "Standby rejected\n");	return apm_reject(apmd_fd);#endif    }    /* Record current time and battery status */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品在线免费观看| 精品一区二区免费看| 丝袜a∨在线一区二区三区不卡| 美腿丝袜亚洲色图| 色哟哟一区二区在线观看| 精品国产区一区| 性做久久久久久久免费看| 丁香一区二区三区| 欧美一区二区三区在线视频| 亚洲精品欧美在线| 粉嫩一区二区三区性色av| 欧美xxx久久| 亚洲国产精品久久人人爱| 99视频一区二区| 久久久久久久综合| 激情综合网av| 精品国内二区三区| 日本亚洲三级在线| 欧美精品乱码久久久久久按摩 | 精品一区二区三区影院在线午夜 | 三级在线观看一区二区 | 精品国产一区a| 免费在线观看日韩欧美| 欧美日韩精品系列| 午夜精品久久久久久久蜜桃app| 99re这里只有精品首页| 国产精品欧美一区二区三区| 国产另类ts人妖一区二区| 欧美精品一区二区在线播放| 国精产品一区一区三区mba视频 | 日韩激情视频在线观看| 欧美色老头old∨ideo| 亚洲小少妇裸体bbw| 在线观看欧美黄色| 五月天欧美精品| 日韩欧美卡一卡二| 精品亚洲成a人| 欧美韩日一区二区三区四区| av日韩在线网站| 一区二区三区四区精品在线视频| 91高清在线观看| 香蕉乱码成人久久天堂爱免费| 欧美日免费三级在线| 日韩av一区二区在线影视| 精品国产一区二区三区忘忧草| 国内精品不卡在线| 国产精品国模大尺度视频| 91影视在线播放| 亚洲国产裸拍裸体视频在线观看乱了| 在线免费观看日本欧美| 日本成人在线电影网| 精品对白一区国产伦| 99热这里都是精品| 亚洲综合一二三区| 精品第一国产综合精品aⅴ| 国产成人在线观看| 亚洲欧美怡红院| 制服丝袜日韩国产| 国产精品一二三四区| 中文字幕日韩av资源站| 欧美午夜一区二区三区免费大片| 男人的天堂亚洲一区| 国产精品系列在线| 91精品欧美久久久久久动漫| 成人一区二区三区中文字幕| 亚洲福利国产精品| 日本欧美一区二区| 国产免费成人在线视频| 欧美视频自拍偷拍| 国产成人精品影院| 同产精品九九九| 国产精品美女一区二区| 欧美一区二区免费| 一本大道av伊人久久综合| 麻豆久久一区二区| 亚洲精品久久久蜜桃| 2023国产精品视频| 欧美日韩国产高清一区二区| 成人午夜精品一区二区三区| 日韩精品电影一区亚洲| 亚洲免费观看高清完整| 精品成人a区在线观看| 欧美自拍偷拍一区| av男人天堂一区| 国产福利一区二区三区视频在线| 性做久久久久久免费观看欧美| 国产精品久久久久桃色tv| 欧美大胆一级视频| 欧美精品v国产精品v日韩精品| 高清视频一区二区| 国产精品一区二区视频| 蜜臀av在线播放一区二区三区| 洋洋av久久久久久久一区| 国产精品无码永久免费888| 欧美一区二区视频免费观看| 欧美日韩精品一区二区在线播放| 成人夜色视频网站在线观看| 国产一区二区在线影院| 老司机精品视频一区二区三区| 亚洲高清免费在线| 亚洲一区二区在线观看视频| 亚洲猫色日本管| **网站欧美大片在线观看| 欧美国产精品专区| 国产精品日韩成人| 国产精品不卡一区| 国产精品久久久久一区二区三区| 久久久不卡网国产精品一区| 精品日韩一区二区| 久久影院电视剧免费观看| 久久一区二区三区四区| 欧美va日韩va| 337p粉嫩大胆色噜噜噜噜亚洲| 日韩欧美亚洲一区二区| 精品国产伦一区二区三区观看方式 | 欧美日韩免费在线视频| 欧美亚一区二区| 欧美人妖巨大在线| 6080亚洲精品一区二区| 91精品欧美久久久久久动漫| 日韩无一区二区| 久久九九久精品国产免费直播| 欧美激情一区二区三区蜜桃视频| 色哟哟国产精品| 日韩欧美国产综合在线一区二区三区| 96av麻豆蜜桃一区二区| av激情成人网| 色婷婷香蕉在线一区二区| 日韩av中文字幕一区二区三区| 香蕉加勒比综合久久| 天天av天天翘天天综合网色鬼国产| 国产夜色精品一区二区av| 亚洲妇女屁股眼交7| av网站一区二区三区| 久久免费电影网| 蜜臀精品一区二区三区在线观看| 一本一道久久a久久精品| 久久综合色之久久综合| 亚洲无线码一区二区三区| 成人免费视频网站在线观看| 日韩视频免费观看高清完整版 | 国产丝袜欧美中文另类| 无码av中文一区二区三区桃花岛| av中文字幕亚洲| 国产欧美日产一区| 韩国毛片一区二区三区| 91麻豆精品国产91久久久久久| 亚洲精品日韩一| 91免费观看国产| 亚洲丝袜美腿综合| 成人一级视频在线观看| 国产色爱av资源综合区| 激情图区综合网| 欧美xxxxx牲另类人与| 免费成人在线视频观看| 欧美精品xxxxbbbb| 日韩**一区毛片| 制服丝袜亚洲播放| 日韩二区三区四区| 337p亚洲精品色噜噜| 日韩电影在线免费看| 在线播放/欧美激情| 五月婷婷另类国产| 欧美男同性恋视频网站| 亚洲妇女屁股眼交7| 69精品人人人人| 美国十次了思思久久精品导航| 欧美一二区视频| 国产在线视频一区二区三区| 欧美精品一区二区精品网| 国产精品综合在线视频| 欧美激情在线观看视频免费| 成人精品鲁一区一区二区| 国产精品免费视频一区| 99久久精品免费| 一区二区三区免费看视频| 欧美挠脚心视频网站| 美女看a上一区| 久久久久99精品国产片| 99v久久综合狠狠综合久久| 一个色在线综合| 7777精品伊人久久久大香线蕉超级流畅 | 久久伊99综合婷婷久久伊| 韩国精品久久久| 中文字幕中文字幕一区二区| 一本大道久久a久久综合| 亚洲成人av中文| 精品久久久久一区二区国产| 国产成人自拍网| 亚洲一区二区成人在线观看| 欧美一级电影网站| 成人在线视频一区| 亚洲成av人片在线观看无码| 日韩视频免费观看高清完整版| 国产成人在线看| 亚洲一线二线三线视频| 欧美精品一区二| 91极品美女在线| 久色婷婷小香蕉久久| 成人欧美一区二区三区|