- Timestamp:
- 2012-04-26T10:24:32+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/tdb-edit/trunk/src/bin/script/TDBServer.pl
r25455 r25477 77 77 # Globally available - but once set these are read-only - so locking isn't 78 78 # an issue 79 my $use_harness = 1;79 my $use_harness = 0; 80 80 my $tdbexe = 'tdbcli'; 81 81 my $parent_pid = 0; … … 404 404 # form <database>:<key>:<value> 405 405 # where: database is [d]oc, [i]ndex, or [s]rc 406 elsif ($data =~ /^([dis]):\[( [^\]]+)\]([+?\-])(.+)$/s)406 elsif ($data =~ /^([dis]):\[(.+?)\]([\+\?\-]?)(.*)$/s) 407 407 { 408 408 my $database = $1; 409 409 my $key = $2; 410 my $action = $3 410 my $action = $3; 411 # by default we add for backwards compatibility 412 if (!defined $action || $action eq '') 413 { 414 #rint STDERR "Warning! Detected request without action (#" . $the_count . ") - assuming add/update.\n"; 415 $action = '+'; 416 } 411 417 my $payload = $4; 418 $payload =~ s/^\s+|\s+$//g; 419 &debugPrint($the_count, $tid, 'PARSED', 'database=' . $database . ', key=' . $key . ', action=' . $action . ', payload=' . $payload); 412 420 # Build path to database file 413 421 my $tdb_path = ''; … … 472 480 elsif ($action eq '?') 473 481 { 474 my $command1 = 'tdbget "' . $tdb_path . '" "' . $key . '"'; 475 &debugPrint($the_count, $tid, 'TDBGET', 'Command: ' . $command1); 476 my $result = `$command1`; 477 &debugPrint($the_count, $tid, 'TDBGET', 'Result: ' . $result); 482 my $command_name = ''; 483 my $command1 = ''; 484 # Special case for retrieve all keys (indicated by *) 485 if ($key eq '*') 486 { 487 $command_name = 'TDBKEYS'; 488 $command1 = 'tdbkeys "' . $tdb_path . '"'; 489 } 490 else 491 { 492 $command_name = 'TDBGET'; 493 $command1 = 'tdbget "' . $tdb_path . '" "' . $key . '"'; 494 } 495 &debugPrint($the_count, $tid, $command_name, 'Command: ' . $command1); 496 $result = `$command1`; 497 &debugPrint($the_count, $tid, $command_name, 'Result: ' . $result); 478 498 if ($result =~ /-{70}/) 479 499 { … … 484 504 elsif ($action eq '+' || $action eq '-') 485 505 { 486 my $command2 = 'txt2tdb "' . $tdb_path . '" -append';506 my $command2 = 'txt2tdb -append "' . $tdb_path . '"'; 487 507 &debugPrint($the_count, $tid, 'TXT2TDB', 'Command: ' . $command2); 488 508 open(my $infodb_handle, '| ' . $command2) or die("Error! Failed to open pipe to TXT2TDB\n"); … … 499 519 else 500 520 { 501 die("Error! Unknown action: " . $action . "\n");521 print STDERR "Warning! Request " . $the_count . " asked for unknown action '" . $action . "' - Ignoring!\n"; 502 522 } 503 523 }
Note:
See TracChangeset
for help on using the changeset viewer.