cleanup: remove unnecessary (=invisible) leading spaces

This commit is contained in:
marschap
2006-04-27 15:10:59 +00:00
parent 9b111eeac4
commit d4a3e7444d
40 changed files with 212 additions and 212 deletions
+10 -10
View File
@@ -147,7 +147,7 @@ if ($twentyfour > 0) {
if ($time[2] > 11) {
$ampmstring = "PM";
}
if ($time[2] > 12) {
$time[2] = $time[2] - 12;
}
@@ -197,9 +197,9 @@ $i = 0;
my $flag = 0;
while (defined($line = <SOCK>)) {
$i++;
if ($line =~ /^%%/) { $i = 1; $flag = 1; }
if ($flag > 0) {
if ($i == 2) {
chop($line);
@@ -229,10 +229,10 @@ close(TMPFILE);
# compare tmpfile with current menufile and possibly update it.
if (-e $menufile) {
my ($tmpline, $menuline, $linecount);
open(MENUFILE, $menufile);
open(TMPFILE, $tmpfile);
# read in the first 'headline' menu entry from each file.
if ($frontpage eq "top") {
$linecount = 3;
@@ -243,7 +243,7 @@ if (-e $menufile) {
for ($i = 0; $i < $linecount; $i++) {
if (eof(TMPFILE)) {
if ($forceupdate == 0) {
close(MENUFILE);
close(TMPFILE);
unlink($tmpfile);
@@ -258,12 +258,12 @@ if (-e $menufile) {
$menuline = <MENUFILE>;
}
}
if (($forceupdate == 0) && (($tmpline =~ /^"$sitename Headlines/) || ($tmpline =~ /^"$sitename Frontpage/) || ($tmpline eq $menuline))) {
close(MENUFILE);
close(TMPFILE);
unlink($tmpfile);
exit();
}
}
@@ -280,11 +280,11 @@ sub wmdie {
if ($string ne "") {
print "$string\n";
}
close(SOCK);
close(TMPFILE);
unlink($tmpfile);
if ($string eq "") {
exit(0);
} else {
+2 -2
View File
@@ -34,7 +34,7 @@ ac_status(int status)
for (i = 0; ac_table[i].name != NULL; i++)
if (status == ac_table[i].status)
return ac_table[i].name;
return ac_table[LCDP_AC_UNKNOWN].name;
}
@@ -55,7 +55,7 @@ battery_status(int status)
for (i = 0; batt_table[i].name != NULL; i++)
if (status == batt_table[i].status)
return batt_table[i].name;
return batt_table[LCDP_AC_UNKNOWN].name;
}
+5 -5
View File
@@ -156,7 +156,7 @@ time_screen (int rep, int display, int *flags_ptr)
hour = ((int) uptime % 86400) / 60 / 60;
min = (((int) uptime % 86400) % 3600) / 60;
sec = ((int) uptime % 60);
if (lcd_wid >= 20)
sprintf (tmp, "Up %3d day%s %02d%c%02d%c%02d",
days, ((days != 1) ? "s" : ""), hour, colon[heartbeat], min, colon[heartbeat], sec);
@@ -175,7 +175,7 @@ time_screen (int rep, int display, int *flags_ptr)
sprintf (buffer, "widget_set T two %i 3 {%s}\n", xoffs, tmp);
if (display)
sock_send_string (sock, buffer);
// display the time & idle time...
sprintf (tmp, "%s %3i%% idle", now, (int) idle);
xoffs = (lcd_wid > strlen(tmp)) ? ((lcd_wid - strlen(tmp)) / 2) + 1 : 1;
@@ -233,7 +233,7 @@ clock_screen (int rep, int display, int *flags_ptr)
sprintf (buffer, "widget_set O title {DATE & TIME}\n");
sock_send_string (sock, buffer);
sprintf (tmp, "%s", get_hostname());
xoffs = (lcd_wid > strlen(tmp)) ? (((lcd_wid - strlen(tmp)) / 2) + 1) : 1;
sprintf (buffer, "widget_set O one %i 2 {%s}\n", xoffs, tmp);
@@ -323,7 +323,7 @@ uptime_screen (int rep, int display, int *flags_ptr)
sock_send_string (sock, "widget_add U three string\n");
sock_send_string (sock, "widget_set U title {SYSTEM UPTIME}\n");
sprintf (tmp, "%s", get_hostname());
xoffs = (lcd_wid > strlen(tmp)) ? (((lcd_wid - strlen(tmp)) / 2) + 1) : 1;
sprintf (buffer, "widget_set U one %i 2 {%s}\n", xoffs, tmp);
@@ -335,7 +335,7 @@ uptime_screen (int rep, int display, int *flags_ptr)
sock_send_string (sock, buffer);
} else {
sock_send_string (sock, "widget_add U one string\n");
sprintf (tmp, "widget_set U title {%s %s: %s}\n", get_sysname(), get_sysrelease(), get_hostname());
sock_send_string (sock, tmp);
}
+3 -3
View File
@@ -49,7 +49,7 @@ cpu_screen(int rep, int display, int *flags_ptr)
sock_send_string(sock, buffer);
if (lcd_hgt >= 4) {
gauge_wid = lcd_wid - 6; // room between 0%...100%
sock_send_string(sock, "widget_add C title title\n");
sock_send_string(sock, "widget_set C title {CPU LOAD}\n");
sock_send_string(sock, "widget_add C one string\n");
@@ -105,14 +105,14 @@ cpu_screen(int rep, int display, int *flags_ptr)
// Read new data
if (load.total > 0L) {
cpu[CPU_BUF_SIZE - 1][0] = 100.0 * ((double) load.user / (double) load.total);
cpu[CPU_BUF_SIZE - 1][1] = 100.0 * ((double) load.system / (double) load.total);
cpu[CPU_BUF_SIZE - 1][1] = 100.0 * ((double) load.system / (double) load.total);
cpu[CPU_BUF_SIZE - 1][2] = 100.0 * ((double) load.nice / (double) load.total);
cpu[CPU_BUF_SIZE - 1][3] = 100.0 * ((double) load.idle / (double) load.total);
cpu[CPU_BUF_SIZE - 1][4] = 100.0 * (((double) load.user + (double) load.system + (double) load.nice) / (double) load.total);
}
else {
cpu[CPU_BUF_SIZE - 1][0] = 0.0;
cpu[CPU_BUF_SIZE - 1][1] = 0.0;
cpu[CPU_BUF_SIZE - 1][1] = 0.0;
cpu[CPU_BUF_SIZE - 1][2] = 0.0;
cpu[CPU_BUF_SIZE - 1][3] = 0.0;
cpu[CPU_BUF_SIZE - 1][4] = 0.0;
+2 -2
View File
@@ -101,7 +101,7 @@ disk_screen (int rep, int display, int *flags_ptr)
sock_send_string (sock, "widget_set D err2 1 3 {Filesystem Stats}\n");
return 0;
}
// Display stuff... (show for two seconds, then scroll once per
// second, then hold at the end for two seconds)
sprintf (buffer, "widget_set D f 1 2 %i %i %i %i v 12\n", lcd_wid, lcd_hgt, lcd_wid, count);
@@ -111,7 +111,7 @@ disk_screen (int rep, int display, int *flags_ptr)
for (i = 0; i < count; i++) {
if (table[i].dev[0] == '\0')
continue;
if (i >= num_disks) { // Make sure we have enough lines...
sprintf (tmp, "widget_add D s%i string -in f\n", i);
sock_send_string (sock, tmp);
+28 -28
View File
@@ -72,16 +72,16 @@ int machine_init()
/* get the page size with "getpagesize" and calculate pageshift from it */
int pagesize = 0;
pageshift = 0;
lcdproc_port = mach_host_self();
host_page_size(lcdproc_port, &pagesize);
while (pagesize > 1)
{
pageshift++;
pagesize >>= 1;
}
/* we only need the amount of log(2)1024 for our conversion */
pageshift -= 10;
@@ -101,11 +101,11 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
int i;
CFDictionaryRef pSource = NULL;
const void *psValue;
*acstat = LCDP_AC_ON;
*battflag = LCDP_BATT_ABSENT;
*percent = 100;
if (CFArrayGetCount(sources) == 0) return(FALSE);
for (i = 0; i < CFArrayGetCount(sources); i++)
@@ -114,11 +114,11 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
if (!pSource) break;
psValue = (CFStringRef)CFDictionaryGetValue(pSource, CFSTR(kIOPSNameKey));
if (CFDictionaryGetValueIfPresent(pSource, CFSTR(kIOPSIsPresentKey), &psValue) && (CFBooleanGetValue(psValue) > 0))
{
psValue = (CFStringRef)CFDictionaryGetValue(pSource, CFSTR(kIOPSPowerSourceStateKey));
if (CFStringCompare(psValue,CFSTR(kIOPSBatteryPowerValue),0)==kCFCompareEqualTo)
{
/* We are running on a battery power source. */
@@ -135,20 +135,20 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
else
*battflag = LCDP_BATT_UNKNOWN;
}
if (*battflag != LCDP_BATT_ABSENT)
{
int curCapacity = 0;
int maxCapacity = 0;
psValue = CFDictionaryGetValue(pSource, CFSTR(kIOPSCurrentCapacityKey));
CFNumberGetValue(psValue, kCFNumberSInt32Type, &curCapacity);
psValue = CFDictionaryGetValue(pSource, CFSTR(kIOPSMaxCapacityKey));
CFNumberGetValue(psValue, kCFNumberSInt32Type, &maxCapacity);
*percent = (int)((double)curCapacity/(double)maxCapacity * 100);
/* There is a way to check this through the IOKit,
but I am not sure what gets for kIOPSLowWarnLevelKey and kIOPSDeadWarnLevelKey, and this is easier.
*/
@@ -161,14 +161,14 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
*battflag = LCDP_BATT_CRITICAL;
}
/* printf ("powerSource %d of %d: percent: %d/%d %d\n", i, CFArrayGetCount(sources), curCapacity, maxCapacity, *percent);*/
}
}
}
CFRelease(blob);
CFRelease(sources);
return(TRUE);
}
@@ -212,7 +212,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
statcnt++;
}
}
*cnt = statcnt;
return(TRUE);
@@ -223,7 +223,7 @@ int machine_get_load(load_type *curr_load)
static load_type last_load = { 0, 0, 0, 0, 0 };
static load_type last_ret_load;
load_type load;
host_cpu_load_info_data_t load_info;
mach_msg_type_number_t info_count;
@@ -233,7 +233,7 @@ int machine_get_load(load_type *curr_load)
perror("host_statistics");
return(FALSE);
}
load.user = (unsigned long) (load_info.cpu_ticks[CPU_STATE_USER]);
load.nice = (unsigned long) (load_info.cpu_ticks[CPU_STATE_NICE]);
load.system = (unsigned long) (load_info.cpu_ticks[CPU_STATE_SYSTEM]);
@@ -277,14 +277,14 @@ int machine_get_meminfo(meminfo_type *result)
vm_statistics_data_t vm_info;
mach_msg_type_number_t info_count;
info_count = HOST_VM_INFO_COUNT;
if (host_statistics(lcdproc_port, HOST_VM_INFO, (host_info_t)&vm_info, &info_count))
{
perror("host_statistics");
return(FALSE);
}
result[0].total = pagetok(vm_info.active_count + vm_info.inactive_count +
vm_info.free_count + vm_info.wire_count);
result[0].free = pagetok(vm_info.free_count);
@@ -312,7 +312,7 @@ int machine_get_procs(LinkedList *procs)
/* FIX ME */
/* This needs to be finished. */
procinfo_type *p;
processor_set_t *psets, pset;
task_t *tasks;
@@ -331,14 +331,14 @@ int machine_get_procs(LinkedList *procs)
perror("host_processor_set_priv");
return(FALSE);
}
p = malloc(sizeof(procinfo_type));
if (!p)
{
perror("mem_top_malloc");
return(FALSE);
}
}
return(TRUE);
}
@@ -406,25 +406,25 @@ static int swapmode(int *rettotal, int *retfree)
mib[0] = CTL_VM;
mib[1] = VM_SWAPUSAGE;
size = sizeof(xsu);
*rettotal = 0;
*retfree = 0;
if (sysctl(mib, 2, &xsu, &size, NULL, 0) != 0)
{
perror("sysctl");
return(FALSE);
}
*rettotal = (xsu.xsu_total/1024);
*retfree = ((xsu.xsu_total-xsu.xsu_used)/1024);
return(TRUE);
#endif
*rettotal = 0;
*retfree = 0;
return(FALSE);
}
+1 -1
View File
@@ -182,7 +182,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
statcnt++;
}
}
*cnt = statcnt;
return(TRUE);
+1 -1
View File
@@ -499,7 +499,7 @@ int machine_get_smpload(load_type *result, int *numcpus)
int machine_get_uptime(double *up, double *idle)
{
double local_up, local_idle;
reread(uptime_fd, "get_uptime:");
sscanf(procbuf, "%lf %lf", &local_up, &local_idle);
if (up != NULL)
+5 -5
View File
@@ -92,7 +92,7 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
{
int apmd;
struct apm_power_info apmi;
if ((apmd = open("/dev/apm", O_RDONLY)) == -1)
{
*acstat = LCDP_AC_ON;
@@ -100,14 +100,14 @@ int machine_get_battstat(int *acstat, int *battflag, int *percent)
*percent = 100;
return(TRUE);
}
memset(&apmi, 0, sizeof(apmi));
if (ioctl(apmd, APM_IOC_GETPOWER, &apmi) == -1)
{
perror("APM_IOC_GETPOWER failed in get_batt_stat()");
return(FALSE);
}
switch(apmi.ac_state)
{
case APM_AC_OFF:
@@ -177,7 +177,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
statcnt++;
}
}
*cnt = statcnt;
return(TRUE);
}
@@ -250,7 +250,7 @@ int machine_get_meminfo(meminfo_type *result)
perror("sysctl vm.uvmexp2 failed");
return(FALSE);
}
/* memory */
result[0].total = pagetok(uvmexp.npages);
result[0].free = pagetok(uvmexp.free);
+1 -1
View File
@@ -185,7 +185,7 @@ int machine_get_fs(mounts_type fs[], int *cnt)
statcnt++;
}
}
*cnt = statcnt;
return(TRUE);
}
+3 -3
View File
@@ -293,11 +293,11 @@ process_command_line(int argc, char **argv)
/* parse arguments */
if (argc > optind) //user specified some modes, so clear all defaults
clear_modes();
for (i = max(optind, 1); i < argc; i++) {
int shortname = (strlen(argv[i]) == 1) ? toupper(argv[i][0]) : '\0';
int found = set_mode(shortname, argv[i], 1);
if (!found) {
fprintf(stderr, "Invalid Mode: %c\n", argv[i][0]);
return(EXIT_FAILURE);
@@ -491,7 +491,7 @@ main_loop()
//for (i=0; i<argc; i++) argv[i]=NULL; // Get rid of old tokens
argc = 0;
newtoken = 1;
for (i = 0; i < len; i++) {
switch (buf[i]) {
case ' ':
+4 -4
View File
@@ -68,7 +68,7 @@ mem_screen (int rep, int display, int *flags_ptr)
} else {
gauge_wid = (lcd_wid >= 18) ? max(2, lcd_wid - 18) : 0;
gauge_offs = (lcd_wid - gauge_wid) / 2 + 2;
sock_send_string(sock, "widget_add M m string\n");
sock_send_string(sock, "widget_add M s string\n");
if (gauge_wid > 0) {
@@ -244,20 +244,20 @@ mem_top_screen (int rep, int display, int *flags_ptr)
if ((*flags_ptr & INITIALIZED) == 0) {
*flags_ptr |= INITIALIZED;
sock_send_string(sock, "screen_add S\n");
sprintf(buffer, "screen_set S -name {Top Memory Use: %s}\n", get_hostname());
sock_send_string(sock, buffer);
sock_send_string(sock, "widget_add S title title\n");
sprintf(buffer, "widget_set S title {TOP MEM: %s}\n", get_hostname());
sock_send_string(sock, buffer);
// frame from (2nd line, left) to (last line, right)
sock_send_string(sock, "widget_add S f frame\n");
sprintf(buffer, "widget_set S f 1 2 %i %i %i 5 v %i\n",
lcd_wid, lcd_hgt, lcd_wid, ((lcd_hgt >= 4) ? 8 : 12));
sock_send_string(sock, buffer);
// frame contents
for (i = 1; i <= 5; i++) {
sprintf(buffer, "widget_add S %i string -in f\n", i);
+1 -1
View File
@@ -52,7 +52,7 @@ sprintf_memory(char *dst, double value, double roundlimit)
format = "%.2f%s";
if (value < 10)
format = "%.3f%s";
sprintf(dst, format, value, units[offs]);
}
return dst;
+5 -5
View File
@@ -197,14 +197,14 @@ while (1) {
# Sanity check
die "METAR is too short! Something went wrong." if (length($metar)<1);
# pass the data to the METAR module.
# print("$metar\n");
$m->metar($metar);
# ask for the temperature(s)
my $temp; my $temp_u; my $dew; my $dew_u; my $wind; my $wind_u; my $wind_dir;
if ($datasystem eq "nautical") {
$temp = $m->C_TEMP;
$temp_u = "C";
@@ -231,18 +231,18 @@ while (1) {
$wind_u = "km/h";
$wind_dir = $m->WIND_DIR_ENG;
}
my $metartime = $m->TIME;
my $sky = $m->SKY;
my $visibility = $m->VISIBILITY;
print $remote sprintf("widget_set metar title {Weather %s %s}\n", $site_code, $metartime);
print $remote sprintf("widget_set metar temp 1 2 {Temp %i%s (%i%s Dew)}\n", $temp, $temp_u, $dew, $dew_u) if ($temp and $dew);
print $remote sprintf("widget_set metar wind 1 3 {Wind %i%s, %s}\n", $wind, $wind_u, $wind_dir) if ($wind_dir and $wind);
print $remote sprintf("widget_set metar visib 1 %i %i %i h 3 {Visibility %s}\n", $lcdheight, $lcdwidth, $lcdheight, $visibility ) if ($visibility);
print $remote sprintf("widget_set metar cloud 1 4 {Sky %s}\n", join(',', @{$m->{sky}}) ) if ($m->{sky} and ($lcdheight>4));
} # end else
# eat all input from LCDd
while(defined(my $input = <$remote>)) { }