Mercurial > audlegacy-plugins
comparison src/evdev-plug/ed_internals.c @ 2323:a48a1a3e835a
- fixed /proc/bus/input/devices parser error when there are multiple lines between phys and handlers, thanks to Checkryzhev Vitaly for report and patch
| author | Giacomo Lozito <james@develia.org> |
|---|---|
| date | Wed, 16 Jan 2008 23:07:15 +0100 |
| parents | 581a057768c2 |
| children | bd3a24b39058 |
comparison
equal
deleted
inserted
replaced
| 2322:4bb86ffd9ddf | 2323:a48a1a3e835a |
|---|---|
| 376 g_io_channel_unref( iochan ); | 376 g_io_channel_unref( iochan ); |
| 377 close( fd ); | 377 close( fd ); |
| 378 | 378 |
| 379 /* parse content of /proc/bus/input/devices */ | 379 /* parse content of /proc/bus/input/devices */ |
| 380 regcomp( &preg, | 380 regcomp( &preg, |
| 381 "I:[^\n]*\nN: Name=\"([^\n]*)\"\nP: Phys=([^\n]*)\n[^\n]+\nH: Handlers=[^\n]*(event[0-9]+)[^\n]*\n" , | 381 "I:[^\n]*\nN: Name=\"([^\n]*)\"\nP: Phys=([^\n]*)\n([^\n]+\n)*H: Handlers=[^\n]*(event[0-9]+)[^\n]*\n" , |
| 382 REG_ICASE | REG_EXTENDED ); | 382 REG_ICASE | REG_EXTENDED ); |
| 383 | 383 |
| 384 while ( search_offset > -1 ) | 384 while ( search_offset > -1 ) |
| 385 { | 385 { |
| 386 size_t nmatch = 4; | 386 size_t nmatch = 5; |
| 387 regmatch_t submatch[4]; | 387 regmatch_t submatch[5]; |
| 388 | 388 |
| 389 if ( regexec( &preg , &buffer[search_offset] , nmatch , submatch , 0 ) == 0 ) | 389 if ( regexec( &preg , &buffer[search_offset] , nmatch , submatch , 0 ) == 0 ) |
| 390 { | 390 { |
| 391 GString *device_name = NULL; | 391 GString *device_name = NULL; |
| 392 GString *device_phys = NULL; | 392 GString *device_phys = NULL; |
| 406 g_string_append_len( device_phys , | 406 g_string_append_len( device_phys , |
| 407 &buffer[(search_offset + submatch[2].rm_so)] , | 407 &buffer[(search_offset + submatch[2].rm_so)] , |
| 408 submatch[2].rm_eo - submatch[2].rm_so ); | 408 submatch[2].rm_eo - submatch[2].rm_so ); |
| 409 } | 409 } |
| 410 | 410 |
| 411 if ( submatch[3].rm_so != -1 ) /* check validity of filename sub-expression */ | 411 if ( submatch[4].rm_so != -1 ) /* check validity of filename sub-expression */ |
| 412 { | 412 { |
| 413 device_file = g_string_new( "" ); | 413 device_file = g_string_new( "" ); |
| 414 GString *device_test = g_string_new( "" ); | 414 GString *device_test = g_string_new( "" ); |
| 415 g_string_append_len( device_file , | 415 g_string_append_len( device_file , |
| 416 &buffer[(search_offset + submatch[3].rm_so)] , | 416 &buffer[(search_offset + submatch[4].rm_so)] , |
| 417 submatch[3].rm_eo - submatch[3].rm_so ); | 417 submatch[4].rm_eo - submatch[4].rm_so ); |
| 418 | 418 |
| 419 /* let's check if the filename actually exists in /dev */ | 419 /* let's check if the filename actually exists in /dev */ |
| 420 g_string_printf( device_test , "/dev/input/%s" , (char*)device_file->str ); | 420 g_string_printf( device_test , "/dev/input/%s" , (char*)device_file->str ); |
| 421 if ( !g_file_test( device_test->str , G_FILE_TEST_EXISTS ) ) | 421 if ( !g_file_test( device_test->str , G_FILE_TEST_EXISTS ) ) |
| 422 { | 422 { |
