@@ -137,7 +137,8 @@ static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc TSRMLS_D
137
137
phpdbg_input_t *arg = emalloc(sizeof(phpdbg_input_t));\
138
138
if (arg) {\
139
139
b[l]=0;\
140
- arg->string = estrndup(b, l);\
140
+ arg->length = l;\
141
+ arg->string = estrndup(b, arg->length);\
141
142
arg->argv=NULL;\
142
143
arg->argc=0;\
143
144
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) /*{{{ */
319
320
}
320
321
} /* }}} */
321
322
323
+ int phpdbg_do_cmd_ex (const phpdbg_command_t * command , phpdbg_input_t * input TSRMLS_DC ) /* {{{ */
324
+ {
325
+ int rc = FAILURE ;
326
+
327
+ if (input -> argc > 0 ) {
328
+ while (command && command -> name && command -> handler ) {
329
+ if (((command -> name_len == input -> argv [0 ]-> length ) &&
330
+ (memcmp (command -> name , input -> argv [0 ]-> string , command -> name_len ) == SUCCESS )) ||
331
+ (command -> alias &&
332
+ (input -> argv [0 ]-> length == 1 ) &&
333
+ (command -> alias == * input -> argv [0 ]-> string ))) {
334
+ if (command -> subs && input -> argc > 1 ) {
335
+ phpdbg_input_t sub ;
336
+
337
+ sub .argc = input -> argc - 1 ;
338
+ sub .argv = & input -> argv [1 ];
339
+
340
+ return phpdbg_do_cmd_ex (command -> subs , & sub TSRMLS_CC );
341
+ }
342
+
343
+ phpdbg_debug (
344
+ "found command %s for %s with %d arguments" ,
345
+ command -> name , input -> argv [0 ]-> string , input -> argc - 1 );
346
+ {
347
+ int arg ;
348
+ for (arg = 1 ; arg < input -> argc ; arg ++ ) {
349
+ phpdbg_debug (
350
+ "\t#%d: [%s=%d]" ,
351
+ arg ,
352
+ input -> argv [arg ]-> string ,
353
+ input -> argv [arg ]-> length );
354
+ }
355
+ }
356
+ break ;
357
+ }
358
+ command ++ ;
359
+ }
360
+ } else {
361
+ /* this should NEVER happen */
362
+ phpdbg_error (
363
+ "No function executed !!" );
364
+ }
365
+
366
+ return rc ;
367
+ } /* }}} */
368
+
322
369
int phpdbg_do_cmd (const phpdbg_command_t * command , char * cmd_line , size_t cmd_len TSRMLS_DC ) /* {{{ */
323
370
{
324
371
int rc = FAILURE ;
0 commit comments