summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-05-25 19:03:26 (UTC)
committer mickeyl <mickeyl>2005-05-25 19:03:26 (UTC)
commit8d2d91b9b6e590e474fe3acd92f71e40779a493b (patch) (unidiff)
tree877bf0b4c6a23892ed0d2d2a0a3e3aa7b82ee2a1
parent5fdc5b4cba7743947a23840ba09fadcc7414309b (diff)
downloadopie-8d2d91b9b6e590e474fe3acd92f71e40779a493b.zip
opie-8d2d91b9b6e590e474fe3acd92f71e40779a493b.tar.gz
opie-8d2d91b9b6e590e474fe3acd92f71e40779a493b.tar.bz2
be nice to gcc 3.3
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/linux/opcmciasystem.cpp b/libopie2/opiecore/linux/opcmciasystem.cpp
index 7bd7178..0f7ff46 100644
--- a/libopie2/opiecore/linux/opcmciasystem.cpp
+++ b/libopie2/opiecore/linux/opcmciasystem.cpp
@@ -65,257 +65,257 @@ OPcmciaSystem::OPcmciaSystem()
65 if ( procfile.exists() && procfile.open( IO_ReadOnly ) ) 65 if ( procfile.exists() && procfile.open( IO_ReadOnly ) )
66 { 66 {
67 QTextStream devstream( &procfile ); 67 QTextStream devstream( &procfile );
68 devstream.readLine(); // skip header 68 devstream.readLine(); // skip header
69 while ( !devstream.atEnd() && !_major ) 69 while ( !devstream.atEnd() && !_major )
70 { 70 {
71 int nodenumber; 71 int nodenumber;
72 QString driver; 72 QString driver;
73 devstream >> nodenumber >> driver; 73 devstream >> nodenumber >> driver;
74 if ( driver == "pcmcia" ) 74 if ( driver == "pcmcia" )
75 { 75 {
76 qDebug( "OPcmciaSystem::OPcmciaSystem(): gotcha! pcmcia node number = %d", nodenumber ); 76 qDebug( "OPcmciaSystem::OPcmciaSystem(): gotcha! pcmcia node number = %d", nodenumber );
77 _major = nodenumber; 77 _major = nodenumber;
78 break; 78 break;
79 } 79 }
80 } 80 }
81 } 81 }
82 else 82 else
83 { 83 {
84 qWarning( "OPcmciaSystem::OPcmciaSystem() - can't open /proc/devices - continuing with limited functionality." ); 84 qWarning( "OPcmciaSystem::OPcmciaSystem() - can't open /proc/devices - continuing with limited functionality." );
85 } 85 }
86 86
87 synchronize(); 87 synchronize();
88} 88}
89 89
90void OPcmciaSystem::synchronize() 90void OPcmciaSystem::synchronize()
91{ 91{
92 qDebug( "OPcmciaSystem::synchronize()" ); 92 qDebug( "OPcmciaSystem::synchronize()" );
93 _interfaces.clear(); 93 _interfaces.clear();
94 94
95 //FIXME: Use cardmgr subsystem ioctls 95 //FIXME: Use cardmgr subsystem ioctls
96 96
97 QString fileName; 97 QString fileName;
98 if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; } 98 if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; }
99 else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; } 99 else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; }
100 else { fileName = "/var/lib/pcmcia/stab"; } 100 else { fileName = "/var/lib/pcmcia/stab"; }
101 QFile cardinfofile( fileName ); 101 QFile cardinfofile( fileName );
102 if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) ) 102 if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) )
103 { 103 {
104 qWarning( "pcmcia info file not found or unaccessible" ); 104 qWarning( "pcmcia info file not found or unaccessible" );
105 return; 105 return;
106 } 106 }
107 QTextStream cardinfo( &cardinfofile ); 107 QTextStream cardinfo( &cardinfofile );
108 while ( !cardinfo.atEnd() ) 108 while ( !cardinfo.atEnd() )
109 { 109 {
110 QString strSocket; 110 QString strSocket;
111 int numSocket; 111 int numSocket;
112 char colon; 112 char colon;
113 QString cardName; 113 QString cardName;
114 cardinfo >> strSocket >> numSocket >> colon; 114 cardinfo >> strSocket >> numSocket >> colon;
115 cardName = cardinfo.readLine().stripWhiteSpace(); 115 cardName = cardinfo.readLine().stripWhiteSpace();
116 qDebug( "strSocket = '%s', numSocket = '%d', colon = '%c', cardName = '%s'", (const char*) strSocket, numSocket, colon, ( const char*) cardName ); 116 qDebug( "strSocket = '%s', numSocket = '%d', colon = '%c', cardName = '%s'", (const char*) strSocket, numSocket, colon, ( const char*) cardName );
117 if ( strSocket == "Socket" && colon == ':' ) 117 if ( strSocket == "Socket" && colon == ':' )
118 { 118 {
119 _interfaces.append( new OPcmciaSocket( _major, numSocket, this, (const char*) cardName ) ); 119 _interfaces.append( new OPcmciaSocket( _major, numSocket, this, (const char*) cardName ) );
120 } 120 }
121 else 121 else
122 { 122 {
123 continue; 123 continue;
124 } 124 }
125 } 125 }
126} 126}
127 127
128 128
129int OPcmciaSystem::count() const 129int OPcmciaSystem::count() const
130{ 130{
131 return _interfaces.count(); 131 return _interfaces.count();
132} 132}
133 133
134 134
135int OPcmciaSystem::cardCount() const 135int OPcmciaSystem::cardCount() const
136{ 136{
137 int nonEmpty = 0; 137 int nonEmpty = 0;
138 OPcmciaSystem::CardIterator it = iterator(); 138 OPcmciaSystem::CardIterator it = iterator();
139 while ( it.current() ) 139 while ( it.current() )
140 { 140 {
141 if ( !it.current()->isEmpty() ) nonEmpty++; 141 if ( !it.current()->isEmpty() ) nonEmpty++;
142 ++it; 142 ++it;
143 } 143 }
144 return nonEmpty; 144 return nonEmpty;
145} 145}
146 146
147 147
148OPcmciaSocket* OPcmciaSystem::socket( unsigned int number ) 148OPcmciaSocket* OPcmciaSystem::socket( unsigned int number )
149{ 149{
150 return _interfaces.at( number ); 150 return _interfaces.at( number );
151} 151}
152 152
153 153
154OPcmciaSystem* OPcmciaSystem::instance() 154OPcmciaSystem* OPcmciaSystem::instance()
155{ 155{
156 if ( !_instance ) _instance = new OPcmciaSystem(); 156 if ( !_instance ) _instance = new OPcmciaSystem();
157 return _instance; 157 return _instance;
158} 158}
159 159
160 160
161OPcmciaSystem::CardIterator OPcmciaSystem::iterator() const 161OPcmciaSystem::CardIterator OPcmciaSystem::iterator() const
162{ 162{
163 return OPcmciaSystem::CardIterator( _interfaces ); 163 return OPcmciaSystem::CardIterator( _interfaces );
164} 164}
165 165
166 166
167/*====================================================================================== 167/*======================================================================================
168 * OPcmciaSocket 168 * OPcmciaSocket
169 *======================================================================================*/ 169 *======================================================================================*/
170 170
171OPcmciaSocket::OPcmciaSocket( int major, int socket, QObject* parent, const char* name ) 171OPcmciaSocket::OPcmciaSocket( int major, int socket, QObject* parent, const char* name )
172 :QObject( parent, name ), _major( major ), _socket( socket ) 172 :QObject( parent, name ), _major( major ), _socket( socket )
173{ 173{
174 qDebug( "OPcmciaSocket::OPcmciaSocket()" ); 174 qDebug( "OPcmciaSocket::OPcmciaSocket()" );
175 175
176 init(); 176 init();
177 buildInformation(); 177 buildInformation();
178} 178}
179 179
180 180
181OPcmciaSocket::~OPcmciaSocket() 181OPcmciaSocket::~OPcmciaSocket()
182{ 182{
183 qDebug( "OPcmciaSocket::~OPcmciaSocket()" ); 183 qDebug( "OPcmciaSocket::~OPcmciaSocket()" );
184 cleanup(); 184 cleanup();
185} 185}
186 186
187 187
188/* internal */ void OPcmciaSocket::init() 188/* internal */ void OPcmciaSocket::init()
189{ 189{
190 // open control socket and gather file descriptor 190 // open control socket and gather file descriptor
191 if ( _major ) 191 if ( _major )
192 { 192 {
193 dev_t dev = ::makedev( _major, _socket ); 193 dev_t dev = makedev( _major, _socket );
194 QString filename = QString().sprintf( "/tmp/opcmciasystem-%d", ::getpid() ); 194 QString filename = QString().sprintf( "/tmp/opcmciasystem-%d", ::getpid() );
195 if ( ::mknod( (const char*) filename, ( S_IFCHR|S_IREAD|S_IWRITE ), dev ) == 0 ) 195 if ( ::mknod( (const char*) filename, ( S_IFCHR|S_IREAD|S_IWRITE ), dev ) == 0 )
196 { 196 {
197 _fd = ::open( (const char*) filename, O_RDONLY); 197 _fd = ::open( (const char*) filename, O_RDONLY);
198 if ( !_fd ) 198 if ( !_fd )
199 { 199 {
200 qWarning( "OPcmciaSocket::init() - can't open control socket (%s)", strerror( errno ) ); 200 qWarning( "OPcmciaSocket::init() - can't open control socket (%s)", strerror( errno ) );
201 } 201 }
202 else 202 else
203 { 203 {
204 ::unlink( (const char*) filename ); 204 ::unlink( (const char*) filename );
205 } 205 }
206 } 206 }
207 else 207 else
208 { 208 {
209 qWarning( "OPcmciaSocket::init() - can't create device node (%s)", strerror( errno ) ); 209 qWarning( "OPcmciaSocket::init() - can't create device node (%s)", strerror( errno ) );
210 } 210 }
211 } 211 }
212} 212}
213 213
214/* internal */ void OPcmciaSocket::buildInformation() 214/* internal */ void OPcmciaSocket::buildInformation()
215{ 215{
216 cistpl_vers_1_t *vers = &_ioctlarg.tuple_parse.parse.version_1; 216 cistpl_vers_1_t *vers = &_ioctlarg.tuple_parse.parse.version_1;
217 cistpl_manfid_t *manfid = &_ioctlarg.tuple_parse.parse.manfid; 217 cistpl_manfid_t *manfid = &_ioctlarg.tuple_parse.parse.manfid;
218 cistpl_funcid_t *funcid = &_ioctlarg.tuple_parse.parse.funcid; 218 cistpl_funcid_t *funcid = &_ioctlarg.tuple_parse.parse.funcid;
219 config_info_t config; 219 config_info_t config;
220 220
221 if ( getTuple( CISTPL_VERS_1 ) ) 221 if ( getTuple( CISTPL_VERS_1 ) )
222 { 222 {
223 for ( int i = 0; i < CISTPL_VERS_1_MAX_PROD_STRINGS; ++i ) 223 for ( int i = 0; i < CISTPL_VERS_1_MAX_PROD_STRINGS; ++i )
224 { 224 {
225 qDebug( " PRODID = '%s'", vers->str+vers->ofs[i] ); 225 qDebug( " PRODID = '%s'", vers->str+vers->ofs[i] );
226 _productId += vers->str+vers->ofs[i]; 226 _productId += vers->str+vers->ofs[i];
227 } 227 }
228 } 228 }
229 /* 229 /*
230 for (i = 0; i < 4; i++) 230 for (i = 0; i < 4; i++)
231 printf("PRODID_%d=\"%s\"\n", i+1, 231 printf("PRODID_%d=\"%s\"\n", i+1,
232 (i < vers->ns) ? vers->str+vers->ofs[i] : ""); 232 (i < vers->ns) ? vers->str+vers->ofs[i] : "");
233 *manfid = (cistpl_manfid_t) { 0, 0 }; 233 *manfid = (cistpl_manfid_t) { 0, 0 };
234 get_tuple(fd, CISTPL_MANFID, &arg); 234 get_tuple(fd, CISTPL_MANFID, &arg);
235 printf("MANFID=%04x,%04x\n", manfid->manf, manfid->card); 235 printf("MANFID=%04x,%04x\n", manfid->manf, manfid->card);
236 *funcid = (cistpl_funcid_t) { 0xff, 0xff }; 236 *funcid = (cistpl_funcid_t) { 0xff, 0xff };
237 get_tuple(fd, CISTPL_FUNCID, &arg); 237 get_tuple(fd, CISTPL_FUNCID, &arg);
238 printf("FUNCID=%d\n", funcid->func); 238 printf("FUNCID=%d\n", funcid->func);
239 config.Function = config.ConfigBase = 0; 239 config.Function = config.ConfigBase = 0;
240 */ 240 */
241} 241}
242 242
243/* internal */ void OPcmciaSocket::cleanup() 243/* internal */ void OPcmciaSocket::cleanup()
244{ 244{
245 // close control socket 245 // close control socket
246} 246}
247 247
248/* internal */ bool OPcmciaSocket::getTuple( cisdata_t tuple ) 248/* internal */ bool OPcmciaSocket::getTuple( cisdata_t tuple )
249{ 249{
250 _ioctlarg.tuple.DesiredTuple = tuple; 250 _ioctlarg.tuple.DesiredTuple = tuple;
251 _ioctlarg.tuple.Attributes = TUPLE_RETURN_COMMON; 251 _ioctlarg.tuple.Attributes = TUPLE_RETURN_COMMON;
252 _ioctlarg.tuple.TupleOffset = 0; 252 _ioctlarg.tuple.TupleOffset = 0;
253 253
254 int result; 254 int result;
255 result = ::ioctl(_fd, DS_GET_FIRST_TUPLE, &_ioctlarg); 255 result = ::ioctl(_fd, DS_GET_FIRST_TUPLE, &_ioctlarg);
256 if ( result != 0 ) 256 if ( result != 0 )
257 { 257 {
258 qWarning( "OPcmciaSocket::getTuple() - DS_GET_FIRST_TUPLE failed (%s)", strerror( errno ) ); 258 qWarning( "OPcmciaSocket::getTuple() - DS_GET_FIRST_TUPLE failed (%s)", strerror( errno ) );
259 return false; 259 return false;
260 } 260 }
261 261
262 result = ::ioctl(_fd, DS_GET_TUPLE_DATA, &_ioctlarg); 262 result = ::ioctl(_fd, DS_GET_TUPLE_DATA, &_ioctlarg);
263 if ( result != 0 ) 263 if ( result != 0 )
264 { 264 {
265 qWarning( "OPcmciaSocket::getTuple() - DS_GET_TUPLE_DATA failed (%s)", strerror( errno ) ); 265 qWarning( "OPcmciaSocket::getTuple() - DS_GET_TUPLE_DATA failed (%s)", strerror( errno ) );
266 return false; 266 return false;
267 } 267 }
268 268
269 result = ::ioctl(_fd, DS_PARSE_TUPLE, &_ioctlarg); 269 result = ::ioctl(_fd, DS_PARSE_TUPLE, &_ioctlarg);
270 if ( result != 0 ) 270 if ( result != 0 )
271 { 271 {
272 qWarning( "OPcmciaSocket::getTuple() - DS_PARSE_TUPLE failed (%s)", strerror( errno ) ); 272 qWarning( "OPcmciaSocket::getTuple() - DS_PARSE_TUPLE failed (%s)", strerror( errno ) );
273 return false; 273 return false;
274 } 274 }
275 275
276 return true; 276 return true;
277} 277}
278 278
279 279
280/* internal */ bool OPcmciaSocket::command( const QString& cmd ) 280/* internal */ bool OPcmciaSocket::command( const QString& cmd )
281{ 281{
282 QString cmdline = QString().sprintf( "cardctl %s %d &", (const char*) cmd, _socket ); 282 QString cmdline = QString().sprintf( "cardctl %s %d &", (const char*) cmd, _socket );
283 ::system( (const char*) cmdline ); 283 ::system( (const char*) cmdline );
284} 284}
285 285
286int OPcmciaSocket::number() const 286int OPcmciaSocket::number() const
287{ 287{
288 return _socket; 288 return _socket;
289} 289}
290 290
291 291
292QString OPcmciaSocket::identity() const 292QString OPcmciaSocket::identity() const
293{ 293{
294 return ( strcmp( name(), "empty" ) == 0 ) ? "<Empty Socket>" : name(); 294 return ( strcmp( name(), "empty" ) == 0 ) ? "<Empty Socket>" : name();
295} 295}
296 296
297 297
298bool OPcmciaSocket::isUnsupported() const 298bool OPcmciaSocket::isUnsupported() const
299{ 299{
300 return ( strcmp( name(), "unsupported card" ) == 0 ); 300 return ( strcmp( name(), "unsupported card" ) == 0 );
301} 301}
302 302
303 303
304bool OPcmciaSocket::isEmpty() const 304bool OPcmciaSocket::isEmpty() const
305{ 305{
306 return ( strcmp( name(), "empty" ) == 0 ); 306 return ( strcmp( name(), "empty" ) == 0 );
307} 307}
308 308
309 309
310bool OPcmciaSocket::isSuspended() const 310bool OPcmciaSocket::isSuspended() const
311{ 311{
312 //FIXME 312 //FIXME
313 return false; 313 return false;
314} 314}
315 315
316bool OPcmciaSocket::eject() 316bool OPcmciaSocket::eject()
317{ 317{
318 return command( "eject" ); 318 return command( "eject" );
319} 319}
320 320
321bool OPcmciaSocket::insert() 321bool OPcmciaSocket::insert()