]> granicus.if.org Git - php/commitdiff
debugging new input stuff
authorkrakjoe <joe.watkins@live.co.uk>
Tue, 19 Nov 2013 20:27:23 +0000 (20:27 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Tue, 19 Nov 2013 20:27:23 +0000 (20:27 +0000)
phpdbg_cmd.c
phpdbg_cmd.h
phpdbg_prompt.c

index 227e65932834513c721f87decac13e5a110826f3..8eb38d7e4faa3fe4475a2ae6a437bf54ba84257a 100644 (file)
@@ -137,7 +137,8 @@ static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc TSRMLS_D
        phpdbg_input_t *arg = emalloc(sizeof(phpdbg_input_t));\
     if (arg) {\
        b[l]=0;\
-       arg->string = estrndup(b, l);\
+       arg->length = l;\
+       arg->string = estrndup(b, arg->length);\
        arg->argv=NULL;\
        arg->argc=0;\
        argv = (phpdbg_input_t**) erealloc(argv, sizeof(phpdbg_input_t*) * ((*argc)+1));\
@@ -319,6 +320,52 @@ void phpdbg_destroy_input(phpdbg_input_t **input TSRMLS_DC) /*{{{ */
        }
 } /* }}} */
 
+int phpdbg_do_cmd_ex(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_DC) /* {{{ */
+{
+       int rc = FAILURE;
+
+       if (input->argc > 0) {
+               while (command && command->name && command->handler) {
+                       if (((command->name_len == input->argv[0]->length) && 
+                               (memcmp(command->name, input->argv[0]->string, command->name_len) == SUCCESS)) ||
+                               (command->alias &&
+                               (input->argv[0]->length == 1) && 
+                               (command->alias == *input->argv[0]->string))) {
+                               if (command->subs && input->argc > 1) {
+                                       phpdbg_input_t sub;
+                                       
+                                       sub.argc = input->argc-1;
+                                       sub.argv = &input->argv[1];
+                                       
+                                       return phpdbg_do_cmd_ex(command->subs, &sub TSRMLS_CC);
+                               }
+                               
+                               phpdbg_debug(
+                                       "found command %s for %s with %d arguments", 
+                                       command->name, input->argv[0]->string, input->argc-1);
+                               {
+                                       int arg;
+                                       for (arg=1; arg<input->argc; arg++) {
+                                               phpdbg_debug(
+                                                       "\t#%d: [%s=%d]", 
+                                                       arg, 
+                                                       input->argv[arg]->string,
+                                                       input->argv[arg]->length);
+                                       }
+                               }
+                               break;
+                       }
+                       command++;
+               }
+       } else {
+               /* this should NEVER happen */
+               phpdbg_error(
+                       "No function executed !!");
+       }
+       
+       return rc;
+} /* }}} */
+
 int phpdbg_do_cmd(const phpdbg_command_t *command, char *cmd_line, size_t cmd_len TSRMLS_DC) /* {{{ */
 {
        int rc = FAILURE;
index a8865ced931e4c6199a834536c2a23344a7dbfb3..47ada44902d02b2a2535edf7470ab584ed540530 100644 (file)
@@ -88,6 +88,7 @@ struct _phpdbg_command_t {
  * Command Executor
  */
 phpdbg_input_t* phpdbg_read_input(TSRMLS_D);
+int phpdbg_do_cmd_ex(const phpdbg_command_t*, phpdbg_input_t *input TSRMLS_DC);
 int phpdbg_do_cmd(const phpdbg_command_t*, char*, size_t TSRMLS_DC);
 phpdbg_param_type phpdbg_parse_param(const char*, size_t, phpdbg_param_t* TSRMLS_DC);
 void phpdbg_clear_param(phpdbg_param_t* TSRMLS_DC);
index d5b4bda3e9c2fa5a2ceb260b22716653b147e8c5..bb7dc001e5d84eb0abe601c8c23e0770e9891264 100644 (file)
@@ -973,6 +973,8 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
        
        if (input && input->length > 0L) {
                do {
+                       phpdbg_do_cmd_ex(phpdbg_prompt_commands, input TSRMLS_CC);
+                       
                        switch (ret = phpdbg_do_cmd(phpdbg_prompt_commands, input->string, input->length TSRMLS_CC)) {
                                case FAILURE:
                                        if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {