[rkward-cvs] rkward/rkward/scriptbackends common.php,1.1,1.2 phpbackend.cpp,1.6,1.7 phpbackend.h,1.1,1.2

Thomas Friedrichsmeier tfry at users.sourceforge.net
Tue Nov 22 16:15:03 UTC 2005


Update of /cvsroot/rkward/rkward/rkward/scriptbackends
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20651/rkward/scriptbackends

Modified Files:
	common.php phpbackend.cpp phpbackend.h 
Log Message:
Some cleanups in PHP-backend. More to come

Index: common.php
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/scriptbackends/common.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** common.php	18 Aug 2004 12:14:25 -0000	1.1
--- common.php	22 Nov 2005 16:15:01 -0000	1.2
***************
*** 25,54 ****
  
  function getInput ($prompt) {
- 	fflush (STDOUT);
  	fputs (STDOUT, "#RKEND#\n" . $prompt);
! 	$stdin = fopen ('php://stdin', 'r');
  	while (1) {
! 		$inp = fgets ($stdin, 4094);
  		if ($inp != "") {
  			$input .= $inp;
  			$inp = "";
! 			if (substr ($input, -8, 8) != "#RKEND#\n") {
! 				usleep (100);
! 			} else {
! 				fclose ($stdin);
  				return (substr ($input, 0, -8));
  			}
- 		} else {
- 			usleep (1000);
  		}
  	}
  }
  
- fclose (STDIN);
- 
  ini_set ("error_prepend_string", "#RKEND#\nPHP-Error");
  
  while (1) {
! 	include (getInput ("requesting code"));
  }
  ?>
\ No newline at end of file
--- 25,47 ----
  
  function getInput ($prompt) {
  	fputs (STDOUT, "#RKEND#\n" . $prompt);
! 	fflush (STDOUT);
  	while (1) {
! 		$inp = fgets (STDIN, 4096);
  		if ($inp != "") {
  			$input .= $inp;
  			$inp = "";
! 			if (substr ($input, -8, 8) == "#RKEND#\n") {
  				return (substr ($input, 0, -8));
  			}
  		}
  	}
  }
  
  ini_set ("error_prepend_string", "#RKEND#\nPHP-Error");
  
  while (1) {
! 	eval (getInput ("requesting code"));
! 	fflush (STDOUT);
  }
  ?>
\ No newline at end of file

Index: phpbackend.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/scriptbackends/phpbackend.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** phpbackend.h	18 Aug 2004 12:14:25 -0000	1.1
--- phpbackend.h	22 Nov 2005 16:15:01 -0000	1.2
***************
*** 59,66 ****
  /// The string singalling the end of transmission to PHP. TODO: make static
  	QString eot_string;
! /** actually only one piece of data gets requested at a time. However, sometimes it takes a while until we realize (via doneWriting ()) that
! 	the last piece was transmitted ok (we have to keep a write buffer until then). So it may happen, that a new piece of information was requested,
! 	before we have completed the process for the previous one. Hence we use a FIFO stack just like for the commands (though it's handled slightly
! 	differently). */
  	QStringList data_stack;
  /// write buffer for the current command
--- 59,63 ----
  /// The string singalling the end of transmission to PHP. TODO: make static
  	QString eot_string;
! /** actually only one piece of data gets requested at a time. However, sometimes it takes a while until we realize (via doneWriting ()) that the last piece was transmitted ok (we have to keep a write buffer until then). So it may happen, that a new piece of information was requested, before we have completed the process for the previous one. Hence we use a FIFO stack just like for the commands (though it's handled slightly differently). */
  	QStringList data_stack;
  /// write buffer for the current command
***************
*** 71,76 ****
  	
  	struct PHPCommand {
! 	/// the temporary file where the command is stored
! 		KTempFile *file;
  	/// flags attached to this command by the parent
  		int flags;
--- 68,73 ----
  	
  	struct PHPCommand {
! 	/// the command string
! 		QString command;
  	/// flags attached to this command by the parent
  		int flags;

Index: phpbackend.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/scriptbackends/phpbackend.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** phpbackend.cpp	20 Oct 2005 19:45:54 -0000	1.6
--- phpbackend.cpp	22 Nov 2005 16:15:01 -0000	1.7
***************
*** 85,90 ****
  	
  	while (command_stack.count ()) {
- 		command_stack.first ()->file->unlink ();
- 		delete command_stack.first ()->file;
  		delete command_stack.first ();
  		command_stack.pop_front ();
--- 85,88 ----
***************
*** 98,106 ****
  	RK_DO (qDebug ("callFunction %s", function.latin1 ()), PHP, DL_DEBUG);
  
- 	KTempFile *file = new KTempFile ();
- 	*(file->textStream ()) << "<? " << function << " ?>\n";
- 	file->close ();
  	PHPCommand *command = new PHPCommand;
! 	command->file = file;
  	command->flags = flags;
  	command->complete = false;
--- 96,101 ----
  	RK_DO (qDebug ("callFunction %s", function.latin1 ()), PHP, DL_DEBUG);
  
  	PHPCommand *command = new PHPCommand;
! 	command->command = function;
  	command->flags = flags;
  	command->complete = false;
***************
*** 115,120 ****
  	/// clean up previous command if applicable
  		if (command_stack.first ()->complete) {
- 			command_stack.first ()->file->unlink ();
- 			delete command_stack.first ()->file;
  			delete command_stack.first ();
  			command_stack.pop_front ();
--- 110,113 ----
***************
*** 123,128 ****
  		}
  		
! 		RK_DO (qDebug ("submitting PHP code: %s", command_stack.first ()->file->name ().latin1 ()), PHP, DL_DEBUG);
! 		current_command = command_stack.first ()->file->name () + eot_string;
  		php_process->writeStdin (current_command.latin1 (), current_command.length ());
  		busy_writing = doing_command = busy = true;
--- 116,121 ----
  		}
  		
! 		RK_DO (qDebug ("submitting PHP code: %s", command_stack.first ()->command.latin1 ()), PHP, DL_DEBUG);
! 		current_command = command_stack.first ()->command + eot_string;
  		php_process->writeStdin (current_command.latin1 (), current_command.length ());
  		busy_writing = doing_command = busy = true;





More information about the rkward-tracker mailing list