mirror of
https://github.com/nmap/nmap.git
synced 2026-11-28 10:30:14 +00:00
Merge d37d285b9c into 4568fbc1b8
This commit is contained in:
commit
56cf381783
3 changed files with 14 additions and 2 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "nmap.h"
|
||||
#include "output.h"
|
||||
#include "nmap_error.h"
|
||||
#include "NmapOps.h"
|
||||
#include "FingerPrintResults.h"
|
||||
|
|
@ -618,7 +619,13 @@ static int l_log_write (lua_State *L)
|
|||
static const char * const ops[] = {"stdout", "stderr", NULL};
|
||||
static const int logs[] = {LOG_STDOUT, LOG_STDERR};
|
||||
int log = logs[luaL_checkoption(L, 1, NULL, ops)];
|
||||
log_write(log, "%s: %s\n", SCRIPT_ENGINE, luaL_checkstring(L, 2));
|
||||
|
||||
size_t message_len;
|
||||
const char *message = luaL_checklstring(L, 2, &message_len);
|
||||
std::string escaped_message =
|
||||
escape_for_screen(std::string(message, message_len));
|
||||
|
||||
log_write(log, "%s: %s\n", SCRIPT_ENGINE, escaped_message.c_str());
|
||||
log_flush(log);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ int print_iflist(void) {
|
|||
|
||||
#ifndef NOLUA
|
||||
/* Escape control characters to make a string safe to display on a terminal. */
|
||||
static std::string escape_for_screen(const std::string s) {
|
||||
std::string escape_for_screen(const std::string s) {
|
||||
std::string r;
|
||||
|
||||
for (unsigned int i = 0; i < s.size(); i++) {
|
||||
|
|
|
|||
5
output.h
5
output.h
|
|
@ -112,6 +112,11 @@ class Target;
|
|||
#include <stdarg.h>
|
||||
#include <string>
|
||||
|
||||
#ifndef NOLUA
|
||||
/* Escape control characters to make a string safe to display on a terminal. */
|
||||
std::string escape_for_screen(const std::string s);
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue