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

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

?? wc.c

?? linux 應用開發技術詳解中的附錄源碼
?? C
字號:
/* GNU's uptime.
   Copyright (C) 1992-2002 Free Software Foundation, Inc.

   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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

/* Created by hacking who.c by Kaveh Ghazi ghazi@caip.rutgers.edu.  */

#include <config.h>
#include <getopt.h>
#include <stdio.h>

#include <sys/types.h>
#include "system.h"

#if HAVE_SYSCTL && HAVE_SYS_SYSCTL_H
# include <sys/sysctl.h>
#endif

#include "error.h"
#include "long-options.h"
#include "readutmp.h"
#include "closeout.h"

/* The official name of this program (e.g., no `g' prefix).  */
#define PROGRAM_NAME "uptime"

#define AUTHORS N_ ("Joseph Arceneaux, David MacKenzie, and Kaveh Ghazi")

int getloadavg ();

/* The name this program was run with. */
char *program_name;

static struct option const longopts[] =
{
  {NULL, 0, NULL, 0}
};

static void
print_uptime (int n, const STRUCT_UTMP *this)
{
  register int entries = 0;
  time_t boot_time = 0;
  time_t time_now;
  time_t uptime = 0;
  int updays;
  int uphours;
  int upmins;
  struct tm *tmn;
  double avg[3];
  int loads;
#ifdef HAVE_PROC_UPTIME
  FILE *fp;
  double upsecs;

  fp = fopen ("/proc/uptime", "r");
  if (fp != NULL)
    {
      char buf[BUFSIZ];
      int res;
      char *b = fgets (buf, BUFSIZ, fp);
      if (b == buf)
	{
	  /* The following sscanf must use the C locale.  */
	  setlocale (LC_NUMERIC, "C");
	  res = sscanf (buf, "%lf", &upsecs);
	  setlocale (LC_NUMERIC, "");
	  if (res == 1)
	    uptime = (time_t) upsecs;
	}

      fclose (fp);
    }
#endif /* HAVE_PROC_UPTIME */

#if HAVE_SYSCTL && defined CTL_KERN && defined KERN_BOOTTIME
  {
    /* FreeBSD specific: fetch sysctl "kern.boottime".  */
    static int request[2] = { CTL_KERN, KERN_BOOTTIME };
    struct timeval result;
    size_t result_len = sizeof result;

    if (sysctl (request, 2, &result, &result_len, NULL, 0) >= 0)
      boot_time = result.tv_sec;
  }
#endif

  /* Loop through all the utmp entries we just read and count up the valid
     ones, also in the process possibly gleaning boottime. */
  while (n--)
    {
      if (UT_USER (this) [0]
#ifdef USER_PROCESS
	  && this->ut_type == USER_PROCESS
#endif
	  )
	{
	  ++entries;
	}
      /* If BOOT_MSG is defined, we can get boottime from utmp.  This avoids
	 possibly needing special privs to read /dev/kmem. */
#ifdef BOOT_MSG
# if HAVE_PROC_UPTIME
      if (uptime == 0)
# endif /* HAVE_PROC_UPTIME */
	if (STREQ (this->ut_line, BOOT_MSG))
	  boot_time = UT_TIME_MEMBER (this);
#endif /* BOOT_MSG */
      ++this;
    }
  time_now = time (0);
#if defined HAVE_PROC_UPTIME
  if (uptime == 0)
#endif
    {
      if (boot_time == 0)
	error (EXIT_FAILURE, errno, _("couldn't get boot time"));
      uptime = time_now - boot_time;
    }
  updays = uptime / 86400;
  uphours = (uptime - (updays * 86400)) / 3600;
  upmins = (uptime - (updays * 86400) - (uphours * 3600)) / 60;
  tmn = localtime (&time_now);
  printf (_(" %2d:%02d%s  up "), ((tmn->tm_hour % 12) == 0
				  ? 12 : tmn->tm_hour % 12),
	  /* FIXME: use strftime, not am, pm.  Uli reports that
	     the german translation is meaningless.  */
	  tmn->tm_min, (tmn->tm_hour < 12 ? _("am") : _("pm")));
  if (updays > 0)
    printf (ngettext("%d day", "%d days", updays), updays);
  printf (" %2d:%02d,  ", uphours, upmins);
  printf (ngettext ("%d user", "%d users", entries), entries);

#if defined (HAVE_GETLOADAVG) || defined (C_GETLOADAVG)
  loads = getloadavg (avg, 3);
#else
  loads = -1;
#endif

  if (loads == -1)
    putchar ('\n');
  else
    {
      if (loads > 0)
	printf (_(",  load average: %.2f"), avg[0]);
      if (loads > 1)
	printf (", %.2f", avg[1]);
      if (loads > 2)
	printf (", %.2f", avg[2]);
      if (loads > 0)
	putchar ('\n');
    }
}

/* Display the system uptime and the number of users on the system,
   according to utmp file FILENAME. */

static void
uptime (const char *filename)
{
  int n_users;
  STRUCT_UTMP *utmp_buf;
  int fail = read_utmp (filename, &n_users, &utmp_buf);

  if (fail)
    error (EXIT_FAILURE, errno, "%s", filename);

  print_uptime (n_users, utmp_buf);
}

void
usage (int status)
{
  if (status != 0)
    fprintf (stderr, _("Try `%s --help' for more information.\n"),
	     program_name);
  else
    {
      printf (_("Usage: %s [OPTION]... [ FILE ]\n"), program_name);
      printf (_("\
Print the current time, the length of time the system has been up,\n\
the number of users on the system, and the average number of jobs\n\
in the run queue over the last 1, 5 and 15 minutes.\n\
If FILE is not specified, use %s.  %s as FILE is common.\n\
\n\
"),
	      UTMP_FILE, WTMP_FILE);
      fputs (HELP_OPTION_DESCRIPTION, stdout);
      fputs (VERSION_OPTION_DESCRIPTION, stdout);
      printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
    }
  exit (status);
}

int
main (int argc, char **argv)
{
  int optc, longind;
  program_name = argv[0];
  setlocale (LC_ALL, "");
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);

  atexit (close_stdout);

  parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
		      AUTHORS, usage);

  while ((optc = getopt_long (argc, argv, "", longopts, &longind)) != -1)
    {
      switch (optc)
	{
	case 0:
	  break;

	default:
	  usage (EXIT_FAILURE);
	}
    }

  switch (argc - optind)
    {
    case 0:			/* uptime */
      uptime (UTMP_FILE);
      break;

    case 1:			/* uptime <utmp file> */
      uptime (argv[optind]);
      break;

    default:			/* lose */
      error (0, 0, _("too many arguments"));
      usage (EXIT_FAILURE);
    }

  exit (EXIT_SUCCESS);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 午夜精品一区在线观看| 久久精品一区二区三区不卡牛牛| 亚洲一区在线播放| 中文字幕人成不卡一区| 国产拍揄自揄精品视频麻豆| 久久午夜老司机| 中文字幕va一区二区三区| 精品久久久久香蕉网| 精品美女一区二区| 精品欧美一区二区三区精品久久| 国产麻豆精品95视频| 国产一区不卡在线| 丰满少妇在线播放bd日韩电影| 国产日韩欧美一区二区三区综合| 国产69精品久久久久777| 国产一区二区看久久| 国产一区二区三区免费播放| 懂色av一区二区三区蜜臀| 成人免费的视频| 在线一区二区三区四区| 日韩一二在线观看| 国产精品午夜在线| 亚洲国产精品人人做人人爽| 视频一区二区国产| 成人听书哪个软件好| 色婷婷精品久久二区二区蜜臂av | 久久五月婷婷丁香社区| 中文字幕av不卡| 亚洲另类一区二区| 久久精品国产亚洲高清剧情介绍 | 亚洲男同1069视频| 亚洲国产精品精华液网站| 国精产品一区一区三区mba视频| 亚洲最新视频在线播放| 麻豆久久久久久| 97久久精品人人澡人人爽| 欧美一级电影网站| 亚洲四区在线观看| 美女视频免费一区| 91久久精品午夜一区二区| 日韩精品一区二| 一区二区三区四区在线免费观看 | 日韩电影一区二区三区四区| 国产黄色精品视频| 欧美日韩国产一级二级| 国产精品国产自产拍在线| 亚洲 欧美综合在线网络| 丰满亚洲少妇av| 日韩免费观看高清完整版 | av中文字幕一区| 日韩一区二区三区在线| 亚洲少妇30p| 国产精品亚洲一区二区三区在线 | 久久综合精品国产一区二区三区| 欧美日韩视频在线第一区| 国产三级欧美三级| 日本视频在线一区| 日本韩国欧美在线| √…a在线天堂一区| 麻豆91精品视频| 欧美日本精品一区二区三区| 亚洲精品国产无天堂网2021 | 欧美色手机在线观看| 国产精品素人一区二区| 久久丁香综合五月国产三级网站| 七七婷婷婷婷精品国产| 91成人免费电影| 亚洲区小说区图片区qvod| 99久久精品免费看| 中文字幕制服丝袜一区二区三区 | 香蕉久久夜色精品国产使用方法| 伊人开心综合网| 97se亚洲国产综合自在线| 久久综合一区二区| 国模一区二区三区白浆| 精品国免费一区二区三区| 午夜久久久久久久久| 在线成人午夜影院| 日本欧美久久久久免费播放网| 国产精品自在在线| 久久影院视频免费| 国产精品亚洲一区二区三区在线 | 色婷婷国产精品久久包臀| 18欧美乱大交hd1984| 色综合久久99| 一区二区三区精品久久久| 色哟哟国产精品| 午夜精品一区二区三区电影天堂| 国产一区二区精品久久99| 久久九九99视频| 风间由美一区二区av101 | 日韩美女在线视频| 国精产品一区一区三区mba视频| 成人午夜又粗又硬又大| 国产精品视频一二| 色天使久久综合网天天| 亚洲大片在线观看| 日韩视频永久免费| 不卡影院免费观看| 亚洲国产精品一区二区久久| 日韩免费视频线观看| 成人高清免费观看| 五月天久久比比资源色| 久久夜色精品国产噜噜av| 91丝袜国产在线播放| 亚洲大片免费看| 欧美国产1区2区| 欧美日韩不卡一区| 成人免费av网站| 日韩av高清在线观看| 中文字幕免费观看一区| 欧美日韩aaaaa| 成人高清免费观看| 久久精品国产一区二区三区免费看 | 亚欧色一区w666天堂| 久久亚洲捆绑美女| 91片黄在线观看| 免费在线欧美视频| 一区二区久久久久| 精品国产乱码久久久久久1区2区| 日韩1区2区3区| 中文字幕五月欧美| 久久综合给合久久狠狠狠97色69| 日韩中文字幕不卡| 国产精品第四页| 久久久www成人免费无遮挡大片| 日本一道高清亚洲日美韩| 国产欧美一区在线| 日韩三级av在线播放| 欧美午夜免费电影| heyzo一本久久综合| 蜜臀av性久久久久蜜臀aⅴ流畅| 91精品国产一区二区人妖| 成人激情图片网| 国产精品一区三区| 国模大尺度一区二区三区| 视频一区二区中文字幕| 亚洲成人精品一区二区| 一区二区三区在线播| 椎名由奈av一区二区三区| 欧美国产1区2区| 国产精品无码永久免费888| 久久久精品国产免费观看同学| 成人动漫视频在线| 国产成人av电影| 国产成人免费av在线| 成人一区二区视频| 成人一区二区三区中文字幕| 成人网在线播放| proumb性欧美在线观看| 成人精品小蝌蚪| 成人一道本在线| 99精品欧美一区二区三区小说 | 久久99精品网久久| 青娱乐精品视频| 五月天亚洲精品| 日本vs亚洲vs韩国一区三区二区 | 国产成人午夜99999| 高清不卡一二三区| 国产高清不卡一区二区| 成人涩涩免费视频| av成人动漫在线观看| 欧美性猛交xxxxxxxx| 欧美美女喷水视频| 欧美成人伊人久久综合网| 久久久久久久久久久电影| 国产精品美日韩| 一区二区三区四区不卡视频| 天堂成人国产精品一区| 日本欧美一区二区三区| 国产激情一区二区三区| 91免费国产在线观看| 欧美亚洲丝袜传媒另类| 91精品国产高清一区二区三区蜜臀| 成人妖精视频yjsp地址| 色偷偷成人一区二区三区91| 337p亚洲精品色噜噜| 久久综合色婷婷| 亚洲日本在线天堂| 日韩高清在线观看| 成人毛片在线观看| 欧美精品xxxxbbbb| 国产精品免费免费| 亚洲国产中文字幕| 国产一区二区剧情av在线| 99在线精品免费| 日韩久久精品一区| 一区二区在线免费| 国产九九视频一区二区三区| 欧美日韩一区 二区 三区 久久精品| 99久久精品免费看国产免费软件| 精品亚洲porn| 91国产免费观看| 久久久久久免费网| 亚洲成人av一区二区三区| 成人91在线观看| 日韩美女一区二区三区四区| 亚洲黄色片在线观看| 国产乱子伦视频一区二区三区|