diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2002-01-26 12:04:32 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2002-01-26 12:04:32 +0100 |
commit | 503c803b8d97e7997bc2a5c42eb6a2014d013528 (patch) | |
tree | c58f7f220f0d54e87dbf028a74e6cf1975ad95b4 /tools.c | |
parent | fe7b03d6b5ecc1e3fbb2804fe179669f8f111c7a (diff) | |
download | vdr-503c803b8d97e7997bc2a5c42eb6a2014d013528.tar.gz vdr-503c803b8d97e7997bc2a5c42eb6a2014d013528.tar.bz2 |
Fixed handling file names that contain single quotes or dollar signs in calls to external commands
Diffstat (limited to 'tools.c')
-rw-r--r-- | tools.c | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.51 2002/01/20 15:43:35 kls Exp $ + * $Id: tools.c 1.52 2002/01/26 12:04:32 kls Exp $ */ #include "tools.h" @@ -136,6 +136,29 @@ char *compactspace(char *s) return s; } +const char *strescape(const char *s, const char *chars) +{ + static char *buffer = NULL; + const char *p = s; + char *t = NULL; + while (*p) { + if (strchr(chars, *p)) { + if (!t) { + buffer = (char *)realloc(buffer, 2 * strlen(s) + 1); + t = buffer + (p - s); + s = strcpy(buffer, s); + } + *t++ = '\\'; + } + if (t) + *t++ = *p; + p++; + } + if (t) + *t = 0; + return s; +} + bool startswith(const char *s, const char *p) { while (*p) { |