summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-03-29 16:33:36 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2006-03-29 16:33:36 (GMT)
commitf5c1cf6dd406be0b795f7388617d5469c6a358be (patch)
tree841b908d652b621846457a1e46f12c397a315286 /plugins/utils.c
parenta0f387467691292fe62c66e56fbc8476c7ecbb2d (diff)
downloadmonitoring-plugins-f5c1cf6dd406be0b795f7388617d5469c6a358be.tar.gz
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
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 685a638..a5245c6 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -727,3 +727,33 @@ char *fperfdata (const char *label,
727 727
728 return data; 728 return data;
729} 729}
730
731char *np_escaped_string (const char *string) {
732 char *data;
733 int i, j=0;
734 data = strdup(string);
735 for (i=0; data[i]; i++) {
736 if (data[i] == '\\') {
737 switch(data[++i]) {
738 case 'n':
739 data[j++] = '\n';
740 break;
741 case 'r':
742 data[j++] = '\r';
743 break;
744 case 't':
745 data[j++] = '\t';
746 break;
747 case '\\':
748 data[j++] = '\\';
749 break;
750 default:
751 data[j++] = data[i];
752 }
753 } else {
754 data[j++] = data[i];
755 }
756 }
757 data[j] = '\0';
758 return data;
759}