Import astro/wmspaceweather version 1.04_4
[dports.git] / astro / wmspaceweather / files / patch-wmSpaceWeather.c
1 --- wmSpaceWeather.c.orig       Thu Feb 18 17:57:45 1999
2 +++ wmSpaceWeather.c    Tue Apr 13 20:06:41 2004
3 @@ -115,7 +115,7 @@ XEvent              event;
4  int                    i, n, s, k, m, dt1, dt2;
5  int            Year, Month, Day, DayOfMonth, OldDayOfMonth;
6  int                    Hours, Mins, Secs, OldSecs, xoff, D[10], xsize;
7 -long           CurrentLocalTime;
8 +time_t         CurrentLocalTime;
9  int                    height, UpToDate, LEDOn;
10  double         UT, TU, TU2, TU3, T0, gmst, hour24();
11  
12 @@ -126,6 +126,7 @@ int                 Kp[8] = { -1, -1, -1, -1, -1, -1, 
13  double         E1, E2, P1, P2, P3;
14  char           Xray[10], digit[2];
15  FILE           *fp;
16 +char           FileName[1024];
17  
18  
19  
20 @@ -249,13 +250,13 @@ FILE              *fp;
21  
22  
23         /*
24 -        *  Check the Kp file every (approx.) 2 seconds.
25 +        *  Check the Kp file every (approx.) 60 seconds.
26          *  Can significantly reduce this frequency later. But its
27          *  easier to debug this way...
28          *  Do this before trying to download again! The file may be there and it
29          *  may be Up-To-Date!
30          */
31 -       if (dt2 > 2){
32 +       if (dt2 > 60){
33             
34             dt2 = 0;
35  
36 @@ -272,13 +273,13 @@ FILE              *fp;
37             Secs  = Time->tm_sec;
38             UT = (double)Hours + (double)Mins/60.0 + (double)Secs/3600.0;
39             CurrentJD = jd(Year, Month, Day, UT);
40 -           
41  
42  
43             /*
44              *  Read in Kp values
45              */
46 -           if ((fp = fopen("/tmp/LatestKp.txt", "r")) != NULL){
47 +           snprintf(FileName, sizeof(FileName), "/tmp/LatestKp.txt", getenv("HOME"));
48 +           if ((fp = fopen(FileName, "r")) != NULL){
49  
50                 for (i=0; i<8; ++i){
51                     fscanf(fp, "%ld %d", &TimeTag[i], &Kp[i]);
52 @@ -289,7 +290,7 @@ FILE                *fp;
53                 fscanf(fp, "%lf", &P3);
54                 fscanf(fp, "%lf", &E1);
55                 fscanf(fp, "%lf", &E2);
56 -               fscanf(fp, "%10s",  Xray);
57 +               fscanf(fp, "%9s",  Xray);
58                 fclose(fp);
59  
60             } else {
61 @@ -318,7 +319,7 @@ FILE                *fp;
62             LatestAvailJD = jd(Year, Month, Day, UT);
63  
64             DeltaT = (CurrentJD - LatestAvailJD)*24.0;
65 -           UpToDate = (DeltaT <= 3.0) ? 1 : 0;
66 +           UpToDate = (DeltaT <= 4.0) ? 1 : 0;
67  
68             if (!UpToDate){
69  
70 @@ -560,7 +561,7 @@ void ParseCMDLine(int argc, char *argv[]
71  
72          } else if ((!strcmp(argv[i], "-url"))||(!strcmp(argv[i], "-u"))){
73  
74 -            strcpy(URL, argv[++i]);
75 +            strlcpy(URL, argv[++i], sizeof(URL));
76  
77          } else {
78  
79 @@ -651,7 +652,7 @@ void pressEvent(XButtonEvent *xev){
80      if (GotDoubleClick1) {
81          GotFirstClick1 = 0;
82          GotDoubleClick1 = 0;
83 -        sprintf(Command, "netscape -remote 'openURL(%s)' || netscape '%s' &", URL, URL);
84 +        snprintf(Command, sizeof(Command), "netscape -remote 'openURL(%s)' || netscape '%s' &", URL, URL);
85          system(Command);
86      }
87