"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "littleutils/lsysinfo.c" between
littleutils-1.2.3.tar.lz and littleutils-1.2.4.tar.lz

About: littleutils are a collection of small and simple utilities (rename files, search for duplicate files, ...).

lsysinfo.c  (littleutils-1.2.3.tar.lz):lsysinfo.c  (littleutils-1.2.4.tar.lz)
/* lsysinfo: Prints out various pieces of system information. /* lsysinfo: Prints out various pieces of system information.
Copyright (C) 2001-2020 by Brian E. Lindholm. Copyright (C) 2001-2021 by Brian E. Lindholm.
This file is part of the littleutils utility set. This file is part of the littleutils utility set.
The lsysinfo utility is free software; you can redistribute it and/or The lsysinfo utility is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option) any the Free Software Foundation; either version 3, or (at your option) any
later version. later version.
The lsysinfo utility is distributed in the hope that it will be useful, but The lsysinfo utility is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
skipping to change at line 29 skipping to change at line 29
#include <config.h> #include <config.h>
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
#endif #endif
#if defined(HAVE_SYS_SYSINFO_H) #if defined(HAVE_SYS_SYSINFO_H)
#include <sys/sysinfo.h> #include <sys/sysinfo.h>
#if defined(__CYGWIN__)
#define SYSINFO_SHIFT 8
#else
#define SYSINFO_SHIFT 20
#endif
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
struct sysinfo info; struct sysinfo info;
int rc; int rc;
rc = sysinfo (&info); rc = sysinfo (&info);
if (rc == 0) if (rc == 0)
{ {
fprintf (stdout, "sysinfo information:\n"); fprintf (stdout, "sysinfo information:\n");
fprintf (stdout, " total RAM = %8.2f MiB\n", (double) info.totalram / 10 fprintf (stdout, " total RAM = %5ld MiB\n", info.totalram >> SYSINFO_SHI
24.0 / 1024.0); FT);
fprintf (stdout, " free RAM = %8.2f MiB\n", (double) info.freeram / 102 fprintf (stdout, " free RAM = %5ld MiB\n", info.freeram >> SYSINFO_SHIF
4.0 / 1024.0); T);
#if !defined(__CYGWIN__) #if !defined(__CYGWIN__)
fprintf (stdout, " shared RAM = %8.2f MiB\n", (double) info.sharedram / 1 fprintf (stdout, " shared RAM = %5ld MiB\n", info.sharedram >> SYSINFO_SH
024.0 / 1024.0); IFT);
fprintf (stdout, " buffer RAM = %8.2f MiB\n", (double) info.bufferram / 1 fprintf (stdout, " buffer RAM = %5ld MiB\n", info.bufferram >> SYSINFO_SH
024.0 / 1024.0); IFT);
#endif #endif
fprintf (stdout, " total SWAP = %8.2f MiB\n", (double) info.totalswap / 1 fprintf (stdout, " total SWAP = %5ld MiB\n", info.totalswap >> SYSINFO_SH
024.0 / 1024.0); IFT);
fprintf (stdout, " free SWAP = %8.2f MiB\n", (double) info.freeswap / 10 fprintf (stdout, " free SWAP = %5ld MiB\n", info.freeswap >> SYSINFO_SHI
24.0 / 1024.0); FT);
fprintf (stdout, " uptime = %ld seconds\n", info.uptime); fprintf (stdout, " uptime = %ld seconds\n", info.uptime);
fprintf (stdout, " processes = %d\n", info.procs); fprintf (stdout, " processes = %d\n", info.procs);
fprintf (stdout, " loadavg = %.4f, %.4f, %.4f\n", info.loads[0] / 65536.0 , fprintf (stdout, " loadavg = %.3f, %.3f, %.3f\n", info.loads[0] / 65536.0 ,
info.loads[1] / 65536.0, info.loads[2] / 65536.0); info.loads[1] / 65536.0, info.loads[2] / 65536.0);
} }
else else
fprintf (stderr, "sysinfo error: bad sysinfo call\n"); fprintf (stderr, "sysinfo error: bad sysinfo call\n");
fprintf (stdout, "sysconf information:\n"); fprintf (stdout, "sysconf information:\n");
fprintf (stdout, " MEMORY = %ld MiB\n", (sysconf(_SC_PAGE_SIZE) / 1024) * fprintf (stdout, " MEMORY = %ld MiB\n", (sysconf(_SC_PAGE_SIZE) >> 10) * (sys
(sysconf(_SC_PHYS_PAGES) / 1024)); conf(_SC_PHYS_PAGES) >> 10));
fprintf (stdout, " PAGE_SIZE = %ld bytes\n", sysconf(_SC_PAGE_SIZE)); fprintf (stdout, " PAGE_SIZE = %ld bytes\n", sysconf(_SC_PAGE_SIZE));
fprintf (stdout, " AVAIL_PHYS_PAGES = %ld\n", sysconf(_SC_AVPHYS_PAGES)); fprintf (stdout, " AVAIL_PHYS_PAGES = %ld\n", sysconf(_SC_AVPHYS_PAGES));
fprintf (stdout, " TOTAL_PHYS_PAGES = %ld\n", sysconf(_SC_PHYS_PAGES)); fprintf (stdout, " TOTAL_PHYS_PAGES = %ld\n", sysconf(_SC_PHYS_PAGES));
fprintf (stdout, " NUM_OF_PROCESSORS_CONF = %lu\n", sysconf(_SC_NPROCESSORS_C ONF)); fprintf (stdout, " NUM_OF_PROCESSORS_CONF = %lu\n", sysconf(_SC_NPROCESSORS_C ONF));
fprintf (stdout, " NUM_OF_PROCESSORS_ONLN = %lu\n", sysconf(_SC_NPROCESSORS_O NLN)); fprintf (stdout, " NUM_OF_PROCESSORS_ONLN = %lu\n", sysconf(_SC_NPROCESSORS_O NLN));
fprintf (stdout, " CLK_TCK = %lu\n", sysconf(_SC_CLK_TCK)); fprintf (stdout, " CLK_TCK = %lu\n", sysconf(_SC_CLK_TCK));
fprintf (stdout, " OPEN_MAX = %lu\n", sysconf(_SC_OPEN_MAX)); fprintf (stdout, " OPEN_MAX = %lu\n", sysconf(_SC_OPEN_MAX));
return (0); return (0);
} }
skipping to change at line 105 skipping to change at line 110
sysinfo (SI_HW_PROVIDER, buf, count); sysinfo (SI_HW_PROVIDER, buf, count);
fprintf (stdout, " HW_PROVIDER = %s\n", buf); fprintf (stdout, " HW_PROVIDER = %s\n", buf);
sysinfo (SI_HW_SERIAL, buf, count); sysinfo (SI_HW_SERIAL, buf, count);
fprintf (stdout, " HW_SERIAL = %s\n", buf); fprintf (stdout, " HW_SERIAL = %s\n", buf);
fprintf (stdout, "sysconf information:\n"); fprintf (stdout, "sysconf information:\n");
fprintf (stdout, " NUM_OF_PROCESSORS_CONF = %lu\n", sysconf(_SC_NPROCESSORS_C ONF)); fprintf (stdout, " NUM_OF_PROCESSORS_CONF = %lu\n", sysconf(_SC_NPROCESSORS_C ONF));
fprintf (stdout, " NUM_OF_PROCESSORS_ONLN = %lu\n", sysconf(_SC_NPROCESSORS_O NLN)); fprintf (stdout, " NUM_OF_PROCESSORS_ONLN = %lu\n", sysconf(_SC_NPROCESSORS_O NLN));
fprintf (stdout, " PAGE_SIZE = %ld bytes\n", sysconf(_SC_PAGE_SIZE)); fprintf (stdout, " PAGE_SIZE = %ld bytes\n", sysconf(_SC_PAGE_SIZE));
fprintf (stdout, " PHYS_PAGES = %ld\n", sysconf(_SC_PHYS_PAGES)); fprintf (stdout, " PHYS_PAGES = %ld\n", sysconf(_SC_PHYS_PAGES));
fprintf (stdout, " MEMORY = %ld MiB\n", fprintf (stdout, " MEMORY = %ld MiB\n", (sysconf(_SC_PAGE_SIZE) >> 10) * (sys
(sysconf(_SC_PAGE_SIZE) / 1024) * (sysconf(_SC_PHYS_PAGES) / 1024)); conf(_SC_PHYS_PAGES) >> 10));
return (0); return (0);
} }
#elif defined(DJGPP) #elif defined(DJGPP)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
fprintf (stdout, "sysconf information:\n"); fprintf (stdout, "sysconf information:\n");
 End of changes. 8 change blocks. 
18 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)