patch-wmSpaceWeather_c 2.7 KB

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