From f5c1cf6dd406be0b795f7388617d5469c6a358be Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Wed, 29 Mar 2006 16:33:36 +0000 Subject: New function to for escaped strings from command line for send/quit. Adapted from Sebastian Wiesinger's patch (1292404) git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1365 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/utils.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'plugins/utils.c') diff --git a/plugins/utils.c b/plugins/utils.c index 685a638a..a5245c67 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -727,3 +727,33 @@ char *fperfdata (const char *label, return data; } + +char *np_escaped_string (const char *string) { + char *data; + int i, j=0; + data = strdup(string); + for (i=0; data[i]; i++) { + if (data[i] == '\\') { + switch(data[++i]) { + case 'n': + data[j++] = '\n'; + break; + case 'r': + data[j++] = '\r'; + break; + case 't': + data[j++] = '\t'; + break; + case '\\': + data[j++] = '\\'; + break; + default: + data[j++] = data[i]; + } + } else { + data[j++] = data[i]; + } + } + data[j] = '\0'; + return data; +} -- cgit v1.2.3