patch-top_setup_c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. $OpenBSD: patch-top_setup_c,v 1.4 2015/08/25 19:58:05 naddy Exp $
  2. --- top_setup.c.orig Tue Jan 12 19:59:40 1993
  3. +++ top_setup.c Tue Aug 25 21:51:40 2015
  4. @@ -19,6 +19,7 @@
  5. # include <X11/Xaw/Form.h>
  6. # include <stdio.h>
  7. +# include <stdlib.h>
  8. # include <string.h>
  9. # include "cdrom_globs.h"
  10. @@ -26,19 +27,9 @@
  11. # include "logo.xbm"
  12. XtAppContext appc;
  13. -char *file;
  14. -char *device;
  15. -Boolean debug = False;
  16. -Boolean display_timer = True;
  17. -float volbase = 187.0;
  18. -float volpcent = .267;
  19. -int replayThreshold = 4;
  20. -int pauseSkipInterval = 15;
  21. -int scanSkipInterval = 1;
  22. -float scanPauseInterval = .062;
  23. -float pausePauseInterval = .500;
  24. -char *cdInfoDir = NULL;
  25. +AppData app_data;
  26. +
  27. extern char *getenv();
  28. static Widget top_shell;
  29. @@ -55,36 +46,36 @@ static XrmOptionDescRec options[] = {
  30. };
  31. static XtResource resources[] = {
  32. - { "file", "File", XtRString, sizeof(String), (Cardinal) &file,
  33. + { "file", "File", XtRString, sizeof(String), XtOffsetOf(AppData,file),
  34. XtRString, (caddr_t) NULL },
  35. - { "device", "Device", XtRString, sizeof(String), (Cardinal) &device,
  36. + { "device", "Device", XtRString, sizeof(String), XtOffsetOf(AppData,device),
  37. XtRString, (caddr_t) NULL },
  38. - { "debug", "Debug", XtRBoolean, sizeof(Boolean), (Cardinal) &debug,
  39. - XtRBoolean, (caddr_t) &debug },
  40. + { "debug", "Debug", XtRBoolean, sizeof(Boolean), XtOffsetOf(AppData,debug),
  41. + XtRBoolean, &app_data.debug },
  42. { "displayTimer", "DisplayTimer", XtRBoolean, sizeof(Boolean),
  43. - (Cardinal) &display_timer, XtRBoolean,
  44. - (caddr_t) &display_timer },
  45. + XtOffsetOf(AppData,display_timer), XtRBoolean,
  46. + &app_data.display_timer },
  47. { "volBase", "VolBase", XtRFloat, sizeof(float),
  48. - (Cardinal) &volbase, XtRFloat, (caddr_t) &volbase },
  49. + XtOffsetOf(AppData,volbase), XtRFloat, &app_data.volbase },
  50. { "volPcent", "VolPcent", XtRFloat, sizeof(float),
  51. - (Cardinal) &volpcent, XtRFloat, (caddr_t) &volpcent },
  52. + XtOffsetOf(AppData,volpcent), XtRFloat, &app_data.volpcent },
  53. { "replayThreshold", "replayThreshold", XtRInt, sizeof(int),
  54. - (Cardinal) &replayThreshold, XtRInt,
  55. - (caddr_t) &replayThreshold },
  56. + XtOffsetOf(AppData,replayThreshold), XtRInt,
  57. + &app_data.replayThreshold },
  58. { "scanSkipInterval", "scanSkipInterval", XtRInt, sizeof(int),
  59. - (Cardinal) &scanSkipInterval, XtRInt,
  60. - (caddr_t) &scanSkipInterval },
  61. + XtOffsetOf(AppData,scanSkipInterval), XtRInt,
  62. + &app_data.scanSkipInterval },
  63. { "scanPauseInterval", "scanPauseInterval", XtRFloat, sizeof(float),
  64. - (Cardinal) &scanPauseInterval, XtRFloat,
  65. - (caddr_t) &scanPauseInterval },
  66. + XtOffsetOf(AppData,scanPauseInterval), XtRFloat,
  67. + &app_data.scanPauseInterval },
  68. { "pauseSkipInterval", "pauseSkipInterval", XtRInt, sizeof(int),
  69. - (Cardinal) &pauseSkipInterval, XtRInt,
  70. - (caddr_t) &pauseSkipInterval },
  71. + XtOffsetOf(AppData,pauseSkipInterval), XtRInt,
  72. + &app_data.pauseSkipInterval },
  73. { "pausePauseInterval", "pausePauseInterval", XtRFloat, sizeof(float),
  74. - (Cardinal) &pausePauseInterval, XtRFloat,
  75. - (caddr_t) &pausePauseInterval },
  76. + XtOffsetOf(AppData,pausePauseInterval), XtRFloat,
  77. + &app_data.pausePauseInterval },
  78. { "cdInfoDir", "cdInfoDir", XtRString, sizeof(String),
  79. - (Cardinal) &cdInfoDir, XtRString, (caddr_t) NULL },
  80. + XtOffsetOf(AppData,cdInfoDir), XtRString, (caddr_t) NULL },
  81. };
  82. Widget
  83. @@ -98,6 +89,20 @@ top_setup(argc, argv)
  84. Arg arg;
  85. char *s;
  86. + /*
  87. + * set default values
  88. + */
  89. +
  90. + app_data.debug = False;
  91. + app_data.display_timer = True;
  92. + app_data.volbase = 187.0;
  93. + app_data.volpcent = 0.267;
  94. + app_data.replayThreshold = 4;
  95. + app_data.pauseSkipInterval = 15;
  96. + app_data.scanSkipInterval = 1;
  97. + app_data.scanPauseInterval = 0.062;
  98. + app_data.pausePauseInterval = 0.500;
  99. +
  100. XtToolkitInitialize();
  101. appc = XtCreateApplicationContext();
  102. @@ -123,12 +128,12 @@ top_setup(argc, argv)
  103. XtSetValues(top_shell, &arg, 1);
  104. - (void) XtGetApplicationResources(top_shell, (caddr_t) NULL,
  105. + (void) XtGetApplicationResources(top_shell, (caddr_t) &app_data,
  106. resources, XtNumber(resources),
  107. (ArgList) NULL, 0);
  108. - if ((cdInfoDir == NULL) && ((s=getenv("XCDINFODIR")) != NULL))
  109. - cdInfoDir = strdup(s);
  110. + if ((app_data.cdInfoDir == NULL) && ((s=getenv("XCDINFODIR")) != NULL))
  111. + app_data.cdInfoDir = strdup(s);
  112. top_form_widget = XtCreateWidget("mainForm", formWidgetClass,
  113. top_shell,