author | erik <erik> | 2007-01-29 21:53:48 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-29 21:53:48 (UTC) |
commit | 02ef45be75a3024df11365956e1cce6392d9103c (patch) (unidiff) | |
tree | 42fd5c909d67a473f57a607e01d32e01b3dd2511 | |
parent | b2c306a99b8dc82c981390f02db859149fac8cf0 (diff) | |
download | opie-02ef45be75a3024df11365956e1cce6392d9103c.zip opie-02ef45be75a3024df11365956e1cce6392d9103c.tar.gz opie-02ef45be75a3024df11365956e1cce6392d9103c.tar.bz2 |
Each file in this commit has an issue where the initial value of a variable
is assumed to be something but no initial value is given.
This commit changes that by either assigning an initial value or removing
the assumption on an initial value (usually the former).
-rw-r--r-- | libopie2/opiecore/device/odevice_htc.cpp | 3 | ||||
-rw-r--r-- | libopie2/opiepim/private/opimeventsortvector.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 59 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_irda.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 10 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CFilter.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CRegExp.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Palm2QImage.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-reader/QTReader.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/plucker_base.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-reader/striphtml.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katehighlight.cpp | 10 | ||||
-rw-r--r-- | noncore/net/ftplib/ftplib.c | 2 | ||||
-rw-r--r-- | noncore/settings/sysinfo/contrib/dhry.c | 2 |
14 files changed, 56 insertions, 56 deletions
diff --git a/libopie2/opiecore/device/odevice_htc.cpp b/libopie2/opiecore/device/odevice_htc.cpp index c21e10d..4e5200b 100644 --- a/libopie2/opiecore/device/odevice_htc.cpp +++ b/libopie2/opiecore/device/odevice_htc.cpp | |||
@@ -231,374 +231,373 @@ void HTC::initButtons() | |||
231 | struct htc_button * phtc_buttons; | 231 | struct htc_button * phtc_buttons; |
232 | int buttoncount; | 232 | int buttoncount; |
233 | switch ( d->m_model ) | 233 | switch ( d->m_model ) |
234 | { | 234 | { |
235 | case Model_HTC_Universal: | 235 | case Model_HTC_Universal: |
236 | if ( isQWS( ) ) | 236 | if ( isQWS( ) ) |
237 | { | 237 | { |
238 | addPreHandler(this); | 238 | addPreHandler(this); |
239 | } | 239 | } |
240 | phtc_buttons = htc_buttons_universal; | 240 | phtc_buttons = htc_buttons_universal; |
241 | buttoncount = ARRAY_SIZE(htc_buttons_universal); | 241 | buttoncount = ARRAY_SIZE(htc_buttons_universal); |
242 | break; | 242 | break; |
243 | default: | 243 | default: |
244 | phtc_buttons = htc_buttons; | 244 | phtc_buttons = htc_buttons; |
245 | buttoncount = ARRAY_SIZE(htc_buttons); | 245 | buttoncount = ARRAY_SIZE(htc_buttons); |
246 | break; | 246 | break; |
247 | } | 247 | } |
248 | 248 | ||
249 | for ( int i = 0; i < buttoncount; i++ ) { | 249 | for ( int i = 0; i < buttoncount; i++ ) { |
250 | struct htc_button *zb = phtc_buttons + i; | 250 | struct htc_button *zb = phtc_buttons + i; |
251 | ODeviceButton b; | 251 | ODeviceButton b; |
252 | 252 | ||
253 | b.setKeycode( zb->code ); | 253 | b.setKeycode( zb->code ); |
254 | b.setUserText( QObject::tr( "Button", zb->utext )); | 254 | b.setUserText( QObject::tr( "Button", zb->utext )); |
255 | b.setPixmap( OResource::loadPixmap( zb->pix )); | 255 | b.setPixmap( OResource::loadPixmap( zb->pix )); |
256 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 256 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
257 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 257 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
258 | d->m_buttons->append( b ); | 258 | d->m_buttons->append( b ); |
259 | } | 259 | } |
260 | 260 | ||
261 | reloadButtonMapping(); | 261 | reloadButtonMapping(); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | 265 | ||
266 | typedef struct sharp_led_status { | 266 | typedef struct sharp_led_status { |
267 | int which; /* select which LED status is wanted. */ | 267 | int which; /* select which LED status is wanted. */ |
268 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 268 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
269 | } sharp_led_status; | 269 | } sharp_led_status; |
270 | 270 | ||
271 | void HTC::buzzer( int sound ) | 271 | void HTC::buzzer( int sound ) |
272 | { | 272 | { |
273 | #ifndef QT_NO_SOUND | 273 | #ifndef QT_NO_SOUND |
274 | Sound *snd = 0; | 274 | Sound *snd = 0; |
275 | 275 | ||
276 | // All devices except SL5500 have a DSP device | 276 | // All devices except SL5500 have a DSP device |
277 | if ( d->m_model == Model_HTC_Universal ) { | 277 | if ( d->m_model == Model_HTC_Universal ) { |
278 | 278 | ||
279 | switch ( sound ){ | 279 | switch ( sound ){ |
280 | case SHARP_BUZ_TOUCHSOUND: { | 280 | case SHARP_BUZ_TOUCHSOUND: { |
281 | static Sound touch_sound("touchsound"); | 281 | static Sound touch_sound("touchsound"); |
282 | snd = &touch_sound; | 282 | snd = &touch_sound; |
283 | } | 283 | } |
284 | break; | 284 | break; |
285 | case SHARP_BUZ_KEYSOUND: { | 285 | case SHARP_BUZ_KEYSOUND: { |
286 | static Sound key_sound( "keysound" ); | 286 | static Sound key_sound( "keysound" ); |
287 | snd = &key_sound; | 287 | snd = &key_sound; |
288 | } | 288 | } |
289 | break; | 289 | break; |
290 | case SHARP_BUZ_SCHEDULE_ALARM: | 290 | case SHARP_BUZ_SCHEDULE_ALARM: |
291 | default: { | 291 | default: { |
292 | static Sound alarm_sound("alarm"); | 292 | static Sound alarm_sound("alarm"); |
293 | snd = &alarm_sound; | 293 | snd = &alarm_sound; |
294 | } | 294 | } |
295 | break; | 295 | break; |
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | // If a soundname is defined, we expect that this device has | 299 | // If a soundname is defined, we expect that this device has |
300 | // sound capabilities.. Otherwise we expect to have the buzzer | 300 | // sound capabilities.. Otherwise we expect to have the buzzer |
301 | // device.. | 301 | // device.. |
302 | if ( snd && snd->isFinished() ){ | 302 | if ( snd && snd->isFinished() ){ |
303 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 303 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
304 | snd->play(); | 304 | snd->play(); |
305 | } else if( !snd ) { | 305 | } else if( !snd ) { |
306 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 306 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
307 | 307 | ||
308 | if ( fd >= 0 ) { | 308 | if ( fd >= 0 ) { |
309 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 309 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
310 | ::close ( fd ); | 310 | ::close ( fd ); |
311 | } | 311 | } |
312 | 312 | ||
313 | } | 313 | } |
314 | #endif | 314 | #endif |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void HTC::playAlarmSound() | 318 | void HTC::playAlarmSound() |
319 | { | 319 | { |
320 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 320 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
321 | } | 321 | } |
322 | 322 | ||
323 | void HTC::playTouchSound() | 323 | void HTC::playTouchSound() |
324 | { | 324 | { |
325 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 325 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
326 | } | 326 | } |
327 | 327 | ||
328 | void HTC::playKeySound() | 328 | void HTC::playKeySound() |
329 | { | 329 | { |
330 | buzzer( SHARP_BUZ_KEYSOUND ); | 330 | buzzer( SHARP_BUZ_KEYSOUND ); |
331 | } | 331 | } |
332 | 332 | ||
333 | 333 | ||
334 | QValueList <OLed> HTC::ledList() const | 334 | QValueList <OLed> HTC::ledList() const |
335 | { | 335 | { |
336 | QValueList <OLed> vl; | 336 | QValueList <OLed> vl; |
337 | vl << Led_Mail; | 337 | vl << Led_Mail; |
338 | return vl; | 338 | return vl; |
339 | } | 339 | } |
340 | 340 | ||
341 | QValueList <OLedState> HTC::ledStateList( OLed l ) const | 341 | QValueList <OLedState> HTC::ledStateList( OLed l ) const |
342 | { | 342 | { |
343 | QValueList <OLedState> vl; | 343 | QValueList <OLedState> vl; |
344 | 344 | ||
345 | if ( l == Led_Mail ) | 345 | if ( l == Led_Mail ) |
346 | vl << Led_Off << Led_On << Led_BlinkSlow; | 346 | vl << Led_Off << Led_On << Led_BlinkSlow; |
347 | return vl; | 347 | return vl; |
348 | } | 348 | } |
349 | 349 | ||
350 | OLedState HTC::ledState( OLed which ) const | 350 | OLedState HTC::ledState( OLed which ) const |
351 | { | 351 | { |
352 | if ( which == Led_Mail ) | 352 | if ( which == Led_Mail ) |
353 | return m_leds [0]; | 353 | return m_leds [0]; |
354 | else | 354 | else |
355 | return Led_Off; | 355 | return Led_Off; |
356 | } | 356 | } |
357 | 357 | ||
358 | bool HTC::setLedState( OLed which, OLedState st ) | 358 | bool HTC::setLedState( OLed which, OLedState st ) |
359 | { | 359 | { |
360 | qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); | 360 | qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); |
361 | return false; | 361 | return false; |
362 | } | 362 | } |
363 | 363 | ||
364 | int HTC::displayBrightnessResolution() const | 364 | int HTC::displayBrightnessResolution() const |
365 | { | 365 | { |
366 | int res = 1; | 366 | int res = 1; |
367 | 367 | ||
368 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 368 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
369 | 369 | ||
370 | if ( fd ) | 370 | if ( fd ) |
371 | { | 371 | { |
372 | char buf[100]; | 372 | char buf[100]; |
373 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 373 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
374 | ::close( fd ); | 374 | ::close( fd ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return res; | 377 | return res; |
378 | } | 378 | } |
379 | 379 | ||
380 | bool HTC::setDisplayBrightness( int bright ) | 380 | bool HTC::setDisplayBrightness( int bright ) |
381 | { | 381 | { |
382 | 382 | ||
383 | //qDebug( "HTC::setDisplayBrightness( %d )", bright ); | 383 | //qDebug( "HTC::setDisplayBrightness( %d )", bright ); |
384 | bool res = false; | 384 | bool res = false; |
385 | 385 | ||
386 | if ( bright > 255 ) bright = 255; | 386 | if ( bright > 255 ) bright = 255; |
387 | if ( bright < 0 ) bright = 0; | 387 | if ( bright < 0 ) bright = 0; |
388 | 388 | ||
389 | int numberOfSteps = displayBrightnessResolution(); | 389 | int numberOfSteps = displayBrightnessResolution(); |
390 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 390 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
391 | 391 | ||
392 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 392 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
393 | if ( fd ) | 393 | if ( fd ) |
394 | { | 394 | { |
395 | char buf[100]; | 395 | char buf[100]; |
396 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 396 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
397 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 397 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
398 | ::close( fd ); | 398 | ::close( fd ); |
399 | } | 399 | } |
400 | return res; | 400 | return res; |
401 | } | 401 | } |
402 | 402 | ||
403 | bool HTC::setDisplayStatus( bool on ) | 403 | bool HTC::setDisplayStatus( bool on ) |
404 | { | 404 | { |
405 | 405 | ||
406 | bool res = false; | 406 | bool res = false; |
407 | 407 | ||
408 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); | 408 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); |
409 | if ( fd ) | 409 | if ( fd ) |
410 | { | 410 | { |
411 | char buf[10]; | 411 | char buf[10]; |
412 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 412 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
413 | buf[1] = '\0'; | 413 | buf[1] = '\0'; |
414 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 414 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
415 | ::close( fd ); | 415 | ::close( fd ); |
416 | } | 416 | } |
417 | return res; | 417 | return res; |
418 | } | 418 | } |
419 | 419 | ||
420 | Transformation HTC::rotation() const | 420 | Transformation HTC::rotation() const |
421 | { | 421 | { |
422 | qDebug( "HTC::rotation()" ); | 422 | qDebug( "HTC::rotation()" ); |
423 | Transformation rot; | 423 | Transformation rot = Rot270; |
424 | 424 | ||
425 | switch ( d->m_model ) { | 425 | switch ( d->m_model ) { |
426 | case Model_HTC_Universal: | 426 | case Model_HTC_Universal: |
427 | { | 427 | { |
428 | OHingeStatus hs = readHingeSensor(); | 428 | OHingeStatus hs = readHingeSensor(); |
429 | qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs ); | 429 | qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs ); |
430 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 430 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
431 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; | 431 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; |
432 | else rot = Rot270; | ||
433 | } | 432 | } |
434 | break; | 433 | break; |
435 | } | 434 | } |
436 | 435 | ||
437 | qDebug( "HTC::rotation() - returning '%d'", rot ); | 436 | qDebug( "HTC::rotation() - returning '%d'", rot ); |
438 | return rot; | 437 | return rot; |
439 | } | 438 | } |
440 | ODirection HTC::direction() const | 439 | ODirection HTC::direction() const |
441 | { | 440 | { |
442 | ODirection dir; | 441 | ODirection dir; |
443 | 442 | ||
444 | switch ( d->m_model ) { | 443 | switch ( d->m_model ) { |
445 | case Model_HTC_Universal: { | 444 | case Model_HTC_Universal: { |
446 | OHingeStatus hs = readHingeSensor(); | 445 | OHingeStatus hs = readHingeSensor(); |
447 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 446 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
448 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 447 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
449 | else dir = CW; | 448 | else dir = CW; |
450 | } | 449 | } |
451 | break; | 450 | break; |
452 | default: dir = d->m_direction; | 451 | default: dir = d->m_direction; |
453 | break; | 452 | break; |
454 | } | 453 | } |
455 | return dir; | 454 | return dir; |
456 | 455 | ||
457 | } | 456 | } |
458 | 457 | ||
459 | bool HTC::hasHingeSensor() const | 458 | bool HTC::hasHingeSensor() const |
460 | { | 459 | { |
461 | return d->m_model == Model_HTC_Universal; | 460 | return d->m_model == Model_HTC_Universal; |
462 | } | 461 | } |
463 | 462 | ||
464 | OHingeStatus HTC::readHingeSensor() const | 463 | OHingeStatus HTC::readHingeSensor() const |
465 | { | 464 | { |
466 | /* | 465 | /* |
467 | * The HTC Universal keyboard is event source 1 in kernel 2.6. | 466 | * The HTC Universal keyboard is event source 1 in kernel 2.6. |
468 | * Hinge status is reported via Input System Switchs 0 and 1 like that: | 467 | * Hinge status is reported via Input System Switchs 0 and 1 like that: |
469 | * | 468 | * |
470 | * ------------------------- | 469 | * ------------------------- |
471 | * | SW0 | SW1 | CASE | | 470 | * | SW0 | SW1 | CASE | |
472 | * |-----|-----|-----------| | 471 | * |-----|-----|-----------| |
473 | * | 0 0 Unknown | | 472 | * | 0 0 Unknown | |
474 | * | 1 0 Portrait | | 473 | * | 1 0 Portrait | |
475 | * | 0 1 Closed | | 474 | * | 0 1 Closed | |
476 | * | 1 1 Landscape | | 475 | * | 1 1 Landscape | |
477 | * ------------------------- | 476 | * ------------------------- |
478 | */ | 477 | */ |
479 | OInputDevice* keyboard = OInputSystem::instance()->device( "event1" ); | 478 | OInputDevice* keyboard = OInputSystem::instance()->device( "event1" ); |
480 | bool switch0 = true; | 479 | bool switch0 = true; |
481 | bool switch1 = false; | 480 | bool switch1 = false; |
482 | if ( keyboard ) | 481 | if ( keyboard ) |
483 | { | 482 | { |
484 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); | 483 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); |
485 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); | 484 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); |
486 | } | 485 | } |
487 | if ( switch0 ) | 486 | if ( switch0 ) |
488 | { | 487 | { |
489 | return switch1 ? CASE_LANDSCAPE : CASE_PORTRAIT; | 488 | return switch1 ? CASE_LANDSCAPE : CASE_PORTRAIT; |
490 | } | 489 | } |
491 | else | 490 | else |
492 | { | 491 | { |
493 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; | 492 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; |
494 | } | 493 | } |
495 | } | 494 | } |
496 | 495 | ||
497 | void HTC::initHingeSensor() | 496 | void HTC::initHingeSensor() |
498 | { | 497 | { |
499 | if ( m_embedix ) return; | 498 | if ( m_embedix ) return; |
500 | 499 | ||
501 | m_hinge.setName( "/dev/input/event1" ); | 500 | m_hinge.setName( "/dev/input/event1" ); |
502 | if ( !m_hinge.open( IO_ReadOnly ) ) | 501 | if ( !m_hinge.open( IO_ReadOnly ) ) |
503 | { | 502 | { |
504 | qWarning( "HTC::init() - Couldn't open /dev/input/event1 for read (%s)", strerror( errno ) ); | 503 | qWarning( "HTC::init() - Couldn't open /dev/input/event1 for read (%s)", strerror( errno ) ); |
505 | return; | 504 | return; |
506 | } | 505 | } |
507 | 506 | ||
508 | QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this ); | 507 | QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this ); |
509 | QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) ); | 508 | QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) ); |
510 | 509 | ||
511 | qDebug( "HTC::init() - Hinge Sensor Initialization successfully completed" ); | 510 | qDebug( "HTC::init() - Hinge Sensor Initialization successfully completed" ); |
512 | } | 511 | } |
513 | 512 | ||
514 | void HTC::hingeSensorTriggered() | 513 | void HTC::hingeSensorTriggered() |
515 | { | 514 | { |
516 | qDebug( "HTC::hingeSensorTriggered() - got event" ); | 515 | qDebug( "HTC::hingeSensorTriggered() - got event" ); |
517 | struct input_event e; | 516 | struct input_event e; |
518 | if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 ) | 517 | if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 ) |
519 | { | 518 | { |
520 | qDebug( "HTC::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value ); | 519 | qDebug( "HTC::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value ); |
521 | if ( e.type != EV_SW ) return; | 520 | if ( e.type != EV_SW ) return; |
522 | if ( readHingeSensor() != CASE_UNKNOWN ) | 521 | if ( readHingeSensor() != CASE_UNKNOWN ) |
523 | { | 522 | { |
524 | qDebug( "HTC::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" ); | 523 | qDebug( "HTC::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" ); |
525 | QCopChannel::send( "QPE/Rotation", "rotateDefault()" ); | 524 | QCopChannel::send( "QPE/Rotation", "rotateDefault()" ); |
526 | } | 525 | } |
527 | } | 526 | } |
528 | } | 527 | } |
529 | 528 | ||
530 | void HTC::systemMessage( const QCString &msg, const QByteArray & ) | 529 | void HTC::systemMessage( const QCString &msg, const QByteArray & ) |
531 | { | 530 | { |
532 | if ( msg == "deviceButtonMappingChanged()" ) { | 531 | if ( msg == "deviceButtonMappingChanged()" ) { |
533 | reloadButtonMapping(); | 532 | reloadButtonMapping(); |
534 | } | 533 | } |
535 | } | 534 | } |
536 | 535 | ||
537 | /* | 536 | /* |
538 | * Take code from iPAQ device. | 537 | * Take code from iPAQ device. |
539 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. | 538 | * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. |
540 | * I hope that is ok - Alwin | 539 | * I hope that is ok - Alwin |
541 | */ | 540 | */ |
542 | bool HTC::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 541 | bool HTC::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
543 | { | 542 | { |
544 | int newkeycode = keycode; | 543 | int newkeycode = keycode; |
545 | 544 | ||
546 | if ( !hasHingeSensor() ) return false; | 545 | if ( !hasHingeSensor() ) return false; |
547 | 546 | ||
548 | /* map cursor keys depending on the hinge status */ | 547 | /* map cursor keys depending on the hinge status */ |
549 | switch ( keycode ) { | 548 | switch ( keycode ) { |
550 | // Rotate cursor keys | 549 | // Rotate cursor keys |
551 | case Key_Left : | 550 | case Key_Left : |
552 | case Key_Right: | 551 | case Key_Right: |
553 | case Key_Up : | 552 | case Key_Up : |
554 | case Key_Down : | 553 | case Key_Down : |
555 | { | 554 | { |
556 | if (rotation()==Rot90) { | 555 | if (rotation()==Rot90) { |
557 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 556 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
558 | } | 557 | } |
559 | } | 558 | } |
560 | break; | 559 | break; |
561 | 560 | ||
562 | } | 561 | } |
563 | if (newkeycode!=keycode) { | 562 | if (newkeycode!=keycode) { |
564 | if ( newkeycode != Key_unknown ) { | 563 | if ( newkeycode != Key_unknown ) { |
565 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 564 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
566 | } | 565 | } |
567 | return true; | 566 | return true; |
568 | } | 567 | } |
569 | return false; | 568 | return false; |
570 | } | 569 | } |
571 | 570 | ||
572 | bool HTC::suspend() { | 571 | bool HTC::suspend() { |
573 | 572 | ||
574 | /* MV */ | 573 | /* MV */ |
575 | return false; | 574 | return false; |
576 | 575 | ||
577 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 576 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
578 | return false; | 577 | return false; |
579 | 578 | ||
580 | bool res = false; | 579 | bool res = false; |
581 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); | 580 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); |
582 | 581 | ||
583 | struct timeval tvs, tvn; | 582 | struct timeval tvs, tvn; |
584 | ::gettimeofday ( &tvs, 0 ); | 583 | ::gettimeofday ( &tvs, 0 ); |
585 | 584 | ||
586 | ::sync(); // flush fs caches | 585 | ::sync(); // flush fs caches |
587 | res = ( ::system ( "apm --suspend" ) == 0 ); | 586 | res = ( ::system ( "apm --suspend" ) == 0 ); |
588 | 587 | ||
589 | // This is needed because some apm implementations are asynchronous and we | 588 | // This is needed because some apm implementations are asynchronous and we |
590 | // can not be sure when exactly the device is really suspended | 589 | // can not be sure when exactly the device is really suspended |
591 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 590 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
592 | // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here. | 591 | // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here. |
593 | 592 | ||
594 | if ( res && m_embedix) { | 593 | if ( res && m_embedix) { |
595 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 594 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
596 | ::usleep ( 200 * 1000 ); | 595 | ::usleep ( 200 * 1000 ); |
597 | ::gettimeofday ( &tvn, 0 ); | 596 | ::gettimeofday ( &tvn, 0 ); |
598 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); | 597 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); |
599 | } | 598 | } |
600 | 599 | ||
601 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); | 600 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); |
602 | 601 | ||
603 | return res; | 602 | return res; |
604 | } | 603 | } |
diff --git a/libopie2/opiepim/private/opimeventsortvector.cpp b/libopie2/opiepim/private/opimeventsortvector.cpp index 4220c63..b85f848 100644 --- a/libopie2/opiepim/private/opimeventsortvector.cpp +++ b/libopie2/opiepim/private/opimeventsortvector.cpp | |||
@@ -1,134 +1,131 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2004 Stefan Eilers <stefan@eilers-online.net> | 3 | Copyright (C) 2004 Stefan Eilers <stefan@eilers-online.net> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "opimeventsortvector.h" | 30 | #include "opimeventsortvector.h" |
31 | #include <opie2/ocontactaccess.h> | 31 | #include <opie2/ocontactaccess.h> |
32 | #include <opie2/opimnotifymanager.h> | 32 | #include <opie2/opimnotifymanager.h> |
33 | #include <opie2/odatebookaccess.h> | 33 | #include <opie2/odatebookaccess.h> |
34 | 34 | ||
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | namespace Opie { | 37 | namespace Opie { |
38 | namespace Internal { | 38 | namespace Internal { |
39 | 39 | ||
40 | namespace{ | 40 | int testAlarmNotifiers( const OPimNotifyManager& leftnotifiers, const OPimNotifyManager& rightnotifiers ){ |
41 | |||
42 | inline int testAlarmNotifiers( const OPimNotifyManager& leftnotifiers, const OPimNotifyManager& rightnotifiers ){ | ||
43 | OPimNotifyManager::Alarms left_alarms = leftnotifiers.alarms(); | 41 | OPimNotifyManager::Alarms left_alarms = leftnotifiers.alarms(); |
44 | OPimNotifyManager::Alarms right_alarms = rightnotifiers.alarms(); | 42 | OPimNotifyManager::Alarms right_alarms = rightnotifiers.alarms(); |
45 | 43 | ||
46 | // Well.. How could we compare two lists of alarms? I think we should find the most early datetimes | 44 | // Well.. How could we compare two lists of alarms? I think we should find the most early datetimes |
47 | // and compare them.. (se) | 45 | // and compare them.. (se) |
48 | // Find the first alarm of the left list | 46 | // Find the first alarm of the left list |
49 | OPimNotifyManager::Alarms::Iterator it; | 47 | OPimNotifyManager::Alarms::Iterator it; |
50 | QDateTime left_earliest; // This datetime is initialized as invalid!! | 48 | QDateTime left_earliest; // This datetime is initialized as invalid!! |
51 | for ( it = left_alarms.begin(); it != left_alarms.end(); ++it ){ | 49 | for ( it = left_alarms.begin(); it != left_alarms.end(); ++it ){ |
52 | if ( !left_earliest.isValid() || left_earliest > (*it).dateTime() ){ | 50 | if ( !left_earliest.isValid() || left_earliest > (*it).dateTime() ){ |
53 | left_earliest = (*it).dateTime(); | 51 | left_earliest = (*it).dateTime(); |
54 | } | 52 | } |
55 | } | 53 | } |
56 | QDateTime right_earliest; // This datetime is initialized as invalid!! | 54 | QDateTime right_earliest; // This datetime is initialized as invalid!! |
57 | for ( it = right_alarms.begin(); it != right_alarms.end(); ++it ){ | 55 | for ( it = right_alarms.begin(); it != right_alarms.end(); ++it ){ |
58 | if ( !right_earliest.isValid() || right_earliest > (*it).dateTime() ){ | 56 | if ( !right_earliest.isValid() || right_earliest > (*it).dateTime() ){ |
59 | right_earliest = (*it).dateTime(); | 57 | right_earliest = (*it).dateTime(); |
60 | } | 58 | } |
61 | } | 59 | } |
62 | 60 | ||
63 | int ret; | 61 | int ret = 0; |
64 | 62 | ||
65 | // Now compare this found alarms | 63 | // Now compare this found alarms |
66 | if ( !left_earliest .isValid() ) ret++; | 64 | if ( !left_earliest .isValid() ) ret++; |
67 | if ( !right_earliest.isValid() ) ret--; | 65 | if ( !right_earliest.isValid() ) ret--; |
68 | 66 | ||
69 | if ( left_earliest.isValid() && right_earliest.isValid() ){ | 67 | if ( left_earliest.isValid() && right_earliest.isValid() ){ |
70 | ret += left_earliest < right_earliest ? -1 : 1; | 68 | left_earliest < right_earliest ? ret-- : ret++; |
71 | } | 69 | } |
72 | 70 | ||
73 | return ret; | 71 | return ret; |
74 | 72 | ||
75 | } | 73 | } |
76 | } | ||
77 | 74 | ||
78 | OPimEventSortVector::OPimEventSortVector( uint size, bool asc, int sort ) | 75 | OPimEventSortVector::OPimEventSortVector( uint size, bool asc, int sort ) |
79 | : OPimSortVector<OPimEvent>( size, asc, sort ) {} | 76 | : OPimSortVector<OPimEvent>( size, asc, sort ) {} |
80 | 77 | ||
81 | int OPimEventSortVector::compareItems( const OPimEvent& left, | 78 | int OPimEventSortVector::compareItems( const OPimEvent& left, |
82 | const OPimEvent& right ) { | 79 | const OPimEvent& right ) { |
83 | if ( left.uid() == right.uid() ) | 80 | if ( left.uid() == right.uid() ) |
84 | return 0; | 81 | return 0; |
85 | 82 | ||
86 | int ret = 0; | 83 | int ret = 0; |
87 | bool asc = sortAscending(); | 84 | bool asc = sortAscending(); |
88 | 85 | ||
89 | switch( sortOrder() ) { | 86 | switch( sortOrder() ) { |
90 | case ODateBookAccess::SortDescription: | 87 | case ODateBookAccess::SortDescription: |
91 | ret = testString( left.description(), right.description() ); | 88 | ret = testString( left.description(), right.description() ); |
92 | break; | 89 | break; |
93 | case ODateBookAccess::SortLocation: | 90 | case ODateBookAccess::SortLocation: |
94 | ret = testString( left.location(), right.location() ); | 91 | ret = testString( left.location(), right.location() ); |
95 | break; | 92 | break; |
96 | case ODateBookAccess::SortNote: | 93 | case ODateBookAccess::SortNote: |
97 | ret = testString( left.note(),right.note() ); | 94 | ret = testString( left.note(),right.note() ); |
98 | break; | 95 | break; |
99 | case ODateBookAccess::SortStartTime: | 96 | case ODateBookAccess::SortStartTime: |
100 | ret = testTime( left.startDateTime().time(), right.startDateTime().time() ); | 97 | ret = testTime( left.startDateTime().time(), right.startDateTime().time() ); |
101 | break; | 98 | break; |
102 | case ODateBookAccess::SortEndTime: | 99 | case ODateBookAccess::SortEndTime: |
103 | ret = testTime( left.endDateTime().time(), right.endDateTime().time() ); | 100 | ret = testTime( left.endDateTime().time(), right.endDateTime().time() ); |
104 | break; | 101 | break; |
105 | case ODateBookAccess::SortStartDate: | 102 | case ODateBookAccess::SortStartDate: |
106 | ret = testDate( left.startDateTime().date(), right.startDateTime().date() ); | 103 | ret = testDate( left.startDateTime().date(), right.startDateTime().date() ); |
107 | break; | 104 | break; |
108 | case ODateBookAccess::SortEndDate: | 105 | case ODateBookAccess::SortEndDate: |
109 | ret = testDate( left.endDateTime().date(), right.endDateTime().date() ); | 106 | ret = testDate( left.endDateTime().date(), right.endDateTime().date() ); |
110 | break; | 107 | break; |
111 | case ODateBookAccess::SortStartDateTime: | 108 | case ODateBookAccess::SortStartDateTime: |
112 | ret = testDateTime( left.startDateTime(), right.startDateTime() ); | 109 | ret = testDateTime( left.startDateTime(), right.startDateTime() ); |
113 | break; | 110 | break; |
114 | case ODateBookAccess::SortEndDateTime: | 111 | case ODateBookAccess::SortEndDateTime: |
115 | ret = testDateTime( left.endDateTime(), right.endDateTime() ); | 112 | ret = testDateTime( left.endDateTime(), right.endDateTime() ); |
116 | break; | 113 | break; |
117 | case ODateBookAccess::SortAlarmDateTime: | 114 | case ODateBookAccess::SortAlarmDateTime: |
118 | ret = testAlarmNotifiers( left.notifiers(), right.notifiers() ); | 115 | ret = testAlarmNotifiers( left.notifiers(), right.notifiers() ); |
119 | break; | 116 | break; |
120 | default: | 117 | default: |
121 | odebug << "OpimEventSortVector: Unknown sortOrder: " << sortOrder() << oendl; | 118 | odebug << "OpimEventSortVector: Unknown sortOrder: " << sortOrder() << oendl; |
122 | } | 119 | } |
123 | 120 | ||
124 | /* twist to honor ascending/descending setting as QVector only sorts ascending */ | 121 | /* twist to honor ascending/descending setting as QVector only sorts ascending */ |
125 | if ( !asc ) | 122 | if ( !asc ) |
126 | ret *= -1; | 123 | ret *= -1; |
127 | 124 | ||
128 | // Maybe differentiate as in OPimTodoSortVector ### FIXME | 125 | // Maybe differentiate as in OPimTodoSortVector ### FIXME |
129 | // if( ret ) | 126 | // if( ret ) |
130 | return ret; | 127 | return ret; |
131 | } | 128 | } |
132 | 129 | ||
133 | } | 130 | } |
134 | } | 131 | } |
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index 2958cf5..a7d6b00 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp | |||
@@ -1,165 +1,170 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
10 | 10 | ||
11 | #include "listviewitemconffile.h" | 11 | #include "listviewitemconffile.h" |
12 | #include "listviewitemconfigentry.h" | 12 | #include "listviewitemconfigentry.h" |
13 | 13 | ||
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | using namespace Opie::Core; | 16 | using namespace Opie::Core; |
17 | 17 | ||
18 | /* QT */ | 18 | /* QT */ |
19 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
20 | #include <qtextstream.h> | 20 | #include <qtextstream.h> |
21 | 21 | ||
22 | #define tr QObject::tr | 22 | #define tr QObject::tr |
23 | 23 | ||
24 | ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent) | 24 | ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent) |
25 | : ListViewItemConf(parent), _valid(false) | 25 | : ListViewItemConf(parent), _valid(false) |
26 | { | 26 | { |
27 | confFileInfo = file; | 27 | confFileInfo = file; |
28 | // parseFile(); | 28 | // parseFile(); |
29 | displayText(); | 29 | displayText(); |
30 | } | 30 | } |
31 | 31 | ||
32 | ListViewItemConfFile::~ListViewItemConfFile() | 32 | ListViewItemConfFile::~ListViewItemConfFile() |
33 | { | 33 | { |
34 | } | 34 | } |
35 | 35 | ||
36 | 36 | ||
37 | void ListViewItemConfFile::displayText() | 37 | void ListViewItemConfFile::displayText() |
38 | { | 38 | { |
39 | setText(0,(_changed?"*":"")+confFileInfo->fileName()); | 39 | setText(0,(_changed?"*":"")+confFileInfo->fileName()); |
40 | } | 40 | } |
41 | 41 | ||
42 | QString ListViewItemConfFile::fileName() | 42 | QString ListViewItemConfFile::fileName() |
43 | { | 43 | { |
44 | return confFileInfo->fileName(); | 44 | return confFileInfo->fileName(); |
45 | } | 45 | } |
46 | 46 | ||
47 | void ListViewItemConfFile::parseFile() | 47 | void ListViewItemConfFile::parseFile() |
48 | { | 48 | { |
49 | //odebug << "ListViewItemConfFile::parseFile BEGIN" << oendl; | 49 | //odebug << "ListViewItemConfFile::parseFile BEGIN" << oendl; |
50 | QFile confFile(confFileInfo->absFilePath()); | 50 | QFile confFile(confFileInfo->absFilePath()); |
51 | if(! confFile.open(IO_ReadOnly)) | 51 | if(! confFile.open(IO_ReadOnly)) |
52 | QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0); | 52 | QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0); |
53 | QTextStream t( &confFile ); | 53 | |
54 | QString s; | 54 | QTextStream t( &confFile ); |
55 | QString s; | ||
55 | QString group; | 56 | QString group; |
56 | ListViewItemConfigEntry *groupItem; | 57 | ListViewItemConfigEntry *groupItem = 0; |
57 | ListViewItemConfigEntry *item; | 58 | ListViewItemConfigEntry *item; |
58 | while ( !t.atEnd() ) | 59 | while ( !t.atEnd() ) |
59 | { | 60 | { |
60 | s = t.readLine().stripWhiteSpace(); | 61 | s = t.readLine().stripWhiteSpace(); |
61 | //odebug << "line: >" << s.latin1() << "<\n" << oendl; | 62 | //odebug << "line: >" << s.latin1() << "<\n" << oendl; |
62 | if (s.contains("<?xml")) | 63 | if (s.contains("<?xml")) |
63 | { | 64 | { |
64 | _valid = false; | 65 | _valid = false; |
65 | break; | 66 | break; |
66 | }else | 67 | } |
67 | if ( s[0] == '[' && s[s.length()-1] == ']' ) | 68 | else if ( s[0] == '[' && s[s.length()-1] == ']' ) |
68 | { | 69 | { |
69 | // odebug << "got group"+s << oendl; | 70 | //odebug << "got group"+s << oendl; |
70 | group = s.mid(1,s.length()-2); | 71 | group = s.mid(1,s.length()-2); |
71 | if (!groupItem) groupItem = new ListViewItemConfigEntry(this, tr("no group") ); | 72 | if (!groupItem) |
73 | groupItem = new ListViewItemConfigEntry(this, tr("no group") ); | ||
74 | |||
72 | groupItem = new ListViewItemConfigEntry(this, group ); | 75 | groupItem = new ListViewItemConfigEntry(this, group ); |
73 | insertItem( groupItem ); | 76 | insertItem( groupItem ); |
74 | } else | 77 | } |
75 | if ( int pos = s.find('=') ) | 78 | else if ( int pos = s.find('=') ) |
76 | { | 79 | { |
77 | // odebug << "got key"+s << oendl; | 80 | //odebug << "got key"+s << oendl; |
78 | if (!groupItem) odebug << "PANIK NO GROUP! >" << group.latin1() << "<" << oendl; | 81 | if (!groupItem) |
79 | item = new ListViewItemConfigEntry(this, group, s ); | 82 | odebug << "PANIC! no group >" << group.latin1() << "<" << oendl; |
83 | |||
84 | item = new ListViewItemConfigEntry(this, group, s ); | ||
80 | groupItem->insertItem( item ); | 85 | groupItem->insertItem( item ); |
81 | } | 86 | } |
82 | } | 87 | } |
83 | confFile.close(); | 88 | confFile.close(); |
84 | setExpandable( _valid ); | 89 | setExpandable( _valid ); |
85 | //odebug << "ListViewItemConfFile::parseFile END" << oendl; | 90 | //odebug << "ListViewItemConfFile::parseFile END" << oendl; |
86 | } | 91 | } |
87 | 92 | ||
88 | 93 | ||
89 | void ListViewItemConfFile::remove() | 94 | void ListViewItemConfFile::remove() |
90 | { | 95 | { |
91 | QFile::remove(confFileInfo->absFilePath()); | 96 | QFile::remove(confFileInfo->absFilePath()); |
92 | QFile::remove(backupFileName()); | 97 | QFile::remove(backupFileName()); |
93 | delete this; | 98 | delete this; |
94 | } | 99 | } |
95 | 100 | ||
96 | void ListViewItemConfFile::revert() | 101 | void ListViewItemConfFile::revert() |
97 | { | 102 | { |
98 | if (!_changed) | 103 | if (!_changed) |
99 | { | 104 | { |
100 | // read the backup file | 105 | // read the backup file |
101 | QFile conf(confFileInfo->absFilePath()); | 106 | QFile conf(confFileInfo->absFilePath()); |
102 | QFile back(backupFileName()); | 107 | QFile back(backupFileName()); |
103 | 108 | ||
104 | if (!back.open(IO_ReadOnly)) return; | 109 | if (!back.open(IO_ReadOnly)) return; |
105 | if (!conf.open(IO_WriteOnly)) return; | 110 | if (!conf.open(IO_WriteOnly)) return; |
106 | 111 | ||
107 | #define SIZE 124 | 112 | #define SIZE 124 |
108 | char buf[SIZE]; | 113 | char buf[SIZE]; |
109 | while (int c = back.readBlock(buf, SIZE) ) conf.writeBlock(buf,c); | 114 | while (int c = back.readBlock(buf, SIZE) ) conf.writeBlock(buf,c); |
110 | conf.close(); | 115 | conf.close(); |
111 | back.close(); | 116 | back.close(); |
112 | } | 117 | } |
113 | parseFile(); | 118 | parseFile(); |
114 | expand(); | 119 | expand(); |
115 | } | 120 | } |
116 | 121 | ||
117 | void ListViewItemConfFile::save() | 122 | void ListViewItemConfFile::save() |
118 | { | 123 | { |
119 | if (!_changed) return; | 124 | if (!_changed) return; |
120 | QFile conf(confFileInfo->absFilePath()); | 125 | QFile conf(confFileInfo->absFilePath()); |
121 | QFile back(backupFileName()); | 126 | QFile back(backupFileName()); |
122 | 127 | ||
123 | if (!conf.open(IO_ReadOnly)) return; | 128 | if (!conf.open(IO_ReadOnly)) return; |
124 | if (!back.open(IO_WriteOnly)) return; | 129 | if (!back.open(IO_WriteOnly)) return; |
125 | 130 | ||
126 | char buf[SIZE]; | 131 | char buf[SIZE]; |
127 | while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); | 132 | while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); |
128 | conf.close(); | 133 | conf.close(); |
129 | back.close(); | 134 | back.close(); |
130 | 135 | ||
131 | 136 | ||
132 | if (!conf.open(IO_WriteOnly)) return; | 137 | if (!conf.open(IO_WriteOnly)) return; |
133 | QTextStream *t = new QTextStream( &conf ); | 138 | QTextStream *t = new QTextStream( &conf ); |
134 | for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) | 139 | for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) |
135 | { | 140 | { |
136 | ((ListViewItemConfigEntry*)it)->save(t); | 141 | ((ListViewItemConfigEntry*)it)->save(t); |
137 | } | 142 | } |
138 | conf.close(); | 143 | conf.close(); |
139 | unchanged(); | 144 | unchanged(); |
140 | } | 145 | } |
141 | 146 | ||
142 | 147 | ||
143 | bool ListViewItemConfFile::revertable() | 148 | bool ListViewItemConfFile::revertable() |
144 | { | 149 | { |
145 | return _changed || QFile(backupFileName()).exists(); | 150 | return _changed || QFile(backupFileName()).exists(); |
146 | } | 151 | } |
147 | 152 | ||
148 | QString ListViewItemConfFile::backupFileName() | 153 | QString ListViewItemConfFile::backupFileName() |
149 | { | 154 | { |
150 | return confFileInfo->absFilePath()+"~"; | 155 | return confFileInfo->absFilePath()+"~"; |
151 | } | 156 | } |
152 | 157 | ||
153 | 158 | ||
154 | void ListViewItemConfFile::expand() | 159 | void ListViewItemConfFile::expand() |
155 | { | 160 | { |
156 | QListViewItem *subItem = firstChild(); | 161 | QListViewItem *subItem = firstChild(); |
157 | QListViewItem *toDel; | 162 | QListViewItem *toDel; |
158 | while(subItem) | 163 | while(subItem) |
159 | { | 164 | { |
160 | toDel = subItem; | 165 | toDel = subItem; |
161 | subItem = subItem->nextSibling(); | 166 | subItem = subItem->nextSibling(); |
162 | delete toDel; | 167 | delete toDel; |
163 | } | 168 | } |
164 | parseFile(); | 169 | parseFile(); |
165 | } | 170 | } |
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp index 9d27c85..a0f72ae 100644 --- a/noncore/apps/opie-console/io_irda.cpp +++ b/noncore/apps/opie-console/io_irda.cpp | |||
@@ -1,64 +1,65 @@ | |||
1 | #include "io_irda.h" | 1 | #include "io_irda.h" |
2 | 2 | ||
3 | IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { | 3 | IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { |
4 | m_attach = 0; | 4 | m_attach = 0; |
5 | } | 5 | } |
6 | 6 | ||
7 | 7 | ||
8 | IOIrda::~IOIrda() { | 8 | IOIrda::~IOIrda() { |
9 | if ( m_attach ) { | 9 | if ( m_attach ) { |
10 | delete m_attach; | 10 | delete m_attach; |
11 | } | 11 | } |
12 | } | 12 | } |
13 | 13 | ||
14 | 14 | ||
15 | void IOIrda::close() { | 15 | void IOIrda::close() { |
16 | 16 | ||
17 | IOSerial::close(); | 17 | IOSerial::close(); |
18 | // still need error handling | 18 | // still need error handling |
19 | delete m_attach; | 19 | delete m_attach; |
20 | } | 20 | } |
21 | 21 | ||
22 | bool IOIrda::open() { | 22 | bool IOIrda::open() { |
23 | bool ret; | 23 | bool ret; |
24 | 24 | ||
25 | // irdaattach here | 25 | // irdaattach here |
26 | m_attach = new Opie::Core::OProcess(); | 26 | m_attach = new Opie::Core::OProcess(); |
27 | *m_attach << "irattach /dev/ttyS2 -s"; | 27 | *m_attach << "irattach /dev/ttyS2 -s"; |
28 | 28 | ||
29 | connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), | 29 | connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), |
30 | this, SLOT( slotExited(Opie::Core::OProcess*) ) ); | 30 | this, SLOT( slotExited(Opie::Core::OProcess*) ) ); |
31 | 31 | ||
32 | if ( m_attach->start() ) { | 32 | if ( m_attach->start() ) { |
33 | ret= IOSerial::open(); | 33 | ret= IOSerial::open(); |
34 | } else { | 34 | } else { |
35 | // emit error!!! | 35 | // emit error!!! |
36 | delete m_attach; | 36 | delete m_attach; |
37 | m_attach = 0l; | 37 | m_attach = 0l; |
38 | ret = false; | ||
38 | } | 39 | } |
39 | return ret; | 40 | return ret; |
40 | } | 41 | } |
41 | 42 | ||
42 | void IOIrda::reload( const Profile &config ) { | 43 | void IOIrda::reload( const Profile &config ) { |
43 | m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); | 44 | m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); |
44 | m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); | 45 | m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); |
45 | m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); | 46 | m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); |
46 | m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); | 47 | m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); |
47 | m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); | 48 | m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); |
48 | m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); | 49 | m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); |
49 | } | 50 | } |
50 | 51 | ||
51 | 52 | ||
52 | QString IOIrda::identifier() const { | 53 | QString IOIrda::identifier() const { |
53 | return "irda"; | 54 | return "irda"; |
54 | } | 55 | } |
55 | 56 | ||
56 | QString IOIrda::name() const { | 57 | QString IOIrda::name() const { |
57 | return "Irda IO Layer"; | 58 | return "Irda IO Layer"; |
58 | } | 59 | } |
59 | 60 | ||
60 | void IOIrda::slotExited(Opie::Core::OProcess* proc ){ | 61 | void IOIrda::slotExited(Opie::Core::OProcess* proc ){ |
61 | close(); | 62 | close(); |
62 | delete proc; | 63 | delete proc; |
63 | } | 64 | } |
64 | 65 | ||
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index aba7244..a884179 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -518,318 +518,314 @@ void MainWindow::slotClose() { | |||
518 | /* | 518 | /* |
519 | * We will get the name | 519 | * We will get the name |
520 | * Then the profile | 520 | * Then the profile |
521 | * and then we will make a profile | 521 | * and then we will make a profile |
522 | */ | 522 | */ |
523 | void MainWindow::slotProfile( int id) { | 523 | void MainWindow::slotProfile( int id) { |
524 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 524 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
525 | create( prof ); | 525 | create( prof ); |
526 | } | 526 | } |
527 | 527 | ||
528 | 528 | ||
529 | 529 | ||
530 | void MainWindow::create( const Profile& prof ) { | 530 | void MainWindow::create( const Profile& prof ) { |
531 | char *homeDir = getenv("HOME"); | 531 | char *homeDir = getenv("HOME"); |
532 | 532 | ||
533 | if ( homeDir ) | 533 | if ( homeDir ) |
534 | ::chdir( homeDir ); | 534 | ::chdir( homeDir ); |
535 | 535 | ||
536 | if(m_curSession) | 536 | if(m_curSession) |
537 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 537 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
538 | 538 | ||
539 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 539 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
540 | 540 | ||
541 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 541 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
542 | { | 542 | { |
543 | QMessageBox::warning(this, | 543 | QMessageBox::warning(this, |
544 | QObject::tr("Session failed"), | 544 | QObject::tr("Session failed"), |
545 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 545 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
546 | //if(ses) delete ses; | 546 | //if(ses) delete ses; |
547 | return; | 547 | return; |
548 | } | 548 | } |
549 | 549 | ||
550 | m_sessions.append( ses ); | 550 | m_sessions.append( ses ); |
551 | tabWidget()->add( ses ); | 551 | tabWidget()->add( ses ); |
552 | tabWidget()->repaint(); | 552 | tabWidget()->repaint(); |
553 | m_curSession = ses; | 553 | m_curSession = ses; |
554 | 554 | ||
555 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 555 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
556 | m_connect->setEnabled( true ); | 556 | m_connect->setEnabled( true ); |
557 | m_disconnect->setEnabled( false ); | 557 | m_disconnect->setEnabled( false ); |
558 | m_terminate->setEnabled( true ); | 558 | m_terminate->setEnabled( true ); |
559 | m_fullscreen->setEnabled( true ); | 559 | m_fullscreen->setEnabled( true ); |
560 | m_wrap->setEnabled( true ); | 560 | m_wrap->setEnabled( true ); |
561 | m_closewindow->setEnabled( true ); | 561 | m_closewindow->setEnabled( true ); |
562 | m_transfer->setEnabled( false ); | 562 | m_transfer->setEnabled( false ); |
563 | m_recordScript->setEnabled( false ); | 563 | m_recordScript->setEnabled( false ); |
564 | m_saveScript->setEnabled( false ); | 564 | m_saveScript->setEnabled( false ); |
565 | m_scripts->setItemEnabled(m_runScript_id, false); | 565 | m_scripts->setItemEnabled(m_runScript_id, false); |
566 | 566 | ||
567 | // is io_layer wants direct connection, then autoconnect | 567 | // is io_layer wants direct connection, then autoconnect |
568 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 568 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
569 | if (prof.autoConnect()) { | 569 | if (prof.autoConnect()) { |
570 | slotConnect(); | 570 | slotConnect(); |
571 | } | 571 | } |
572 | 572 | ||
573 | QWidget *w = currentSession()->widget(); | 573 | QWidget *w = currentSession()->widget(); |
574 | if(w) w->setFocus(); | 574 | if(w) w->setFocus(); |
575 | 575 | ||
576 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 576 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
577 | m_isWrapped = true; | 577 | m_isWrapped = true; |
578 | } else { | 578 | } else { |
579 | m_isWrapped = false; | 579 | m_isWrapped = false; |
580 | } | 580 | } |
581 | 581 | ||
582 | m_kb->load(currentSession()->profile()); | 582 | m_kb->load(currentSession()->profile()); |
583 | } | 583 | } |
584 | 584 | ||
585 | void MainWindow::slotTransfer() | 585 | void MainWindow::slotTransfer() |
586 | { | 586 | { |
587 | if ( currentSession() ) { | 587 | if ( currentSession() ) { |
588 | Session *mysession = currentSession(); | 588 | Session *mysession = currentSession(); |
589 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); | 589 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); |
590 | mysession->setTransferDialog(&dlg); | 590 | mysession->setTransferDialog(&dlg); |
591 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); | 591 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); |
592 | //dlg.showMaximized(); | 592 | //dlg.showMaximized(); |
593 | currentSession()->widgetStack()->addWidget(&dlg, -1); | 593 | currentSession()->widgetStack()->addWidget(&dlg, -1); |
594 | dlg.show(); | 594 | dlg.show(); |
595 | //dlg.exec(); | 595 | //dlg.exec(); |
596 | while(dlg.isRunning()) qApp->processEvents(); | 596 | while(dlg.isRunning()) qApp->processEvents(); |
597 | mysession->setTransferDialog(0l); | 597 | mysession->setTransferDialog(0l); |
598 | } | 598 | } |
599 | } | 599 | } |
600 | 600 | ||
601 | 601 | ||
602 | void MainWindow::slotOpenKeb(bool state) { | 602 | void MainWindow::slotOpenKeb(bool state) { |
603 | 603 | ||
604 | if (state) m_keyBar->show(); | 604 | if (state) m_keyBar->show(); |
605 | else m_keyBar->hide(); | 605 | else m_keyBar->hide(); |
606 | 606 | ||
607 | } | 607 | } |
608 | 608 | ||
609 | 609 | ||
610 | void MainWindow::slotOpenButtons( bool state ) { | 610 | void MainWindow::slotOpenButtons( bool state ) { |
611 | 611 | ||
612 | if ( state ) { | 612 | if ( state ) { |
613 | m_buttonBar->show(); | 613 | m_buttonBar->show(); |
614 | } else { | 614 | } else { |
615 | m_buttonBar->hide(); | 615 | m_buttonBar->hide(); |
616 | } | 616 | } |
617 | } | 617 | } |
618 | 618 | ||
619 | 619 | ||
620 | 620 | ||
621 | void MainWindow::slotSessionChanged( Session* ses ) { | 621 | void MainWindow::slotSessionChanged( Session* ses ) { |
622 | if(m_curSession) | 622 | if(m_curSession) |
623 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 623 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
624 | if(ses) | 624 | if(ses) |
625 | if(ses->transferDialog()) ses->transferDialog()->show(); | 625 | if(ses->transferDialog()) ses->transferDialog()->show(); |
626 | 626 | ||
627 | if ( ses ) { | 627 | if ( ses ) { |
628 | m_curSession = ses; | 628 | m_curSession = ses; |
629 | if ( m_curSession->layer()->isConnected() ) { | 629 | if ( m_curSession->layer()->isConnected() ) { |
630 | m_connect->setEnabled( false ); | 630 | m_connect->setEnabled( false ); |
631 | m_disconnect->setEnabled( true ); | 631 | m_disconnect->setEnabled( true ); |
632 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 632 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
633 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 633 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
634 | m_scripts->setItemEnabled(m_runScript_id, true); | 634 | m_scripts->setItemEnabled(m_runScript_id, true); |
635 | } else { | 635 | } else { |
636 | m_connect->setEnabled( true ); | 636 | m_connect->setEnabled( true ); |
637 | m_disconnect->setEnabled( false ); | 637 | m_disconnect->setEnabled( false ); |
638 | m_recordScript->setEnabled( false ); | 638 | m_recordScript->setEnabled( false ); |
639 | m_saveScript->setEnabled( false ); | 639 | m_saveScript->setEnabled( false ); |
640 | m_scripts->setItemEnabled(m_runScript_id, false); | 640 | m_scripts->setItemEnabled(m_runScript_id, false); |
641 | } | 641 | } |
642 | 642 | ||
643 | if ( ( currentSession()->emulationHandler()->isLogging() ) ) { | 643 | if ( ( currentSession()->emulationHandler()->isLogging() ) ) { |
644 | m_recordLog->setText( tr("Stop log") ); | 644 | m_recordLog->setText( tr("Stop log") ); |
645 | } else { | 645 | } else { |
646 | m_recordLog->setText( tr("Start log") ); | 646 | m_recordLog->setText( tr("Start log") ); |
647 | } | 647 | } |
648 | 648 | ||
649 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 649 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
650 | m_transfer->setEnabled( false ); | 650 | m_transfer->setEnabled( false ); |
651 | } else { | 651 | } else { |
652 | m_transfer->setEnabled( true ); | 652 | m_transfer->setEnabled( true ); |
653 | } | 653 | } |
654 | 654 | ||
655 | QWidget *w = m_curSession->widget(); | 655 | QWidget *w = m_curSession->widget(); |
656 | if(w) w->setFocus(); | 656 | if(w) w->setFocus(); |
657 | 657 | ||
658 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 658 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
659 | m_isWrapped = true; | 659 | m_isWrapped = true; |
660 | } else { | 660 | } else { |
661 | m_isWrapped = false; | 661 | m_isWrapped = false; |
662 | } | 662 | } |
663 | 663 | ||
664 | m_kb->load(currentSession()->profile()); | 664 | m_kb->load(currentSession()->profile()); |
665 | } | 665 | } |
666 | } | 666 | } |
667 | 667 | ||
668 | void MainWindow::slotWrap() | 668 | void MainWindow::slotWrap() |
669 | { | 669 | { |
670 | if(m_curSession) | 670 | if(m_curSession) |
671 | { | 671 | { |
672 | EmulationHandler *e = m_curSession->emulationHandler(); | 672 | EmulationHandler *e = m_curSession->emulationHandler(); |
673 | if(e) | 673 | if(e) |
674 | { | 674 | { |
675 | e->setWrap( m_isWrapped ? 80:0 ); | 675 | e->setWrap( m_isWrapped ? 80:0 ); |
676 | m_isWrapped = !m_isWrapped; | 676 | m_isWrapped = !m_isWrapped; |
677 | } | 677 | } |
678 | } | 678 | } |
679 | } | 679 | } |
680 | 680 | ||
681 | void MainWindow::slotFullscreen() { | 681 | void MainWindow::slotFullscreen() { |
682 | 682 | ||
683 | 683 | ||
684 | 684 | ||
685 | if ( m_isFullscreen ) { | 685 | if ( m_isFullscreen ) { |
686 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 686 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
687 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 687 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
688 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 688 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
689 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 689 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
690 | 690 | ||
691 | } else { | 691 | } else { |
692 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 692 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
693 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 693 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
694 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 694 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
695 | , QPoint(0,0), false ); | 695 | , QPoint(0,0), false ); |
696 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 696 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
697 | ( m_curSession->widgetStack() )->setFocus(); | 697 | ( m_curSession->widgetStack() )->setFocus(); |
698 | ( m_curSession->widgetStack() )->show(); | 698 | ( m_curSession->widgetStack() )->show(); |
699 | 699 | ||
700 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 700 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
701 | 701 | ||
702 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 702 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
703 | } | 703 | } |
704 | 704 | ||
705 | m_isFullscreen = !m_isFullscreen; | 705 | m_isFullscreen = !m_isFullscreen; |
706 | } | 706 | } |
707 | 707 | ||
708 | void MainWindow::slotScrollbarSelected(int index) | 708 | void MainWindow::slotScrollbarSelected(int index) |
709 | { | 709 | { |
710 | int loc; | 710 | int loc = 0; |
711 | 711 | ||
712 | Config cfg( "Konsole" ); | 712 | Config cfg( "Konsole" ); |
713 | cfg.setGroup("ScrollBar"); | 713 | cfg.setGroup("ScrollBar"); |
714 | if(index == sm_none) | 714 | if(index == sm_left) |
715 | { | ||
716 | loc = 0; | ||
717 | } | ||
718 | else if(index == sm_left) | ||
719 | { | 715 | { |
720 | loc = 1; | 716 | loc = 1; |
721 | } | 717 | } |
722 | else if(index == sm_right) | 718 | else if(index == sm_right) |
723 | { | 719 | { |
724 | loc = 2; | 720 | loc = 2; |
725 | } | 721 | } |
726 | 722 | ||
727 | cfg.writeEntry("Position", loc); | 723 | cfg.writeEntry("Position", loc); |
728 | 724 | ||
729 | if (currentSession()) { | 725 | if (currentSession()) { |
730 | currentSession()->emulationHandler()->setScrollbarLocation(loc); | 726 | currentSession()->emulationHandler()->setScrollbarLocation(loc); |
731 | } | 727 | } |
732 | 728 | ||
733 | m_scrollbar->setItemChecked(sm_none, index == sm_none); | 729 | m_scrollbar->setItemChecked(sm_none, index == sm_none); |
734 | m_scrollbar->setItemChecked(sm_left, index == sm_left); | 730 | m_scrollbar->setItemChecked(sm_left, index == sm_left); |
735 | m_scrollbar->setItemChecked(sm_right, index == sm_right); | 731 | m_scrollbar->setItemChecked(sm_right, index == sm_right); |
736 | } | 732 | } |
737 | 733 | ||
738 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 734 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
739 | 735 | ||
740 | if ( m_curSession ) { | 736 | if ( m_curSession ) { |
741 | 737 | ||
742 | QEvent::Type state; | 738 | QEvent::Type state; |
743 | 739 | ||
744 | if (pressed) state = QEvent::KeyPress; | 740 | if (pressed) state = QEvent::KeyPress; |
745 | else state = QEvent::KeyRelease; | 741 | else state = QEvent::KeyRelease; |
746 | 742 | ||
747 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 743 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
748 | 744 | ||
749 | // is this the best way to do this? cant figure out any other way to work | 745 | // is this the best way to do this? cant figure out any other way to work |
750 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 746 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
751 | ke.ignore(); | 747 | ke.ignore(); |
752 | } | 748 | } |
753 | } | 749 | } |
754 | void MainWindow::slotCopy() { | 750 | void MainWindow::slotCopy() { |
755 | if (!currentSession() ) return; | 751 | if (!currentSession() ) return; |
756 | currentSession()->emulationHandler()->copy(); | 752 | currentSession()->emulationHandler()->copy(); |
757 | } | 753 | } |
758 | void MainWindow::slotPaste() { | 754 | void MainWindow::slotPaste() { |
759 | if (!currentSession() ) return; | 755 | if (!currentSession() ) return; |
760 | currentSession()->emulationHandler()->paste(); | 756 | currentSession()->emulationHandler()->paste(); |
761 | } | 757 | } |
762 | 758 | ||
763 | /* | 759 | /* |
764 | * Save the session | 760 | * Save the session |
765 | */ | 761 | */ |
766 | 762 | ||
767 | void MainWindow::slotSaveSession() { | 763 | void MainWindow::slotSaveSession() { |
768 | if (!currentSession() ) { | 764 | if (!currentSession() ) { |
769 | QMessageBox::information(this, tr("Save Connection"), | 765 | QMessageBox::information(this, tr("Save Connection"), |
770 | tr("<qt>There is no Connection.</qt>"), 1 ); | 766 | tr("<qt>There is no Connection.</qt>"), 1 ); |
771 | return; | 767 | return; |
772 | } | 768 | } |
773 | manager()->add( currentSession()->profile() ); | 769 | manager()->add( currentSession()->profile() ); |
774 | manager()->save(); | 770 | manager()->save(); |
775 | populateProfiles(); | 771 | populateProfiles(); |
776 | } | 772 | } |
777 | 773 | ||
778 | 774 | ||
779 | 775 | ||
780 | void MainWindow::slotSaveLog() { | 776 | void MainWindow::slotSaveLog() { |
781 | 777 | ||
782 | if( currentSession()->emulationHandler()->isLogging() ) { | 778 | if( currentSession()->emulationHandler()->isLogging() ) { |
783 | DocLnk nf; | 779 | DocLnk nf; |
784 | QString m_logName = currentSession()->emulationHandler()->logFileName(); | 780 | QString m_logName = currentSession()->emulationHandler()->logFileName(); |
785 | QFileInfo info(m_logName); | 781 | QFileInfo info(m_logName); |
786 | nf.setType("text/plain"); | 782 | nf.setType("text/plain"); |
787 | nf.setFile(m_logName); | 783 | nf.setFile(m_logName); |
788 | nf.setName(info.fileName()); | 784 | nf.setName(info.fileName()); |
789 | nf.writeLink(); | 785 | nf.writeLink(); |
790 | m_recordLog->setText( tr("Start log") ); | 786 | m_recordLog->setText( tr("Start log") ); |
791 | m_recordingLog = false; | 787 | m_recordingLog = false; |
792 | currentSession()->emulationHandler()->clearLog(); | 788 | currentSession()->emulationHandler()->clearLog(); |
793 | } else { | 789 | } else { |
794 | QMap<QString, QStringList> map; | 790 | QMap<QString, QStringList> map; |
795 | QStringList text; | 791 | QStringList text; |
796 | text << "text/plain"; | 792 | text << "text/plain"; |
797 | map.insert(tr("Log"), text ); | 793 | map.insert(tr("Log"), text ); |
798 | Opie::Core::OConfig cfg("opie-console"); | 794 | Opie::Core::OConfig cfg("opie-console"); |
799 | cfg.setGroup("defaults"); | 795 | cfg.setGroup("defaults"); |
800 | QString startDir = cfg.readEntry("defaultlogdir", QPEApplication::documentDir() ); | 796 | QString startDir = cfg.readEntry("defaultlogdir", QPEApplication::documentDir() ); |
801 | QString m_logName = OFileDialog::getSaveFileName(2, startDir, QString::null, map, 0, startDir); | 797 | QString m_logName = OFileDialog::getSaveFileName(2, startDir, QString::null, map, 0, startDir); |
802 | if (m_logName.isEmpty() ) return; | 798 | if (m_logName.isEmpty() ) return; |
803 | 799 | ||
804 | m_recordLog->setText( tr("Stop log") ); | 800 | m_recordLog->setText( tr("Stop log") ); |
805 | m_recordingLog = true; | 801 | m_recordingLog = true; |
806 | currentSession()->emulationHandler()->startLogging(m_logName); | 802 | currentSession()->emulationHandler()->startLogging(m_logName); |
807 | } | 803 | } |
808 | } | 804 | } |
809 | 805 | ||
810 | void MainWindow::slotSaveHistory() { | 806 | void MainWindow::slotSaveHistory() { |
811 | QMap<QString, QStringList> map; | 807 | QMap<QString, QStringList> map; |
812 | QStringList text; | 808 | QStringList text; |
813 | text << "text/plain"; | 809 | text << "text/plain"; |
814 | map.insert(tr("History"), text ); | 810 | map.insert(tr("History"), text ); |
815 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 811 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
816 | if (filename.isEmpty() ) return; | 812 | if (filename.isEmpty() ) return; |
817 | 813 | ||
818 | QFileInfo info(filename); | 814 | QFileInfo info(filename); |
819 | 815 | ||
820 | DocLnk nf; | 816 | DocLnk nf; |
821 | nf.setType("text/plain"); | 817 | nf.setType("text/plain"); |
822 | nf.setFile(filename); | 818 | nf.setFile(filename); |
823 | nf.setName(info.fileName()); | 819 | nf.setName(info.fileName()); |
824 | 820 | ||
825 | 821 | ||
826 | QFile file(filename); | 822 | QFile file(filename); |
827 | if ( !file.open(IO_WriteOnly ) ) return; | 823 | if ( !file.open(IO_WriteOnly ) ) return; |
828 | 824 | ||
829 | QTextStream str(&file ); | 825 | QTextStream str(&file ); |
830 | if ( currentSession() ) | 826 | if ( currentSession() ) |
831 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | 827 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); |
832 | 828 | ||
833 | file.close(); | 829 | file.close(); |
834 | nf.writeLink(); | 830 | nf.writeLink(); |
835 | } | 831 | } |
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp index 25cdfae..a4ea60a 100644 --- a/noncore/apps/opie-reader/CFilter.cpp +++ b/noncore/apps/opie-reader/CFilter.cpp | |||
@@ -312,385 +312,385 @@ void PeanutFormatter::getch(tchar& ch, CStyle& sty, unsigned long& pos) | |||
312 | currentstyle.unsetItalic(); | 312 | currentstyle.unsetItalic(); |
313 | } | 313 | } |
314 | else | 314 | else |
315 | { | 315 | { |
316 | currentstyle.setItalic(); | 316 | currentstyle.setItalic(); |
317 | } | 317 | } |
318 | parent->getch(ch, dummy, pos); | 318 | parent->getch(ch, dummy, pos); |
319 | break; | 319 | break; |
320 | case 'b': | 320 | case 'b': |
321 | case 'B': | 321 | case 'B': |
322 | if (currentstyle.isBold()) | 322 | if (currentstyle.isBold()) |
323 | { | 323 | { |
324 | currentstyle.unsetBold(); | 324 | currentstyle.unsetBold(); |
325 | } | 325 | } |
326 | else | 326 | else |
327 | { | 327 | { |
328 | currentstyle.setBold(); | 328 | currentstyle.setBold(); |
329 | } | 329 | } |
330 | parent->getch(ch, dummy, pos); | 330 | parent->getch(ch, dummy, pos); |
331 | break; | 331 | break; |
332 | case 'c': | 332 | case 'c': |
333 | if (currentstyle.getJustify() == m_AlignCentre) | 333 | if (currentstyle.getJustify() == m_AlignCentre) |
334 | { | 334 | { |
335 | currentstyle.setLeftJustify(); | 335 | currentstyle.setLeftJustify(); |
336 | } | 336 | } |
337 | else | 337 | else |
338 | { | 338 | { |
339 | currentstyle.setCentreJustify(); | 339 | currentstyle.setCentreJustify(); |
340 | } | 340 | } |
341 | parent->getch(ch, dummy, pos); | 341 | parent->getch(ch, dummy, pos); |
342 | break; | 342 | break; |
343 | case 'r': | 343 | case 'r': |
344 | if (currentstyle.getJustify() == m_AlignRight) | 344 | if (currentstyle.getJustify() == m_AlignRight) |
345 | { | 345 | { |
346 | currentstyle.setLeftJustify(); | 346 | currentstyle.setLeftJustify(); |
347 | } | 347 | } |
348 | else | 348 | else |
349 | { | 349 | { |
350 | currentstyle.setRightJustify(); | 350 | currentstyle.setRightJustify(); |
351 | } | 351 | } |
352 | parent->getch(ch, dummy, pos); | 352 | parent->getch(ch, dummy, pos); |
353 | break; | 353 | break; |
354 | default: | 354 | default: |
355 | currentstyle.setColour(255,0,0); | 355 | currentstyle.setColour(255,0,0); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | sty = currentstyle; | 358 | sty = currentstyle; |
359 | } | 359 | } |
360 | 360 | ||
361 | void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 361 | void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
362 | { | 362 | { |
363 | parent->getch(ch, sty, pos); | 363 | parent->getch(ch, sty, pos); |
364 | if (m_lastchar == 10) | 364 | if (m_lastchar == 10) |
365 | { | 365 | { |
366 | while (ch == 10) parent->getch(ch, sty, pos); | 366 | while (ch == 10) parent->getch(ch, sty, pos); |
367 | } | 367 | } |
368 | m_lastchar = ch; | 368 | m_lastchar = ch; |
369 | } | 369 | } |
370 | 370 | ||
371 | void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 371 | void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
372 | { | 372 | { |
373 | parent->getch(ch, sty, pos); | 373 | parent->getch(ch, sty, pos); |
374 | switch (ch) | 374 | switch (ch) |
375 | { | 375 | { |
376 | case 0x80: | 376 | case 0x80: |
377 | ch = 0x20ac; | 377 | ch = 0x20ac; |
378 | break; | 378 | break; |
379 | case 0x82: | 379 | case 0x82: |
380 | ch = 0x201a; | 380 | ch = 0x201a; |
381 | break; | 381 | break; |
382 | case 0x83: | 382 | case 0x83: |
383 | ch = 0x0192; | 383 | ch = 0x0192; |
384 | break; | 384 | break; |
385 | case 0x84: | 385 | case 0x84: |
386 | ch = 0x201e; | 386 | ch = 0x201e; |
387 | break; | 387 | break; |
388 | case 0x85: | 388 | case 0x85: |
389 | ch = 0x2026; | 389 | ch = 0x2026; |
390 | break; | 390 | break; |
391 | case 0x86: | 391 | case 0x86: |
392 | ch = 0x2020; | 392 | ch = 0x2020; |
393 | break; | 393 | break; |
394 | case 0x87: | 394 | case 0x87: |
395 | ch = 0x2021; | 395 | ch = 0x2021; |
396 | break; | 396 | break; |
397 | case 0x88: | 397 | case 0x88: |
398 | ch = 0x02c6; | 398 | ch = 0x02c6; |
399 | break; | 399 | break; |
400 | case 0x89: | 400 | case 0x89: |
401 | ch = 0x2030; | 401 | ch = 0x2030; |
402 | break; | 402 | break; |
403 | case 0x8a: | 403 | case 0x8a: |
404 | ch = 0x0160; | 404 | ch = 0x0160; |
405 | break; | 405 | break; |
406 | case 0x8b: | 406 | case 0x8b: |
407 | ch = 0x2039; | 407 | ch = 0x2039; |
408 | break; | 408 | break; |
409 | case 0x8c: | 409 | case 0x8c: |
410 | ch = 0x0152; | 410 | ch = 0x0152; |
411 | break; | 411 | break; |
412 | /* | 412 | /* |
413 | case 0x8e: | 413 | case 0x8e: |
414 | ch = 0x017d; | 414 | ch = 0x017d; |
415 | break; | 415 | break; |
416 | */ | 416 | */ |
417 | case 0x91: | 417 | case 0x91: |
418 | ch = 0x2018; | 418 | ch = 0x2018; |
419 | break; | 419 | break; |
420 | case 0x92: | 420 | case 0x92: |
421 | ch = 0x2019; | 421 | ch = 0x2019; |
422 | break; | 422 | break; |
423 | case 0x93: | 423 | case 0x93: |
424 | ch = 0x201c; | 424 | ch = 0x201c; |
425 | break; | 425 | break; |
426 | case 0x94: | 426 | case 0x94: |
427 | ch = 0x201d; | 427 | ch = 0x201d; |
428 | break; | 428 | break; |
429 | case 0x95: | 429 | case 0x95: |
430 | ch = 0x2022; | 430 | ch = 0x2022; |
431 | break; | 431 | break; |
432 | case 0x96: | 432 | case 0x96: |
433 | ch = 0x2013; | 433 | ch = 0x2013; |
434 | break; | 434 | break; |
435 | case 0x97: | 435 | case 0x97: |
436 | ch = 0x2014; | 436 | ch = 0x2014; |
437 | break; | 437 | break; |
438 | case 0x98: | 438 | case 0x98: |
439 | ch = 0x02dc; | 439 | ch = 0x02dc; |
440 | break; | 440 | break; |
441 | case 0x99: | 441 | case 0x99: |
442 | ch = 0x2122; | 442 | ch = 0x2122; |
443 | break; | 443 | break; |
444 | case 0x9a: | 444 | case 0x9a: |
445 | ch = 0x0161; | 445 | ch = 0x0161; |
446 | break; | 446 | break; |
447 | case 0x9b: | 447 | case 0x9b: |
448 | ch = 0x203a; | 448 | ch = 0x203a; |
449 | break; | 449 | break; |
450 | case 0x9c: | 450 | case 0x9c: |
451 | ch = 0x0153; | 451 | ch = 0x0153; |
452 | break; | 452 | break; |
453 | case 0x9e: | 453 | case 0x9e: |
454 | ch = 0x017e; | 454 | ch = 0x017e; |
455 | break; | 455 | break; |
456 | case 0x9f: | 456 | case 0x9f: |
457 | ch = 0x0178; | 457 | ch = 0x0178; |
458 | break; | 458 | break; |
459 | case 0x18: | 459 | case 0x18: |
460 | ch = 0x2026; | 460 | ch = 0x2026; |
461 | break; | 461 | break; |
462 | case 0x19: | 462 | case 0x19: |
463 | ch = 0x2007; | 463 | ch = 0x2007; |
464 | break; | 464 | break; |
465 | case 0x8d: | 465 | case 0x8d: |
466 | ch = 0x2662; | 466 | ch = 0x2662; |
467 | break; | 467 | break; |
468 | case 0x8e: | 468 | case 0x8e: |
469 | ch = 0x2663; | 469 | ch = 0x2663; |
470 | break; | 470 | break; |
471 | case 0x8f: | 471 | case 0x8f: |
472 | ch = 0x2661; | 472 | ch = 0x2661; |
473 | break; | 473 | break; |
474 | case 0x90: | 474 | case 0x90: |
475 | ch = 0x2660; | 475 | ch = 0x2660; |
476 | break; | 476 | break; |
477 | default: | 477 | default: |
478 | break; | 478 | break; |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | //static tchar nextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; | 482 | //static tchar nextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; |
483 | //static tchar prevpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','a','r','t',0 }; | 483 | //static tchar prevpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','a','r','t',0 }; |
484 | 484 | ||
485 | void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 485 | void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
486 | { | 486 | { |
487 | if (m_buffed > 0) | 487 | if (m_buffed > 0) |
488 | { | 488 | { |
489 | sty = m_laststyle; | 489 | sty = m_laststyle; |
490 | ch = nextpart[m_current++]; | 490 | ch = nextpart[m_current++]; |
491 | if (m_current == m_buffed) | 491 | if (m_current == m_buffed) |
492 | { | 492 | { |
493 | m_current = m_buffed = 0; | 493 | m_current = m_buffed = 0; |
494 | } | 494 | } |
495 | } | 495 | } |
496 | else | 496 | else |
497 | { | 497 | { |
498 | if (m_buffer != 0) | 498 | if (m_buffer != 0) |
499 | { | 499 | { |
500 | ch = m_buffer; | 500 | ch = m_buffer; |
501 | m_buffer = 0; | 501 | m_buffer = 0; |
502 | return; | 502 | return; |
503 | } | 503 | } |
504 | unsigned long lnk, lnkoff; | 504 | unsigned long lnk = 0, lnkoff = 0; |
505 | do | 505 | do |
506 | { | 506 | { |
507 | if (nextpart[m_buffed] == 0) break; | 507 | if (nextpart[m_buffed] == 0) break; |
508 | parent->getch(ch, sty, pos); | 508 | parent->getch(ch, sty, pos); |
509 | m_laststyle = sty; | 509 | m_laststyle = sty; |
510 | if (sty.getLink()) | 510 | if (sty.getLink()) |
511 | { | 511 | { |
512 | lnk = sty.getData(); | 512 | lnk = sty.getData(); |
513 | lnkoff = sty.getOffset(); | 513 | lnkoff = sty.getOffset(); |
514 | } | 514 | } |
515 | } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); | 515 | } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); |
516 | m_current = 0; | 516 | m_current = 0; |
517 | if (nextpart[m_buffed] == 0) | 517 | if (nextpart[m_buffed] == 0) |
518 | { | 518 | { |
519 | m_buffed = 0; | 519 | m_buffed = 0; |
520 | QString dmy, dmy2; | 520 | QString dmy, dmy2; |
521 | parent->hyperlink(lnk, lnkoff, dmy, dmy2); | 521 | parent->hyperlink(lnk, lnkoff, dmy, dmy2); |
522 | do | 522 | do |
523 | { | 523 | { |
524 | parent->getch(ch, sty, pos); | 524 | parent->getch(ch, sty, pos); |
525 | } | 525 | } |
526 | while (ch != 10); | 526 | while (ch != 10); |
527 | parent->getch(ch, sty, pos); | 527 | parent->getch(ch, sty, pos); |
528 | } | 528 | } |
529 | else if (m_buffed > 0) | 529 | else if (m_buffed > 0) |
530 | { | 530 | { |
531 | m_buffer = ch; | 531 | m_buffer = ch; |
532 | ch = nextpart[0]; | 532 | ch = nextpart[0]; |
533 | if (m_buffed == 1) | 533 | if (m_buffed == 1) |
534 | { | 534 | { |
535 | m_buffed = 0; | 535 | m_buffed = 0; |
536 | } | 536 | } |
537 | else m_current = 1; | 537 | else m_current = 1; |
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | return; | 541 | return; |
542 | } | 542 | } |
543 | 543 | ||
544 | HighlightFilter::HighlightFilter(QTReader* _p) : pReader(_p), lastpos(0), nextpos(0), red(255), green(255), blue(255) | 544 | HighlightFilter::HighlightFilter(QTReader* _p) : pReader(_p), lastpos(0), nextpos(0), red(255), green(255), blue(255) |
545 | { | 545 | { |
546 | } | 546 | } |
547 | 547 | ||
548 | #include "Bkmks.h" | 548 | #include "Bkmks.h" |
549 | #include "QTReader.h" | 549 | #include "QTReader.h" |
550 | 550 | ||
551 | void HighlightFilter::refresh(unsigned long pos) | 551 | void HighlightFilter::refresh(unsigned long pos) |
552 | { | 552 | { |
553 | bkmks = pReader->Bkmklist(); | 553 | bkmks = pReader->Bkmklist(); |
554 | 554 | ||
555 | red = green = blue = 255; | 555 | red = green = blue = 255; |
556 | 556 | ||
557 | if (bkmks == NULL) | 557 | if (bkmks == NULL) |
558 | { | 558 | { |
559 | lastpos = 0; | 559 | lastpos = 0; |
560 | nextpos = 0xffffffff; | 560 | nextpos = 0xffffffff; |
561 | } | 561 | } |
562 | else | 562 | else |
563 | { | 563 | { |
564 | lastpos = 0; | 564 | lastpos = 0; |
565 | nextpos = 0xffffffff; | 565 | nextpos = 0xffffffff; |
566 | for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++) | 566 | for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++) |
567 | { | 567 | { |
568 | if ((*i).value() <= pos && pos < (*i).value2()) | 568 | if ((*i).value() <= pos && pos < (*i).value2()) |
569 | { | 569 | { |
570 | red = i->red(); | 570 | red = i->red(); |
571 | green = i->green(); | 571 | green = i->green(); |
572 | blue = i->blue(); | 572 | blue = i->blue(); |
573 | lastpos = (*i).value(); | 573 | lastpos = (*i).value(); |
574 | nextpos = (*i).value2(); | 574 | nextpos = (*i).value2(); |
575 | break; | 575 | break; |
576 | } | 576 | } |
577 | if ((*i).value() > pos) | 577 | if ((*i).value() > pos) |
578 | { | 578 | { |
579 | nextpos = (*i).value(); | 579 | nextpos = (*i).value(); |
580 | break; | 580 | break; |
581 | } | 581 | } |
582 | lastpos = (*i).value(); | 582 | lastpos = (*i).value(); |
583 | } | 583 | } |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 587 | void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
588 | { | 588 | { |
589 | parent->getch(ch, sty, pos); | 589 | parent->getch(ch, sty, pos); |
590 | if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) | 590 | if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) |
591 | { | 591 | { |
592 | // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); | 592 | // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); |
593 | refresh(pos); | 593 | refresh(pos); |
594 | // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); | 594 | // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); |
595 | } | 595 | } |
596 | int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); | 596 | int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); |
597 | if (r == 255 && g == 255 && b == 255) | 597 | if (r == 255 && g == 255 && b == 255) |
598 | { | 598 | { |
599 | sty.setBackground(red, green, blue); | 599 | sty.setBackground(red, green, blue); |
600 | } | 600 | } |
601 | } | 601 | } |
602 | 602 | ||
603 | void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 603 | void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
604 | { | 604 | { |
605 | if (uselast) | 605 | if (uselast) |
606 | { | 606 | { |
607 | ch = lastchar; | 607 | ch = lastchar; |
608 | sty = laststy; | 608 | sty = laststy; |
609 | uselast = false; | 609 | uselast = false; |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | else | 612 | else |
613 | { | 613 | { |
614 | parent->getch(ch, sty, pos); | 614 | parent->getch(ch, sty, pos); |
615 | } | 615 | } |
616 | switch (ch) | 616 | switch (ch) |
617 | { | 617 | { |
618 | case 'f': | 618 | case 'f': |
619 | { | 619 | { |
620 | tchar savedchar = 'f'; | 620 | tchar savedchar = 'f'; |
621 | parent->getch(ch, sty, pos); | 621 | parent->getch(ch, sty, pos); |
622 | switch (ch) | 622 | switch (ch) |
623 | { | 623 | { |
624 | case 'i': | 624 | case 'i': |
625 | ch = (251 << 8) + 1; | 625 | ch = (251 << 8) + 1; |
626 | break; | 626 | break; |
627 | case 'l': | 627 | case 'l': |
628 | ch = (251 << 8) + 2; | 628 | ch = (251 << 8) + 2; |
629 | break; | 629 | break; |
630 | default: | 630 | default: |
631 | lastchar = ch; | 631 | lastchar = ch; |
632 | uselast = true; | 632 | uselast = true; |
633 | laststy = sty; | 633 | laststy = sty; |
634 | ch = savedchar; | 634 | ch = savedchar; |
635 | } | 635 | } |
636 | } | 636 | } |
637 | break; | 637 | break; |
638 | default: | 638 | default: |
639 | break; | 639 | break; |
640 | } | 640 | } |
641 | } | 641 | } |
642 | 642 | ||
643 | class ErrorFilter : public CFilter | 643 | class ErrorFilter : public CFilter |
644 | { | 644 | { |
645 | QString error; | 645 | QString error; |
646 | int currentpos; | 646 | int currentpos; |
647 | public: | 647 | public: |
648 | ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} | 648 | ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} |
649 | ~ErrorFilter() {} | 649 | ~ErrorFilter() {} |
650 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 650 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
651 | { | 651 | { |
652 | if (currentpos == error.length()) | 652 | if (currentpos == error.length()) |
653 | { | 653 | { |
654 | ch = UEOF; | 654 | ch = UEOF; |
655 | currentpos = 0; | 655 | currentpos = 0; |
656 | } | 656 | } |
657 | else | 657 | else |
658 | { | 658 | { |
659 | ch = error[currentpos++].unicode(); | 659 | ch = error[currentpos++].unicode(); |
660 | } | 660 | } |
661 | } | 661 | } |
662 | QString about() { return parent->about(); } | 662 | QString about() { return parent->about(); } |
663 | }; | 663 | }; |
664 | 664 | ||
665 | #ifndef __STATIC | 665 | #ifndef __STATIC |
666 | ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) | 666 | ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) |
667 | { | 667 | { |
668 | #ifdef USEQPE | 668 | #ifdef USEQPE |
669 | #ifdef OPIE | 669 | #ifdef OPIE |
670 | QString filterpath(getenv("OPIEDIR")); | 670 | QString filterpath(getenv("OPIEDIR")); |
671 | #else | 671 | #else |
672 | QString filterpath(getenv("QTDIR")); | 672 | QString filterpath(getenv("QTDIR")); |
673 | #endif | 673 | #endif |
674 | filterpath += "/plugins/reader/filters/lib"; | 674 | filterpath += "/plugins/reader/filters/lib"; |
675 | #else | 675 | #else |
676 | QString filterpath(getenv("READERDIR")); | 676 | QString filterpath(getenv("READERDIR")); |
677 | filterpath += "/filters/lib"; | 677 | filterpath += "/filters/lib"; |
678 | #endif | 678 | #endif |
679 | filterpath += nm; | 679 | filterpath += nm; |
680 | filterpath += ".so"; | 680 | filterpath += ".so"; |
681 | if (QFile::exists(filterpath)) | 681 | if (QFile::exists(filterpath)) |
682 | { | 682 | { |
683 | qDebug("Filter:%s", (const char*)filterpath); | 683 | qDebug("Filter:%s", (const char*)filterpath); |
684 | handle = dlopen(filterpath, RTLD_LAZY); | 684 | handle = dlopen(filterpath, RTLD_LAZY); |
685 | if (handle == 0) | 685 | if (handle == 0) |
686 | { | 686 | { |
687 | qDebug("Can't find filter:%s", dlerror()); | 687 | qDebug("Can't find filter:%s", dlerror()); |
688 | // status = -10; | 688 | // status = -10; |
689 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); | 689 | filt = new ErrorFilter(QString("Can't find plugin:")+nm); |
690 | return; | 690 | return; |
691 | } | 691 | } |
692 | CFilter* (*newfilter)(const QString&); | 692 | CFilter* (*newfilter)(const QString&); |
693 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); | 693 | newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); |
694 | if (newfilter == NULL) | 694 | if (newfilter == NULL) |
695 | { | 695 | { |
696 | qDebug("Can't find newfilter"); | 696 | qDebug("Can't find newfilter"); |
diff --git a/noncore/apps/opie-reader/CRegExp.cpp b/noncore/apps/opie-reader/CRegExp.cpp index 6318d28..e3194df 100644 --- a/noncore/apps/opie-reader/CRegExp.cpp +++ b/noncore/apps/opie-reader/CRegExp.cpp | |||
@@ -1,482 +1,482 @@ | |||
1 | #include "CRegExp.h" | 1 | #include "CRegExp.h" |
2 | 2 | ||
3 | //#include <stdio.h> | 3 | //#include <stdio.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | //#include <string.h> | 5 | //#include <string.h> |
6 | 6 | ||
7 | 7 | ||
8 | tchar CRegExpFilt::escapedchar(tchar c) | 8 | tchar CRegExpFilt::escapedchar(tchar c) |
9 | { | 9 | { |
10 | switch (c) | 10 | switch (c) |
11 | { | 11 | { |
12 | case '\\': | 12 | case '\\': |
13 | return '\\'; | 13 | return '\\'; |
14 | break; | 14 | break; |
15 | case '"': | 15 | case '"': |
16 | return '\"'; | 16 | return '\"'; |
17 | break; | 17 | break; |
18 | case 'a': | 18 | case 'a': |
19 | return '\a'; | 19 | return '\a'; |
20 | break; | 20 | break; |
21 | case 'b': | 21 | case 'b': |
22 | return '\b'; | 22 | return '\b'; |
23 | break; | 23 | break; |
24 | case 'f': | 24 | case 'f': |
25 | return '\f'; | 25 | return '\f'; |
26 | break; | 26 | break; |
27 | case 'n': | 27 | case 'n': |
28 | return '\n'; | 28 | return '\n'; |
29 | break; | 29 | break; |
30 | case 'r': | 30 | case 'r': |
31 | return '\r'; | 31 | return '\r'; |
32 | break; | 32 | break; |
33 | case 't': | 33 | case 't': |
34 | return '\t'; | 34 | return '\t'; |
35 | break; | 35 | break; |
36 | case 'v': | 36 | case 'v': |
37 | return '\v'; | 37 | return '\v'; |
38 | break; | 38 | break; |
39 | default: | 39 | default: |
40 | return c; | 40 | return c; |
41 | break; | 41 | break; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
45 | void CRegExpFilt::regchar(tchar c, bool insens) | 45 | void CRegExpFilt::regchar(tchar c, bool insens) |
46 | { | 46 | { |
47 | if (insens) | 47 | if (insens) |
48 | { | 48 | { |
49 | tchar t = upper(c); | 49 | tchar t = upper(c); |
50 | CV[t] = 0; | 50 | CV[t] = 0; |
51 | t = lower(c); | 51 | t = lower(c); |
52 | CV[t] = 0; | 52 | CV[t] = 0; |
53 | } | 53 | } |
54 | else | 54 | else |
55 | { | 55 | { |
56 | CV[c] = 0; | 56 | CV[c] = 0; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | void CRegExpFilt::prepreprocessing(const QString& pat, bool insens) | 60 | void CRegExpFilt::prepreprocessing(const QString& pat, bool insens) |
61 | { | 61 | { |
62 | for (unsigned int p = 0; p < pat.length(); p++) | 62 | for (unsigned int p = 0; p < pat.length(); p++) |
63 | { | 63 | { |
64 | #ifdef _WINDOWS | 64 | #ifdef _WINDOWS |
65 | switch (pat.at(p).unicode()) | 65 | switch (pat.at(p).unicode()) |
66 | #else | 66 | #else |
67 | switch (pat[p].unicode()) | 67 | switch (pat[p].unicode()) |
68 | #endif | 68 | #endif |
69 | { | 69 | { |
70 | case '{': | 70 | case '{': |
71 | { | 71 | { |
72 | break; | 72 | break; |
73 | } | 73 | } |
74 | case '}': | 74 | case '}': |
75 | { | 75 | { |
76 | break; | 76 | break; |
77 | } | 77 | } |
78 | case '^': | 78 | case '^': |
79 | { | 79 | { |
80 | break; | 80 | break; |
81 | } | 81 | } |
82 | case '.' : | 82 | case '.' : |
83 | { | 83 | { |
84 | break; | 84 | break; |
85 | } | 85 | } |
86 | case '#': | 86 | case '#': |
87 | { | 87 | { |
88 | p++; | 88 | p++; |
89 | #ifdef _WINDOWS | 89 | #ifdef _WINDOWS |
90 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') | 90 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') |
91 | #else | 91 | #else |
92 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') | 92 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') |
93 | #endif | 93 | #endif |
94 | { | 94 | { |
95 | } | 95 | } |
96 | p--; | 96 | p--; |
97 | break; | 97 | break; |
98 | } | 98 | } |
99 | case '\\' : | 99 | case '\\' : |
100 | { | 100 | { |
101 | #ifdef _WINDOWS | 101 | #ifdef _WINDOWS |
102 | tchar c = escapedchar(pat.at(++p).unicode()); | 102 | tchar c = escapedchar(pat.at(++p).unicode()); |
103 | #else | 103 | #else |
104 | tchar c = escapedchar(pat[++p].unicode()); | 104 | tchar c = escapedchar(pat[++p].unicode()); |
105 | #endif | 105 | #endif |
106 | regchar(c, insens); | 106 | regchar(c, insens); |
107 | break; | 107 | break; |
108 | } | 108 | } |
109 | 109 | ||
110 | case '[' : | 110 | case '[' : |
111 | { | 111 | { |
112 | tchar clast; | 112 | tchar clast = 0; |
113 | bool invert = false; | 113 | bool invert = false; |
114 | tchar c; | 114 | tchar c; |
115 | #ifdef _WINDOWS | 115 | #ifdef _WINDOWS |
116 | if (pat.at(p+1).unicode() == '^') | 116 | if (pat.at(p+1).unicode() == '^') |
117 | #else | 117 | #else |
118 | if (pat[p+1].unicode() == '^') | 118 | if (pat[p+1].unicode() == '^') |
119 | #endif | 119 | #endif |
120 | { | 120 | { |
121 | p++; | 121 | p++; |
122 | invert = true; | 122 | invert = true; |
123 | } | 123 | } |
124 | #ifdef _WINDOWS | 124 | #ifdef _WINDOWS |
125 | while ((c = pat.at(++p).unicode()) != ']') | 125 | while ((c = pat.at(++p).unicode()) != ']') |
126 | #else | 126 | #else |
127 | while ((c = pat[++p].unicode()) != ']') | 127 | while ((c = pat[++p].unicode()) != ']') |
128 | #endif | 128 | #endif |
129 | { | 129 | { |
130 | if (c == '\\') | 130 | if (c == '\\') |
131 | { | 131 | { |
132 | #ifdef _WINDOWS | 132 | #ifdef _WINDOWS |
133 | c = escapedchar(pat.at(++p).unicode()); | 133 | c = escapedchar(pat.at(++p).unicode()); |
134 | #else | 134 | #else |
135 | c = escapedchar(pat[++p].unicode()); | 135 | c = escapedchar(pat[++p].unicode()); |
136 | #endif | 136 | #endif |
137 | if (c == ']') break; | 137 | if (c == ']') break; |
138 | } | 138 | } |
139 | if (c == '-') | 139 | if (c == '-') |
140 | { | 140 | { |
141 | #ifdef _WINDOWS | 141 | #ifdef _WINDOWS |
142 | c = pat.at(++p).unicode(); | 142 | c = pat.at(++p).unicode(); |
143 | #else | 143 | #else |
144 | c = pat[++p].unicode(); | 144 | c = pat[++p].unicode(); |
145 | #endif | 145 | #endif |
146 | for (tchar j = clast; j <= c; j++) | 146 | for (tchar j = clast; j <= c; j++) |
147 | { | 147 | { |
148 | regchar(j, insens); | 148 | regchar(j, insens); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | else | 151 | else |
152 | { | 152 | { |
153 | regchar(c, insens); | 153 | regchar(c, insens); |
154 | } | 154 | } |
155 | clast = c; | 155 | clast = c; |
156 | } | 156 | } |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | default : | 159 | default : |
160 | { | 160 | { |
161 | #ifdef _WINDOWS | 161 | #ifdef _WINDOWS |
162 | regchar(pat.at(p).unicode(), insens); | 162 | regchar(pat.at(p).unicode(), insens); |
163 | #else | 163 | #else |
164 | regchar(pat[p].unicode(), insens); | 164 | regchar(pat[p].unicode(), insens); |
165 | #endif | 165 | #endif |
166 | break; | 166 | break; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } | 169 | } |
170 | /* | 170 | /* |
171 | for (iter i = CV.begin(); i != CV.end(); ++i) | 171 | for (iter i = CV.begin(); i != CV.end(); ++i) |
172 | { | 172 | { |
173 | printf("Pre: [%u]\n", i.first()); | 173 | printf("Pre: [%u]\n", i.first()); |
174 | } | 174 | } |
175 | */ | 175 | */ |
176 | CV[0] = 0; | 176 | CV[0] = 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens) | 179 | unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens) |
180 | { | 180 | { |
181 | prepreprocessing(pat, insens); | 181 | prepreprocessing(pat, insens); |
182 | qDebug("PrePreProcessing done"); | 182 | qDebug("PrePreProcessing done"); |
183 | unsigned int p, m; | 183 | unsigned int p, m; |
184 | bool inkeep = false; | 184 | bool inkeep = false; |
185 | keep = 0; | 185 | keep = 0; |
186 | replace = 0; | 186 | replace = 0; |
187 | for (unsigned int j = 0; j < WORD_SIZE; j++) | 187 | for (unsigned int j = 0; j < WORD_SIZE; j++) |
188 | { | 188 | { |
189 | bit[j] = (1 << (WORD_SIZE -j -1)); | 189 | bit[j] = (1 << (WORD_SIZE -j -1)); |
190 | lfcnt[j] = 0; | 190 | lfcnt[j] = 0; |
191 | } | 191 | } |
192 | 192 | ||
193 | for (p = 0, m = 0; p < pat.length(); p++) | 193 | for (p = 0, m = 0; p < pat.length(); p++) |
194 | { | 194 | { |
195 | qDebug("m is %u", m); | 195 | qDebug("m is %u", m); |
196 | if (inkeep) keep |= bit[m]; | 196 | if (inkeep) keep |= bit[m]; |
197 | #ifdef _WINDOWS | 197 | #ifdef _WINDOWS |
198 | switch (pat.at(p).unicode()) | 198 | switch (pat.at(p).unicode()) |
199 | #else | 199 | #else |
200 | switch (pat[p].unicode()) | 200 | switch (pat[p].unicode()) |
201 | #endif | 201 | #endif |
202 | { | 202 | { |
203 | case '{': | 203 | case '{': |
204 | { | 204 | { |
205 | inkeep = true; | 205 | inkeep = true; |
206 | break; | 206 | break; |
207 | } | 207 | } |
208 | case '}': | 208 | case '}': |
209 | { | 209 | { |
210 | keep ^= bit[m]; | 210 | keep ^= bit[m]; |
211 | inkeep = false; | 211 | inkeep = false; |
212 | break; | 212 | break; |
213 | } | 213 | } |
214 | case '^': | 214 | case '^': |
215 | { | 215 | { |
216 | replace |= bit[m]; | 216 | replace |= bit[m]; |
217 | lfcnt[m]++; | 217 | lfcnt[m]++; |
218 | break; | 218 | break; |
219 | } | 219 | } |
220 | case '.' : | 220 | case '.' : |
221 | { | 221 | { |
222 | for (iter j = CV.begin(); j != CV.end(); ++j) CV[j.first()] |= bit[m]; | 222 | for (iter j = CV.begin(); j != CV.end(); ++j) CV[j.first()] |= bit[m]; |
223 | m++; | 223 | m++; |
224 | break; | 224 | break; |
225 | } | 225 | } |
226 | case '#': | 226 | case '#': |
227 | { | 227 | { |
228 | if (m > 0) | 228 | if (m > 0) |
229 | { | 229 | { |
230 | p++; | 230 | p++; |
231 | int count = 0; | 231 | int count = 0; |
232 | #ifdef _WINDOWS | 232 | #ifdef _WINDOWS |
233 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') | 233 | while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') |
234 | #else | 234 | #else |
235 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') | 235 | while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') |
236 | #endif | 236 | #endif |
237 | { | 237 | { |
238 | #ifdef _WINDOWS | 238 | #ifdef _WINDOWS |
239 | count = 10*count + pat.at(p++).unicode() - '0'; | 239 | count = 10*count + pat.at(p++).unicode() - '0'; |
240 | #else | 240 | #else |
241 | count = 10*count + pat[p++].unicode() - '0'; | 241 | count = 10*count + pat[p++].unicode() - '0'; |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | p--; | 244 | p--; |
245 | count = count-1; | 245 | count = count-1; |
246 | unsigned int mask = 0; | 246 | unsigned int mask = 0; |
247 | for (unsigned int i = m; i < m+count; i++) | 247 | for (unsigned int i = m; i < m+count; i++) |
248 | { | 248 | { |
249 | mask |= bit[i]; | 249 | mask |= bit[i]; |
250 | } | 250 | } |
251 | 251 | ||
252 | for (iter it = CV.begin(); it != CV.end(); ++it) | 252 | for (iter it = CV.begin(); it != CV.end(); ++it) |
253 | { | 253 | { |
254 | if (CV[it.first()] & bit[m-1]) | 254 | if (CV[it.first()] & bit[m-1]) |
255 | { | 255 | { |
256 | CV[it.first()] |= mask; | 256 | CV[it.first()] |= mask; |
257 | } | 257 | } |
258 | } | 258 | } |
259 | if (keep & bit[m-1]) keep |= mask; | 259 | if (keep & bit[m-1]) keep |= mask; |
260 | m += count; | 260 | m += count; |
261 | } | 261 | } |
262 | else | 262 | else |
263 | { | 263 | { |
264 | p++; | 264 | p++; |
265 | } | 265 | } |
266 | break; | 266 | break; |
267 | } | 267 | } |
268 | case '\\' : | 268 | case '\\' : |
269 | { | 269 | { |
270 | #ifdef _WINDOWS | 270 | #ifdef _WINDOWS |
271 | tchar c = escapedchar(pat.at(++p).unicode()); | 271 | tchar c = escapedchar(pat.at(++p).unicode()); |
272 | #else | 272 | #else |
273 | tchar c = escapedchar(pat[++p].unicode()); | 273 | tchar c = escapedchar(pat[++p].unicode()); |
274 | #endif | 274 | #endif |
275 | if (insens) | 275 | if (insens) |
276 | { | 276 | { |
277 | CV[upper(c)] |= bit[m]; | 277 | CV[upper(c)] |= bit[m]; |
278 | CV[lower(c)] |= bit[m]; | 278 | CV[lower(c)] |= bit[m]; |
279 | } | 279 | } |
280 | else | 280 | else |
281 | { | 281 | { |
282 | CV[c] |= bit[m]; | 282 | CV[c] |= bit[m]; |
283 | } | 283 | } |
284 | m++; | 284 | m++; |
285 | break; | 285 | break; |
286 | } | 286 | } |
287 | 287 | ||
288 | case '[' : | 288 | case '[' : |
289 | { | 289 | { |
290 | tchar c, clast; | 290 | tchar c, clast = 0; |
291 | bool invert = false; | 291 | bool invert = false; |
292 | #ifdef _WINDOWS | 292 | #ifdef _WINDOWS |
293 | if (pat.at(p+1).unicode() == '^') | 293 | if (pat.at(p+1).unicode() == '^') |
294 | #else | 294 | #else |
295 | if (pat[p+1].unicode() == '^') | 295 | if (pat[p+1].unicode() == '^') |
296 | #endif | 296 | #endif |
297 | { | 297 | { |
298 | p++; | 298 | p++; |
299 | invert = true; | 299 | invert = true; |
300 | } | 300 | } |
301 | #ifdef _WINDOWS | 301 | #ifdef _WINDOWS |
302 | while ((c = pat.at(++p).unicode()) != ']') | 302 | while ((c = pat.at(++p).unicode()) != ']') |
303 | #else | 303 | #else |
304 | while ((c = pat[++p].unicode()) != ']') | 304 | while ((c = pat[++p].unicode()) != ']') |
305 | #endif | 305 | #endif |
306 | { | 306 | { |
307 | if (c == '\\') | 307 | if (c == '\\') |
308 | { | 308 | { |
309 | #ifdef _WINDOWS | 309 | #ifdef _WINDOWS |
310 | c = escapedchar(pat.at(++p).unicode()); | 310 | c = escapedchar(pat.at(++p).unicode()); |
311 | #else | 311 | #else |
312 | c = escapedchar(pat[++p].unicode()); | 312 | c = escapedchar(pat[++p].unicode()); |
313 | #endif | 313 | #endif |
314 | if (c == ']') break; | 314 | if (c == ']') break; |
315 | } | 315 | } |
316 | if (c == '-') | 316 | if (c == '-') |
317 | { | 317 | { |
318 | #ifdef _WINDOWS | 318 | #ifdef _WINDOWS |
319 | c = pat.at(++p).unicode(); | 319 | c = pat.at(++p).unicode(); |
320 | #else | 320 | #else |
321 | c = pat[++p].unicode(); | 321 | c = pat[++p].unicode(); |
322 | #endif | 322 | #endif |
323 | for (tchar j = clast; j <= c; j++) | 323 | for (tchar j = clast; j <= c; j++) |
324 | { | 324 | { |
325 | if (insens) | 325 | if (insens) |
326 | { | 326 | { |
327 | iter it; | 327 | iter it; |
328 | if ((it = CV.find(upper(j))) != CV.end()) | 328 | if ((it = CV.find(upper(j))) != CV.end()) |
329 | CV[it] |= bit[m]; | 329 | CV[it] |= bit[m]; |
330 | else | 330 | else |
331 | CV[0] |= bit[m]; | 331 | CV[0] |= bit[m]; |
332 | if ((it = CV.find(lower(j))) != CV.end()) | 332 | if ((it = CV.find(lower(j))) != CV.end()) |
333 | CV[it] |= bit[m]; | 333 | CV[it] |= bit[m]; |
334 | else | 334 | else |
335 | CV[0] |= bit[m]; | 335 | CV[0] |= bit[m]; |
336 | } | 336 | } |
337 | else | 337 | else |
338 | { | 338 | { |
339 | iter it; | 339 | iter it; |
340 | if ((it = CV.find(j)) != CV.end()) | 340 | if ((it = CV.find(j)) != CV.end()) |
341 | CV[it] |= bit[m]; | 341 | CV[it] |= bit[m]; |
342 | else | 342 | else |
343 | { | 343 | { |
344 | CV[0] |= bit[m]; | 344 | CV[0] |= bit[m]; |
345 | } | 345 | } |
346 | } | 346 | } |
347 | } | 347 | } |
348 | } | 348 | } |
349 | else | 349 | else |
350 | { | 350 | { |
351 | if (insens) | 351 | if (insens) |
352 | { | 352 | { |
353 | iter it; | 353 | iter it; |
354 | if ((it = CV.find(upper(c))) != CV.end()) | 354 | if ((it = CV.find(upper(c))) != CV.end()) |
355 | CV[it] |= bit[m]; | 355 | CV[it] |= bit[m]; |
356 | else | 356 | else |
357 | CV[0] |= bit[m]; | 357 | CV[0] |= bit[m]; |
358 | if ((it = CV.find(lower(c))) != CV.end()) | 358 | if ((it = CV.find(lower(c))) != CV.end()) |
359 | CV[it] |= bit[m]; | 359 | CV[it] |= bit[m]; |
360 | else | 360 | else |
361 | CV[0] |= bit[m]; | 361 | CV[0] |= bit[m]; |
362 | } | 362 | } |
363 | else | 363 | else |
364 | { | 364 | { |
365 | iter it; | 365 | iter it; |
366 | if ((it = CV.find(c)) != CV.end()) | 366 | if ((it = CV.find(c)) != CV.end()) |
367 | CV[it] |= bit[m]; | 367 | CV[it] |= bit[m]; |
368 | else | 368 | else |
369 | CV[0] |= bit[m]; | 369 | CV[0] |= bit[m]; |
370 | } | 370 | } |
371 | } | 371 | } |
372 | clast = c; | 372 | clast = c; |
373 | } | 373 | } |
374 | if (invert) | 374 | if (invert) |
375 | { | 375 | { |
376 | for (iter i = CV.begin(); i != CV.end(); ++i) | 376 | for (iter i = CV.begin(); i != CV.end(); ++i) |
377 | { | 377 | { |
378 | CV[i.first()] ^= bit[m]; | 378 | CV[i.first()] ^= bit[m]; |
379 | } | 379 | } |
380 | } | 380 | } |
381 | m++; | 381 | m++; |
382 | break; | 382 | break; |
383 | } | 383 | } |
384 | default : | 384 | default : |
385 | { | 385 | { |
386 | #ifdef _WINDOWS | 386 | #ifdef _WINDOWS |
387 | tchar c = pat.at(p).unicode(); | 387 | tchar c = pat.at(p).unicode(); |
388 | #else | 388 | #else |
389 | tchar c = pat[p].unicode(); | 389 | tchar c = pat[p].unicode(); |
390 | #endif | 390 | #endif |
391 | if (insens) | 391 | if (insens) |
392 | { | 392 | { |
393 | CV[upper(c)] |= bit[m]; | 393 | CV[upper(c)] |= bit[m]; |
394 | CV[lower(c)] |= bit[m]; | 394 | CV[lower(c)] |= bit[m]; |
395 | } | 395 | } |
396 | else CV[c] |= bit[m]; | 396 | else CV[c] |= bit[m]; |
397 | m++; | 397 | m++; |
398 | break; | 398 | break; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | } | 401 | } |
402 | qDebug("Returning:%u",m); | 402 | qDebug("Returning:%u",m); |
403 | return m; | 403 | return m; |
404 | } | 404 | } |
405 | 405 | ||
406 | bool CRegExpFilt::empty() | 406 | bool CRegExpFilt::empty() |
407 | { | 407 | { |
408 | return m_outQueue.empty(); | 408 | return m_outQueue.empty(); |
409 | } | 409 | } |
410 | 410 | ||
411 | tchar CRegExpFilt::pop() | 411 | tchar CRegExpFilt::pop() |
412 | { | 412 | { |
413 | return m_outQueue.pop(); | 413 | return m_outQueue.pop(); |
414 | } | 414 | } |
415 | 415 | ||
416 | bool CRegExpFilt::addch(tchar ch) | 416 | bool CRegExpFilt::addch(tchar ch) |
417 | { | 417 | { |
418 | word[cur] = ch; | 418 | word[cur] = ch; |
419 | cur = (cur+1)%patlength; | 419 | cur = (cur+1)%patlength; |
420 | if (len < patlength) len++; | 420 | if (len < patlength) len++; |
421 | 421 | ||
422 | unsigned int cv = 0; | 422 | unsigned int cv = 0; |
423 | iter it; | 423 | iter it; |
424 | if ((it = CV.find(ch)) == CV.end()) | 424 | if ((it = CV.find(ch)) == CV.end()) |
425 | { | 425 | { |
426 | cv = CV[0]; | 426 | cv = CV[0]; |
427 | } | 427 | } |
428 | else | 428 | else |
429 | { | 429 | { |
430 | cv = CV[it]; | 430 | cv = CV[it]; |
431 | } | 431 | } |
432 | 432 | ||
433 | R = ((R >> 1) | bit_0) & cv; /* Exact matches */ | 433 | R = ((R >> 1) | bit_0) & cv; /* Exact matches */ |
434 | if (R & endpos) | 434 | if (R & endpos) |
435 | { | 435 | { |
436 | for (unsigned int i = 0; i < patlength; i++) | 436 | for (unsigned int i = 0; i < patlength; i++) |
437 | { | 437 | { |
438 | if (replace & bit[i]) | 438 | if (replace & bit[i]) |
439 | { | 439 | { |
440 | for (unsigned int j = 0; j < lfcnt[i]; j++) | 440 | for (unsigned int j = 0; j < lfcnt[i]; j++) |
441 | { | 441 | { |
442 | m_outQueue.push(10); | 442 | m_outQueue.push(10); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | if (keep & bit[i]) | 445 | if (keep & bit[i]) |
446 | { | 446 | { |
447 | m_outQueue.push(word[(cur+i)%patlength]); | 447 | m_outQueue.push(word[(cur+i)%patlength]); |
448 | // putchar('*'); | 448 | // putchar('*'); |
449 | // putchar(i + '0'); | 449 | // putchar(i + '0'); |
450 | } | 450 | } |
451 | len = 0; | 451 | len = 0; |
452 | } | 452 | } |
453 | return true; | 453 | return true; |
454 | } | 454 | } |
455 | else | 455 | else |
456 | { | 456 | { |
457 | if (len == patlength) | 457 | if (len == patlength) |
458 | { | 458 | { |
459 | tchar ch = word[cur]; | 459 | tchar ch = word[cur]; |
460 | if (ch == 10) ch = ' '; | 460 | if (ch == 10) ch = ' '; |
461 | m_outQueue.push(ch); | 461 | m_outQueue.push(ch); |
462 | } | 462 | } |
463 | return false; | 463 | return false; |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | void CRegExpFilt::restart() | 467 | void CRegExpFilt::restart() |
468 | { | 468 | { |
469 | R = 0; | 469 | R = 0; |
470 | len = 0; | 470 | len = 0; |
471 | } | 471 | } |
472 | 472 | ||
473 | CRegExpFilt::CRegExpFilt(const QString& pat, bool insensflag) : CV(300) | 473 | CRegExpFilt::CRegExpFilt(const QString& pat, bool insensflag) : CV(300) |
474 | { | 474 | { |
475 | cur = 0; | 475 | cur = 0; |
476 | patlength = preprocessing(pat, insensflag); | 476 | patlength = preprocessing(pat, insensflag); |
477 | qDebug("Preprocesing done:%u", patlength); | 477 | qDebug("Preprocesing done:%u", patlength); |
478 | endpos = bit[patlength-1]; | 478 | endpos = bit[patlength-1]; |
479 | bit_0 = bit[0]; | 479 | bit_0 = bit[0]; |
480 | 480 | ||
481 | restart(); | 481 | restart(); |
482 | 482 | ||
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp index 361755f..09cad1c 100644 --- a/noncore/apps/opie-reader/Palm2QImage.cpp +++ b/noncore/apps/opie-reader/Palm2QImage.cpp | |||
@@ -1,299 +1,299 @@ | |||
1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ | 1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ |
2 | 2 | ||
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include <string.h> | 5 | #include <string.h> |
6 | #ifndef _WINDOWS | 6 | #ifndef _WINDOWS |
7 | #include <unistd.h> /* for link */ | 7 | #include <unistd.h> /* for link */ |
8 | #endif | 8 | #endif |
9 | #include <sys/types.h> | 9 | #include <sys/types.h> |
10 | #include <sys/stat.h> | 10 | #include <sys/stat.h> |
11 | #include <stdarg.h> | 11 | #include <stdarg.h> |
12 | 12 | ||
13 | #include <qimage.h> | 13 | #include <qimage.h> |
14 | 14 | ||
15 | /***********************************************************************/ | 15 | /***********************************************************************/ |
16 | /***********************************************************************/ | 16 | /***********************************************************************/ |
17 | /***** *****/ | 17 | /***** *****/ |
18 | /***** Code to decode the Palm image format to JPEG *****/ | 18 | /***** Code to decode the Palm image format to JPEG *****/ |
19 | /***** *****/ | 19 | /***** *****/ |
20 | /***********************************************************************/ | 20 | /***********************************************************************/ |
21 | /***********************************************************************/ | 21 | /***********************************************************************/ |
22 | 22 | ||
23 | #define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1])) | 23 | #define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1])) |
24 | #define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3])) | 24 | #define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3])) |
25 | 25 | ||
26 | #define PALM_IS_COMPRESSED_FLAG 0x8000 | 26 | #define PALM_IS_COMPRESSED_FLAG 0x8000 |
27 | #define PALM_HAS_COLORMAP_FLAG 0x4000 | 27 | #define PALM_HAS_COLORMAP_FLAG 0x4000 |
28 | #define PALM_HAS_TRANSPARENCY_FLAG 0x2000 | 28 | #define PALM_HAS_TRANSPARENCY_FLAG 0x2000 |
29 | #define PALM_DIRECT_COLOR_FLAG 0x0400 | 29 | #define PALM_DIRECT_COLOR_FLAG 0x0400 |
30 | #define PALM_4_BYTE_FIELD_FLAG 0x0200 | 30 | #define PALM_4_BYTE_FIELD_FLAG 0x0200 |
31 | 31 | ||
32 | #define PALM_COMPRESSION_SCANLINE 0x00 | 32 | #define PALM_COMPRESSION_SCANLINE 0x00 |
33 | #define PALM_COMPRESSION_RLE 0x01 | 33 | #define PALM_COMPRESSION_RLE 0x01 |
34 | #define PALM_COMPRESSION_PACKBITS 0x02 | 34 | #define PALM_COMPRESSION_PACKBITS 0x02 |
35 | #define PALM_COMPRESSION_NONE 0xFF | 35 | #define PALM_COMPRESSION_NONE 0xFF |
36 | 36 | ||
37 | #define PALM_COLORMAP_SIZE 232 | 37 | #define PALM_COLORMAP_SIZE 232 |
38 | 38 | ||
39 | typedef struct { | 39 | typedef struct { |
40 | unsigned char red; | 40 | unsigned char red; |
41 | unsigned char green; | 41 | unsigned char green; |
42 | unsigned char blue; | 42 | unsigned char blue; |
43 | } ColorMapEntry; | 43 | } ColorMapEntry; |
44 | 44 | ||
45 | static ColorMapEntry Palm8BitColormap[] = { | 45 | static ColorMapEntry Palm8BitColormap[] = { |
46 | { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, | 46 | { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, |
47 | { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, | 47 | { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, |
48 | { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, | 48 | { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, |
49 | { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, | 49 | { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, |
50 | { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, | 50 | { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, |
51 | { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 }, | 51 | { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 }, |
52 | { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 }, | 52 | { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 }, |
53 | { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 }, | 53 | { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 }, |
54 | { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 }, | 54 | { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 }, |
55 | { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 }, | 55 | { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 }, |
56 | { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 }, | 56 | { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 }, |
57 | { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 }, | 57 | { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 }, |
58 | { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 }, | 58 | { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 }, |
59 | { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 }, | 59 | { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 }, |
60 | { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 }, | 60 | { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 }, |
61 | { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 }, | 61 | { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 }, |
62 | { 102, 51, 204 }, { 102, 0, 204 }, { 102, 255, 153 }, { 102, 204, 153 }, | 62 | { 102, 51, 204 }, { 102, 0, 204 }, { 102, 255, 153 }, { 102, 204, 153 }, |
63 | { 102, 153, 153 }, { 102, 102, 153 }, { 102, 51, 153 }, { 102, 0, 153 }, | 63 | { 102, 153, 153 }, { 102, 102, 153 }, { 102, 51, 153 }, { 102, 0, 153 }, |
64 | { 51, 255, 255 }, { 51, 204, 255 }, { 51, 153, 255 }, { 51, 102, 255 }, | 64 | { 51, 255, 255 }, { 51, 204, 255 }, { 51, 153, 255 }, { 51, 102, 255 }, |
65 | { 51, 51, 255 }, { 51, 0, 255 }, { 51, 255, 204 }, { 51, 204, 204 }, | 65 | { 51, 51, 255 }, { 51, 0, 255 }, { 51, 255, 204 }, { 51, 204, 204 }, |
66 | { 51, 153, 204 }, { 51, 102, 204 }, { 51, 51, 204 }, { 51, 0, 204 }, | 66 | { 51, 153, 204 }, { 51, 102, 204 }, { 51, 51, 204 }, { 51, 0, 204 }, |
67 | { 51, 255, 153 }, { 51, 204, 153 }, { 51, 153, 153 }, { 51, 102, 153 }, | 67 | { 51, 255, 153 }, { 51, 204, 153 }, { 51, 153, 153 }, { 51, 102, 153 }, |
68 | { 51, 51, 153 }, { 51, 0, 153 }, { 0, 255, 255 }, { 0, 204, 255 }, | 68 | { 51, 51, 153 }, { 51, 0, 153 }, { 0, 255, 255 }, { 0, 204, 255 }, |
69 | { 0, 153, 255 }, { 0, 102, 255 }, { 0, 51, 255 }, { 0, 0, 255 }, | 69 | { 0, 153, 255 }, { 0, 102, 255 }, { 0, 51, 255 }, { 0, 0, 255 }, |
70 | { 0, 255, 204 }, { 0, 204, 204 }, { 0, 153, 204 }, { 0, 102, 204 }, | 70 | { 0, 255, 204 }, { 0, 204, 204 }, { 0, 153, 204 }, { 0, 102, 204 }, |
71 | { 0, 51, 204 }, { 0, 0, 204 }, { 0, 255, 153 }, { 0, 204, 153 }, | 71 | { 0, 51, 204 }, { 0, 0, 204 }, { 0, 255, 153 }, { 0, 204, 153 }, |
72 | { 0, 153, 153 }, { 0, 102, 153 }, { 0, 51, 153 }, { 0, 0, 153 }, | 72 | { 0, 153, 153 }, { 0, 102, 153 }, { 0, 51, 153 }, { 0, 0, 153 }, |
73 | { 255, 255, 102 }, { 255, 204, 102 }, { 255, 153, 102 }, { 255, 102, 102 }, | 73 | { 255, 255, 102 }, { 255, 204, 102 }, { 255, 153, 102 }, { 255, 102, 102 }, |
74 | { 255, 51, 102 }, { 255, 0, 102 }, { 255, 255, 51 }, { 255, 204, 51 }, | 74 | { 255, 51, 102 }, { 255, 0, 102 }, { 255, 255, 51 }, { 255, 204, 51 }, |
75 | { 255, 153, 51 }, { 255, 102, 51 }, { 255, 51, 51 }, { 255, 0, 51 }, | 75 | { 255, 153, 51 }, { 255, 102, 51 }, { 255, 51, 51 }, { 255, 0, 51 }, |
76 | { 255, 255, 0 }, { 255, 204, 0 }, { 255, 153, 0 }, { 255, 102, 0 }, | 76 | { 255, 255, 0 }, { 255, 204, 0 }, { 255, 153, 0 }, { 255, 102, 0 }, |
77 | { 255, 51, 0 }, { 255, 0, 0 }, { 204, 255, 102 }, { 204, 204, 102 }, | 77 | { 255, 51, 0 }, { 255, 0, 0 }, { 204, 255, 102 }, { 204, 204, 102 }, |
78 | { 204, 153, 102 }, { 204, 102, 102 }, { 204, 51, 102 }, { 204, 0, 102 }, | 78 | { 204, 153, 102 }, { 204, 102, 102 }, { 204, 51, 102 }, { 204, 0, 102 }, |
79 | { 204, 255, 51 }, { 204, 204, 51 }, { 204, 153, 51 }, { 204, 102, 51 }, | 79 | { 204, 255, 51 }, { 204, 204, 51 }, { 204, 153, 51 }, { 204, 102, 51 }, |
80 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, | 80 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, |
81 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, | 81 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, |
82 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, | 82 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, |
83 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, | 83 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, |
84 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, | 84 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, |
85 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, | 85 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, |
86 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, | 86 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, |
87 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, | 87 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, |
88 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, | 88 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, |
89 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, | 89 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, |
90 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, | 90 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, |
91 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, | 91 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, |
92 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, | 92 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, |
93 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, | 93 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, |
94 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, | 94 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, |
95 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, | 95 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, |
96 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, | 96 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, |
97 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, | 97 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, |
98 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, | 98 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, |
99 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, | 99 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, |
100 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, | 100 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, |
101 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, | 101 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, |
102 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, | 102 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, |
103 | { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, | 103 | { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, |
104 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 104 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
105 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 105 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
106 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 106 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
107 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 107 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
108 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 108 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
109 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}; | 109 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}; |
110 | 110 | ||
111 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; | 111 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; |
112 | 112 | ||
113 | static ColorMapEntry Palm2BitColormap[] = { | 113 | static ColorMapEntry Palm2BitColormap[] = { |
114 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; | 114 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; |
115 | 115 | ||
116 | static ColorMapEntry Palm4BitColormap[] = { | 116 | static ColorMapEntry Palm4BitColormap[] = { |
117 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, | 117 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, |
118 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, | 118 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, |
119 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, | 119 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, |
120 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; | 120 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; |
121 | 121 | ||
122 | QImage* Palm2QImage | 122 | QImage* Palm2QImage |
123 | (unsigned char *image_bytes_in, int byte_count_in) | 123 | (unsigned char *image_bytes_in, int byte_count_in) |
124 | { | 124 | { |
125 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; | 125 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; |
126 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; | 126 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; |
127 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; | 127 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; |
128 | unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow, | 128 | unsigned char *palm_ptr, *x_ptr, *inbyte, *rowbuf, *lastrow, |
129 | *imagedatastart, *palmimage; | 129 | *imagedatastart, *palmimage; |
130 | ColorMapEntry *colormap; | 130 | ColorMapEntry *colormap; |
131 | 131 | ||
132 | palmimage = image_bytes_in; | 132 | palmimage = image_bytes_in; |
133 | width = READ_BIGENDIAN_SHORT(palmimage + 0); | 133 | width = READ_BIGENDIAN_SHORT(palmimage + 0); |
134 | height = READ_BIGENDIAN_SHORT(palmimage + 2); | 134 | height = READ_BIGENDIAN_SHORT(palmimage + 2); |
135 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); | 135 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); |
136 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); | 136 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); |
137 | bits_per_pixel = palmimage[8]; | 137 | bits_per_pixel = palmimage[8]; |
138 | version = palmimage[9]; | 138 | version = palmimage[9]; |
139 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); | 139 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); |
140 | transparent_index = palmimage[12]; | 140 | transparent_index = palmimage[12]; |
141 | compression_type = palmimage[13]; | 141 | compression_type = palmimage[13]; |
142 | /* bytes 14 and 15 are reserved by Palm and always 0 */ | 142 | /* bytes 14 and 15 are reserved by Palm and always 0 */ |
143 | 143 | ||
144 | #if 0 | 144 | #if 0 |
145 | // qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", width, height, bits_per_pixel, version, flags, compression_type); | 145 | // qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", width, height, bits_per_pixel, version, flags, compression_type); |
146 | #endif | 146 | #endif |
147 | 147 | ||
148 | if (compression_type == PALM_COMPRESSION_PACKBITS) { | 148 | if (compression_type == PALM_COMPRESSION_PACKBITS) { |
149 | // qDebug ("Image uses packbits compression; not yet supported"); | 149 | // qDebug ("Image uses packbits compression; not yet supported"); |
150 | return NULL; | 150 | return NULL; |
151 | } else if ((compression_type != PALM_COMPRESSION_NONE) && | 151 | } else if ((compression_type != PALM_COMPRESSION_NONE) && |
152 | (compression_type != PALM_COMPRESSION_RLE) && | 152 | (compression_type != PALM_COMPRESSION_RLE) && |
153 | (compression_type != PALM_COMPRESSION_SCANLINE)) { | 153 | (compression_type != PALM_COMPRESSION_SCANLINE)) { |
154 | // qDebug ("Image uses unknown compression, code 0x%x", compression_type); | 154 | // qDebug ("Image uses unknown compression, code 0x%x", compression_type); |
155 | return NULL; | 155 | return NULL; |
156 | } | 156 | } |
157 | 157 | ||
158 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: | 158 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: |
159 | 159 | ||
160 | 1, 2, or 4 bit grayscale | 160 | 1, 2, or 4 bit grayscale |
161 | 8-bit StaticColor using the Palm standard colormap | 161 | 8-bit StaticColor using the Palm standard colormap |
162 | 8-bit PseudoColor using a user-specified colormap | 162 | 8-bit PseudoColor using a user-specified colormap |
163 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue | 163 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue |
164 | 164 | ||
165 | Each of these can be compressed with one of four compression schemes, | 165 | Each of these can be compressed with one of four compression schemes, |
166 | "RLE", "Scanline", "PackBits", or none. | 166 | "RLE", "Scanline", "PackBits", or none. |
167 | 167 | ||
168 | We begin by constructing the colormap. | 168 | We begin by constructing the colormap. |
169 | */ | 169 | */ |
170 | 170 | ||
171 | if (flags & PALM_HAS_COLORMAP_FLAG) { | 171 | if (flags & PALM_HAS_COLORMAP_FLAG) { |
172 | // qDebug("Palm images with custom colormaps are not currently supported.\n"); | 172 | // qDebug("Palm images with custom colormaps are not currently supported.\n"); |
173 | return NULL; | 173 | return NULL; |
174 | } else if (bits_per_pixel == 1) { | 174 | } else if (bits_per_pixel == 1) { |
175 | colormap = Palm1BitColormap; | 175 | colormap = Palm1BitColormap; |
176 | imagedatastart = palmimage + 16; | 176 | imagedatastart = palmimage + 16; |
177 | } else if (bits_per_pixel == 2) { | 177 | } else if (bits_per_pixel == 2) { |
178 | colormap = Palm2BitColormap; | 178 | colormap = Palm2BitColormap; |
179 | imagedatastart = palmimage + 16; | 179 | imagedatastart = palmimage + 16; |
180 | } else if (bits_per_pixel == 4) { | 180 | } else if (bits_per_pixel == 4) { |
181 | colormap = Palm4BitColormap; | 181 | colormap = Palm4BitColormap; |
182 | imagedatastart = palmimage + 16; | 182 | imagedatastart = palmimage + 16; |
183 | } else if (bits_per_pixel == 8) { | 183 | } else if (bits_per_pixel == 8) { |
184 | colormap = Palm8BitColormap; | 184 | colormap = Palm8BitColormap; |
185 | imagedatastart = palmimage + 16; | 185 | imagedatastart = palmimage + 16; |
186 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { | 186 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { |
187 | colormap = NULL; | 187 | colormap = NULL; |
188 | palm_red_bits = palmimage[16]; | 188 | palm_red_bits = palmimage[16]; |
189 | palm_green_bits = palmimage[17]; | 189 | palm_green_bits = palmimage[17]; |
190 | palm_blue_bits = palmimage[18]; | 190 | palm_blue_bits = palmimage[18]; |
191 | // qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); | 191 | // qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); |
192 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { | 192 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { |
193 | // qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits); | 193 | // qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits); |
194 | return NULL; | 194 | return NULL; |
195 | } | 195 | } |
196 | if (bits_per_pixel > (8 * sizeof(unsigned long))) { | 196 | if (bits_per_pixel > (8 * sizeof(unsigned long))) { |
197 | // qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); | 197 | // qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); |
198 | return NULL; | 198 | return NULL; |
199 | } | 199 | } |
200 | imagedatastart = palmimage + 24; | 200 | imagedatastart = palmimage + 24; |
201 | } else { | 201 | } else { |
202 | // qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); | 202 | // qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); |
203 | return NULL; | 203 | return NULL; |
204 | } | 204 | } |
205 | 205 | ||
206 | #ifndef USEQPE | 206 | #ifndef USEQPE |
207 | QImage* qimage = new QImage(width, height, 32); | 207 | QImage* qimage = new QImage(width, height, 32); |
208 | #else | 208 | #else |
209 | QImage* qimage = new QImage(width, height, 16); | 209 | QImage* qimage = new QImage(width, height, 16); |
210 | #endif | 210 | #endif |
211 | 211 | ||
212 | /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ | 212 | /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ |
213 | rowbuf = new unsigned char[bytes_per_row * width]; | 213 | rowbuf = new unsigned char[bytes_per_row * width]; |
214 | lastrow = new unsigned char[bytes_per_row * width]; | 214 | lastrow = new unsigned char[bytes_per_row * width]; |
215 | 215 | ||
216 | for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) { | 216 | for (i=0, palm_ptr = imagedatastart , x_ptr = 0; i < height; ++i) { |
217 | // qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); | 217 | // qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); |
218 | 218 | ||
219 | /* first, uncompress the Palm image */ | 219 | /* first, uncompress the Palm image */ |
220 | if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { | 220 | if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { |
221 | for (j = 0; j < bytes_per_row; ) { | 221 | for (j = 0; j < bytes_per_row; ) { |
222 | incount = *palm_ptr++; | 222 | incount = *palm_ptr++; |
223 | inval = *palm_ptr++; | 223 | inval = *palm_ptr++; |
224 | memset(rowbuf + j, inval, incount); | 224 | memset(rowbuf + j, inval, incount); |
225 | j += incount; | 225 | j += incount; |
226 | } | 226 | } |
227 | } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { | 227 | } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { |
228 | for (j = 0; j < bytes_per_row; j += 8) { | 228 | for (j = 0; j < bytes_per_row; j += 8) { |
229 | incount = *palm_ptr++; | 229 | incount = *palm_ptr++; |
230 | inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; | 230 | inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; |
231 | for (inbit = 0; inbit < inval; inbit += 1) { | 231 | for (inbit = 0; inbit < inval; inbit += 1) { |
232 | if (incount & (1 << (7 - inbit))) | 232 | if (incount & (1 << (7 - inbit))) |
233 | rowbuf[j + inbit] = *palm_ptr++; | 233 | rowbuf[j + inbit] = *palm_ptr++; |
234 | else | 234 | else |
235 | rowbuf[j + inbit] = lastrow[j + inbit]; | 235 | rowbuf[j + inbit] = lastrow[j + inbit]; |
236 | } | 236 | } |
237 | } | 237 | } |
238 | memcpy (lastrow, rowbuf, bytes_per_row); | 238 | memcpy (lastrow, rowbuf, bytes_per_row); |
239 | } else if (((flags & PALM_IS_COMPRESSED_FLAG) && | 239 | } else if (((flags & PALM_IS_COMPRESSED_FLAG) && |
240 | (compression_type == PALM_COMPRESSION_NONE)) || | 240 | (compression_type == PALM_COMPRESSION_NONE)) || |
241 | ((flags & PALM_IS_COMPRESSED_FLAG) == 0)) | 241 | ((flags & PALM_IS_COMPRESSED_FLAG) == 0)) |
242 | { | 242 | { |
243 | memcpy (rowbuf, palm_ptr, bytes_per_row); | 243 | memcpy (rowbuf, palm_ptr, bytes_per_row); |
244 | palm_ptr += bytes_per_row; | 244 | palm_ptr += bytes_per_row; |
245 | } | 245 | } |
246 | else { | 246 | else { |
247 | qDebug("Case 4"); | 247 | qDebug("Case 4"); |
248 | qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); | 248 | qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); |
249 | qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); | 249 | qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); |
250 | qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); | 250 | qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); |
251 | qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); | 251 | qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); |
252 | qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); | 252 | qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); |
253 | memcpy (rowbuf, palm_ptr, bytes_per_row); | 253 | memcpy (rowbuf, palm_ptr, bytes_per_row); |
254 | palm_ptr += bytes_per_row; | 254 | palm_ptr += bytes_per_row; |
255 | } | 255 | } |
256 | /* next, write it to the GDK bitmap */ | 256 | /* next, write it to the GDK bitmap */ |
257 | if (colormap) { | 257 | if (colormap) { |
258 | mask = (1 << bits_per_pixel) - 1; | 258 | mask = (1 << bits_per_pixel) - 1; |
259 | for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { | 259 | for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { |
260 | inval = ((*inbyte) & (mask << inbit)) >> inbit; | 260 | inval = ((*inbyte) & (mask << inbit)) >> inbit; |
261 | /* correct for oddity of the 8-bit color Palm pixmap... */ | 261 | /* correct for oddity of the 8-bit color Palm pixmap... */ |
262 | if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; | 262 | if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; |
263 | /* now lookup the correct color and set the pixel in the GTK bitmap */ | 263 | /* now lookup the correct color and set the pixel in the GTK bitmap */ |
264 | QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); | 264 | QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); |
265 | qimage->setPixel(j, i, colour); | 265 | qimage->setPixel(j, i, colour); |
266 | if (!inbit) { | 266 | if (!inbit) { |
267 | ++inbyte; | 267 | ++inbyte; |
268 | inbit = 8 - bits_per_pixel; | 268 | inbit = 8 - bits_per_pixel; |
269 | } else { | 269 | } else { |
270 | inbit -= bits_per_pixel; | 270 | inbit -= bits_per_pixel; |
271 | } | 271 | } |
272 | } | 272 | } |
273 | } else if (!colormap && | 273 | } else if (!colormap && |
274 | bits_per_pixel == 16) { | 274 | bits_per_pixel == 16) { |
275 | for (inbyte = rowbuf, j = 0; j < width; ++j) { | 275 | for (inbyte = rowbuf, j = 0; j < width; ++j) { |
276 | inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1]; | 276 | inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1]; |
277 | 277 | ||
278 | /* | 278 | /* |
279 | qDebug ("pixel is %d,%d (%d:%d:%d)", | 279 | qDebug ("pixel is %d,%d (%d:%d:%d)", |
280 | j, i, | 280 | j, i, |
281 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), | 281 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), |
282 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), | 282 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), |
283 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); | 283 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); |
284 | */ | 284 | */ |
285 | QRgb colour = qRgb( | 285 | QRgb colour = qRgb( |
286 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), | 286 | ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), |
287 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), | 287 | ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), |
288 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); | 288 | ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); |
289 | qimage->setPixel(j, i, colour); | 289 | qimage->setPixel(j, i, colour); |
290 | inbyte += 2; | 290 | inbyte += 2; |
291 | } | 291 | } |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | delete [] rowbuf; | 295 | delete [] rowbuf; |
296 | delete [] lastrow; | 296 | delete [] lastrow; |
297 | 297 | ||
298 | return qimage; | 298 | return qimage; |
299 | } | 299 | } |
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index 0c56dd4..75da8ac 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp | |||
@@ -355,385 +355,385 @@ void QTReader::processmousepositionevent( QMouseEvent* _e ) | |||
355 | if (x < wh/3) | 355 | if (x < wh/3) |
356 | { | 356 | { |
357 | goBack(); | 357 | goBack(); |
358 | } | 358 | } |
359 | else if (x > (2*wh)/3) | 359 | else if (x > (2*wh)/3) |
360 | { | 360 | { |
361 | goForward(); | 361 | goForward(); |
362 | } | 362 | } |
363 | else | 363 | else |
364 | { | 364 | { |
365 | goHome(); | 365 | goHome(); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | } | 368 | } |
369 | else | 369 | else |
370 | { | 370 | { |
371 | if (y > ht/2) | 371 | if (y > ht/2) |
372 | { | 372 | { |
373 | goDown(); | 373 | goDown(); |
374 | } | 374 | } |
375 | else | 375 | else |
376 | { | 376 | { |
377 | goUp(); | 377 | goUp(); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | } | 380 | } |
381 | 381 | ||
382 | void QTReader::goHome() | 382 | void QTReader::goHome() |
383 | { | 383 | { |
384 | if (buffdoc.hasnavigation()) | 384 | if (buffdoc.hasnavigation()) |
385 | { | 385 | { |
386 | size_t current=pagelocate(); | 386 | size_t current=pagelocate(); |
387 | size_t home=buffdoc.getHome(); | 387 | size_t home=buffdoc.getHome(); |
388 | if (current!=home) | 388 | if (current!=home) |
389 | { | 389 | { |
390 | buffdoc.saveposn(m_lastfile, current); | 390 | buffdoc.saveposn(m_lastfile, current); |
391 | locate(home); | 391 | locate(home); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | else | 394 | else |
395 | locate(0); | 395 | locate(0); |
396 | } | 396 | } |
397 | 397 | ||
398 | void QTReader::goBack() | 398 | void QTReader::goBack() |
399 | { | 399 | { |
400 | if (buffdoc.hasnavigation()) | 400 | if (buffdoc.hasnavigation()) |
401 | { | 401 | { |
402 | size_t target = pagelocate(); | 402 | size_t target = pagelocate(); |
403 | QString nxt = m_lastfile; | 403 | QString nxt = m_lastfile; |
404 | buffdoc.writeposn(m_lastfile, target); | 404 | buffdoc.writeposn(m_lastfile, target); |
405 | linkType lt = buffdoc.back(nxt, target); | 405 | linkType lt = buffdoc.back(nxt, target); |
406 | if ((lt & eFile) != 0) | 406 | if ((lt & eFile) != 0) |
407 | { | 407 | { |
408 | if (nxt != m_lastfile) | 408 | if (nxt != m_lastfile) |
409 | { | 409 | { |
410 | emit NewFileRequest(nxt); | 410 | emit NewFileRequest(nxt); |
411 | } | 411 | } |
412 | locate(target); | 412 | locate(target); |
413 | } | 413 | } |
414 | else if ((lt & eLink) != 0) | 414 | else if ((lt & eLink) != 0) |
415 | { | 415 | { |
416 | locate(target); | 416 | locate(target); |
417 | } | 417 | } |
418 | } | 418 | } |
419 | } | 419 | } |
420 | 420 | ||
421 | void QTReader::goForward() | 421 | void QTReader::goForward() |
422 | { | 422 | { |
423 | if (buffdoc.hasnavigation()) | 423 | if (buffdoc.hasnavigation()) |
424 | { | 424 | { |
425 | size_t target = pagelocate(); | 425 | size_t target = pagelocate(); |
426 | QString nxt = m_lastfile; | 426 | QString nxt = m_lastfile; |
427 | linkType lt = buffdoc.forward(nxt, target); | 427 | linkType lt = buffdoc.forward(nxt, target); |
428 | if ((lt & eFile) != 0) | 428 | if ((lt & eFile) != 0) |
429 | { | 429 | { |
430 | if (nxt != m_lastfile) | 430 | if (nxt != m_lastfile) |
431 | { | 431 | { |
432 | emit NewFileRequest(nxt); | 432 | emit NewFileRequest(nxt); |
433 | } | 433 | } |
434 | locate(target); | 434 | locate(target); |
435 | } | 435 | } |
436 | else if ((lt & eLink) != 0) | 436 | else if ((lt & eLink) != 0) |
437 | { | 437 | { |
438 | locate(target); | 438 | locate(target); |
439 | } | 439 | } |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img, size_t& tabtgt) | 443 | linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img, size_t& tabtgt) |
444 | { | 444 | { |
445 | int ht; | 445 | int ht; |
446 | if (m_scrolldy == m_topmargin) | 446 | if (m_scrolldy == m_topmargin) |
447 | { | 447 | { |
448 | lineno = 0; | 448 | lineno = 0; |
449 | ht = textarray[0]->lineSpacing()-m_scrolldy1 + m_topmargin; | 449 | ht = textarray[0]->lineSpacing()-m_scrolldy1 + m_topmargin; |
450 | } | 450 | } |
451 | else | 451 | else |
452 | { | 452 | { |
453 | if (y >= m_scrolldy) | 453 | if (y >= m_scrolldy) |
454 | { | 454 | { |
455 | lineno = 0; | 455 | lineno = 0; |
456 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy + m_topmargin; | 456 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy + m_topmargin; |
457 | } | 457 | } |
458 | else | 458 | else |
459 | { | 459 | { |
460 | lineno = 0; | 460 | lineno = 0; |
461 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy+m_topmargin; | 461 | ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy+m_topmargin; |
462 | while ((ht < h) && (lineno < numlines-1)) | 462 | while ((ht < h) && (lineno < numlines-1)) |
463 | { | 463 | { |
464 | ht += textarray[++lineno]->lineSpacing(); | 464 | ht += textarray[++lineno]->lineSpacing(); |
465 | } | 465 | } |
466 | ht = textarray[lineno]->lineSpacing(); | 466 | ht = textarray[lineno]->lineSpacing(); |
467 | } | 467 | } |
468 | } | 468 | } |
469 | while ((ht < y) && (lineno < numlines-1)) | 469 | while ((ht < y) && (lineno < numlines-1)) |
470 | { | 470 | { |
471 | ht += textarray[++lineno]->lineSpacing(); | 471 | ht += textarray[++lineno]->lineSpacing(); |
472 | } | 472 | } |
473 | if (ht < y && textarray[numlines]->showPartial()) lineno = numlines; | 473 | if (ht < y && textarray[numlines]->showPartial()) lineno = numlines; |
474 | start = locnarray[lineno]; | 474 | start = locnarray[lineno]; |
475 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 475 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
476 | if (m_bMonoSpaced) | 476 | if (m_bMonoSpaced) |
477 | { | 477 | { |
478 | offset = (x - textarray[lineno]->offset(w, m_left_border, m_right_border, availht))/m_charWidth; | 478 | offset = (x - textarray[lineno]->offset(w, m_left_border, m_right_border, availht))/m_charWidth; |
479 | } | 479 | } |
480 | else | 480 | else |
481 | { | 481 | { |
482 | int i; | 482 | int i; |
483 | CDrawBuffer* t = textarray[lineno]; | 483 | CDrawBuffer* t = textarray[lineno]; |
484 | x = x - t->offset(width(), m_left_border, m_right_border, availht); | 484 | x = x - t->offset(width(), m_left_border, m_right_border, availht); |
485 | for (i = t->length(); i > 0 && t->width(availht, i, true, w, m_left_border, m_right_border) > x; i--); | 485 | for (i = t->length(); i > 0 && t->width(availht, i, true, w, m_left_border, m_right_border) > x; i--); |
486 | offset = i; | 486 | offset = i; |
487 | } | 487 | } |
488 | return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img, tabtgt); | 488 | return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img, tabtgt); |
489 | } | 489 | } |
490 | 490 | ||
491 | void QTReader::suspend() | 491 | void QTReader::suspend() |
492 | { | 492 | { |
493 | buffdoc.suspend(); | 493 | buffdoc.suspend(); |
494 | /*#ifdef OPIE | 494 | /*#ifdef OPIE |
495 | if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); | 495 | if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); |
496 | #else | 496 | #else |
497 | if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); | 497 | if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); |
498 | #endif | 498 | #endif |
499 | */ | 499 | */ |
500 | } | 500 | } |
501 | 501 | ||
502 | void QTReader::setDoubleBuffer(bool _b) | 502 | void QTReader::setDoubleBuffer(bool _b) |
503 | { | 503 | { |
504 | m_doubleBuffered = _b; | 504 | m_doubleBuffered = _b; |
505 | if (_b || m_rotated) | 505 | if (_b || m_rotated) |
506 | { | 506 | { |
507 | if (dbuff == NULL) | 507 | if (dbuff == NULL) |
508 | { | 508 | { |
509 | dbuff = new QPixmap(); | 509 | dbuff = new QPixmap(); |
510 | dbp = new QPainter(); | 510 | dbp = new QPainter(); |
511 | } | 511 | } |
512 | if (m_rotated) | 512 | if (m_rotated) |
513 | { | 513 | { |
514 | dbuff->resize(height(), width()); | 514 | dbuff->resize(height(), width()); |
515 | } | 515 | } |
516 | else | 516 | else |
517 | { | 517 | { |
518 | dbuff->resize(width(), height()); | 518 | dbuff->resize(width(), height()); |
519 | } | 519 | } |
520 | m_outofdate = true; | 520 | m_outofdate = true; |
521 | } | 521 | } |
522 | else | 522 | else |
523 | { | 523 | { |
524 | if (dbuff != NULL) | 524 | if (dbuff != NULL) |
525 | { | 525 | { |
526 | delete dbuff; | 526 | delete dbuff; |
527 | delete dbp; | 527 | delete dbp; |
528 | } | 528 | } |
529 | dbuff = NULL; | 529 | dbuff = NULL; |
530 | dbp = NULL; | 530 | dbp = NULL; |
531 | } | 531 | } |
532 | } | 532 | } |
533 | 533 | ||
534 | void QTReader::setTwoTouch(bool _b) | 534 | void QTReader::setTwoTouch(bool _b) |
535 | { | 535 | { |
536 | setBackgroundColor( m_bg ); | 536 | setBackgroundColor( m_bg ); |
537 | m_twotouch = m_touchone = _b; | 537 | m_twotouch = m_touchone = _b; |
538 | } | 538 | } |
539 | 539 | ||
540 | void QTReader::setContinuous(bool _b) | 540 | void QTReader::setContinuous(bool _b) |
541 | { | 541 | { |
542 | buffdoc.setContinuous(m_continuousDocument = _b); | 542 | buffdoc.setContinuous(m_continuousDocument = _b); |
543 | } | 543 | } |
544 | 544 | ||
545 | void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) | 545 | void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) |
546 | { | 546 | { |
547 | unsigned long wrdstart, wrdend; | 547 | unsigned long wrdstart = 0, wrdend = 0; |
548 | QString wrd; | 548 | QString wrd; |
549 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 549 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
550 | if (m_twotouch) | 550 | if (m_twotouch) |
551 | { | 551 | { |
552 | if (m_touchone) | 552 | if (m_touchone) |
553 | { | 553 | { |
554 | m_touchone = false; | 554 | m_touchone = false; |
555 | m_startpos = startpos; | 555 | m_startpos = startpos; |
556 | m_startoffset = startoffset; | 556 | m_startoffset = startoffset; |
557 | setBackgroundColor( lightGray ); | 557 | setBackgroundColor( lightGray ); |
558 | } | 558 | } |
559 | else | 559 | else |
560 | { | 560 | { |
561 | m_touchone = true; | 561 | m_touchone = true; |
562 | setBackgroundColor( m_bg ); | 562 | setBackgroundColor( m_bg ); |
563 | size_t endpos, endoffset; | 563 | size_t endpos, endoffset; |
564 | endpos = startpos; | 564 | endpos = startpos; |
565 | endoffset = startoffset; | 565 | endoffset = startoffset; |
566 | size_t currentpos = locate(); | 566 | size_t currentpos = locate(); |
567 | if (endpos >= m_startpos) | 567 | if (endpos >= m_startpos) |
568 | { | 568 | { |
569 | jumpto(m_startpos); | 569 | jumpto(m_startpos); |
570 | for (int i = 0; i < m_startoffset; i++) | 570 | for (int i = 0; i < m_startoffset; i++) |
571 | { | 571 | { |
572 | getch(); | 572 | getch(); |
573 | } | 573 | } |
574 | wrdstart = buffdoc.explocate(); | 574 | wrdstart = buffdoc.explocate(); |
575 | if (m_startpos == endpos) | 575 | if (m_startpos == endpos) |
576 | { | 576 | { |
577 | for (int i = m_startoffset; i <= endoffset; i++) | 577 | for (int i = m_startoffset; i <= endoffset; i++) |
578 | { | 578 | { |
579 | wrd += QChar(getch()); | 579 | wrd += QChar(getch()); |
580 | } | 580 | } |
581 | } | 581 | } |
582 | else | 582 | else |
583 | { | 583 | { |
584 | while (buffdoc.explocate() <= endpos) | 584 | while (buffdoc.explocate() <= endpos) |
585 | { | 585 | { |
586 | wrd += QChar(getch()); | 586 | wrd += QChar(getch()); |
587 | } | 587 | } |
588 | for (int i = 0; i < endoffset; i++) | 588 | for (int i = 0; i < endoffset; i++) |
589 | { | 589 | { |
590 | wrd += QChar(getch()); | 590 | wrd += QChar(getch()); |
591 | } | 591 | } |
592 | } | 592 | } |
593 | wrdend = buffdoc.explocate(); | 593 | wrdend = buffdoc.explocate(); |
594 | jumpto(currentpos); | 594 | jumpto(currentpos); |
595 | } | 595 | } |
596 | } | 596 | } |
597 | } | 597 | } |
598 | else if (m_bMonoSpaced) | 598 | else if (m_bMonoSpaced) |
599 | { | 599 | { |
600 | int chno = (m_rotated) ? | 600 | int chno = (m_rotated) ? |
601 | (_e->y()-textarray[lineno]->offset(height(), m_left_border, m_right_border, availht))/m_charWidth | 601 | (_e->y()-textarray[lineno]->offset(height(), m_left_border, m_right_border, availht))/m_charWidth |
602 | : | 602 | : |
603 | (_e->x()-textarray[lineno]->offset(width(), m_left_border, m_right_border, availht))/m_charWidth; | 603 | (_e->x()-textarray[lineno]->offset(width(), m_left_border, m_right_border, availht))/m_charWidth; |
604 | if (chno < ustrlen(textarray[lineno]->data())) | 604 | if (chno < ustrlen(textarray[lineno]->data())) |
605 | { | 605 | { |
606 | wrd[0] = textarray[lineno]->data()[chno]; | 606 | wrd[0] = textarray[lineno]->data()[chno]; |
607 | } | 607 | } |
608 | } | 608 | } |
609 | else | 609 | else |
610 | { | 610 | { |
611 | CDrawBuffer* t = textarray[lineno]; | 611 | CDrawBuffer* t = textarray[lineno]; |
612 | int first = 0; | 612 | int first = 0; |
613 | int tgt = (m_rotated) ? | 613 | int tgt = (m_rotated) ? |
614 | _e->y() - t->offset(height(), m_left_border, m_right_border, availht) : | 614 | _e->y() - t->offset(height(), m_left_border, m_right_border, availht) : |
615 | _e->x() - t->offset(width(), m_left_border, m_right_border, availht); | 615 | _e->x() - t->offset(width(), m_left_border, m_right_border, availht); |
616 | while (1) | 616 | while (1) |
617 | { | 617 | { |
618 | int i = first+1; | 618 | int i = first+1; |
619 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; | 619 | int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; |
620 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 620 | while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
621 | if (t->width(availht, i, true, (m_rotated) ? height() : width(), m_left_border, m_right_border) > tgt) | 621 | if (t->width(availht, i, true, (m_rotated) ? height() : width(), m_left_border, m_right_border) > tgt) |
622 | { | 622 | { |
623 | wrd = toQString(t->data()+first, i - first); | 623 | wrd = toQString(t->data()+first, i - first); |
624 | // qDebug("Got %s", (const char *)wrd); | 624 | // qDebug("Got %s", (const char *)wrd); |
625 | break; | 625 | break; |
626 | } | 626 | } |
627 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; | 627 | while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; |
628 | if ((*t)[i] == 0) break; | 628 | if ((*t)[i] == 0) break; |
629 | first = i; | 629 | first = i; |
630 | } | 630 | } |
631 | } | 631 | } |
632 | if (!wrd.isEmpty()) | 632 | if (!wrd.isEmpty()) |
633 | { | 633 | { |
634 | qDebug("Selected:%s", (const char*)wrd); | 634 | qDebug("Selected:%s", (const char*)wrd); |
635 | if (m_twotouch) | 635 | if (m_twotouch) |
636 | { | 636 | { |
637 | emit OnWordSelected(wrd, wrdstart, wrdend, wrd); | 637 | emit OnWordSelected(wrd, wrdstart, wrdend, wrd); |
638 | } | 638 | } |
639 | else | 639 | else |
640 | { | 640 | { |
641 | QString line = toQString(textarray[lineno]->data()); | 641 | QString line = toQString(textarray[lineno]->data()); |
642 | emit OnWordSelected(wrd, locnarray[lineno], locnarray[lineno]+line.length(), line); | 642 | emit OnWordSelected(wrd, locnarray[lineno], locnarray[lineno]+line.length(), line); |
643 | } | 643 | } |
644 | } | 644 | } |
645 | } | 645 | } |
646 | 646 | ||
647 | #ifdef USETIMER | 647 | #ifdef USETIMER |
648 | void QTReader::actionDrag() | 648 | void QTReader::actionDrag() |
649 | { | 649 | { |
650 | if (m_drageligible) | 650 | if (m_drageligible) |
651 | { | 651 | { |
652 | int fivepages = 5*((2*width()+m_textsize/2)/m_textsize)*((height()+m_textsize/2)/m_textsize); | 652 | int fivepages = 5*((2*width()+m_textsize/2)/m_textsize)*((height()+m_textsize/2)/m_textsize); |
653 | if (m_dragtarget > fivepages && locnarray[numlines] < m_dragtarget - fivepages) | 653 | if (m_dragtarget > fivepages && locnarray[numlines] < m_dragtarget - fivepages) |
654 | { | 654 | { |
655 | int tgt = m_dragtarget - fivepages/2; | 655 | int tgt = m_dragtarget - fivepages/2; |
656 | //qDebug("Jumping to %u (%u)", tgt, fivepages); | 656 | //qDebug("Jumping to %u (%u)", tgt, fivepages); |
657 | if (tgt < buffdoc.startSection()) | 657 | if (tgt < buffdoc.startSection()) |
658 | { | 658 | { |
659 | tgt = buffdoc.startSection(); | 659 | tgt = buffdoc.startSection(); |
660 | } | 660 | } |
661 | locate(tgt); | 661 | locate(tgt); |
662 | drawFonts(); | 662 | drawFonts(); |
663 | } | 663 | } |
664 | else if (locnarray[0] > m_dragtarget+fivepages) | 664 | else if (locnarray[0] > m_dragtarget+fivepages) |
665 | { | 665 | { |
666 | int tgt = m_dragtarget + fivepages/2; | 666 | int tgt = m_dragtarget + fivepages/2; |
667 | //qDebug("Jumping to %u (%u)", tgt, fivepages); | 667 | //qDebug("Jumping to %u (%u)", tgt, fivepages); |
668 | if (tgt > buffdoc.endSection()) | 668 | if (tgt > buffdoc.endSection()) |
669 | { | 669 | { |
670 | dopageup(); | 670 | dopageup(); |
671 | } | 671 | } |
672 | else | 672 | else |
673 | { | 673 | { |
674 | locate(tgt); | 674 | locate(tgt); |
675 | drawFonts(); | 675 | drawFonts(); |
676 | } | 676 | } |
677 | } | 677 | } |
678 | else if (locnarray[numlines] <= m_dragtarget) | 678 | else if (locnarray[numlines] <= m_dragtarget) |
679 | { | 679 | { |
680 | dopagedn(); | 680 | dopagedn(); |
681 | } | 681 | } |
682 | else if (locnarray[0] > m_dragtarget) | 682 | else if (locnarray[0] > m_dragtarget) |
683 | { | 683 | { |
684 | dopageup(); | 684 | dopageup(); |
685 | } | 685 | } |
686 | } | 686 | } |
687 | else | 687 | else |
688 | { | 688 | { |
689 | m_dragtimer->stop(); | 689 | m_dragtimer->stop(); |
690 | } | 690 | } |
691 | } | 691 | } |
692 | #endif | 692 | #endif |
693 | 693 | ||
694 | void QTReader::mouseMoveEvent( QMouseEvent* _e ) | 694 | void QTReader::mouseMoveEvent( QMouseEvent* _e ) |
695 | { | 695 | { |
696 | if (m_drageligible) | 696 | if (m_drageligible) |
697 | { | 697 | { |
698 | int ht; | 698 | int ht; |
699 | int mp; | 699 | int mp; |
700 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); | 700 | int sectionsize = (buffdoc.endSection()-buffdoc.startSection()); |
701 | //qDebug("Mouse moved to (%u, %u)", _e->x(), _e->y()); | 701 | //qDebug("Mouse moved to (%u, %u)", _e->x(), _e->y()); |
702 | switch (m_scrollpos) | 702 | switch (m_scrollpos) |
703 | { | 703 | { |
704 | case 1: | 704 | case 1: |
705 | { | 705 | { |
706 | if (m_rotated) | 706 | if (m_rotated) |
707 | { | 707 | { |
708 | ht = height(); | 708 | ht = height(); |
709 | mp = _e->y(); | 709 | mp = _e->y(); |
710 | } | 710 | } |
711 | else | 711 | else |
712 | { | 712 | { |
713 | ht = width(); | 713 | ht = width(); |
714 | mp = _e->x(); | 714 | mp = _e->x(); |
715 | } | 715 | } |
716 | } | 716 | } |
717 | break; | 717 | break; |
718 | case 2: | 718 | case 2: |
719 | case 3: | 719 | case 3: |
720 | { | 720 | { |
721 | if (m_rotated) | 721 | if (m_rotated) |
722 | { | 722 | { |
723 | ht = width(); | 723 | ht = width(); |
724 | mp = width()-_e->x(); | 724 | mp = width()-_e->x(); |
725 | } | 725 | } |
726 | else | 726 | else |
727 | { | 727 | { |
728 | ht = height(); | 728 | ht = height(); |
729 | mp = _e->y(); | 729 | mp = _e->y(); |
730 | } | 730 | } |
731 | } | 731 | } |
732 | break; | 732 | break; |
733 | case 0: | 733 | case 0: |
734 | default: | 734 | default: |
735 | ht = -1; | 735 | ht = -1; |
736 | break; | 736 | break; |
737 | } | 737 | } |
738 | if (ht >= 0) | 738 | if (ht >= 0) |
739 | { | 739 | { |
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp index 849edfc..302ac73 100644 --- a/noncore/apps/opie-reader/plucker_base.cpp +++ b/noncore/apps/opie-reader/plucker_base.cpp | |||
@@ -516,385 +516,385 @@ void CPlucker_base::home() | |||
516 | CList<Bkmk>* CPlucker_base::getbkmklist() | 516 | CList<Bkmk>* CPlucker_base::getbkmklist() |
517 | { | 517 | { |
518 | /* | 518 | /* |
519 | UInt16 thishdr_uid, thishdr_nParagraphs; | 519 | UInt16 thishdr_uid, thishdr_nParagraphs; |
520 | UInt32 thishdr_size; | 520 | UInt32 thishdr_size; |
521 | UInt8 thishdr_type, thishdr_reserved; | 521 | UInt8 thishdr_type, thishdr_reserved; |
522 | 522 | ||
523 | for (int i = 1; i < ntohs(head.recordList.numRecords); i++) | 523 | for (int i = 1; i < ntohs(head.recordList.numRecords); i++) |
524 | { | 524 | { |
525 | gotorecordnumber(i); | 525 | gotorecordnumber(i); |
526 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 526 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
527 | if (thishdr_type == 8) | 527 | if (thishdr_type == 8) |
528 | { | 528 | { |
529 | UInt16 n; | 529 | UInt16 n; |
530 | fread(&n, 1, sizeof(n), fin); | 530 | fread(&n, 1, sizeof(n), fin); |
531 | n = ntohs(n); | 531 | n = ntohs(n); |
532 | //qDebug("Found %u bookmarks", n); | 532 | //qDebug("Found %u bookmarks", n); |
533 | } | 533 | } |
534 | //qDebug("Found:%d, %u", i , thishdr_type); | 534 | //qDebug("Found:%d, %u", i , thishdr_type); |
535 | } | 535 | } |
536 | */ | 536 | */ |
537 | return NULL; | 537 | return NULL; |
538 | } | 538 | } |
539 | 539 | ||
540 | #include <qnamespace.h> | 540 | #include <qnamespace.h> |
541 | 541 | ||
542 | QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) | 542 | QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) |
543 | { | 543 | { |
544 | QImage* qimage = getimg(tgt); | 544 | QImage* qimage = getimg(tgt); |
545 | QImage* ret; | 545 | QImage* ret; |
546 | if (qimage == NULL) return NULL; | 546 | if (qimage == NULL) return NULL; |
547 | if (border) | 547 | if (border) |
548 | { | 548 | { |
549 | QPixmap* image = new QPixmap(0,0); | 549 | QPixmap* image = new QPixmap(0,0); |
550 | image->convertFromImage(*qimage); | 550 | image->convertFromImage(*qimage); |
551 | delete qimage; | 551 | delete qimage; |
552 | QPixmap* pret = new QPixmap(image->width()+4, image->height()+4); | 552 | QPixmap* pret = new QPixmap(image->width()+4, image->height()+4); |
553 | pret->fill(Qt::red); | 553 | pret->fill(Qt::red); |
554 | bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); | 554 | bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); |
555 | delete image; | 555 | delete image; |
556 | ret = new QImage(pret->convertToImage()); | 556 | ret = new QImage(pret->convertToImage()); |
557 | } | 557 | } |
558 | else | 558 | else |
559 | { | 559 | { |
560 | ret = qimage; | 560 | ret = qimage; |
561 | } | 561 | } |
562 | return ret; | 562 | return ret; |
563 | } | 563 | } |
564 | 564 | ||
565 | #ifdef _BUFFERPICS | 565 | #ifdef _BUFFERPICS |
566 | #include <qmap.h> | 566 | #include <qmap.h> |
567 | #endif | 567 | #endif |
568 | 568 | ||
569 | QImage* CPlucker_base::getPicture(unsigned long tgt) | 569 | QImage* CPlucker_base::getPicture(unsigned long tgt) |
570 | { | 570 | { |
571 | #ifdef _BUFFERPICS | 571 | #ifdef _BUFFERPICS |
572 | static QMap<unsigned long, QPixmap> pix; | 572 | static QMap<unsigned long, QPixmap> pix; |
573 | QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); | 573 | QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); |
574 | if (t == pix.end()) | 574 | if (t == pix.end()) |
575 | { | 575 | { |
576 | pix[tgt] = *expandimg(tgt); | 576 | pix[tgt] = *expandimg(tgt); |
577 | return &pix[tgt]; | 577 | return &pix[tgt]; |
578 | } | 578 | } |
579 | else | 579 | else |
580 | return &(t.data()); | 580 | return &(t.data()); |
581 | #else | 581 | #else |
582 | return expandimg(tgt >> 16); | 582 | return expandimg(tgt >> 16); |
583 | #endif | 583 | #endif |
584 | } | 584 | } |
585 | 585 | ||
586 | #ifdef LOCALPICTURES | 586 | #ifdef LOCALPICTURES |
587 | #include <unistd.h> | 587 | #include <unistd.h> |
588 | #include <qpe/global.h> | 588 | #include <qpe/global.h> |
589 | void CPlucker_base::showimg(UInt16 tgt) | 589 | void CPlucker_base::showimg(UInt16 tgt) |
590 | { | 590 | { |
591 | //qDebug("Crassssssh!"); | 591 | //qDebug("Crassssssh!"); |
592 | QPixmap* qimage = expandimg(tgt); | 592 | QPixmap* qimage = expandimg(tgt); |
593 | m_picture->setFixedSize(qimage->size()); | 593 | m_picture->setFixedSize(qimage->size()); |
594 | m_picture->setBackgroundPixmap(*qimage); | 594 | m_picture->setBackgroundPixmap(*qimage); |
595 | delete qimage; | 595 | delete qimage; |
596 | m_viewer->show(); | 596 | m_viewer->show(); |
597 | 597 | ||
598 | /* | 598 | /* |
599 | char tmp[] = "uqtreader.XXXXXX"; | 599 | char tmp[] = "uqtreader.XXXXXX"; |
600 | QImage* qimage = getimg(tgt); | 600 | QImage* qimage = getimg(tgt); |
601 | QPixmap* image = new QPixmap(0,0); | 601 | QPixmap* image = new QPixmap(0,0); |
602 | // //qDebug("New image"); | 602 | // //qDebug("New image"); |
603 | image->convertFromImage(*qimage); | 603 | image->convertFromImage(*qimage); |
604 | delete qimage; | 604 | delete qimage; |
605 | char tmpfile[sizeof(tmp)+1]; | 605 | char tmpfile[sizeof(tmp)+1]; |
606 | strcpy(tmpfile,tmp); | 606 | strcpy(tmpfile,tmp); |
607 | int f = mkstemp(tmpfile); | 607 | int f = mkstemp(tmpfile); |
608 | close(f); | 608 | close(f); |
609 | //qDebug("TMPFILE:%s", tmpfile); | 609 | //qDebug("TMPFILE:%s", tmpfile); |
610 | if (image->save(tmpfile,"PNG")) | 610 | if (image->save(tmpfile,"PNG")) |
611 | { | 611 | { |
612 | QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); | 612 | QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); |
613 | e << QString(tmpfile); | 613 | e << QString(tmpfile); |
614 | } | 614 | } |
615 | Global::statusMessage("Opening image"); | 615 | Global::statusMessage("Opening image"); |
616 | sleep(5); | 616 | sleep(5); |
617 | delete image; | 617 | delete image; |
618 | unlink(tmpfile); | 618 | unlink(tmpfile); |
619 | */ | 619 | */ |
620 | } | 620 | } |
621 | 621 | ||
622 | #endif | 622 | #endif |
623 | 623 | ||
624 | unsigned short CPlucker_base::finduid(unsigned short urlid) | 624 | unsigned short CPlucker_base::finduid(unsigned short urlid) |
625 | { | 625 | { |
626 | // //qDebug("Finding %u", urlid); | 626 | // //qDebug("Finding %u", urlid); |
627 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); | 627 | unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); |
628 | unsigned short jmid = (jmin+jmax) >> 1; | 628 | unsigned short jmid = (jmin+jmax) >> 1; |
629 | while (jmax - jmin > 1) | 629 | while (jmax - jmin > 1) |
630 | { | 630 | { |
631 | gotorecordnumber(jmid); | 631 | gotorecordnumber(jmid); |
632 | UInt16 thishdr_uid, thishdr_nParagraphs; | 632 | UInt16 thishdr_uid, thishdr_nParagraphs; |
633 | UInt32 thishdr_size; | 633 | UInt32 thishdr_size; |
634 | UInt8 thishdr_type, thishdr_reserved; | 634 | UInt8 thishdr_type, thishdr_reserved; |
635 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 635 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
636 | unsigned short luid = thishdr_uid; | 636 | unsigned short luid = thishdr_uid; |
637 | ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); | 637 | ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); |
638 | if (luid == urlid) | 638 | if (luid == urlid) |
639 | { | 639 | { |
640 | return jmid; | 640 | return jmid; |
641 | } | 641 | } |
642 | if (luid < urlid) | 642 | if (luid < urlid) |
643 | { | 643 | { |
644 | jmin = jmid; | 644 | jmin = jmid; |
645 | } | 645 | } |
646 | else | 646 | else |
647 | { | 647 | { |
648 | jmax = jmid; | 648 | jmax = jmid; |
649 | } | 649 | } |
650 | jmid = (jmin+jmax) >> 1; | 650 | jmid = (jmin+jmax) >> 1; |
651 | } | 651 | } |
652 | gotorecordnumber(jmin); | 652 | gotorecordnumber(jmin); |
653 | UInt16 thishdr_uid, thishdr_nParagraphs; | 653 | UInt16 thishdr_uid, thishdr_nParagraphs; |
654 | UInt32 thishdr_size; | 654 | UInt32 thishdr_size; |
655 | UInt8 thishdr_type, thishdr_reserved; | 655 | UInt8 thishdr_type, thishdr_reserved; |
656 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 656 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
657 | unsigned short luid = thishdr_uid; | 657 | unsigned short luid = thishdr_uid; |
658 | //qDebug("jmin at end:%u,%u", jmin, luid); | 658 | //qDebug("jmin at end:%u,%u", jmin, luid); |
659 | if (luid == urlid) | 659 | if (luid == urlid) |
660 | { | 660 | { |
661 | return jmin; | 661 | return jmin; |
662 | } | 662 | } |
663 | gotorecordnumber(jmax); | 663 | gotorecordnumber(jmax); |
664 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 664 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
665 | luid = thishdr_uid; | 665 | luid = thishdr_uid; |
666 | //qDebug("jmax at end:%u,%u", jmax, luid); | 666 | //qDebug("jmax at end:%u,%u", jmax, luid); |
667 | if (luid == urlid) | 667 | if (luid == urlid) |
668 | { | 668 | { |
669 | return jmax; | 669 | return jmax; |
670 | } | 670 | } |
671 | //qDebug("Couldn't find %u", urlid); | 671 | //qDebug("Couldn't find %u", urlid); |
672 | return 0; // Not found! | 672 | return 0; // Not found! |
673 | } | 673 | } |
674 | 674 | ||
675 | #include <qnamespace.h> | 675 | #include <qnamespace.h> |
676 | 676 | ||
677 | void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 677 | void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
678 | { | 678 | { |
679 | unsigned short sz = 0; | 679 | unsigned short sz = 0; |
680 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 680 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
681 | { | 681 | { |
682 | sz++; | 682 | sz++; |
683 | } | 683 | } |
684 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); | 684 | size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); |
685 | unsigned char* newdata = new unsigned char[newlen]; | 685 | unsigned char* newdata = new unsigned char[newlen]; |
686 | unsigned char* pdata = newdata; | 686 | unsigned char* pdata = newdata; |
687 | memcpy(newdata, src, srclen); | 687 | memcpy(newdata, src, srclen); |
688 | newdata += srclen; | 688 | newdata += srclen; |
689 | memcpy(newdata, &sz, sizeof(sz)); | 689 | memcpy(newdata, &sz, sizeof(sz)); |
690 | newdata += sizeof(sz); | 690 | newdata += sizeof(sz); |
691 | #ifdef _WINDOWS | 691 | #ifdef _WINDOWS |
692 | for (it = visited.begin(); it != visited.end(); it++) | 692 | for (it = visited.begin(); it != visited.end(); it++) |
693 | #else | 693 | #else |
694 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) | 694 | for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) |
695 | #endif | 695 | #endif |
696 | { | 696 | { |
697 | unsigned long t = *it; | 697 | unsigned long t = *it; |
698 | //qDebug("[%u]", t); | 698 | //qDebug("[%u]", t); |
699 | memcpy(newdata, &t, sizeof(t)); | 699 | memcpy(newdata, &t, sizeof(t)); |
700 | newdata += sizeof(t); | 700 | newdata += sizeof(t); |
701 | } | 701 | } |
702 | m_nav.setSaveData(data, len, pdata, newlen); | 702 | m_nav.setSaveData(data, len, pdata, newlen); |
703 | delete [] pdata; | 703 | delete [] pdata; |
704 | } | 704 | } |
705 | 705 | ||
706 | void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) | 706 | void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) |
707 | { | 707 | { |
708 | unsigned short sz; | 708 | unsigned short sz = 0; |
709 | if (srclen >= sizeof(sz)) | 709 | if (srclen >= sizeof(sz)) |
710 | { | 710 | { |
711 | memcpy(&sz, src, sizeof(sz)); | 711 | memcpy(&sz, src, sizeof(sz)); |
712 | src += sizeof(sz); | 712 | src += sizeof(sz); |
713 | srclen -= sizeof(sz); | 713 | srclen -= sizeof(sz); |
714 | } | 714 | } |
715 | for (int i = 0; i < sz; i++) | 715 | for (int i = 0; i < sz; i++) |
716 | { | 716 | { |
717 | unsigned long t; | 717 | unsigned long t; |
718 | if (srclen >= sizeof(t)) | 718 | if (srclen >= sizeof(t)) |
719 | { | 719 | { |
720 | memcpy(&t, src, sizeof(t)); | 720 | memcpy(&t, src, sizeof(t)); |
721 | // qDebug("[%u]", t); | 721 | // qDebug("[%u]", t); |
722 | visited.push_front(t); | 722 | visited.push_front(t); |
723 | src += sizeof(t); | 723 | src += sizeof(t); |
724 | srclen -= sizeof(t); | 724 | srclen -= sizeof(t); |
725 | } | 725 | } |
726 | else | 726 | else |
727 | { | 727 | { |
728 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); | 728 | QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); |
729 | break; | 729 | break; |
730 | } | 730 | } |
731 | } | 731 | } |
732 | m_nav.putSaveData(src, srclen); | 732 | m_nav.putSaveData(src, srclen); |
733 | } | 733 | } |
734 | 734 | ||
735 | int CPlucker_base::OpenFile(const char *src) | 735 | int CPlucker_base::OpenFile(const char *src) |
736 | { | 736 | { |
737 | qDebug("plucker openfile:%s", src); | 737 | qDebug("plucker openfile:%s", src); |
738 | m_lastBreak = 0; | 738 | m_lastBreak = 0; |
739 | if (!Cpdb::openpdbfile(src)) | 739 | if (!Cpdb::openpdbfile(src)) |
740 | { | 740 | { |
741 | return -1; | 741 | return -1; |
742 | } | 742 | } |
743 | 743 | ||
744 | if (!CorrectDecoder()) return -1; | 744 | if (!CorrectDecoder()) return -1; |
745 | 745 | ||
746 | gotorecordnumber(0); | 746 | gotorecordnumber(0); |
747 | fread(&hdr0, 1, 6, fin); | 747 | fread(&hdr0, 1, 6, fin); |
748 | qDebug("Compression type:%u", ntohs(hdr0.version)); | 748 | qDebug("Compression type:%u", ntohs(hdr0.version)); |
749 | 749 | ||
750 | 750 | ||
751 | switch (ntohs(hdr0.version)) | 751 | switch (ntohs(hdr0.version)) |
752 | { | 752 | { |
753 | case 2: | 753 | case 2: |
754 | m_decompress = UnZip; | 754 | m_decompress = UnZip; |
755 | break; | 755 | break; |
756 | case 1: | 756 | case 1: |
757 | m_decompress = UnDoc; | 757 | m_decompress = UnDoc; |
758 | break; | 758 | break; |
759 | #ifdef USENEF | 759 | #ifdef USENEF |
760 | case 3: | 760 | case 3: |
761 | m_decompress = getdecompressor("PluckerDecompress3"); | 761 | m_decompress = getdecompressor("PluckerDecompress3"); |
762 | break; | 762 | break; |
763 | case 4: | 763 | case 4: |
764 | m_decompress = getdecompressor("PluckerDecompress4"); | 764 | m_decompress = getdecompressor("PluckerDecompress4"); |
765 | break; | 765 | break; |
766 | #endif | 766 | #endif |
767 | default: | 767 | default: |
768 | m_decompress = NULL; | 768 | m_decompress = NULL; |
769 | } | 769 | } |
770 | if (m_decompress == NULL) return -1; | 770 | if (m_decompress == NULL) return -1; |
771 | 771 | ||
772 | setbuffersize(); | 772 | setbuffersize(); |
773 | compressedtextbuffer = new UInt8[compressedbuffersize]; | 773 | compressedtextbuffer = new UInt8[compressedbuffersize]; |
774 | expandedtextbuffer = new UInt8[buffersize]; | 774 | expandedtextbuffer = new UInt8[buffersize]; |
775 | 775 | ||
776 | unsigned int nrecs = ntohs(hdr0.nRecords); | 776 | unsigned int nrecs = ntohs(hdr0.nRecords); |
777 | qDebug("Version %u, no. reserved recs %u", ntohs(hdr0.version), nrecs); | 777 | qDebug("Version %u, no. reserved recs %u", ntohs(hdr0.version), nrecs); |
778 | textlength = ntohl(head.sortInfoID); | 778 | textlength = ntohl(head.sortInfoID); |
779 | qDebug("Textlength at startup:%u", textlength); | 779 | qDebug("Textlength at startup:%u", textlength); |
780 | UInt16 homerecid = 1; | 780 | UInt16 homerecid = 1; |
781 | for (unsigned int i = 0; i < nrecs; i++) | 781 | for (unsigned int i = 0; i < nrecs; i++) |
782 | { | 782 | { |
783 | UInt16 id, name; | 783 | UInt16 id, name; |
784 | fread(&name, 1, sizeof(name), fin); | 784 | fread(&name, 1, sizeof(name), fin); |
785 | fread(&id, 1, sizeof(id), fin); | 785 | fread(&id, 1, sizeof(id), fin); |
786 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); | 786 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); |
787 | if (ntohs(name) == 0) homerecid = ntohs(id); | 787 | if (ntohs(name) == 0) homerecid = ntohs(id); |
788 | } | 788 | } |
789 | 789 | ||
790 | textlength = 0; | 790 | textlength = 0; |
791 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 791 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
792 | { | 792 | { |
793 | gotorecordnumber(recptr); | 793 | gotorecordnumber(recptr); |
794 | UInt16 thishdr_uid, thishdr_nParagraphs; | 794 | UInt16 thishdr_uid, thishdr_nParagraphs; |
795 | UInt32 thishdr_size; | 795 | UInt32 thishdr_size; |
796 | UInt8 thishdr_type, thishdr_reserved; | 796 | UInt8 thishdr_type, thishdr_reserved; |
797 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 797 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
798 | if (thishdr_uid == homerecid) | 798 | if (thishdr_uid == homerecid) |
799 | { | 799 | { |
800 | m_homepos = textlength; | 800 | m_homepos = textlength; |
801 | break; | 801 | break; |
802 | } | 802 | } |
803 | if (thishdr_type < 2) textlength += thishdr_size; | 803 | if (thishdr_type < 2) textlength += thishdr_size; |
804 | } | 804 | } |
805 | qDebug("Found home"); | 805 | qDebug("Found home"); |
806 | textlength = 0; | 806 | textlength = 0; |
807 | home(); | 807 | home(); |
808 | qDebug("Gone home"); | 808 | qDebug("Gone home"); |
809 | #ifdef LOCALPICTURES | 809 | #ifdef LOCALPICTURES |
810 | if (m_viewer == NULL) | 810 | if (m_viewer == NULL) |
811 | { | 811 | { |
812 | m_viewer = new QScrollView(NULL); | 812 | m_viewer = new QScrollView(NULL); |
813 | m_picture = new QWidget(m_viewer->viewport()); | 813 | m_picture = new QWidget(m_viewer->viewport()); |
814 | m_viewer->addChild(m_picture); | 814 | m_viewer->addChild(m_picture); |
815 | } | 815 | } |
816 | #endif | 816 | #endif |
817 | return 0; | 817 | return 0; |
818 | 818 | ||
819 | } | 819 | } |
820 | 820 | ||
821 | QImage* CPlucker_base::getimg(UInt16 tgt) | 821 | QImage* CPlucker_base::getimg(UInt16 tgt) |
822 | { | 822 | { |
823 | size_t reclen; | 823 | size_t reclen; |
824 | UInt16 thisrec = finduid(tgt); | 824 | UInt16 thisrec = finduid(tgt); |
825 | qDebug("getimg:Found %u from uid:%u", thisrec, tgt); | 825 | qDebug("getimg:Found %u from uid:%u", thisrec, tgt); |
826 | reclen = recordlength(thisrec); | 826 | reclen = recordlength(thisrec); |
827 | gotorecordnumber(thisrec); | 827 | gotorecordnumber(thisrec); |
828 | UInt16 thishdr_uid, thishdr_nParagraphs; | 828 | UInt16 thishdr_uid, thishdr_nParagraphs; |
829 | UInt32 thishdr_size; | 829 | UInt32 thishdr_size; |
830 | UInt8 thishdr_type, thishdr_reserved; | 830 | UInt8 thishdr_type, thishdr_reserved; |
831 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 831 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
832 | if (thishdr_type == 15) | 832 | if (thishdr_type == 15) |
833 | { | 833 | { |
834 | char *buffer = new char[thishdr_size]; | 834 | char *buffer = new char[thishdr_size]; |
835 | fread(buffer, thishdr_size, sizeof(char), fin); | 835 | fread(buffer, thishdr_size, sizeof(char), fin); |
836 | unsigned short tmp; | 836 | unsigned short tmp; |
837 | memcpy(&tmp, buffer, sizeof(tmp)); | 837 | memcpy(&tmp, buffer, sizeof(tmp)); |
838 | unsigned short cols = ntohs(tmp); | 838 | unsigned short cols = ntohs(tmp); |
839 | memcpy(&tmp, buffer+sizeof(tmp), sizeof(tmp)); | 839 | memcpy(&tmp, buffer+sizeof(tmp), sizeof(tmp)); |
840 | unsigned short rows = ntohs(tmp); | 840 | unsigned short rows = ntohs(tmp); |
841 | qDebug("Found a picture of type:%u [%u,%u]", thishdr_type, rows, cols); | 841 | qDebug("Found a picture of type:%u [%u,%u]", thishdr_type, rows, cols); |
842 | QImage*** images; | 842 | QImage*** images; |
843 | images = new QImage**[rows]; | 843 | images = new QImage**[rows]; |
844 | #ifdef _WINDOWS | 844 | #ifdef _WINDOWS |
845 | int i; | 845 | int i; |
846 | for (i = 0; i < rows; i++) | 846 | for (i = 0; i < rows; i++) |
847 | #else | 847 | #else |
848 | for (int i = 0; i < rows; i++) | 848 | for (int i = 0; i < rows; i++) |
849 | #endif | 849 | #endif |
850 | { | 850 | { |
851 | images[i] = new QImage*[cols]; | 851 | images[i] = new QImage*[cols]; |
852 | } | 852 | } |
853 | int height = 0; | 853 | int height = 0; |
854 | int width = 0; | 854 | int width = 0; |
855 | #ifdef _WINDOWS | 855 | #ifdef _WINDOWS |
856 | for (i = 0; i < rows; i++) | 856 | for (i = 0; i < rows; i++) |
857 | #else | 857 | #else |
858 | for (int i = 0; i < rows; i++) | 858 | for (int i = 0; i < rows; i++) |
859 | #endif | 859 | #endif |
860 | { | 860 | { |
861 | width = 0; | 861 | width = 0; |
862 | for (int j = 0; j < cols; j++) | 862 | for (int j = 0; j < cols; j++) |
863 | { | 863 | { |
864 | memcpy(&tmp, buffer+(i*cols+j+2)*sizeof(tmp), sizeof(tmp)); | 864 | memcpy(&tmp, buffer+(i*cols+j+2)*sizeof(tmp), sizeof(tmp)); |
865 | unsigned short uid = ntohs(tmp); | 865 | unsigned short uid = ntohs(tmp); |
866 | images[i][j] = getimg(uid); | 866 | images[i][j] = getimg(uid); |
867 | width += images[i][j]->width(); | 867 | width += images[i][j]->width(); |
868 | } | 868 | } |
869 | height += images[i][0]->height(); | 869 | height += images[i][0]->height(); |
870 | } | 870 | } |
871 | delete [] buffer; | 871 | delete [] buffer; |
872 | QPixmap pm(width, height); | 872 | QPixmap pm(width, height); |
873 | int hoffset = 0; | 873 | int hoffset = 0; |
874 | #ifdef _WINDOWS | 874 | #ifdef _WINDOWS |
875 | for (i = 0; i < rows; i++) | 875 | for (i = 0; i < rows; i++) |
876 | #else | 876 | #else |
877 | for (int i = 0; i < rows; i++) | 877 | for (int i = 0; i < rows; i++) |
878 | #endif | 878 | #endif |
879 | { | 879 | { |
880 | int woffset = 0; | 880 | int woffset = 0; |
881 | int delht = images[i][0]->height(); | 881 | int delht = images[i][0]->height(); |
882 | for (int j = 0; j < cols; j++) | 882 | for (int j = 0; j < cols; j++) |
883 | { | 883 | { |
884 | QPixmap pm2; | 884 | QPixmap pm2; |
885 | pm2.convertFromImage(*(images[i][j])); | 885 | pm2.convertFromImage(*(images[i][j])); |
886 | delete images[i][j]; | 886 | delete images[i][j]; |
887 | bitBlt(&pm, woffset, hoffset, &pm2, 0, 0, pm2.width(), pm2.height()); | 887 | bitBlt(&pm, woffset, hoffset, &pm2, 0, 0, pm2.width(), pm2.height()); |
888 | woffset += pm2.width(); | 888 | woffset += pm2.width(); |
889 | } | 889 | } |
890 | hoffset += delht; | 890 | hoffset += delht; |
891 | } | 891 | } |
892 | #ifdef _WINDOWS | 892 | #ifdef _WINDOWS |
893 | for (i = 0; i < rows; i++) | 893 | for (i = 0; i < rows; i++) |
894 | #else | 894 | #else |
895 | for (int i = 0; i < rows; i++) | 895 | for (int i = 0; i < rows; i++) |
896 | #endif | 896 | #endif |
897 | { | 897 | { |
898 | delete [] images[i]; | 898 | delete [] images[i]; |
899 | } | 899 | } |
900 | delete [] images; | 900 | delete [] images; |
diff --git a/noncore/apps/opie-reader/striphtml.cpp b/noncore/apps/opie-reader/striphtml.cpp index c434dbb..a2ad56b 100644 --- a/noncore/apps/opie-reader/striphtml.cpp +++ b/noncore/apps/opie-reader/striphtml.cpp | |||
@@ -284,385 +284,385 @@ bool striphtml::findanchor(const QString& _info) | |||
284 | { | 284 | { |
285 | while (1) | 285 | while (1) |
286 | { | 286 | { |
287 | // qApp->processEvents(); | 287 | // qApp->processEvents(); |
288 | if ((offset = name.match(toQString(test.data()))) != -1) break; | 288 | if ((offset = name.match(toQString(test.data()))) != -1) break; |
289 | #ifdef USEQPE | 289 | #ifdef USEQPE |
290 | if ((offset = id.match(toQString(test.data()))) != -1) break; | 290 | if ((offset = id.match(toQString(test.data()))) != -1) break; |
291 | #endif | 291 | #endif |
292 | if (getpara(test, pos) < 0) | 292 | if (getpara(test, pos) < 0) |
293 | { | 293 | { |
294 | locate(startpos); | 294 | locate(startpos); |
295 | qDebug("Not found"); | 295 | qDebug("Not found"); |
296 | return false; | 296 | return false; |
297 | } | 297 | } |
298 | } | 298 | } |
299 | locate(pos); | 299 | locate(pos); |
300 | qDebug("Found"); | 300 | qDebug("Found"); |
301 | ret = true; | 301 | ret = true; |
302 | } | 302 | } |
303 | else | 303 | else |
304 | { | 304 | { |
305 | locate(startpos); | 305 | locate(startpos); |
306 | qDebug("Not found"); | 306 | qDebug("Not found"); |
307 | ret = false; | 307 | ret = false; |
308 | } | 308 | } |
309 | return ret; | 309 | return ret; |
310 | } | 310 | } |
311 | 311 | ||
312 | striphtml::striphtml(const QString& _s) : entmap(NULL), isPre(false), currentid(0), lastch(0), currentfile(_s), indent(0), forcecentre(false), m_inblock(false), m_bchm(false), ignorespace(false), tablenesteddepth(0) | 312 | striphtml::striphtml(const QString& _s) : entmap(NULL), isPre(false), currentid(0), lastch(0), currentfile(_s), indent(0), forcecentre(false), m_inblock(false), m_bchm(false), ignorespace(false), tablenesteddepth(0) |
313 | { | 313 | { |
314 | href2filepos = new QMap<QString, unsigned long>; | 314 | href2filepos = new QMap<QString, unsigned long>; |
315 | id2href = new QMap<unsigned long, QString>; | 315 | id2href = new QMap<unsigned long, QString>; |
316 | } | 316 | } |
317 | 317 | ||
318 | striphtml::~striphtml() | 318 | striphtml::~striphtml() |
319 | { | 319 | { |
320 | if (entmap != NULL) delete entmap; | 320 | if (entmap != NULL) delete entmap; |
321 | delete href2filepos; | 321 | delete href2filepos; |
322 | delete id2href; | 322 | delete id2href; |
323 | } | 323 | } |
324 | 324 | ||
325 | void striphtml::initentmap() | 325 | void striphtml::initentmap() |
326 | { | 326 | { |
327 | entmap = new QMap<QString, tchar>; | 327 | entmap = new QMap<QString, tchar>; |
328 | #ifdef USEQPE | 328 | #ifdef USEQPE |
329 | #ifdef OPIE | 329 | #ifdef OPIE |
330 | QString fname(getenv("OPIEDIR")); | 330 | QString fname(getenv("OPIEDIR")); |
331 | #else | 331 | #else |
332 | QString fname(getenv("QTDIR")); | 332 | QString fname(getenv("QTDIR")); |
333 | #endif | 333 | #endif |
334 | fname += "/plugins/reader/data"; | 334 | fname += "/plugins/reader/data"; |
335 | #else | 335 | #else |
336 | QString fname(getenv("READERDIR")); | 336 | QString fname(getenv("READERDIR")); |
337 | fname += "/data"; | 337 | fname += "/data"; |
338 | #endif | 338 | #endif |
339 | QFileInfo fi; | 339 | QFileInfo fi; |
340 | fi.setFile(fname, "HTMLentities"); | 340 | fi.setFile(fname, "HTMLentities"); |
341 | if (fi.exists()) | 341 | if (fi.exists()) |
342 | { | 342 | { |
343 | fname = fi.absFilePath(); | 343 | fname = fi.absFilePath(); |
344 | 344 | ||
345 | QFile fl(fname); | 345 | QFile fl(fname); |
346 | if (fl.open(IO_ReadOnly)) | 346 | if (fl.open(IO_ReadOnly)) |
347 | { | 347 | { |
348 | QTextStream t(&fl); | 348 | QTextStream t(&fl); |
349 | QString key, value; | 349 | QString key, value; |
350 | while (!t.eof()) | 350 | while (!t.eof()) |
351 | { | 351 | { |
352 | QString data = t.readLine(); | 352 | QString data = t.readLine(); |
353 | int colon = data.find(':'); | 353 | int colon = data.find(':'); |
354 | if (colon > 0) | 354 | if (colon > 0) |
355 | { | 355 | { |
356 | QString key = data.left(colon); | 356 | QString key = data.left(colon); |
357 | QString value = data.right(data.length()-colon-1); | 357 | QString value = data.right(data.length()-colon-1); |
358 | bool ok; | 358 | bool ok; |
359 | int ret = value.toInt(&ok); | 359 | int ret = value.toInt(&ok); |
360 | if (ok) | 360 | if (ok) |
361 | { | 361 | { |
362 | (*entmap)[key] = ret; | 362 | (*entmap)[key] = ret; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | } | 365 | } |
366 | fl.close(); | 366 | fl.close(); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | unsigned short striphtml::skip_ws() | 371 | unsigned short striphtml::skip_ws() |
372 | { | 372 | { |
373 | tchar ch; | 373 | tchar ch; |
374 | CStyle sty; | 374 | CStyle sty; |
375 | unsigned long dummy; | 375 | unsigned long dummy; |
376 | do | 376 | do |
377 | { | 377 | { |
378 | mygetch(ch, sty, dummy); | 378 | mygetch(ch, sty, dummy); |
379 | } | 379 | } |
380 | while (ch < 33 && ch != UEOF); | 380 | while (ch < 33 && ch != UEOF); |
381 | return ch; | 381 | return ch; |
382 | } | 382 | } |
383 | 383 | ||
384 | unsigned short striphtml::skip_ws_end() | 384 | unsigned short striphtml::skip_ws_end() |
385 | { | 385 | { |
386 | unsigned long dummy; | 386 | unsigned long dummy; |
387 | return skip_ws_end(dummy); | 387 | return skip_ws_end(dummy); |
388 | } | 388 | } |
389 | 389 | ||
390 | unsigned short striphtml::skip_ws_end(unsigned long& pos) | 390 | unsigned short striphtml::skip_ws_end(unsigned long& pos) |
391 | { | 391 | { |
392 | tchar ch; | 392 | tchar ch; |
393 | CStyle sty; | 393 | CStyle sty; |
394 | do | 394 | do |
395 | { | 395 | { |
396 | mygetch(ch, sty, pos); | 396 | mygetch(ch, sty, pos); |
397 | } | 397 | } |
398 | while (ch != '>' && ch != UEOF); | 398 | while (ch != '>' && ch != UEOF); |
399 | return ch; | 399 | return ch; |
400 | } | 400 | } |
401 | 401 | ||
402 | QString striphtml::getname(tchar& ch, const QString& nd) | 402 | QString striphtml::getname(tchar& ch, const QString& nd) |
403 | { | 403 | { |
404 | QString nm = ""; | 404 | QString nm = ""; |
405 | // nm += ch; | 405 | // nm += ch; |
406 | CStyle sty; | 406 | CStyle sty; |
407 | unsigned long dummy; | 407 | unsigned long dummy; |
408 | while (1) | 408 | while (1) |
409 | { | 409 | { |
410 | // if ( QChar(ch).isLetterOrNumber() ) | 410 | // if ( QChar(ch).isLetterOrNumber() ) |
411 | if (ch != UEOF && nd.find(ch, 0, false) == -1 && nm.length() < 2048) | 411 | if (ch != UEOF && nd.find(ch, 0, false) == -1 && nm.length() < 2048) |
412 | { | 412 | { |
413 | nm += ch; | 413 | nm += ch; |
414 | } | 414 | } |
415 | else | 415 | else |
416 | { | 416 | { |
417 | break; | 417 | break; |
418 | } | 418 | } |
419 | mygetch(ch, sty, dummy); | 419 | mygetch(ch, sty, dummy); |
420 | } | 420 | } |
421 | return nm; | 421 | return nm; |
422 | } | 422 | } |
423 | 423 | ||
424 | QString striphtml::getattr(tchar& ch) | 424 | QString striphtml::getattr(tchar& ch) |
425 | { | 425 | { |
426 | QString ref; | 426 | QString ref; |
427 | CStyle sty; | 427 | CStyle sty; |
428 | unsigned long pos; | 428 | unsigned long pos; |
429 | if (ch == ' ') ch = skip_ws(); | 429 | if (ch == ' ') ch = skip_ws(); |
430 | if (ch == '=') | 430 | if (ch == '=') |
431 | { | 431 | { |
432 | ch = skip_ws(); | 432 | ch = skip_ws(); |
433 | if (ch == '"') | 433 | if (ch == '"') |
434 | { | 434 | { |
435 | mygetch(ch, sty, pos); | 435 | mygetch(ch, sty, pos); |
436 | ref = getname(ch, "\""); | 436 | ref = getname(ch, "\""); |
437 | ch = skip_ws(); | 437 | ch = skip_ws(); |
438 | } | 438 | } |
439 | else if (ch == '\'') | 439 | else if (ch == '\'') |
440 | { | 440 | { |
441 | mygetch(ch, sty, pos); | 441 | mygetch(ch, sty, pos); |
442 | ref = getname(ch, "\'"); | 442 | ref = getname(ch, "\'"); |
443 | ch = skip_ws(); | 443 | ch = skip_ws(); |
444 | } | 444 | } |
445 | else | 445 | else |
446 | { | 446 | { |
447 | ref = getname(ch, " >"); | 447 | ref = getname(ch, " >"); |
448 | if (ch == ' ') ch = skip_ws(); | 448 | if (ch == ' ') ch = skip_ws(); |
449 | } | 449 | } |
450 | } | 450 | } |
451 | return ref; | 451 | return ref; |
452 | } | 452 | } |
453 | 453 | ||
454 | linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& nm) | 454 | linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& nm) |
455 | { | 455 | { |
456 | #if defined(USEQPE) || defined(_WINDOWS) | 456 | #if defined(USEQPE) || defined(_WINDOWS) |
457 | QMap<unsigned long, QString>::Iterator hrefit = id2href->find(n); | 457 | QMap<unsigned long, QString>::Iterator hrefit = id2href->find(n); |
458 | #else | 458 | #else |
459 | QMap<unsigned long, QString>::iterator hrefit = id2href->find(n); | 459 | QMap<unsigned long, QString>::iterator hrefit = id2href->find(n); |
460 | #endif | 460 | #endif |
461 | if (hrefit == id2href->end()) | 461 | if (hrefit == id2href->end()) |
462 | { | 462 | { |
463 | return eNone; | 463 | return eNone; |
464 | } | 464 | } |
465 | QString href = *hrefit; | 465 | QString href = *hrefit; |
466 | #if defined(USEQPE) || defined(_WINDOWS) | 466 | #if defined(USEQPE) || defined(_WINDOWS) |
467 | QMap<QString, unsigned long>::Iterator fpit = href2filepos->find(href); | 467 | QMap<QString, unsigned long>::Iterator fpit = href2filepos->find(href); |
468 | #else | 468 | #else |
469 | QMap<QString, unsigned long>::iterator fpit = href2filepos->find(href); | 469 | QMap<QString, unsigned long>::iterator fpit = href2filepos->find(href); |
470 | #endif | 470 | #endif |
471 | if (fpit == href2filepos->end()) | 471 | if (fpit == href2filepos->end()) |
472 | { | 472 | { |
473 | if (href == "history.back()") | 473 | if (href == "history.back()") |
474 | { | 474 | { |
475 | QString fc = currentfile; | 475 | QString fc = currentfile; |
476 | unsigned long loc; | 476 | unsigned long loc = 0; |
477 | htmlmark m(fc, loc); | 477 | htmlmark m(fc, loc); |
478 | linkType ret = (m_nav.back(m)) ? eFile : eNone; | 478 | linkType ret = (m_nav.back(m)) ? eFile : eNone; |
479 | if (fc == m.filename()) | 479 | if (fc == m.filename()) |
480 | { | 480 | { |
481 | if ((ret & eFile) != 0) | 481 | if ((ret & eFile) != 0) |
482 | { | 482 | { |
483 | locate(m.posn()); | 483 | locate(m.posn()); |
484 | return eLink; | 484 | return eLink; |
485 | } | 485 | } |
486 | } | 486 | } |
487 | return eNone; | 487 | return eNone; |
488 | } | 488 | } |
489 | qDebug("Searching for %s", (const char*)href); | 489 | qDebug("Searching for %s", (const char*)href); |
490 | 490 | ||
491 | 491 | ||
492 | QString file, name; | 492 | QString file, name; |
493 | 493 | ||
494 | int colon = href.find('#'); | 494 | int colon = href.find('#'); |
495 | if (colon >= 0) | 495 | if (colon >= 0) |
496 | { | 496 | { |
497 | file = dehtml(href.left(colon)); | 497 | file = dehtml(href.left(colon)); |
498 | name = dehtml(href.right(href.length()-colon-1)); | 498 | name = dehtml(href.right(href.length()-colon-1)); |
499 | } | 499 | } |
500 | else | 500 | else |
501 | { | 501 | { |
502 | file = dehtml(href); | 502 | file = dehtml(href); |
503 | } | 503 | } |
504 | 504 | ||
505 | qDebug("File:%s", (const char*)file); | 505 | qDebug("File:%s", (const char*)file); |
506 | qDebug("Name:%s", (const char*)name); | 506 | qDebug("Name:%s", (const char*)name); |
507 | 507 | ||
508 | 508 | ||
509 | if (file.isEmpty()) | 509 | if (file.isEmpty()) |
510 | { | 510 | { |
511 | if (parent->findanchor(name)) | 511 | if (parent->findanchor(name)) |
512 | { | 512 | { |
513 | reset(); | 513 | reset(); |
514 | return eLink; | 514 | return eLink; |
515 | } | 515 | } |
516 | fpit = href2filepos->find(name); | 516 | fpit = href2filepos->find(name); |
517 | if (fpit != href2filepos->end()) | 517 | if (fpit != href2filepos->end()) |
518 | { | 518 | { |
519 | locate(*fpit); | 519 | locate(*fpit); |
520 | return eLink; | 520 | return eLink; |
521 | } | 521 | } |
522 | else | 522 | else |
523 | { | 523 | { |
524 | // nm = QString("<a[^>]*name[ \t]*=[ \t]*\"") + name + "\""; | 524 | // nm = QString("<a[^>]*name[ \t]*=[ \t]*\"") + name + "\""; |
525 | qDebug("Do a search for:%s", (const char*)name); | 525 | qDebug("Do a search for:%s", (const char*)name); |
526 | findanchor(name); | 526 | findanchor(name); |
527 | return eLink; | 527 | return eLink; |
528 | } | 528 | } |
529 | } | 529 | } |
530 | else | 530 | else |
531 | // if (href.find('#') == -1) | 531 | // if (href.find('#') == -1) |
532 | { | 532 | { |
533 | if (m_bchm) | 533 | if (m_bchm) |
534 | { | 534 | { |
535 | w = file; | 535 | w = file; |
536 | nm = name; | 536 | nm = name; |
537 | return eFile; | 537 | return eFile; |
538 | } | 538 | } |
539 | else | 539 | else |
540 | { | 540 | { |
541 | QFileInfo f(currentfile); | 541 | QFileInfo f(currentfile); |
542 | QFileInfo f1(f.dir(true), file); | 542 | QFileInfo f1(f.dir(true), file); |
543 | if (f1.exists()) | 543 | if (f1.exists()) |
544 | { | 544 | { |
545 | w = f1.absFilePath(); | 545 | w = f1.absFilePath(); |
546 | nm = name; | 546 | nm = name; |
547 | } | 547 | } |
548 | else | 548 | else |
549 | { | 549 | { |
550 | w = file; | 550 | w = file; |
551 | } | 551 | } |
552 | return (f1.exists() ? eFile : eNone); | 552 | return (f1.exists() ? eFile : eNone); |
553 | } | 553 | } |
554 | } | 554 | } |
555 | return eNone; | 555 | return eNone; |
556 | } | 556 | } |
557 | locate(*fpit); | 557 | locate(*fpit); |
558 | // parent->locate((*href2filepos)[(*id2href)[n]]); | 558 | // parent->locate((*href2filepos)[(*id2href)[n]]); |
559 | return eLink; | 559 | return eLink; |
560 | } | 560 | } |
561 | /* | 561 | /* |
562 | unsigned short striphtml::parse_m() | 562 | unsigned short striphtml::parse_m() |
563 | { | 563 | { |
564 | tchar ch; | 564 | tchar ch; |
565 | CStyle sty; | 565 | CStyle sty; |
566 | unsigned long dummy; | 566 | unsigned long dummy; |
567 | mygetch(ch, sty, dummy); | 567 | mygetch(ch, sty, dummy); |
568 | if (ch == 'm' || ch == 'M') | 568 | if (ch == 'm' || ch == 'M') |
569 | { | 569 | { |
570 | ch = skip_ws_end(); | 570 | ch = skip_ws_end(); |
571 | if (ch == '>') | 571 | if (ch == '>') |
572 | { | 572 | { |
573 | return 0; | 573 | return 0; |
574 | } | 574 | } |
575 | } | 575 | } |
576 | return ch; | 576 | return ch; |
577 | } | 577 | } |
578 | */ | 578 | */ |
579 | 579 | ||
580 | void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) | 580 | void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) |
581 | { | 581 | { |
582 | if (!text_q.isEmpty() && !m_inblock) | 582 | if (!text_q.isEmpty() && !m_inblock) |
583 | { | 583 | { |
584 | ch = text_q[0].unicode(); | 584 | ch = text_q[0].unicode(); |
585 | text_q = text_q.right(text_q.length()-1); | 585 | text_q = text_q.right(text_q.length()-1); |
586 | } | 586 | } |
587 | else | 587 | else |
588 | { | 588 | { |
589 | parent->getch(ch, sty, pos); | 589 | parent->getch(ch, sty, pos); |
590 | if (ch == '<') | 590 | if (ch == '<') |
591 | { | 591 | { |
592 | m_inblock = true; | 592 | m_inblock = true; |
593 | } | 593 | } |
594 | if (ch == '>') | 594 | if (ch == '>') |
595 | { | 595 | { |
596 | m_inblock = false; | 596 | m_inblock = false; |
597 | } | 597 | } |
598 | } | 598 | } |
599 | if (ch == 10 && !isPre) | 599 | if (ch == 10 && !isPre) |
600 | { | 600 | { |
601 | #ifdef REMOVE_LF_BEFORE_ENDTAG | 601 | #ifdef REMOVE_LF_BEFORE_ENDTAG |
602 | parent->getch(ch, sty, pos); | 602 | parent->getch(ch, sty, pos); |
603 | if (ch == '<') | 603 | if (ch == '<') |
604 | { | 604 | { |
605 | parent->getch(ch, sty, pos); | 605 | parent->getch(ch, sty, pos); |
606 | if (ch == '/') | 606 | if (ch == '/') |
607 | { | 607 | { |
608 | ch = '<'; | 608 | ch = '<'; |
609 | text_q += '/'; | 609 | text_q += '/'; |
610 | } | 610 | } |
611 | else | 611 | else |
612 | { | 612 | { |
613 | text_q += '<'; | 613 | text_q += '<'; |
614 | text_q += ch; | 614 | text_q += ch; |
615 | ch = ' '; | 615 | ch = ' '; |
616 | } | 616 | } |
617 | } | 617 | } |
618 | else | 618 | else |
619 | { | 619 | { |
620 | text_q += ch; | 620 | text_q += ch; |
621 | ch = ' '; | 621 | ch = ' '; |
622 | } | 622 | } |
623 | #else | 623 | #else |
624 | ch = ' '; | 624 | ch = ' '; |
625 | #endif | 625 | #endif |
626 | } | 626 | } |
627 | } | 627 | } |
628 | 628 | ||
629 | void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long pos) | 629 | void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long pos) |
630 | { | 630 | { |
631 | /* | 631 | /* |
632 | int count = 0; | 632 | int count = 0; |
633 | for (CList<CStyle>::iterator iter = stylestack.begin(); iter != stylestack.end(); ++iter) | 633 | for (CList<CStyle>::iterator iter = stylestack.begin(); iter != stylestack.end(); ++iter) |
634 | { | 634 | { |
635 | count++; | 635 | count++; |
636 | } | 636 | } |
637 | qDebug("Currently have %u styles", count); | 637 | qDebug("Currently have %u styles", count); |
638 | */ | 638 | */ |
639 | if (stylestack.isEmpty()) | 639 | if (stylestack.isEmpty()) |
640 | { | 640 | { |
641 | currentstyle.unset(); | 641 | currentstyle.unset(); |
642 | } | 642 | } |
643 | else | 643 | else |
644 | { | 644 | { |
645 | currentstyle = stylestack.first(); | 645 | currentstyle = stylestack.first(); |
646 | } | 646 | } |
647 | if (forcecentre) | 647 | if (forcecentre) |
648 | { | 648 | { |
649 | currentstyle.setCentreJustify(); | 649 | currentstyle.setCentreJustify(); |
650 | } | 650 | } |
651 | if (ch == ' ') ch = skip_ws(); | 651 | if (ch == ' ') ch = skip_ws(); |
652 | while (ch != '>' && ch != UEOF) | 652 | while (ch != '>' && ch != UEOF) |
653 | { | 653 | { |
654 | QString ent = getname(ch, " =>").lower(); | 654 | QString ent = getname(ch, " =>").lower(); |
655 | QString attr = getattr(ch).lower(); | 655 | QString attr = getattr(ch).lower(); |
656 | //qDebug("(Paragraph)Entity:%s Attr:%s", (const char*)ent, (const char*)attr); | 656 | //qDebug("(Paragraph)Entity:%s Attr:%s", (const char*)ent, (const char*)attr); |
657 | if (ent == "align") | 657 | if (ent == "align") |
658 | { | 658 | { |
659 | if (attr == "center") | 659 | if (attr == "center") |
660 | { | 660 | { |
661 | currentstyle.setCentreJustify(); | 661 | currentstyle.setCentreJustify(); |
662 | } | 662 | } |
663 | if (attr == "right") | 663 | if (attr == "right") |
664 | { | 664 | { |
665 | currentstyle.setRightJustify(); | 665 | currentstyle.setRightJustify(); |
666 | } | 666 | } |
667 | if (attr == "justify") | 667 | if (attr == "justify") |
668 | { | 668 | { |
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp index 89024f7..ee6030f 100644 --- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp +++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp | |||
@@ -1127,342 +1127,344 @@ void Highlight::readGlobalKeywordConfig() | |||
1127 | casesensitive=true; else {casesensitive=false; kdDebug(13010)<<"Turning on case insensitiveness"<<endl;} | 1127 | casesensitive=true; else {casesensitive=false; kdDebug(13010)<<"Turning on case insensitiveness"<<endl;} |
1128 | //get the weak deliminators | 1128 | //get the weak deliminators |
1129 | weakDeliminator=(!HlManager::self()->syntax->groupItemData(data,QString("weakDeliminator"))); | 1129 | weakDeliminator=(!HlManager::self()->syntax->groupItemData(data,QString("weakDeliminator"))); |
1130 | 1130 | ||
1131 | // remove any weakDelimitars (if any) from the default list and store this list. | 1131 | // remove any weakDelimitars (if any) from the default list and store this list. |
1132 | int f; | 1132 | int f; |
1133 | for (int s=0; s < weakDeliminator.length(); s++) | 1133 | for (int s=0; s < weakDeliminator.length(); s++) |
1134 | { | 1134 | { |
1135 | f = 0; | 1135 | f = 0; |
1136 | f = deliminator.find (weakDeliminator[s]); | 1136 | f = deliminator.find (weakDeliminator[s]); |
1137 | 1137 | ||
1138 | if (f > -1) | 1138 | if (f > -1) |
1139 | deliminator.remove (f, 1); | 1139 | deliminator.remove (f, 1); |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | deliminatorChars = deliminator.unicode(); | 1142 | deliminatorChars = deliminator.unicode(); |
1143 | deliminatorLen = deliminator.length(); | 1143 | deliminatorLen = deliminator.length(); |
1144 | 1144 | ||
1145 | HlManager::self()->syntax->freeGroupInfo(data); | 1145 | HlManager::self()->syntax->freeGroupInfo(data); |
1146 | } | 1146 | } |
1147 | else | 1147 | else |
1148 | { | 1148 | { |
1149 | //Default values | 1149 | //Default values |
1150 | casesensitive=true; | 1150 | casesensitive=true; |
1151 | weakDeliminator=QString(""); | 1151 | weakDeliminator=QString(""); |
1152 | } | 1152 | } |
1153 | 1153 | ||
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | /******************************************************************************************* | 1156 | /******************************************************************************************* |
1157 | Highlight - makeContextList | 1157 | Highlight - makeContextList |
1158 | That's the most important initialization function for each highlighting. It's called | 1158 | That's the most important initialization function for each highlighting. It's called |
1159 | each time a document gets a highlighting style assigned. parses the xml file and | 1159 | each time a document gets a highlighting style assigned. parses the xml file and |
1160 | creates a corresponding internal structure | 1160 | creates a corresponding internal structure |
1161 | 1161 | ||
1162 | * input: none | 1162 | * input: none |
1163 | ************* | 1163 | ************* |
1164 | * output: none | 1164 | * output: none |
1165 | ************* | 1165 | ************* |
1166 | * return value: none | 1166 | * return value: none |
1167 | *******************************************************************************************/ | 1167 | *******************************************************************************************/ |
1168 | 1168 | ||
1169 | 1169 | ||
1170 | void Highlight::makeContextList() | 1170 | void Highlight::makeContextList() |
1171 | { | 1171 | { |
1172 | if (noHl) | 1172 | if (noHl) |
1173 | return; | 1173 | return; |
1174 | 1174 | ||
1175 | HlKeyword *keyword=0, *dataType=0; | 1175 | HlKeyword *keyword=0, *dataType=0; |
1176 | syntaxContextData *data, *datasub; | 1176 | syntaxContextData *data, *datasub; |
1177 | HlItem *c; | 1177 | HlItem *c; |
1178 | 1178 | ||
1179 | readCommentConfig(); | 1179 | readCommentConfig(); |
1180 | readGlobalKeywordConfig(); | 1180 | readGlobalKeywordConfig(); |
1181 | 1181 | ||
1182 | // Let the syntax document class know, which file we'd like to parse | 1182 | // Let the syntax document class know, which file we'd like to parse |
1183 | HlManager::self()->syntax->setIdentifier(identifier); | 1183 | HlManager::self()->syntax->setIdentifier(identifier); |
1184 | 1184 | ||
1185 | // This list is needed for the translation of the attribute parameter, if the itemData name is given instead of the index | 1185 | // This list is needed for the translation of the attribute parameter, if the itemData name is given instead of the index |
1186 | ItemDataList iDl; | 1186 | ItemDataList iDl; |
1187 | createItemData(iDl); | 1187 | createItemData(iDl); |
1188 | 1188 | ||
1189 | //start the real work | 1189 | //start the real work |
1190 | data=HlManager::self()->syntax->getGroupInfo("highlighting","context"); | 1190 | data=HlManager::self()->syntax->getGroupInfo("highlighting","context"); |
1191 | int i=0; | 1191 | int i=0; |
1192 | if (data) | 1192 | if (data) |
1193 | { | 1193 | { |
1194 | while (HlManager::self()->syntax->nextGroup(data)) | 1194 | while (HlManager::self()->syntax->nextGroup(data)) |
1195 | { | 1195 | { |
1196 | 1196 | ||
1197 | // BEGIN - Translation of the attribute parameter | 1197 | // BEGIN - Translation of the attribute parameter |
1198 | QString tmpAttr=HlManager::self()->syntax->groupData(data,QString("attribute")).simplifyWhiteSpace(); | 1198 | QString tmpAttr=HlManager::self()->syntax->groupData(data,QString("attribute")).simplifyWhiteSpace(); |
1199 | int attr; | 1199 | int attr; |
1200 | if (QString("%1").arg(tmpAttr.toInt())==tmpAttr) | 1200 | if (QString("%1").arg(tmpAttr.toInt())==tmpAttr) |
1201 | attr=tmpAttr.toInt(); | 1201 | attr=tmpAttr.toInt(); |
1202 | else | 1202 | else |
1203 | attr=lookupAttrName(tmpAttr,iDl); | 1203 | attr=lookupAttrName(tmpAttr,iDl); |
1204 | // END - Translation of the attribute parameter | 1204 | // END - Translation of the attribute parameter |
1205 | 1205 | ||
1206 | contextList[i]=new HlContext( | 1206 | contextList[i]=new HlContext( |
1207 | attr, | 1207 | attr, |
1208 | (HlManager::self()->syntax->groupData(data,QString("lineEndContext"))).toInt(), | 1208 | (HlManager::self()->syntax->groupData(data,QString("lineEndContext"))).toInt(), |
1209 | (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).isEmpty()?-1: | 1209 | (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).isEmpty()?-1: |
1210 | (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).toInt()); | 1210 | (HlManager::self()->syntax->groupData(data,QString("lineBeginContext"))).toInt()); |
1211 | 1211 | ||
1212 | 1212 | ||
1213 | //Let's create all items for the context | 1213 | //Let's create all items for the context |
1214 | while (HlManager::self()->syntax->nextItem(data)) | 1214 | while (HlManager::self()->syntax->nextItem(data)) |
1215 | { | 1215 | { |
1216 | // kdDebug(13010)<< "In make Contextlist: Item:"<<endl; | 1216 | // kdDebug(13010)<< "In make Contextlist: Item:"<<endl; |
1217 | c=createHlItem(data,iDl); | 1217 | c=createHlItem(data,iDl); |
1218 | if (c) | 1218 | if (c) |
1219 | { | 1219 | { |
1220 | contextList[i]->items.append(c); | 1220 | contextList[i]->items.append(c); |
1221 | 1221 | ||
1222 | // Not supported completely atm and only one level. Subitems.(all have to be matched to at once) | 1222 | // Not supported completely atm and only one level. Subitems.(all have to be matched to at once) |
1223 | datasub=HlManager::self()->syntax->getSubItems(data); | 1223 | datasub=HlManager::self()->syntax->getSubItems(data); |
1224 | bool tmpbool; | 1224 | bool tmpbool; |
1225 | if (tmpbool=HlManager::self()->syntax->nextItem(datasub)) | 1225 | if (tmpbool=HlManager::self()->syntax->nextItem(datasub)) |
1226 | { | 1226 | { |
1227 | c->subItems=new QList<HlItem>; | 1227 | c->subItems=new QList<HlItem>; |
1228 | for (;tmpbool;tmpbool=HlManager::self()->syntax->nextItem(datasub)) | 1228 | for (;tmpbool;tmpbool=HlManager::self()->syntax->nextItem(datasub)) |
1229 | c->subItems->append(createHlItem(datasub,iDl)); | 1229 | c->subItems->append(createHlItem(datasub,iDl)); |
1230 | } | 1230 | } |
1231 | HlManager::self()->syntax->freeGroupInfo(datasub); | 1231 | HlManager::self()->syntax->freeGroupInfo(datasub); |
1232 | // end of sublevel | 1232 | // end of sublevel |
1233 | } | 1233 | } |
1234 | // kdDebug(13010)<<"Last line in loop"<<endl; | 1234 | // kdDebug(13010)<<"Last line in loop"<<endl; |
1235 | } | 1235 | } |
1236 | i++; | 1236 | i++; |
1237 | } | 1237 | } |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | HlManager::self()->syntax->freeGroupInfo(data); | 1240 | HlManager::self()->syntax->freeGroupInfo(data); |
1241 | 1241 | ||
1242 | 1242 | ||
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | HlManager::HlManager() : QObject(0L) | 1245 | HlManager::HlManager() : QObject(0L) |
1246 | { | 1246 | { |
1247 | syntax = new SyntaxDocument(); | 1247 | syntax = new SyntaxDocument(); |
1248 | SyntaxModeList modeList = syntax->modeList(); | 1248 | SyntaxModeList modeList = syntax->modeList(); |
1249 | 1249 | ||
1250 | hlList.setAutoDelete(true); | 1250 | hlList.setAutoDelete(true); |
1251 | hlList.append(new Highlight(0)); | 1251 | hlList.append(new Highlight(0)); |
1252 | 1252 | ||
1253 | uint i=0; | 1253 | uint i=0; |
1254 | while (i < modeList.count()) | 1254 | while (i < modeList.count()) |
1255 | { | 1255 | { |
1256 | hlList.append(new Highlight(modeList.at(i))); | 1256 | hlList.append(new Highlight(modeList.at(i))); |
1257 | i++; | 1257 | i++; |
1258 | } | 1258 | } |
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | HlManager::~HlManager() { | 1261 | HlManager::~HlManager() { |
1262 | if(syntax) delete syntax; | 1262 | if(syntax) delete syntax; |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | HlManager *HlManager::self() | 1265 | HlManager *HlManager::self() |
1266 | { | 1266 | { |
1267 | if ( !s_pSelf ) | 1267 | if ( !s_pSelf ) |
1268 | s_pSelf = new HlManager; | 1268 | s_pSelf = new HlManager; |
1269 | return s_pSelf; | 1269 | return s_pSelf; |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | Highlight *HlManager::getHl(int n) { | 1272 | Highlight *HlManager::getHl(int n) { |
1273 | if (n < 0 || n >= (int) hlList.count()) n = 0; | 1273 | if (n < 0 || n >= (int) hlList.count()) n = 0; |
1274 | return hlList.at(n); | 1274 | return hlList.at(n); |
1275 | } | 1275 | } |
1276 | 1276 | ||
1277 | int HlManager::defaultHl() { | 1277 | int HlManager::defaultHl() { |
1278 | KateConfig *config; | 1278 | KateConfig *config; |
1279 | config = KGlobal::config(); | 1279 | config = KGlobal::config(); |
1280 | config->setGroup("General Options"); | 1280 | config->setGroup("General Options"); |
1281 | 1281 | ||
1282 | #warning fixme return nameFind(config->readEntry("Highlight")); | 1282 | #warning fixme return nameFind(config->readEntry("Highlight")); |
1283 | 1283 | ||
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | 1286 | ||
1287 | int HlManager::nameFind(const QString &name) { | 1287 | int HlManager::nameFind(const QString &name) { |
1288 | int z; | 1288 | int z; |
1289 | 1289 | ||
1290 | for (z = hlList.count() - 1; z > 0; z--) { | 1290 | for (z = hlList.count() - 1; z > 0; z--) { |
1291 | if (hlList.at(z)->iName == name) break; | 1291 | if (hlList.at(z)->iName == name) break; |
1292 | } | 1292 | } |
1293 | return z; | 1293 | return z; |
1294 | } | 1294 | } |
1295 | 1295 | ||
1296 | int HlManager::wildcardFind(const QString &fileName) { | 1296 | int HlManager::wildcardFind(const QString &fileName) { |
1297 | Highlight *highlight; | 1297 | Highlight *highlight; |
1298 | int p1, p2; | 1298 | int p1, p2; |
1299 | QString w; | 1299 | QString w; |
1300 | for (highlight = hlList.first(); highlight != 0L; highlight = hlList.next()) { | 1300 | for (highlight = hlList.first(); highlight != 0L; highlight = hlList.next()) { |
1301 | p1 = 0; | 1301 | p1 = 0; |
1302 | w = highlight->getWildcards(); | 1302 | w = highlight->getWildcards(); |
1303 | while (p1 < (int) w.length()) { | 1303 | while (p1 < (int) w.length()) { |
1304 | p2 = w.find(';',p1); | 1304 | p2 = w.find(';',p1); |
1305 | if (p2 == -1) p2 = w.length(); | 1305 | if (p2 == -1) p2 = w.length(); |
1306 | if (p1 < p2) { | 1306 | if (p1 < p2) { |
1307 | QRegExp regExp(w.mid(p1,p2 - p1),true,true); | 1307 | QRegExp regExp(w.mid(p1,p2 - p1),true,true); |
1308 | if (regExp.match(fileName) == 0) return hlList.at(); | 1308 | if (regExp.match(fileName) == 0) return hlList.at(); |
1309 | } | 1309 | } |
1310 | p1 = p2 + 1; | 1310 | p1 = p2 + 1; |
1311 | } | 1311 | } |
1312 | } | 1312 | } |
1313 | return -1; | 1313 | return -1; |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | 1316 | ||
1317 | int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) { | 1317 | int HlManager::makeAttribs(Highlight *highlight, Attribute *a, int maxAttribs) { |
1318 | ItemStyleList defaultStyleList; | 1318 | ItemStyleList defaultStyleList; |
1319 | ItemStyle *defaultStyle; | 1319 | ItemStyle *defaultStyle = 0; |
1320 | ItemDataList itemDataList; | 1320 | ItemDataList itemDataList; |
1321 | ItemData *itemData; | 1321 | ItemData *itemData; |
1322 | int nAttribs, z; | 1322 | int nAttribs, z; |
1323 | 1323 | ||
1324 | odebug << "HlManager::makeAttribs" << oendl; | 1324 | odebug << "HlManager::makeAttribs" << oendl; |
1325 | 1325 | ||
1326 | defaultStyleList.setAutoDelete(true); | 1326 | defaultStyleList.setAutoDelete(true); |
1327 | getDefaults(defaultStyleList); | 1327 | getDefaults(defaultStyleList); |
1328 | 1328 | ||
1329 | // itemDataList.setAutoDelete(true); | 1329 | // itemDataList.setAutoDelete(true); |
1330 | highlight->getItemDataList(itemDataList); | 1330 | highlight->getItemDataList(itemDataList); |
1331 | nAttribs = itemDataList.count(); | 1331 | nAttribs = itemDataList.count(); |
1332 | for (z = 0; z < nAttribs; z++) { | 1332 | for (z = 0; z < nAttribs; z++) { |
1333 | odebug << "HlManager::makeAttribs: createing one attribute definition" << oendl; | 1333 | odebug << "HlManager::makeAttribs: creating an attribute definition" << oendl; |
1334 | itemData = itemDataList.at(z); | 1334 | itemData = itemDataList.at(z); |
1335 | if (itemData->defStyle) { | 1335 | if (itemData->defStyle) { |
1336 | // default style | 1336 | // default style |
1337 | defaultStyle = defaultStyleList.at(itemData->defStyleNum); | 1337 | defaultStyle = defaultStyleList.at(itemData->defStyleNum); |
1338 | a[z].col = defaultStyle->col; | 1338 | a[z].col = defaultStyle->col; |
1339 | a[z].selCol = defaultStyle->selCol; | 1339 | a[z].selCol = defaultStyle->selCol; |
1340 | a[z].bold = defaultStyle->bold; | 1340 | a[z].bold = defaultStyle->bold; |
1341 | a[z].italic = defaultStyle->italic; | 1341 | a[z].italic = defaultStyle->italic; |
1342 | } else { | 1342 | } else { |
1343 | // custom style | 1343 | // custom style |
1344 | a[z].col = itemData->col; | 1344 | a[z].col = itemData->col; |
1345 | a[z].selCol = itemData->selCol; | 1345 | a[z].selCol = itemData->selCol; |
1346 | a[z].bold = itemData->bold; | 1346 | a[z].bold = itemData->bold; |
1347 | a[z].italic = itemData->italic; | 1347 | a[z].italic = itemData->italic; |
1348 | } | 1348 | } |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | for (; z < maxAttribs; z++) { | 1351 | for (; z < maxAttribs; z++) { |
1352 | a[z].col = black; | 1352 | a[z].col = black; |
1353 | a[z].selCol = black; | 1353 | a[z].selCol = black; |
1354 | a[z].bold = defaultStyle->bold; | 1354 | if (defaultStyle) { |
1355 | a[z].italic = defaultStyle->italic; | 1355 | a[z].bold = defaultStyle->bold; |
1356 | a[z].italic = defaultStyle->italic; | ||
1357 | } | ||
1356 | } | 1358 | } |
1357 | return nAttribs; | 1359 | return nAttribs; |
1358 | } | 1360 | } |
1359 | 1361 | ||
1360 | int HlManager::defaultStyles() { | 1362 | int HlManager::defaultStyles() { |
1361 | return 10; | 1363 | return 10; |
1362 | } | 1364 | } |
1363 | 1365 | ||
1364 | QString HlManager::defaultStyleName(int n) | 1366 | QString HlManager::defaultStyleName(int n) |
1365 | { | 1367 | { |
1366 | static QStringList names; | 1368 | static QStringList names; |
1367 | 1369 | ||
1368 | if (names.isEmpty()) | 1370 | if (names.isEmpty()) |
1369 | { | 1371 | { |
1370 | names << i18n("Normal"); | 1372 | names << i18n("Normal"); |
1371 | names << i18n("Keyword"); | 1373 | names << i18n("Keyword"); |
1372 | names << i18n("Data Type"); | 1374 | names << i18n("Data Type"); |
1373 | names << i18n("Decimal/Value"); | 1375 | names << i18n("Decimal/Value"); |
1374 | names << i18n("Base-N Integer"); | 1376 | names << i18n("Base-N Integer"); |
1375 | names << i18n("Floating Point"); | 1377 | names << i18n("Floating Point"); |
1376 | names << i18n("Character"); | 1378 | names << i18n("Character"); |
1377 | names << i18n("String"); | 1379 | names << i18n("String"); |
1378 | names << i18n("Comment"); | 1380 | names << i18n("Comment"); |
1379 | names << i18n("Others"); | 1381 | names << i18n("Others"); |
1380 | } | 1382 | } |
1381 | 1383 | ||
1382 | return names[n]; | 1384 | return names[n]; |
1383 | } | 1385 | } |
1384 | 1386 | ||
1385 | void HlManager::getDefaults(ItemStyleList &list) { | 1387 | void HlManager::getDefaults(ItemStyleList &list) { |
1386 | KateConfig *config; | 1388 | KateConfig *config; |
1387 | int z; | 1389 | int z; |
1388 | ItemStyle *i; | 1390 | ItemStyle *i; |
1389 | QString s; | 1391 | QString s; |
1390 | QRgb col, selCol; | 1392 | QRgb col, selCol; |
1391 | 1393 | ||
1392 | list.setAutoDelete(true); | 1394 | list.setAutoDelete(true); |
1393 | //ItemStyle(color, selected color, bold, italic) | 1395 | //ItemStyle(color, selected color, bold, italic) |
1394 | list.append(new ItemStyle(black,white,false,false)); //normal | 1396 | list.append(new ItemStyle(black,white,false,false)); //normal |
1395 | list.append(new ItemStyle(black,white,true,false)); //keyword | 1397 | list.append(new ItemStyle(black,white,true,false)); //keyword |
1396 | list.append(new ItemStyle(darkRed,white,false,false)); //datatype | 1398 | list.append(new ItemStyle(darkRed,white,false,false)); //datatype |
1397 | list.append(new ItemStyle(blue,cyan,false,false)); //decimal/value | 1399 | list.append(new ItemStyle(blue,cyan,false,false)); //decimal/value |
1398 | list.append(new ItemStyle(darkCyan,cyan,false,false)); //base n | 1400 | list.append(new ItemStyle(darkCyan,cyan,false,false)); //base n |
1399 | list.append(new ItemStyle(darkMagenta,cyan,false,false));//float | 1401 | list.append(new ItemStyle(darkMagenta,cyan,false,false));//float |
1400 | list.append(new ItemStyle(magenta,magenta,false,false)); //char | 1402 | list.append(new ItemStyle(magenta,magenta,false,false)); //char |
1401 | list.append(new ItemStyle(red,red,false,false)); //string | 1403 | list.append(new ItemStyle(red,red,false,false)); //string |
1402 | list.append(new ItemStyle(darkGray,gray,false,true)); //comment | 1404 | list.append(new ItemStyle(darkGray,gray,false,true)); //comment |
1403 | list.append(new ItemStyle(darkGreen,green,false,false)); //others | 1405 | list.append(new ItemStyle(darkGreen,green,false,false)); //others |
1404 | 1406 | ||
1405 | #warning fixme | 1407 | #warning fixme |
1406 | /* | 1408 | /* |
1407 | config = KateFactory::instance()->config(); | 1409 | config = KateFactory::instance()->config(); |
1408 | config->setGroup("Default Item Styles"); | 1410 | config->setGroup("Default Item Styles"); |
1409 | for (z = 0; z < defaultStyles(); z++) { | 1411 | for (z = 0; z < defaultStyles(); z++) { |
1410 | i = list.at(z); | 1412 | i = list.at(z); |
1411 | s = config->readEntry(defaultStyleName(z)); | 1413 | s = config->readEntry(defaultStyleName(z)); |
1412 | if (!s.isEmpty()) { | 1414 | if (!s.isEmpty()) { |
1413 | sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic); | 1415 | sscanf(s.latin1(),"%X,%X,%d,%d",&col,&selCol,&i->bold,&i->italic); |
1414 | i->col.setRgb(col); | 1416 | i->col.setRgb(col); |
1415 | i->selCol.setRgb(selCol); | 1417 | i->selCol.setRgb(selCol); |
1416 | } | 1418 | } |
1417 | } | 1419 | } |
1418 | */ | 1420 | */ |
1419 | } | 1421 | } |
1420 | 1422 | ||
1421 | void HlManager::setDefaults(ItemStyleList &list) { | 1423 | void HlManager::setDefaults(ItemStyleList &list) { |
1422 | KateConfig *config; | 1424 | KateConfig *config; |
1423 | int z; | 1425 | int z; |
1424 | ItemStyle *i; | 1426 | ItemStyle *i; |
1425 | char s[64]; | 1427 | char s[64]; |
1426 | #warning fixme | 1428 | #warning fixme |
1427 | /* | 1429 | /* |
1428 | config = KateFactory::instance()->config(); | 1430 | config = KateFactory::instance()->config(); |
1429 | config->setGroup("Default Item Styles"); | 1431 | config->setGroup("Default Item Styles"); |
1430 | for (z = 0; z < defaultStyles(); z++) { | 1432 | for (z = 0; z < defaultStyles(); z++) { |
1431 | i = list.at(z); | 1433 | i = list.at(z); |
1432 | sprintf(s,"%X,%X,%d,%d",i->col.rgb(),i->selCol.rgb(),i->bold, i->italic); | 1434 | sprintf(s,"%X,%X,%d,%d",i->col.rgb(),i->selCol.rgb(),i->bold, i->italic); |
1433 | config->writeEntry(defaultStyleName(z),s); | 1435 | config->writeEntry(defaultStyleName(z),s); |
1434 | } | 1436 | } |
1435 | */ | 1437 | */ |
1436 | emit changed(); | 1438 | emit changed(); |
1437 | } | 1439 | } |
1438 | 1440 | ||
1439 | 1441 | ||
1440 | int HlManager::highlights() { | 1442 | int HlManager::highlights() { |
1441 | return (int) hlList.count(); | 1443 | return (int) hlList.count(); |
1442 | } | 1444 | } |
1443 | 1445 | ||
1444 | QString HlManager::hlName(int n) { | 1446 | QString HlManager::hlName(int n) { |
1445 | return hlList.at(n)->iName; | 1447 | return hlList.at(n)->iName; |
1446 | } | 1448 | } |
1447 | 1449 | ||
1448 | QString HlManager::hlSection(int n) { | 1450 | QString HlManager::hlSection(int n) { |
1449 | return hlList.at(n)->iSection; | 1451 | return hlList.at(n)->iSection; |
1450 | } | 1452 | } |
1451 | 1453 | ||
1452 | void HlManager::getHlDataList(HlDataList &list) { | 1454 | void HlManager::getHlDataList(HlDataList &list) { |
1453 | int z; | 1455 | int z; |
1454 | 1456 | ||
1455 | for (z = 0; z < (int) hlList.count(); z++) { | 1457 | for (z = 0; z < (int) hlList.count(); z++) { |
1456 | list.append(hlList.at(z)->getData()); | 1458 | list.append(hlList.at(z)->getData()); |
1457 | } | 1459 | } |
1458 | } | 1460 | } |
1459 | 1461 | ||
1460 | void HlManager::setHlDataList(HlDataList &list) { | 1462 | void HlManager::setHlDataList(HlDataList &list) { |
1461 | int z; | 1463 | int z; |
1462 | 1464 | ||
1463 | for (z = 0; z < (int) hlList.count(); z++) { | 1465 | for (z = 0; z < (int) hlList.count(); z++) { |
1464 | hlList.at(z)->setData(list.at(z)); | 1466 | hlList.at(z)->setData(list.at(z)); |
1465 | } | 1467 | } |
1466 | //notify documents about changes in highlight configuration | 1468 | //notify documents about changes in highlight configuration |
1467 | emit changed(); | 1469 | emit changed(); |
1468 | } | 1470 | } |
diff --git a/noncore/net/ftplib/ftplib.c b/noncore/net/ftplib/ftplib.c index addf9d2..ce4c05f 100644 --- a/noncore/net/ftplib/ftplib.c +++ b/noncore/net/ftplib/ftplib.c | |||
@@ -592,385 +592,385 @@ static int FtpSendCmd(const char *cmd, char expresp, netbuf *nControl) | |||
592 | sprintf(buf,"%s\r\n",cmd); | 592 | sprintf(buf,"%s\r\n",cmd); |
593 | if (net_write(nControl->handle,buf,strlen(buf)) <= 0) | 593 | if (net_write(nControl->handle,buf,strlen(buf)) <= 0) |
594 | { | 594 | { |
595 | perror("write"); | 595 | perror("write"); |
596 | return 0; | 596 | return 0; |
597 | } | 597 | } |
598 | return readresp(expresp, nControl); | 598 | return readresp(expresp, nControl); |
599 | } | 599 | } |
600 | 600 | ||
601 | /* | 601 | /* |
602 | * FtpLogin - log in to remote server | 602 | * FtpLogin - log in to remote server |
603 | * | 603 | * |
604 | * return 1 if logged in, 0 otherwise | 604 | * return 1 if logged in, 0 otherwise |
605 | */ | 605 | */ |
606 | GLOBALDEF int FtpLogin(const char *user, const char *pass, netbuf *nControl) | 606 | GLOBALDEF int FtpLogin(const char *user, const char *pass, netbuf *nControl) |
607 | { | 607 | { |
608 | char tempbuf[64]; | 608 | char tempbuf[64]; |
609 | 609 | ||
610 | if (((strlen(user) + 7) > sizeof(tempbuf)) || | 610 | if (((strlen(user) + 7) > sizeof(tempbuf)) || |
611 | ((strlen(pass) + 7) > sizeof(tempbuf))) | 611 | ((strlen(pass) + 7) > sizeof(tempbuf))) |
612 | return 0; | 612 | return 0; |
613 | sprintf(tempbuf,"USER %s",user); | 613 | sprintf(tempbuf,"USER %s",user); |
614 | if (!FtpSendCmd(tempbuf,'3',nControl)) | 614 | if (!FtpSendCmd(tempbuf,'3',nControl)) |
615 | { | 615 | { |
616 | if (nControl->response[0] == '2') | 616 | if (nControl->response[0] == '2') |
617 | return 1; | 617 | return 1; |
618 | return 0; | 618 | return 0; |
619 | } | 619 | } |
620 | sprintf(tempbuf,"PASS %s",pass); | 620 | sprintf(tempbuf,"PASS %s",pass); |
621 | return FtpSendCmd(tempbuf,'2',nControl); | 621 | return FtpSendCmd(tempbuf,'2',nControl); |
622 | } | 622 | } |
623 | 623 | ||
624 | /* | 624 | /* |
625 | * FtpOpenPort - set up data connection | 625 | * FtpOpenPort - set up data connection |
626 | * | 626 | * |
627 | * return 1 if successful, 0 otherwise | 627 | * return 1 if successful, 0 otherwise |
628 | */ | 628 | */ |
629 | static int FtpOpenPort(netbuf *nControl, netbuf **nData, int mode, int dir) | 629 | static int FtpOpenPort(netbuf *nControl, netbuf **nData, int mode, int dir) |
630 | { | 630 | { |
631 | int sData; | 631 | int sData; |
632 | union { | 632 | union { |
633 | struct sockaddr sa; | 633 | struct sockaddr sa; |
634 | struct sockaddr_in in; | 634 | struct sockaddr_in in; |
635 | } sin; | 635 | } sin; |
636 | struct linger lng = { 0, 0 }; | 636 | struct linger lng = { 0, 0 }; |
637 | unsigned int l; | 637 | unsigned int l; |
638 | int on=1; | 638 | int on=1; |
639 | netbuf *ctrl; | 639 | netbuf *ctrl; |
640 | char *cp; | 640 | char *cp; |
641 | unsigned int v[6]; | 641 | unsigned int v[6]; |
642 | char buf[256]; | 642 | char buf[256]; |
643 | 643 | ||
644 | if (nControl->dir != FTPLIB_CONTROL) | 644 | if (nControl->dir != FTPLIB_CONTROL) |
645 | return -1; | 645 | return -1; |
646 | if ((dir != FTPLIB_READ) && (dir != FTPLIB_WRITE)) | 646 | if ((dir != FTPLIB_READ) && (dir != FTPLIB_WRITE)) |
647 | { | 647 | { |
648 | sprintf(nControl->response, "Invalid direction %d\n", dir); | 648 | sprintf(nControl->response, "Invalid direction %d\n", dir); |
649 | return -1; | 649 | return -1; |
650 | } | 650 | } |
651 | if ((mode != FTPLIB_ASCII) && (mode != FTPLIB_IMAGE)) | 651 | if ((mode != FTPLIB_ASCII) && (mode != FTPLIB_IMAGE)) |
652 | { | 652 | { |
653 | sprintf(nControl->response, "Invalid mode %c\n", mode); | 653 | sprintf(nControl->response, "Invalid mode %c\n", mode); |
654 | return -1; | 654 | return -1; |
655 | } | 655 | } |
656 | l = sizeof(sin); | 656 | l = sizeof(sin); |
657 | if (nControl->cmode == FTPLIB_PASSIVE) | 657 | if (nControl->cmode == FTPLIB_PASSIVE) |
658 | { | 658 | { |
659 | memset(&sin, 0, l); | 659 | memset(&sin, 0, l); |
660 | sin.in.sin_family = AF_INET; | 660 | sin.in.sin_family = AF_INET; |
661 | if (!FtpSendCmd("PASV",'2',nControl)) | 661 | if (!FtpSendCmd("PASV",'2',nControl)) |
662 | return -1; | 662 | return -1; |
663 | cp = strchr(nControl->response,'('); | 663 | cp = strchr(nControl->response,'('); |
664 | if (cp == NULL) | 664 | if (cp == NULL) |
665 | return -1; | 665 | return -1; |
666 | cp++; | 666 | cp++; |
667 | sscanf(cp,"%u,%u,%u,%u,%u,%u",&v[2],&v[3],&v[4],&v[5],&v[0],&v[1]); | 667 | sscanf(cp,"%u,%u,%u,%u,%u,%u",&v[2],&v[3],&v[4],&v[5],&v[0],&v[1]); |
668 | sin.sa.sa_data[2] = v[2]; | 668 | sin.sa.sa_data[2] = v[2]; |
669 | sin.sa.sa_data[3] = v[3]; | 669 | sin.sa.sa_data[3] = v[3]; |
670 | sin.sa.sa_data[4] = v[4]; | 670 | sin.sa.sa_data[4] = v[4]; |
671 | sin.sa.sa_data[5] = v[5]; | 671 | sin.sa.sa_data[5] = v[5]; |
672 | sin.sa.sa_data[0] = v[0]; | 672 | sin.sa.sa_data[0] = v[0]; |
673 | sin.sa.sa_data[1] = v[1]; | 673 | sin.sa.sa_data[1] = v[1]; |
674 | } | 674 | } |
675 | else | 675 | else |
676 | { | 676 | { |
677 | if (getsockname(nControl->handle, &sin.sa, &l) < 0) | 677 | if (getsockname(nControl->handle, &sin.sa, &l) < 0) |
678 | { | 678 | { |
679 | perror("getsockname"); | 679 | perror("getsockname"); |
680 | return 0; | 680 | return 0; |
681 | } | 681 | } |
682 | } | 682 | } |
683 | sData = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP); | 683 | sData = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP); |
684 | if (sData == -1) | 684 | if (sData == -1) |
685 | { | 685 | { |
686 | perror("socket"); | 686 | perror("socket"); |
687 | return -1; | 687 | return -1; |
688 | } | 688 | } |
689 | if (setsockopt(sData,SOL_SOCKET,SO_REUSEADDR, | 689 | if (setsockopt(sData,SOL_SOCKET,SO_REUSEADDR, |
690 | SETSOCKOPT_OPTVAL_TYPE &on,sizeof(on)) == -1) | 690 | SETSOCKOPT_OPTVAL_TYPE &on,sizeof(on)) == -1) |
691 | { | 691 | { |
692 | perror("setsockopt"); | 692 | perror("setsockopt"); |
693 | net_close(sData); | 693 | net_close(sData); |
694 | return -1; | 694 | return -1; |
695 | } | 695 | } |
696 | if (setsockopt(sData,SOL_SOCKET,SO_LINGER, | 696 | if (setsockopt(sData,SOL_SOCKET,SO_LINGER, |
697 | SETSOCKOPT_OPTVAL_TYPE &lng,sizeof(lng)) == -1) | 697 | SETSOCKOPT_OPTVAL_TYPE &lng,sizeof(lng)) == -1) |
698 | { | 698 | { |
699 | perror("setsockopt"); | 699 | perror("setsockopt"); |
700 | net_close(sData); | 700 | net_close(sData); |
701 | return -1; | 701 | return -1; |
702 | } | 702 | } |
703 | if (nControl->cmode == FTPLIB_PASSIVE) | 703 | if (nControl->cmode == FTPLIB_PASSIVE) |
704 | { | 704 | { |
705 | if (connect(sData, &sin.sa, sizeof(sin.sa)) == -1) | 705 | if (connect(sData, &sin.sa, sizeof(sin.sa)) == -1) |
706 | { | 706 | { |
707 | perror("connect"); | 707 | perror("connect"); |
708 | net_close(sData); | 708 | net_close(sData); |
709 | return -1; | 709 | return -1; |
710 | } | 710 | } |
711 | } | 711 | } |
712 | else | 712 | else |
713 | { | 713 | { |
714 | sin.in.sin_port = 0; | 714 | sin.in.sin_port = 0; |
715 | if (bind(sData, &sin.sa, sizeof(sin)) == -1) | 715 | if (bind(sData, &sin.sa, sizeof(sin)) == -1) |
716 | { | 716 | { |
717 | perror("bind"); | 717 | perror("bind"); |
718 | net_close(sData); | 718 | net_close(sData); |
719 | return 0; | 719 | return 0; |
720 | } | 720 | } |
721 | if (listen(sData, 1) < 0) | 721 | if (listen(sData, 1) < 0) |
722 | { | 722 | { |
723 | perror("listen"); | 723 | perror("listen"); |
724 | net_close(sData); | 724 | net_close(sData); |
725 | return 0; | 725 | return 0; |
726 | } | 726 | } |
727 | if (getsockname(sData, &sin.sa, &l) < 0) | 727 | if (getsockname(sData, &sin.sa, &l) < 0) |
728 | return 0; | 728 | return 0; |
729 | sprintf(buf, "PORT %d,%d,%d,%d,%d,%d", | 729 | sprintf(buf, "PORT %d,%d,%d,%d,%d,%d", |
730 | (unsigned char) sin.sa.sa_data[2], | 730 | (unsigned char) sin.sa.sa_data[2], |
731 | (unsigned char) sin.sa.sa_data[3], | 731 | (unsigned char) sin.sa.sa_data[3], |
732 | (unsigned char) sin.sa.sa_data[4], | 732 | (unsigned char) sin.sa.sa_data[4], |
733 | (unsigned char) sin.sa.sa_data[5], | 733 | (unsigned char) sin.sa.sa_data[5], |
734 | (unsigned char) sin.sa.sa_data[0], | 734 | (unsigned char) sin.sa.sa_data[0], |
735 | (unsigned char) sin.sa.sa_data[1]); | 735 | (unsigned char) sin.sa.sa_data[1]); |
736 | if (!FtpSendCmd(buf,'2',nControl)) | 736 | if (!FtpSendCmd(buf,'2',nControl)) |
737 | { | 737 | { |
738 | net_close(sData); | 738 | net_close(sData); |
739 | return 0; | 739 | return 0; |
740 | } | 740 | } |
741 | } | 741 | } |
742 | ctrl = calloc(1,sizeof(netbuf)); | 742 | ctrl = calloc(1,sizeof(netbuf)); |
743 | if (ctrl == NULL) | 743 | if (ctrl == NULL) |
744 | { | 744 | { |
745 | perror("calloc"); | 745 | perror("calloc"); |
746 | net_close(sData); | 746 | net_close(sData); |
747 | return -1; | 747 | return -1; |
748 | } | 748 | } |
749 | if ((mode == 'A') && ((ctrl->buf = malloc(FTPLIB_BUFSIZ)) == NULL)) | 749 | if ((mode == 'A') && ((ctrl->buf = malloc(FTPLIB_BUFSIZ)) == NULL)) |
750 | { | 750 | { |
751 | perror("calloc"); | 751 | perror("calloc"); |
752 | net_close(sData); | 752 | net_close(sData); |
753 | free(ctrl); | 753 | free(ctrl); |
754 | return -1; | 754 | return -1; |
755 | } | 755 | } |
756 | ctrl->handle = sData; | 756 | ctrl->handle = sData; |
757 | ctrl->dir = dir; | 757 | ctrl->dir = dir; |
758 | ctrl->idletime = nControl->idletime; | 758 | ctrl->idletime = nControl->idletime; |
759 | ctrl->idlearg = nControl->idlearg; | 759 | ctrl->idlearg = nControl->idlearg; |
760 | ctrl->xfered = 0; | 760 | ctrl->xfered = 0; |
761 | ctrl->xfered1 = 0; | 761 | ctrl->xfered1 = 0; |
762 | ctrl->cbbytes = nControl->cbbytes; | 762 | ctrl->cbbytes = nControl->cbbytes; |
763 | if (ctrl->idletime.tv_sec || ctrl->idletime.tv_usec || ctrl->cbbytes) | 763 | if (ctrl->idletime.tv_sec || ctrl->idletime.tv_usec || ctrl->cbbytes) |
764 | ctrl->idlecb = nControl->idlecb; | 764 | ctrl->idlecb = nControl->idlecb; |
765 | else | 765 | else |
766 | ctrl->idlecb = NULL; | 766 | ctrl->idlecb = NULL; |
767 | *nData = ctrl; | 767 | *nData = ctrl; |
768 | return 1; | 768 | return 1; |
769 | } | 769 | } |
770 | 770 | ||
771 | /* | 771 | /* |
772 | * FtpAcceptConnection - accept connection from server | 772 | * FtpAcceptConnection - accept connection from server |
773 | * | 773 | * |
774 | * return 1 if successful, 0 otherwise | 774 | * return 1 if successful, 0 otherwise |
775 | */ | 775 | */ |
776 | static int FtpAcceptConnection(netbuf *nData, netbuf *nControl) | 776 | static int FtpAcceptConnection(netbuf *nData, netbuf *nControl) |
777 | { | 777 | { |
778 | int sData; | 778 | int sData; |
779 | struct sockaddr addr; | 779 | struct sockaddr addr; |
780 | unsigned int l; | 780 | unsigned int l; |
781 | int i; | 781 | int i; |
782 | struct timeval tv; | 782 | struct timeval tv; |
783 | fd_set mask; | 783 | fd_set mask; |
784 | int rv; | 784 | int rv = 1; |
785 | 785 | ||
786 | FD_ZERO(&mask); | 786 | FD_ZERO(&mask); |
787 | FD_SET(nControl->handle, &mask); | 787 | FD_SET(nControl->handle, &mask); |
788 | FD_SET(nData->handle, &mask); | 788 | FD_SET(nData->handle, &mask); |
789 | tv.tv_usec = 0; | 789 | tv.tv_usec = 0; |
790 | tv.tv_sec = ACCEPT_TIMEOUT; | 790 | tv.tv_sec = ACCEPT_TIMEOUT; |
791 | printf("<<<<<<<<<<<<<<<<%d\n",ACCEPT_TIMEOUT); | 791 | printf("<<<<<<<<<<<<<<<<%d\n",ACCEPT_TIMEOUT); |
792 | i = nControl->handle; | 792 | i = nControl->handle; |
793 | if (i < nData->handle) | 793 | if (i < nData->handle) |
794 | i = nData->handle; | 794 | i = nData->handle; |
795 | i = select(i+1, &mask, NULL, NULL, &tv); | 795 | i = select(i+1, &mask, NULL, NULL, &tv); |
796 | if (i == -1) | 796 | if (i == -1) |
797 | { | 797 | { |
798 | strncpy(nControl->response, strerror(errno), | 798 | strncpy(nControl->response, strerror(errno), |
799 | sizeof(nControl->response)); | 799 | sizeof(nControl->response)); |
800 | net_close(nData->handle); | 800 | net_close(nData->handle); |
801 | nData->handle = 0; | 801 | nData->handle = 0; |
802 | rv = 0; | 802 | rv = 0; |
803 | } | 803 | } |
804 | else if (i == 0) | 804 | else if (i == 0) |
805 | { | 805 | { |
806 | strcpy(nControl->response, "timed out waiting for connection"); | 806 | strcpy(nControl->response, "timed out waiting for connection"); |
807 | net_close(nData->handle); | 807 | net_close(nData->handle); |
808 | nData->handle = 0; | 808 | nData->handle = 0; |
809 | rv = 0; | 809 | rv = 0; |
810 | } | 810 | } |
811 | else | 811 | else |
812 | { | 812 | { |
813 | if (FD_ISSET(nData->handle, &mask)) | 813 | if (FD_ISSET(nData->handle, &mask)) |
814 | { | 814 | { |
815 | l = sizeof(addr); | 815 | l = sizeof(addr); |
816 | sData = accept(nData->handle, &addr, &l); | 816 | sData = accept(nData->handle, &addr, &l); |
817 | i = errno; | 817 | i = errno; |
818 | net_close(nData->handle); | 818 | net_close(nData->handle); |
819 | if (sData > 0) | 819 | if (sData > 0) |
820 | { | 820 | { |
821 | rv = 1; | 821 | rv = 1; |
822 | nData->handle = sData; | 822 | nData->handle = sData; |
823 | } | 823 | } |
824 | else | 824 | else |
825 | { | 825 | { |
826 | strncpy(nControl->response, strerror(i), | 826 | strncpy(nControl->response, strerror(i), |
827 | sizeof(nControl->response)); | 827 | sizeof(nControl->response)); |
828 | nData->handle = 0; | 828 | nData->handle = 0; |
829 | rv = 0; | 829 | rv = 0; |
830 | } | 830 | } |
831 | } | 831 | } |
832 | else if (FD_ISSET(nControl->handle, &mask)) | 832 | else if (FD_ISSET(nControl->handle, &mask)) |
833 | { | 833 | { |
834 | net_close(nData->handle); | 834 | net_close(nData->handle); |
835 | nData->handle = 0; | 835 | nData->handle = 0; |
836 | readresp('2', nControl); | 836 | readresp('2', nControl); |
837 | rv = 0; | 837 | rv = 0; |
838 | } | 838 | } |
839 | } | 839 | } |
840 | return rv; | 840 | return rv; |
841 | } | 841 | } |
842 | 842 | ||
843 | /* | 843 | /* |
844 | * FtpAccess - return a handle for a data stream | 844 | * FtpAccess - return a handle for a data stream |
845 | * | 845 | * |
846 | * return 1 if successful, 0 otherwise | 846 | * return 1 if successful, 0 otherwise |
847 | */ | 847 | */ |
848 | GLOBALDEF int FtpAccess(const char *path, int typ, int mode, netbuf *nControl, | 848 | GLOBALDEF int FtpAccess(const char *path, int typ, int mode, netbuf *nControl, |
849 | netbuf **nData) | 849 | netbuf **nData) |
850 | { | 850 | { |
851 | char buf[256]; | 851 | char buf[256]; |
852 | int dir; | 852 | int dir; |
853 | if ((path == NULL) && | 853 | if ((path == NULL) && |
854 | ((typ == FTPLIB_FILE_WRITE) || (typ == FTPLIB_FILE_READ))) | 854 | ((typ == FTPLIB_FILE_WRITE) || (typ == FTPLIB_FILE_READ))) |
855 | { | 855 | { |
856 | sprintf(nControl->response, | 856 | sprintf(nControl->response, |
857 | "Missing path argument for file transfer\n"); | 857 | "Missing path argument for file transfer\n"); |
858 | return 0; | 858 | return 0; |
859 | } | 859 | } |
860 | sprintf(buf, "TYPE %c", mode); | 860 | sprintf(buf, "TYPE %c", mode); |
861 | if (!FtpSendCmd(buf, '2', nControl)) | 861 | if (!FtpSendCmd(buf, '2', nControl)) |
862 | return 0; | 862 | return 0; |
863 | switch (typ) | 863 | switch (typ) |
864 | { | 864 | { |
865 | case FTPLIB_DIR: | 865 | case FTPLIB_DIR: |
866 | strcpy(buf,"NLST"); | 866 | strcpy(buf,"NLST"); |
867 | dir = FTPLIB_READ; | 867 | dir = FTPLIB_READ; |
868 | break; | 868 | break; |
869 | case FTPLIB_DIR_VERBOSE: | 869 | case FTPLIB_DIR_VERBOSE: |
870 | strcpy(buf,"LIST"); | 870 | strcpy(buf,"LIST"); |
871 | dir = FTPLIB_READ; | 871 | dir = FTPLIB_READ; |
872 | break; | 872 | break; |
873 | case FTPLIB_FILE_READ: | 873 | case FTPLIB_FILE_READ: |
874 | strcpy(buf,"RETR"); | 874 | strcpy(buf,"RETR"); |
875 | dir = FTPLIB_READ; | 875 | dir = FTPLIB_READ; |
876 | break; | 876 | break; |
877 | case FTPLIB_FILE_WRITE: | 877 | case FTPLIB_FILE_WRITE: |
878 | strcpy(buf,"STOR"); | 878 | strcpy(buf,"STOR"); |
879 | dir = FTPLIB_WRITE; | 879 | dir = FTPLIB_WRITE; |
880 | break; | 880 | break; |
881 | default: | 881 | default: |
882 | sprintf(nControl->response, "Invalid open type %d\n", typ); | 882 | sprintf(nControl->response, "Invalid open type %d\n", typ); |
883 | return 0; | 883 | return 0; |
884 | } | 884 | } |
885 | if (path != NULL) | 885 | if (path != NULL) |
886 | { | 886 | { |
887 | int i = strlen(buf); | 887 | int i = strlen(buf); |
888 | buf[i++] = ' '; | 888 | buf[i++] = ' '; |
889 | if ((strlen(path) + i) >= sizeof(buf)) | 889 | if ((strlen(path) + i) >= sizeof(buf)) |
890 | return 0; | 890 | return 0; |
891 | strcpy(&buf[i],path); | 891 | strcpy(&buf[i],path); |
892 | } | 892 | } |
893 | if (FtpOpenPort(nControl, nData, mode, dir) == -1) | 893 | if (FtpOpenPort(nControl, nData, mode, dir) == -1) |
894 | return 0; | 894 | return 0; |
895 | if (!FtpSendCmd(buf, '1', nControl)) | 895 | if (!FtpSendCmd(buf, '1', nControl)) |
896 | { | 896 | { |
897 | FtpClose(*nData); | 897 | FtpClose(*nData); |
898 | *nData = NULL; | 898 | *nData = NULL; |
899 | return 0; | 899 | return 0; |
900 | } | 900 | } |
901 | (*nData)->ctrl = nControl; | 901 | (*nData)->ctrl = nControl; |
902 | nControl->data = *nData; | 902 | nControl->data = *nData; |
903 | if (nControl->cmode == FTPLIB_PORT) | 903 | if (nControl->cmode == FTPLIB_PORT) |
904 | { | 904 | { |
905 | if (!FtpAcceptConnection(*nData,nControl)) | 905 | if (!FtpAcceptConnection(*nData,nControl)) |
906 | { | 906 | { |
907 | FtpClose(*nData); | 907 | FtpClose(*nData); |
908 | *nData = NULL; | 908 | *nData = NULL; |
909 | nControl->data = NULL; | 909 | nControl->data = NULL; |
910 | return 0; | 910 | return 0; |
911 | } | 911 | } |
912 | } | 912 | } |
913 | return 1; | 913 | return 1; |
914 | } | 914 | } |
915 | 915 | ||
916 | /* | 916 | /* |
917 | * FtpRead - read from a data connection | 917 | * FtpRead - read from a data connection |
918 | */ | 918 | */ |
919 | GLOBALDEF int FtpRead(void *buf, int max, netbuf *nData) | 919 | GLOBALDEF int FtpRead(void *buf, int max, netbuf *nData) |
920 | { | 920 | { |
921 | int i; | 921 | int i; |
922 | if (nData->dir != FTPLIB_READ) | 922 | if (nData->dir != FTPLIB_READ) |
923 | return 0; | 923 | return 0; |
924 | if (nData->buf) | 924 | if (nData->buf) |
925 | i = readline(buf, max, nData); | 925 | i = readline(buf, max, nData); |
926 | else | 926 | else |
927 | { | 927 | { |
928 | i = socket_wait(nData); | 928 | i = socket_wait(nData); |
929 | if (i != 1) | 929 | if (i != 1) |
930 | return 0; | 930 | return 0; |
931 | i = net_read(nData->handle, buf, max); | 931 | i = net_read(nData->handle, buf, max); |
932 | } | 932 | } |
933 | if (i == -1) | 933 | if (i == -1) |
934 | return 0; | 934 | return 0; |
935 | nData->xfered += i; | 935 | nData->xfered += i; |
936 | if (nData->idlecb && nData->cbbytes) | 936 | if (nData->idlecb && nData->cbbytes) |
937 | { | 937 | { |
938 | nData->xfered1 += i; | 938 | nData->xfered1 += i; |
939 | if (nData->xfered1 > nData->cbbytes) | 939 | if (nData->xfered1 > nData->cbbytes) |
940 | { | 940 | { |
941 | if (nData->idlecb(nData, nData->xfered, nData->idlearg) == 0) | 941 | if (nData->idlecb(nData, nData->xfered, nData->idlearg) == 0) |
942 | return 0; | 942 | return 0; |
943 | nData->xfered1 = 0; | 943 | nData->xfered1 = 0; |
944 | } | 944 | } |
945 | } | 945 | } |
946 | return i; | 946 | return i; |
947 | } | 947 | } |
948 | 948 | ||
949 | /* | 949 | /* |
950 | * FtpWrite - write to a data connection | 950 | * FtpWrite - write to a data connection |
951 | */ | 951 | */ |
952 | GLOBALDEF int FtpWrite(void *buf, int len, netbuf *nData) | 952 | GLOBALDEF int FtpWrite(void *buf, int len, netbuf *nData) |
953 | { | 953 | { |
954 | int i; | 954 | int i; |
955 | if (nData->dir != FTPLIB_WRITE) | 955 | if (nData->dir != FTPLIB_WRITE) |
956 | return 0; | 956 | return 0; |
957 | if (nData->buf) | 957 | if (nData->buf) |
958 | i = writeline(buf, len, nData); | 958 | i = writeline(buf, len, nData); |
959 | else | 959 | else |
960 | { | 960 | { |
961 | if (socket_wait(nData) < 0) | 961 | if (socket_wait(nData) < 0) |
962 | fprintf(stderr, "FtpWrite: socket_wait failed with %s\n", nData->ctrl->response); | 962 | fprintf(stderr, "FtpWrite: socket_wait failed with %s\n", nData->ctrl->response); |
963 | i = net_write(nData->handle, buf, len); | 963 | i = net_write(nData->handle, buf, len); |
964 | } | 964 | } |
965 | if (i == -1) | 965 | if (i == -1) |
966 | return 0; | 966 | return 0; |
967 | nData->xfered += i; | 967 | nData->xfered += i; |
968 | if (nData->idlecb && nData->cbbytes) | 968 | if (nData->idlecb && nData->cbbytes) |
969 | { | 969 | { |
970 | nData->xfered1 += i; | 970 | nData->xfered1 += i; |
971 | if (nData->xfered1 > nData->cbbytes) | 971 | if (nData->xfered1 > nData->cbbytes) |
972 | { | 972 | { |
973 | nData->idlecb(nData, nData->xfered, nData->idlearg); | 973 | nData->idlecb(nData, nData->xfered, nData->idlearg); |
974 | nData->xfered1 = 0; | 974 | nData->xfered1 = 0; |
975 | } | 975 | } |
976 | } | 976 | } |
diff --git a/noncore/settings/sysinfo/contrib/dhry.c b/noncore/settings/sysinfo/contrib/dhry.c index 07fd1c0..5426157 100644 --- a/noncore/settings/sysinfo/contrib/dhry.c +++ b/noncore/settings/sysinfo/contrib/dhry.c | |||
@@ -383,385 +383,385 @@ double dtime( ) | |||
383 | /* Parsytec GCel timer. */ | 383 | /* Parsytec GCel timer. */ |
384 | /* Provided by: Georg Wambach, gw@informatik.uni-koeln.de */ | 384 | /* Provided by: Georg Wambach, gw@informatik.uni-koeln.de */ |
385 | /***********************************************************/ | 385 | /***********************************************************/ |
386 | #ifdef PARIX | 386 | #ifdef PARIX |
387 | #include <sys/time.h> | 387 | #include <sys/time.h> |
388 | 388 | ||
389 | double dtime() | 389 | double dtime() |
390 | { | 390 | { |
391 | double q; | 391 | double q; |
392 | 392 | ||
393 | q = (double) (TimeNowHigh()) / (double) CLK_TCK_HIGH; | 393 | q = (double) (TimeNowHigh()) / (double) CLK_TCK_HIGH; |
394 | 394 | ||
395 | return q; | 395 | return q; |
396 | } | 396 | } |
397 | #endif | 397 | #endif |
398 | 398 | ||
399 | /************************************************/ | 399 | /************************************************/ |
400 | /* Sun Solaris POSIX dtime() routine */ | 400 | /* Sun Solaris POSIX dtime() routine */ |
401 | /* Provided by: Case Larsen, CTLarsen.lbl.gov */ | 401 | /* Provided by: Case Larsen, CTLarsen.lbl.gov */ |
402 | /************************************************/ | 402 | /************************************************/ |
403 | #ifdef POSIX | 403 | #ifdef POSIX |
404 | #include <sys/time.h> | 404 | #include <sys/time.h> |
405 | #include <sys/resource.h> | 405 | #include <sys/resource.h> |
406 | #include <sys/rusage.h> | 406 | #include <sys/rusage.h> |
407 | 407 | ||
408 | #ifdef __hpux | 408 | #ifdef __hpux |
409 | #include <sys/syscall.h> | 409 | #include <sys/syscall.h> |
410 | #endif | 410 | #endif |
411 | 411 | ||
412 | struct rusage rusage; | 412 | struct rusage rusage; |
413 | 413 | ||
414 | double dtime() | 414 | double dtime() |
415 | { | 415 | { |
416 | double q; | 416 | double q; |
417 | 417 | ||
418 | getrusage(RUSAGE_SELF,&rusage); | 418 | getrusage(RUSAGE_SELF,&rusage); |
419 | 419 | ||
420 | q = (double)(rusage.ru_utime.tv_sec); | 420 | q = (double)(rusage.ru_utime.tv_sec); |
421 | q = q + (double)(rusage.ru_utime.tv_nsec) * 1.0e-09; | 421 | q = q + (double)(rusage.ru_utime.tv_nsec) * 1.0e-09; |
422 | 422 | ||
423 | return q; | 423 | return q; |
424 | } | 424 | } |
425 | #endif | 425 | #endif |
426 | 426 | ||
427 | 427 | ||
428 | /****************************************************/ | 428 | /****************************************************/ |
429 | /* Windows NT (32 bit) dtime() routine */ | 429 | /* Windows NT (32 bit) dtime() routine */ |
430 | /* Provided by: Piers Haken, piersh@microsoft.com */ | 430 | /* Provided by: Piers Haken, piersh@microsoft.com */ |
431 | /****************************************************/ | 431 | /****************************************************/ |
432 | #ifdef WIN32 | 432 | #ifdef WIN32 |
433 | #include <windows.h> | 433 | #include <windows.h> |
434 | 434 | ||
435 | double dtime(void) | 435 | double dtime(void) |
436 | { | 436 | { |
437 | double q; | 437 | double q; |
438 | 438 | ||
439 | q = (double)GetTickCount() * 1.0e-03; | 439 | q = (double)GetTickCount() * 1.0e-03; |
440 | 440 | ||
441 | return q; | 441 | return q; |
442 | } | 442 | } |
443 | #endif | 443 | #endif |
444 | 444 | ||
445 | /*****************************************************/ | 445 | /*****************************************************/ |
446 | /* Time according to POSIX.1 - <J.Pelan@qub.ac.uk> */ | 446 | /* Time according to POSIX.1 - <J.Pelan@qub.ac.uk> */ |
447 | /* Ref: "POSIX Programmer's Guide" O'Reilly & Assoc.*/ | 447 | /* Ref: "POSIX Programmer's Guide" O'Reilly & Assoc.*/ |
448 | /*****************************************************/ | 448 | /*****************************************************/ |
449 | #ifdef POSIX1 | 449 | #ifdef POSIX1 |
450 | #define _POSIX_SOURCE 1 | 450 | #define _POSIX_SOURCE 1 |
451 | #include <unistd.h> | 451 | #include <unistd.h> |
452 | #include <limits.h> | 452 | #include <limits.h> |
453 | #include <sys/times.h> | 453 | #include <sys/times.h> |
454 | 454 | ||
455 | struct tms tms; | 455 | struct tms tms; |
456 | 456 | ||
457 | double dtime() | 457 | double dtime() |
458 | { | 458 | { |
459 | double q; | 459 | double q; |
460 | times(&tms); | 460 | times(&tms); |
461 | q = (double)tms.tms_utime / (double)CLK_TCK; | 461 | q = (double)tms.tms_utime / (double)CLK_TCK; |
462 | return q; | 462 | return q; |
463 | } | 463 | } |
464 | #endif | 464 | #endif |
465 | /* | 465 | /* |
466 | ************************************************************************* | 466 | ************************************************************************* |
467 | * | 467 | * |
468 | * "DHRYSTONE" Benchmark Program | 468 | * "DHRYSTONE" Benchmark Program |
469 | * ----------------------------- | 469 | * ----------------------------- |
470 | * | 470 | * |
471 | * Version: C, Version 2.1 | 471 | * Version: C, Version 2.1 |
472 | * | 472 | * |
473 | * File: dhry_1.c (part 2 of 3) | 473 | * File: dhry_1.c (part 2 of 3) |
474 | * | 474 | * |
475 | * Date: May 25, 1988 | 475 | * Date: May 25, 1988 |
476 | * | 476 | * |
477 | * Author: Reinhold P. Weicker | 477 | * Author: Reinhold P. Weicker |
478 | * | 478 | * |
479 | ************************************************************************* | 479 | ************************************************************************* |
480 | */ | 480 | */ |
481 | 481 | ||
482 | #include <stdio.h> | 482 | #include <stdio.h> |
483 | #include <stdlib.h> | 483 | #include <stdlib.h> |
484 | #include <string.h> | 484 | #include <string.h> |
485 | #include "dhry.h" | 485 | #include "dhry.h" |
486 | 486 | ||
487 | /* Global Variables: */ | 487 | /* Global Variables: */ |
488 | 488 | ||
489 | Rec_Pointer Ptr_Glob, | 489 | Rec_Pointer Ptr_Glob, |
490 | Next_Ptr_Glob; | 490 | Next_Ptr_Glob; |
491 | int Int_Glob; | 491 | int Int_Glob; |
492 | Boolean Bool_Glob; | 492 | Boolean Bool_Glob; |
493 | char Ch_1_Glob, | 493 | char Ch_1_Glob, |
494 | Ch_2_Glob; | 494 | Ch_2_Glob; |
495 | int Arr_1_Glob [50]; | 495 | int Arr_1_Glob [50]; |
496 | int Arr_2_Glob [50] [50]; | 496 | int Arr_2_Glob [50] [50]; |
497 | 497 | ||
498 | char Reg_Define[32] = "Register option selected."; | 498 | char Reg_Define[32] = "Register option selected."; |
499 | 499 | ||
500 | //extern char *malloc (); | 500 | //extern char *malloc (); |
501 | Enumeration Func_1 (); | 501 | Enumeration Func_1 (); |
502 | /* | 502 | /* |
503 | forward declaration necessary since Enumeration may not simply be int | 503 | forward declaration necessary since Enumeration may not simply be int |
504 | */ | 504 | */ |
505 | 505 | ||
506 | #ifndef ROPT | 506 | #ifndef ROPT |
507 | #define REG | 507 | #define REG |
508 | /* REG becomes defined as empty */ | 508 | /* REG becomes defined as empty */ |
509 | /* i.e. no register variables */ | 509 | /* i.e. no register variables */ |
510 | #else | 510 | #else |
511 | #define REG register | 511 | #define REG register |
512 | #endif | 512 | #endif |
513 | 513 | ||
514 | 514 | ||
515 | /* variables for time measurement: */ | 515 | /* variables for time measurement: */ |
516 | 516 | ||
517 | #define Too_Small_Time 2 | 517 | #define Too_Small_Time 2 |
518 | /* Measurements should last at least 2 seconds */ | 518 | /* Measurements should last at least 2 seconds */ |
519 | 519 | ||
520 | double Begin_Time, | 520 | double Begin_Time, |
521 | End_Time, | 521 | End_Time, |
522 | User_Time; | 522 | User_Time; |
523 | 523 | ||
524 | double Microseconds, | 524 | double Microseconds, |
525 | Dhrystones_Per_Second, | 525 | Dhrystones_Per_Second, |
526 | Vax_Mips; | 526 | Vax_Mips; |
527 | 527 | ||
528 | /* end of variables for time measurement */ | 528 | /* end of variables for time measurement */ |
529 | 529 | ||
530 | /**********************************************************************************************/ | 530 | /**********************************************************************************************/ |
531 | 531 | ||
532 | 532 | ||
533 | Proc_1 (Ptr_Val_Par) | 533 | Proc_1 (Ptr_Val_Par) |
534 | /******************/ | 534 | /******************/ |
535 | 535 | ||
536 | REG Rec_Pointer Ptr_Val_Par; | 536 | REG Rec_Pointer Ptr_Val_Par; |
537 | /* executed once */ | 537 | /* executed once */ |
538 | { | 538 | { |
539 | REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp; | 539 | REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp; |
540 | /* == Ptr_Glob_Next */ | 540 | /* == Ptr_Glob_Next */ |
541 | /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */ | 541 | /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */ |
542 | /* corresponds to "rename" in Ada, "with" in Pascal */ | 542 | /* corresponds to "rename" in Ada, "with" in Pascal */ |
543 | 543 | ||
544 | structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob); | 544 | structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob); |
545 | Ptr_Val_Par->variant.var_1.Int_Comp = 5; | 545 | Ptr_Val_Par->variant.var_1.Int_Comp = 5; |
546 | Next_Record->variant.var_1.Int_Comp | 546 | Next_Record->variant.var_1.Int_Comp |
547 | = Ptr_Val_Par->variant.var_1.Int_Comp; | 547 | = Ptr_Val_Par->variant.var_1.Int_Comp; |
548 | Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp; | 548 | Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp; |
549 | Proc_3 (&Next_Record->Ptr_Comp); | 549 | Proc_3 (&Next_Record->Ptr_Comp); |
550 | /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp | 550 | /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp |
551 | == Ptr_Glob->Ptr_Comp */ | 551 | == Ptr_Glob->Ptr_Comp */ |
552 | if (Next_Record->Discr == Ident_1) | 552 | if (Next_Record->Discr == Ident_1) |
553 | /* then, executed */ | 553 | /* then, executed */ |
554 | { | 554 | { |
555 | Next_Record->variant.var_1.Int_Comp = 6; | 555 | Next_Record->variant.var_1.Int_Comp = 6; |
556 | Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp, | 556 | Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp, |
557 | &Next_Record->variant.var_1.Enum_Comp); | 557 | &Next_Record->variant.var_1.Enum_Comp); |
558 | Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp; | 558 | Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp; |
559 | Proc_7 (Next_Record->variant.var_1.Int_Comp, 10, | 559 | Proc_7 (Next_Record->variant.var_1.Int_Comp, 10, |
560 | &Next_Record->variant.var_1.Int_Comp); | 560 | &Next_Record->variant.var_1.Int_Comp); |
561 | } | 561 | } |
562 | else /* not executed */ | 562 | else /* not executed */ |
563 | structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp); | 563 | structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp); |
564 | } /* Proc_1 */ | 564 | } /* Proc_1 */ |
565 | 565 | ||
566 | 566 | ||
567 | Proc_2 (Int_Par_Ref) | 567 | Proc_2 (Int_Par_Ref) |
568 | /******************/ | 568 | /******************/ |
569 | /* executed once */ | 569 | /* executed once */ |
570 | /* *Int_Par_Ref == 1, becomes 4 */ | 570 | /* *Int_Par_Ref == 1, becomes 4 */ |
571 | 571 | ||
572 | One_Fifty *Int_Par_Ref; | 572 | One_Fifty *Int_Par_Ref; |
573 | { | 573 | { |
574 | One_Fifty Int_Loc; | 574 | One_Fifty Int_Loc; |
575 | Enumeration Enum_Loc; | 575 | Enumeration Enum_Loc = Ident_2; |
576 | 576 | ||
577 | Int_Loc = *Int_Par_Ref + 10; | 577 | Int_Loc = *Int_Par_Ref + 10; |
578 | do /* executed once */ | 578 | do /* executed once */ |
579 | if (Ch_1_Glob == 'A') | 579 | if (Ch_1_Glob == 'A') |
580 | /* then, executed */ | 580 | /* then, executed */ |
581 | { | 581 | { |
582 | Int_Loc -= 1; | 582 | Int_Loc -= 1; |
583 | *Int_Par_Ref = Int_Loc - Int_Glob; | 583 | *Int_Par_Ref = Int_Loc - Int_Glob; |
584 | Enum_Loc = Ident_1; | 584 | Enum_Loc = Ident_1; |
585 | } /* if */ | 585 | } /* if */ |
586 | while (Enum_Loc != Ident_1); /* true */ | 586 | while (Enum_Loc != Ident_1); /* true */ |
587 | } /* Proc_2 */ | 587 | } /* Proc_2 */ |
588 | 588 | ||
589 | 589 | ||
590 | Proc_3 (Ptr_Ref_Par) | 590 | Proc_3 (Ptr_Ref_Par) |
591 | /******************/ | 591 | /******************/ |
592 | /* executed once */ | 592 | /* executed once */ |
593 | /* Ptr_Ref_Par becomes Ptr_Glob */ | 593 | /* Ptr_Ref_Par becomes Ptr_Glob */ |
594 | 594 | ||
595 | Rec_Pointer *Ptr_Ref_Par; | 595 | Rec_Pointer *Ptr_Ref_Par; |
596 | 596 | ||
597 | { | 597 | { |
598 | if (Ptr_Glob != Null) | 598 | if (Ptr_Glob != Null) |
599 | /* then, executed */ | 599 | /* then, executed */ |
600 | *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp; | 600 | *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp; |
601 | Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp); | 601 | Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp); |
602 | } /* Proc_3 */ | 602 | } /* Proc_3 */ |
603 | 603 | ||
604 | 604 | ||
605 | Proc_4 () /* without parameters */ | 605 | Proc_4 () /* without parameters */ |
606 | /*******/ | 606 | /*******/ |
607 | /* executed once */ | 607 | /* executed once */ |
608 | { | 608 | { |
609 | Boolean Bool_Loc; | 609 | Boolean Bool_Loc; |
610 | 610 | ||
611 | Bool_Loc = Ch_1_Glob == 'A'; | 611 | Bool_Loc = Ch_1_Glob == 'A'; |
612 | Bool_Glob = Bool_Loc | Bool_Glob; | 612 | Bool_Glob = Bool_Loc | Bool_Glob; |
613 | Ch_2_Glob = 'B'; | 613 | Ch_2_Glob = 'B'; |
614 | } /* Proc_4 */ | 614 | } /* Proc_4 */ |
615 | 615 | ||
616 | 616 | ||
617 | Proc_5 () /* without parameters */ | 617 | Proc_5 () /* without parameters */ |
618 | /*******/ | 618 | /*******/ |
619 | /* executed once */ | 619 | /* executed once */ |
620 | { | 620 | { |
621 | Ch_1_Glob = 'A'; | 621 | Ch_1_Glob = 'A'; |
622 | Bool_Glob = false; | 622 | Bool_Glob = false; |
623 | } /* Proc_5 */ | 623 | } /* Proc_5 */ |
624 | 624 | ||
625 | 625 | ||
626 | /* Procedure for the assignment of structures, */ | 626 | /* Procedure for the assignment of structures, */ |
627 | /* if the C compiler doesn't support this feature */ | 627 | /* if the C compiler doesn't support this feature */ |
628 | #ifdef NOSTRUCTASSIGN | 628 | #ifdef NOSTRUCTASSIGN |
629 | memcpy (d, s, l) | 629 | memcpy (d, s, l) |
630 | register char *d; | 630 | register char *d; |
631 | register char *s; | 631 | register char *s; |
632 | register int l; | 632 | register int l; |
633 | { | 633 | { |
634 | while (l--) *d++ = *s++; | 634 | while (l--) *d++ = *s++; |
635 | } | 635 | } |
636 | #endif | 636 | #endif |
637 | 637 | ||
638 | 638 | ||
639 | Proc_6 (Enum_Val_Par, Enum_Ref_Par) | 639 | Proc_6 (Enum_Val_Par, Enum_Ref_Par) |
640 | /*********************************/ | 640 | /*********************************/ |
641 | /* executed once */ | 641 | /* executed once */ |
642 | /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */ | 642 | /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */ |
643 | 643 | ||
644 | Enumeration Enum_Val_Par; | 644 | Enumeration Enum_Val_Par; |
645 | Enumeration *Enum_Ref_Par; | 645 | Enumeration *Enum_Ref_Par; |
646 | { | 646 | { |
647 | *Enum_Ref_Par = Enum_Val_Par; | 647 | *Enum_Ref_Par = Enum_Val_Par; |
648 | if (! Func_3 (Enum_Val_Par)) | 648 | if (! Func_3 (Enum_Val_Par)) |
649 | /* then, not executed */ | 649 | /* then, not executed */ |
650 | *Enum_Ref_Par = Ident_4; | 650 | *Enum_Ref_Par = Ident_4; |
651 | switch (Enum_Val_Par) | 651 | switch (Enum_Val_Par) |
652 | { | 652 | { |
653 | case Ident_1: | 653 | case Ident_1: |
654 | *Enum_Ref_Par = Ident_1; | 654 | *Enum_Ref_Par = Ident_1; |
655 | break; | 655 | break; |
656 | case Ident_2: | 656 | case Ident_2: |
657 | if (Int_Glob > 100) | 657 | if (Int_Glob > 100) |
658 | /* then */ | 658 | /* then */ |
659 | *Enum_Ref_Par = Ident_1; | 659 | *Enum_Ref_Par = Ident_1; |
660 | else *Enum_Ref_Par = Ident_4; | 660 | else *Enum_Ref_Par = Ident_4; |
661 | break; | 661 | break; |
662 | case Ident_3: /* executed */ | 662 | case Ident_3: /* executed */ |
663 | *Enum_Ref_Par = Ident_2; | 663 | *Enum_Ref_Par = Ident_2; |
664 | break; | 664 | break; |
665 | case Ident_4: break; | 665 | case Ident_4: break; |
666 | case Ident_5: | 666 | case Ident_5: |
667 | *Enum_Ref_Par = Ident_3; | 667 | *Enum_Ref_Par = Ident_3; |
668 | break; | 668 | break; |
669 | } /* switch */ | 669 | } /* switch */ |
670 | } /* Proc_6 */ | 670 | } /* Proc_6 */ |
671 | 671 | ||
672 | 672 | ||
673 | Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref) | 673 | Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref) |
674 | /**********************************************/ | 674 | /**********************************************/ |
675 | /* executed three times */ | 675 | /* executed three times */ |
676 | /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */ | 676 | /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */ |
677 | /* Int_Par_Ref becomes 7 */ | 677 | /* Int_Par_Ref becomes 7 */ |
678 | /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */ | 678 | /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */ |
679 | /* Int_Par_Ref becomes 17 */ | 679 | /* Int_Par_Ref becomes 17 */ |
680 | /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */ | 680 | /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */ |
681 | /* Int_Par_Ref becomes 18 */ | 681 | /* Int_Par_Ref becomes 18 */ |
682 | One_Fifty Int_1_Par_Val; | 682 | One_Fifty Int_1_Par_Val; |
683 | One_Fifty Int_2_Par_Val; | 683 | One_Fifty Int_2_Par_Val; |
684 | One_Fifty *Int_Par_Ref; | 684 | One_Fifty *Int_Par_Ref; |
685 | { | 685 | { |
686 | One_Fifty Int_Loc; | 686 | One_Fifty Int_Loc; |
687 | 687 | ||
688 | Int_Loc = Int_1_Par_Val + 2; | 688 | Int_Loc = Int_1_Par_Val + 2; |
689 | *Int_Par_Ref = Int_2_Par_Val + Int_Loc; | 689 | *Int_Par_Ref = Int_2_Par_Val + Int_Loc; |
690 | } /* Proc_7 */ | 690 | } /* Proc_7 */ |
691 | 691 | ||
692 | 692 | ||
693 | Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val) | 693 | Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val) |
694 | /*********************************************************************/ | 694 | /*********************************************************************/ |
695 | /* executed once */ | 695 | /* executed once */ |
696 | /* Int_Par_Val_1 == 3 */ | 696 | /* Int_Par_Val_1 == 3 */ |
697 | /* Int_Par_Val_2 == 7 */ | 697 | /* Int_Par_Val_2 == 7 */ |
698 | Arr_1_Dim Arr_1_Par_Ref; | 698 | Arr_1_Dim Arr_1_Par_Ref; |
699 | Arr_2_Dim Arr_2_Par_Ref; | 699 | Arr_2_Dim Arr_2_Par_Ref; |
700 | int Int_1_Par_Val; | 700 | int Int_1_Par_Val; |
701 | int Int_2_Par_Val; | 701 | int Int_2_Par_Val; |
702 | { | 702 | { |
703 | REG One_Fifty Int_Index; | 703 | REG One_Fifty Int_Index; |
704 | REG One_Fifty Int_Loc; | 704 | REG One_Fifty Int_Loc; |
705 | 705 | ||
706 | Int_Loc = Int_1_Par_Val + 5; | 706 | Int_Loc = Int_1_Par_Val + 5; |
707 | Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val; | 707 | Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val; |
708 | Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc]; | 708 | Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc]; |
709 | Arr_1_Par_Ref [Int_Loc+30] = Int_Loc; | 709 | Arr_1_Par_Ref [Int_Loc+30] = Int_Loc; |
710 | for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index) | 710 | for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index) |
711 | Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc; | 711 | Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc; |
712 | Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1; | 712 | Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1; |
713 | Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc]; | 713 | Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc]; |
714 | Int_Glob = 5; | 714 | Int_Glob = 5; |
715 | } /* Proc_8 */ | 715 | } /* Proc_8 */ |
716 | 716 | ||
717 | 717 | ||
718 | Enumeration Func_1 (Ch_1_Par_Val, Ch_2_Par_Val) | 718 | Enumeration Func_1 (Ch_1_Par_Val, Ch_2_Par_Val) |
719 | /*************************************************/ | 719 | /*************************************************/ |
720 | /* executed three times */ | 720 | /* executed three times */ |
721 | /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */ | 721 | /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */ |
722 | /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */ | 722 | /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */ |
723 | /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */ | 723 | /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */ |
724 | 724 | ||
725 | Capital_Letter Ch_1_Par_Val; | 725 | Capital_Letter Ch_1_Par_Val; |
726 | Capital_Letter Ch_2_Par_Val; | 726 | Capital_Letter Ch_2_Par_Val; |
727 | { | 727 | { |
728 | Capital_Letter Ch_1_Loc; | 728 | Capital_Letter Ch_1_Loc; |
729 | Capital_Letter Ch_2_Loc; | 729 | Capital_Letter Ch_2_Loc; |
730 | 730 | ||
731 | Ch_1_Loc = Ch_1_Par_Val; | 731 | Ch_1_Loc = Ch_1_Par_Val; |
732 | Ch_2_Loc = Ch_1_Loc; | 732 | Ch_2_Loc = Ch_1_Loc; |
733 | if (Ch_2_Loc != Ch_2_Par_Val) | 733 | if (Ch_2_Loc != Ch_2_Par_Val) |
734 | /* then, executed */ | 734 | /* then, executed */ |
735 | return (Ident_1); | 735 | return (Ident_1); |
736 | else /* not executed */ | 736 | else /* not executed */ |
737 | { | 737 | { |
738 | Ch_1_Glob = Ch_1_Loc; | 738 | Ch_1_Glob = Ch_1_Loc; |
739 | return (Ident_2); | 739 | return (Ident_2); |
740 | } | 740 | } |
741 | } /* Func_1 */ | 741 | } /* Func_1 */ |
742 | 742 | ||
743 | 743 | ||
744 | Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref) | 744 | Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref) |
745 | /*************************************************/ | 745 | /*************************************************/ |
746 | /* executed once */ | 746 | /* executed once */ |
747 | /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */ | 747 | /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */ |
748 | /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */ | 748 | /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */ |
749 | 749 | ||
750 | Str_30 Str_1_Par_Ref; | 750 | Str_30 Str_1_Par_Ref; |
751 | Str_30 Str_2_Par_Ref; | 751 | Str_30 Str_2_Par_Ref; |
752 | { | 752 | { |
753 | REG One_Thirty Int_Loc; | 753 | REG One_Thirty Int_Loc; |
754 | Capital_Letter Ch_Loc; | 754 | Capital_Letter Ch_Loc; |
755 | 755 | ||
756 | Int_Loc = 2; | 756 | Int_Loc = 2; |
757 | while (Int_Loc <= 2) /* loop body executed once */ | 757 | while (Int_Loc <= 2) /* loop body executed once */ |
758 | if (Func_1 (Str_1_Par_Ref[Int_Loc], | 758 | if (Func_1 (Str_1_Par_Ref[Int_Loc], |
759 | Str_2_Par_Ref[Int_Loc+1]) == Ident_1) | 759 | Str_2_Par_Ref[Int_Loc+1]) == Ident_1) |
760 | /* then, executed */ | 760 | /* then, executed */ |
761 | { | 761 | { |
762 | Ch_Loc = 'A'; | 762 | Ch_Loc = 'A'; |
763 | Int_Loc += 1; | 763 | Int_Loc += 1; |
764 | } /* if, while */ | 764 | } /* if, while */ |
765 | if (Ch_Loc >= 'W' && Ch_Loc < 'Z') | 765 | if (Ch_Loc >= 'W' && Ch_Loc < 'Z') |
766 | /* then, not executed */ | 766 | /* then, not executed */ |
767 | Int_Loc = 7; | 767 | Int_Loc = 7; |