summaryrefslogtreecommitdiff
path: root/sysutils/libretto-config/files/patch-libapm.c
blob: 69d218e0b4acf15713a09d69f20b629d2d86482b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
$FreeBSD$

--- libapm.c.orig	Fri Jun 19 02:28:23 1998
+++ libapm.c	Sun Aug 22 23:31:55 2004
@@ -8,12 +8,19 @@
 /*                                                         */
 /***********************************************************/
 
+#undef HAVE_GETOPT_LONG
+#ifdef __linux__
+#define HAVE_GETOPT_LONG 1
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
 #include <string.h>
 #include <ctype.h>
+#ifdef HAVE_GETOPT_LONG
 #include <getopt.h>
+#endif
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/mman.h>
@@ -63,6 +70,7 @@
     int r;
     char c;
 
+#ifdef HAVE_GETOPT_LONG
     struct option longopts[] = {
       { "Help",        0, 0, 'h' },
       { "Version",     0, 0, 'v' },
@@ -78,6 +86,7 @@
 #endif /* CMOS_ACCESS */
       {0, 0, 0, 0}
     };
+#endif
 
     if( 0 != geteuid() ){
         printf("%s: Only root can execute !!\n", argv[0]);
@@ -98,8 +107,12 @@
 
     get_status();
 
+#ifdef HAVE_GETOPT_LONG
     while ((c = getopt_long(argc,argv,
                             "hvP:T:a:S:A:L:V:O:", longopts, NULL)) != -1) {
+#else
+    while ((c = getopt(argc,argv, "hvP:T:a:S:A:L:V:O:")) != -1) {
+#endif
       switch (c) {
         case 'h':
           usage();
@@ -189,7 +202,7 @@
         case '?':
           usage();
           break;
-        default:
+        default: break;
       }
     }
 #ifdef DEBUG
@@ -215,29 +228,60 @@
 void usage(void)
 {
 #ifdef CMOS_ACCESS
-    printf("
-usage: libapm [-v --Version]
-              [-h --Help]
-              [-P --PowerUp {boot,hibernation}]
-              [-T --StandbyTime {0,5,10,15,30,45,60,unlimit}]
-              [-a --AutoOff {disable,10,20,30,40,50,60}]
-              [-S --PanelSwitch {disable,enable}]
-              [-A --AlarmOn {disable,<time>}]
-              [-L --LcdPower {0,1,2,3}]
+# ifdef HAVE_GETOPT_LONG
+    printf("\n\
+usage: libretto-config [-v --Version]\n\
+              [-h --Help]\n\
+              [-P --PowerUp {boot,hibernation}]\n\
+              [-T --StandbyTime {0,5,10,15,30,45,60,unlimit}]\n\
+              [-a --AutoOff {disable,10,20,30,40,50,60}]\n\
+              [-S --PanelSwitch {disable,enable}]\n\
+              [-A --AlarmOn {disable,<time>}]\n\
+              [-L --LcdPower {0,1,2,3}]\n\
           \n");
-#else
-    printf("
-usage: libapm [-v --Version]
-              [-h --Help]
-              [-P --PowerUp {boot,hibernation}]
-              [-T --StandbyTime {0,5,10,15,30,45,60,unlimit}]
-              [-a --AutoOff {disable,10,20,30,40,50,60}]
-              [-S --PanelSwitch {disable,enable}]
-              [-A --AlarmOn {disable,<time>}]
-              [-L --LcdPower {0,1,2,3}]
-              [-V --Volume {0,1,2,3}]
-              [-O --Off {suspend|hibernation}  Use Only >= Libretto100]
+# else /* not HAVE_GETOPT_LONG */
+    printf("\n\
+usage: libretto-config [-v			: Version]\n\
+              [-h				: Help]\n\
+              [-P {boot,hibernation}		: PowerUp]\n\
+              [-T {0,5,10,15,30,45,60,unlimit}	: StandbyTime]\n\
+              [-a {disable,10,20,30,40,50,60}	: AutoOff]\n\
+              [-S {disable,enable}		: PanelSwitch]\n\
+              [-A {disable,<time>}		: AlarmOn]\n\
+              [-L {0,1,2,3}			: LcdPower]\n\
+          \n");
+# endif /* HAVE_GETOPT_LONG */
+
+#else /* not CMOS_ACCESS */
+
+# ifdef HAVE_GETOPT_LONG
+    printf("\
+usage: libretto-config [-v --Version]\n\
+              [-h --Help]\n\
+              [-P --PowerUp {boot,hibernation}]\n\
+              [-T --StandbyTime {0,5,10,15,30,45,60,unlimit}]\n\
+              [-a --AutoOff {disable,10,20,30,40,50,60}]\n\
+              [-S --PanelSwitch {disable,enable}]\n\
+              [-A --AlarmOn {disable,<time>}]\n\
+              [-L --LcdPower {0,1,2,3}]\n\
+              [-V --Volume {0,1,2,3}]\n\
+              [-O --Off {suspend|hibernation}  Use Only >= Libretto100]\n\
           \n");
+# else /* not HAVE_GETOPT_LONG */
+    printf("\
+usage: libretto-config [-v			: Version]\n\
+              [-h				: Help]\n\
+              [-P {boot,hibernation}		: PowerUp]\n\
+              [-T {0,5,10,15,30,45,60,unlimit}	: StandbyTime]\n\
+              [-a {disable,10,20,30,40,50,60}	: AutoOff]\n\
+              [-S {disable,enable}		: PanelSwitch]\n\
+              [-A {disable,<time>}		: AlarmOn]\n\
+              [-L {0,1,2,3}			: LcdPower]\n\
+              [-V {0,1,2,3}			: Volume]\n\
+              [-O {suspend|hibernation}		: Off (Use Only>=Libretto100)]\n\
+          \n");
+# endif /* HAVE_GETOPT_LONG */
+
 #endif /* CMOS_ACCESS */
     exit(1);
 }
@@ -246,7 +290,11 @@
 void init(void)
 {
   /* SMI port */
+#ifdef __linux__
   ioperm(0xb2, 1, 1);
+#else
+  open("/dev/io", O_RDWR, 0);
+#endif
 }
 #endif /* CMOS_ACCESS */
 
@@ -754,29 +802,29 @@
 #endif /* CMOS_ACCESS */
 
 #ifndef CMOS_ACCESS
-    printf("
-Power Management for Libretto V%-8s
-+-----------------------------------------------------------+
-|   0) Power-up Mode      : %-32s|
-|   1) Standby Time       : %-32s|
-|   2) System Auto Off    : %-32s|
-|   3) Panel Power On/Off : %-32s|
-|   4) Alarm Power On     : %-32s|
-|   5) LCD Power          : %-32s|
-|   6) Volume             : %-32s|
-|   7) Off (Suspend/Hiber): %-32s|
+    printf("\
+Power Management for Libretto V%-8s\n\
++-----------------------------------------------------------+\n\
+|   0) Power-up Mode      : %-32s|\n\
+|   1) Standby Time       : %-32s|\n\
+|   2) System Auto Off    : %-32s|\n\
+|   3) Panel Power On/Off : %-32s|\n\
+|   4) Alarm Power On     : %-32s|\n\
+|   5) LCD Power          : %-32s|\n\
+|   6) Volume             : %-32s|\n\
+|   7) Off (Suspend/Hiber): %-32s|\n\
 +-----------------------------------------------------------+\n\n",
     version, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]);
 #else
-    printf("
-Power Management for Libretto V%-8s
-+-----------------------------------------------------------+
-|   0) Power-up Mode      : %-32s|
-|   1) Standby Time       : %-32s|
-|   2) System Auto Off    : %-32s|
-|   3) Panel Power On/Off : %-32s|
-|   4) Alarm Power On     : %-32s|
-|   5) LCD Power          : %-32s|
+    printf("\
+Power Management for Libretto V%-8s\n\
++-----------------------------------------------------------+\n\
+|   0) Power-up Mode      : %-32s|\n\
+|   1) Standby Time       : %-32s|\n\
+|   2) System Auto Off    : %-32s|\n\
+|   3) Panel Power On/Off : %-32s|\n\
+|   4) Alarm Power On     : %-32s|\n\
+|   5) LCD Power          : %-32s|\n\
 +-----------------------------------------------------------+\n\n",
     version, s[0], s[1], s[2], s[3], s[4], s[5]);
 #endif /* CMOS_ACCESS */