return SUCCESS;
} /* }}} */
+PHPDBG_HELP(register) /* {{{ */
+{
+ phpdbg_help_header();
+ phpdbg_writeln("Register any global function that accepts 0 or 1 arguments for use as a command in phpdbg console");
+ phpdbg_writeln(EMPTY);
+ phpdbg_notice("Examples");
+ phpdbg_writeln("\t%sregister scandir", PROMPT);
+ phpdbg_writeln("\t%sR scandir", PROMPT);
+ phpdbg_writeln("\tWill register the scandir function for use in phpdbg");
+ phpdbg_writeln(EMPTY);
+ phpdbg_writeln("Note: argument will be passed as a string to the function and the return printed to the console");
+ phpdbg_help_footer();
+ return SUCCESS;
+} /* }}} */
+
PHPDBG_HELP(shell) /* {{{ */
{
phpdbg_help_header();
PHPDBG_HELP(quiet);
PHPDBG_HELP(list);
PHPDBG_HELP(oplog);
+PHPDBG_HELP(register);
PHPDBG_HELP(shell);
/**
PHPDBG_COMMAND_D_EX(quiet, "be quiet during execution", 'Q', help_quiet, NULL, 0),
PHPDBG_COMMAND_D_EX(list, "list code gives you quick access to code", 'l', help_list, NULL, 0),
PHPDBG_COMMAND_D_EX(oplog, "keep clutter off the screen by logging oplines", 'O', help_oplog, NULL, 0),
+ PHPDBG_COMMAND_D_EX(register, "register a php function for use as a command", 'R', help_register,NULL, 0),
PHPDBG_COMMAND_D_EX(shell, "execute system commands with direct shell access", '-', help_shell, NULL, 0),
PHPDBG_END_COMMAND
};
while (prompt_command && prompt_command->name) {
phpdbg_writeln(
- "\t%s\t%s", prompt_command->name, prompt_command->tip);
+ " %10s\t%s", prompt_command->name, prompt_command->tip);
++prompt_command;
}
- phpdbg_notice("Helpers Loaded");
+ phpdbg_notice("Help Commands");
while (help_command && help_command->name) {
- phpdbg_writeln("\t%s\t%s", help_command->name, help_command->tip);
+ phpdbg_writeln(" %10s\t%s", help_command->name, help_command->tip);
++help_command;
}
phpdbg_notice("Command Line Options and Flags");
- phpdbg_writeln("\tOption\tExample\t\t\tPurpose");
+ phpdbg_writeln(" Option\tExample\t\t\tPurpose");
phpdbg_writeln(EMPTY);
- phpdbg_writeln("\t-c\t-c/my/php.ini\t\tSet php.ini file to load");
- phpdbg_writeln("\t-d\t-dmemory_limit=4G\tSet a php.ini directive");
- phpdbg_writeln("\t-n\t-N/A\t\t\tDisable default php.ini");
- phpdbg_writeln("\t-e\t-emytest.php\t\tSet execution context");
- phpdbg_writeln("\t-v\tN/A\t\t\tEnable oplog output");
- phpdbg_writeln("\t-s\tN/A\t\t\tEnable stepping");
- phpdbg_writeln("\t-b\tN/A\t\t\tDisable colour");
- phpdbg_writeln("\t-i\t-imy.init\t\tSet .phpdbginit file");
- phpdbg_writeln("\t-I\tN/A\t\t\tIgnore default .phpdbginit");
- phpdbg_writeln("\t-O\t-Omy.oplog\t\tSets oplog output file");
+ phpdbg_writeln(" -c\t-c/my/php.ini\t\tSet php.ini file to load");
+ phpdbg_writeln(" -d\t-dmemory_limit=4G\tSet a php.ini directive");
+ phpdbg_writeln(" -n\t-N/A\t\t\tDisable default php.ini");
+ phpdbg_writeln(" -e\t-emytest.php\t\tSet execution context");
+ phpdbg_writeln(" -v\tN/A\t\t\tEnable oplog output");
+ phpdbg_writeln(" -s\tN/A\t\t\tEnable stepping");
+ phpdbg_writeln(" -b\tN/A\t\t\tDisable colour");
+ phpdbg_writeln(" -i\t-imy.init\t\tSet .phpdbginit file");
+ phpdbg_writeln(" -I\tN/A\t\t\tIgnore default .phpdbginit");
+ phpdbg_writeln(" -O\t-Omy.oplog\t\tSets oplog output file");
phpdbg_help_footer();
} break;
{
size_t cmd_len;
int ret = SUCCESS;
-
+ char *start = NULL;
+
#ifndef HAVE_LIBREADLINE
char cmd[PHPDBG_MAX_CMD];
cmd_len = strlen(cmd) - 1;
#else
char *cmd = NULL;
- const char *start = NULL;
-
+
while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
cmd = readline(PROMPT);
cmd_len = cmd ? strlen(cmd) : 0;
+#endif
start = estrndup(cmd, cmd_len);
-#endif
+
/* trim space from end of input */
while (*cmd && isspace(cmd[cmd_len-1]))
cmd_len--;
ZVAL_STRINGL(&fname, cmd, strlen(cmd), 1);
-
fci.size = sizeof(fci);
fci.function_table = &PHPDBG_G(registered);
fci.function_name = &fname;
if (!EG(in_execution)) {
phpdbg_error("Not running");
}
+ if (start) {
+ efree(start);
+ }
goto out;
}
}
}
#endif
} else {
+ if (start) {
+ efree(start);
+ }
+
if (PHPDBG_G(lcmd)) {
ret = PHPDBG_G(lcmd)->handler(
&PHPDBG_G(lparam) TSRMLS_CC);
goto out;
}
}
+
+ if (start) {
+ efree(start);
+ }
}
out: