|
Lines 20-43
Link Here
|
| 20 |
// |
20 |
// |
| 21 |
|
21 |
|
| 22 |
#include <X11/Xlib.h> |
22 |
#include <X11/Xlib.h> |
| 23 |
#include <iostream.h> |
23 |
#include <iostream> |
| 24 |
#include <fstream.h> |
24 |
#include <fstream> |
| 25 |
#include <stdlib.h> |
25 |
#include <cstdlib> |
| 26 |
#include <stdio.h> |
26 |
#include <cstdio> |
| 27 |
#include <string.h> |
27 |
#include <cstring> |
| 28 |
#include <unistd.h> |
28 |
#include <unistd.h> |
| 29 |
#include <signal.h> |
29 |
#include <csignal> |
| 30 |
#include <errno.h> |
30 |
#include <cerrno> |
| 31 |
#include <sys/types.h> |
31 |
#include <sys/types.h> |
| 32 |
#include <sys/wait.h> |
32 |
#include <sys/wait.h> |
| 33 |
#include <math.h> |
33 |
#include <cmath> |
| 34 |
#include <time.h> |
34 |
#include <ctime> |
| 35 |
#include "Xpm.h" |
35 |
#include "Xpm.h" |
| 36 |
#include "Temperature.h" |
36 |
#include "Temperature.h" |
| 37 |
|
37 |
|
| 38 |
#include "pixmaps/main.xpm" |
38 |
#include "pixmaps/main.xpm" |
| 39 |
#include "pixmaps/redlight.xpm" |
39 |
#include "pixmaps/redlight.xpm" |
| 40 |
|
40 |
|
|
|
41 |
using std::cerr; |
| 42 |
using std::cout; |
| 43 |
using std::endl; |
| 44 |
using std::fstream; |
| 45 |
|
| 41 |
volatile static ChildStatus childStatus; |
46 |
volatile static ChildStatus childStatus; |
| 42 |
|
47 |
|
| 43 |
static void catchBrokenPipe(int sig) |
48 |
static void catchBrokenPipe(int sig) |
|
Lines 357-369
Link Here
|
| 357 |
if (!strcmp(buffer, "Temperature:")) { |
362 |
if (!strcmp(buffer, "Temperature:")) { |
| 358 |
file >> buffer; |
363 |
file >> buffer; |
| 359 |
if (buffer && strlen(buffer) < 5) { |
364 |
if (buffer && strlen(buffer) < 5) { |
| 360 |
char* unit; |
365 |
char unit[3]; |
| 361 |
if (mFahrenheit) { |
366 |
if (mFahrenheit) { |
| 362 |
strcpy(mTemperature, buffer); |
367 |
strcpy(mTemperature, buffer); |
| 363 |
unit = " °F"; |
368 |
sprintf(unit," F\0"); |
| 364 |
} else { |
369 |
} else { |
| 365 |
sprintf(mTemperature, "%d", (int)rint((atoi(buffer) - 32) / 1.8)); |
370 |
sprintf(mTemperature, "%d", (int)rint((atoi(buffer) - 32) / 1.8)); |
| 366 |
unit = " °C"; |
371 |
sprintf(unit," C\0"); |
| 367 |
} |
372 |
} |
| 368 |
|
373 |
|
| 369 |
Xpm* image = new Xpm(mDisplay, mRoot, main_xpm); |
374 |
Xpm* image = new Xpm(mDisplay, mRoot, main_xpm); |
|
Lines 415-421
Link Here
|
| 415 |
const char* verbose = (mVerbose ? "--verbose" : "--quiet"); |
420 |
const char* verbose = (mVerbose ? "--verbose" : "--quiet"); |
| 416 |
char* URL = new char[strlen(METAR_URL) + strlen(mStationId) + 1]; |
421 |
char* URL = new char[strlen(METAR_URL) + strlen(mStationId) + 1]; |
| 417 |
sprintf(URL, METAR_URL, mStationId); |
422 |
sprintf(URL, METAR_URL, mStationId); |
| 418 |
execlp("wget", "wget", "--cache=off", "--tries=0", verbose, "-O", tmpFile, URL, 0); |
423 |
execlp("wget", "wget", "--no-cache", "--tries=0", verbose, "-O", tmpFile, URL, 0); |
| 419 |
cerr << APPNAME << ": could not fetch temperature (wget not found in $PATH)" << endl; |
424 |
cerr << APPNAME << ": could not fetch temperature (wget not found in $PATH)" << endl; |
| 420 |
remove(tmpFile); |
425 |
remove(tmpFile); |
| 421 |
exit(0); |
426 |
exit(0); |