add menu support to lcdproc client (currently hidden behind #ifdef LCDPROC_MENUS) -

patch provided by Andrew Foss
This commit is contained in:
marschap
2006-02-18 16:18:22 +00:00
parent dd66eac255
commit d77ada0bde
24 changed files with 619 additions and 238 deletions
+20 -20
View File
@@ -65,7 +65,7 @@ int machine_init()
/* get the page size with "getpagesize" and calculate pageshift from it */
int pagesize = getpagesize();
pageshift = 0;
while(pagesize > 1)
while (pagesize > 1)
{
pageshift++;
pagesize >>= 1;
@@ -91,13 +91,13 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
*battflag = LCDP_BATT_ABSENT;
*percent = 100;
if((apmd = open("/dev/apm", O_RDONLY)) == -1)
if ((apmd = open("/dev/apm", O_RDONLY)) == -1)
{
perror("get_battstat_open");
return(TRUE);
}
if(ioctl(apmd, APM_IOC_GETPOWER, &api) == -1)
if (ioctl(apmd, APM_IOC_GETPOWER, &api) == -1)
{
perror("get_battstat_ioctl");
return(FALSE);
@@ -152,14 +152,14 @@ int machine_get_fs(mounts_type fs[], int *cnt)
int statcnt, fscnt, i;
fscnt = getmntinfo(&mntbuf, MNT_WAIT);
if(fscnt == 0)
if (fscnt == 0)
{
perror("getmntinfo");
return(FALSE);
}
for(statcnt = 0, pp = mntbuf, i = 0; i < fscnt; pp++, i++)
for (statcnt = 0, pp = mntbuf, i = 0; i < fscnt; pp++, i++)
{
if(strcmp(pp->f_fstypename, "procfs")
if (strcmp(pp->f_fstypename, "procfs")
&& strcmp(pp->f_fstypename, "kernfs")
&& strcmp(pp->f_fstypename, "linprocfs")
#ifndef STAT_NFS
@@ -175,7 +175,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
snprintf(fs[statcnt].type, 255, "%s", pp->f_fstypename);
fs[statcnt].blocks = pp->f_blocks;
if(fs[statcnt].blocks > 0)
if (fs[statcnt].blocks > 0)
{
fs[statcnt].bsize = pp->f_bsize;
fs[statcnt].bfree = pp->f_bfree;
@@ -202,7 +202,7 @@ int machine_get_load(load_type *curr_load)
mib[0] = CTL_KERN;
mib[1] = KERN_CPTIME;
size = sizeof(cp_time);
if(sysctl(mib, 2, cp_time, &size, NULL, 0) < 0)
if (sysctl(mib, 2, cp_time, &size, NULL, 0) < 0)
{
perror("sysctl kern.cp_time failed");
return(FALSE);
@@ -214,7 +214,7 @@ int machine_get_load(load_type *curr_load)
load.idle = (unsigned long) (cp_time[CP_IDLE]);
load.total = load.user + load.nice + load.system + load.idle;
if(load.total != last_load.total)
if (load.total != last_load.total)
{
curr_load->user = load.user - last_load.user;
curr_load->nice = load.nice - last_load.nice;
@@ -236,7 +236,7 @@ int machine_get_loadavg(double *load)
{
double loadavg[1];
if(getloadavg(loadavg, 1) == -1)
if (getloadavg(loadavg, 1) == -1)
return(FALSE);
*load = loadavg[0];
@@ -254,7 +254,7 @@ int machine_get_meminfo(meminfo_type *result)
mib[1] = VM_UVMEXP;
size = sizeof(suvm);
if(sysctl(mib, 2, &suvm, &size, NULL, 0) < 0)
if (sysctl(mib, 2, &suvm, &size, NULL, 0) < 0)
{
perror("sysctl vm.uvmexp failed");
return(FALSE);
@@ -284,24 +284,24 @@ int machine_get_procs(LinkedList *procs)
procinfo_type *p;
kvm_t *kvmd;
if((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
if ((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
{
perror("kvm_open");
return(FALSE);
}
kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
if(kprocs == NULL)
if (kprocs == NULL)
{
perror("kvm_getprocs");
kvm_close(kvmd);
return(FALSE);
}
for(i = 0; i < nproc; i++)
for (i = 0; i < nproc; i++)
{
p = malloc(sizeof(procinfo_type));
if(!p)
if (!p)
{
perror("mem_top_malloc");
kvm_close(kvmd);
@@ -330,19 +330,19 @@ int machine_get_smpload(load_type *result, int *numcpus)
mib[1] = HW_NCPU;
size = sizeof(int);
if(sysctl(mib, 2, &num, &size, NULL, 0) < 0)
if (sysctl(mib, 2, &num, &size, NULL, 0) < 0)
{
perror("sysctl hw.ncpu");
return(FALSE);
}
if(machine_get_load(&curr_load) == FALSE)
if (machine_get_load(&curr_load) == FALSE)
return(FALSE);
*numcpus = num;
num = num > 8 ? 8 : num;
/* Don't know how to get per-cpu-load values */
for(i = 0; i < num; i++)
for (i = 0; i < num; i++)
{
result[i] = curr_load;
}
@@ -362,7 +362,7 @@ int machine_get_uptime(double *up, double *idle)
mib[1] = KERN_BOOTTIME;
size = sizeof(boottime);
time(&now);
if(sysctl(mib, 2, &boottime, &size, NULL, 0) < 0)
if (sysctl(mib, 2, &boottime, &size, NULL, 0) < 0)
{
perror("sysctl kern.boottime failed");
return(FALSE);
@@ -370,7 +370,7 @@ int machine_get_uptime(double *up, double *idle)
*up = (double)(now - boottime.tv_sec);
if(machine_get_load(&curr_load) == FALSE)
if (machine_get_load(&curr_load) == FALSE)
*idle = 100.;
else
*idle = 100.*curr_load.idle/curr_load.total;