summaryrefslogtreecommitdiffstats
path: root/jnlib
diff options
context:
space:
mode:
authorMarcus Brinkmann <mb@g10code.com>2007-06-18 22:15:01 +0200
committerMarcus Brinkmann <mb@g10code.com>2007-06-18 22:15:01 +0200
commite47321829dde8fb24d63b42d20047db8028ff227 (patch)
treeef177e4395132ffa15688d8f0bf593823b9a97c3 /jnlib
parent2007-06-18 Marcus Brinkmann <marcus@g10code.de> (diff)
downloadgnupg2-e47321829dde8fb24d63b42d20047db8028ff227.tar.xz
gnupg2-e47321829dde8fb24d63b42d20047db8028ff227.zip
jnlib/
2007-06-18 Marcus Brinkmann <marcus@g10code.de> * stringhelp.h (percent_escape): New prototype. * stringhelp.c (percent_escape): New function. agent/ 2007-06-18 Marcus Brinkmann <marcus@g10code.de> * gpg-agent.c (main): Percent escape pathname in --gpgconf-list output. g10/ 2007-06-18 Marcus Brinkmann <marcus@g10code.de> * gpg.c (gpgconf_list): Percent escape output of --gpgconf-list. scdaemon/ 2007-06-18 Marcus Brinkmann <marcus@g10code.de> * scdaemon.c (main): Percent escape output of --gpgconf-list. sm/ 2007-06-18 Marcus Brinkmann <marcus@g10code.de> * gpgsm.c (main): Percent escape output of --gpgconf-list.
Diffstat (limited to 'jnlib')
-rw-r--r--jnlib/ChangeLog7
-rw-r--r--jnlib/stringhelp.c36
-rw-r--r--jnlib/stringhelp.h5
3 files changed, 45 insertions, 3 deletions
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog
index 81f250791..f98b1a282 100644
--- a/jnlib/ChangeLog
+++ b/jnlib/ChangeLog
@@ -1,3 +1,8 @@
+2007-06-18 Marcus Brinkmann <marcus@g10code.de>
+
+ * stringhelp.h (percent_escape): New prototype.
+ * stringhelp.c (percent_escape): New function.
+
2007-06-11 Werner Koch <wk@g10code.com>
* utf8conv.c (jnlib_iconv_open, jnlib_iconv, jnlib_iconv_close): New.
@@ -470,7 +475,7 @@ Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de>
***********************************************************
Copyright 2000, 2001, 2002, 2003, 2004,
- 2005, 2006 Free Software Foundation, Inc.
+ 2005, 2006, 2007 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
diff --git a/jnlib/stringhelp.c b/jnlib/stringhelp.c
index b7f8b28db..49d91c075 100644
--- a/jnlib/stringhelp.c
+++ b/jnlib/stringhelp.c
@@ -1,6 +1,6 @@
/* stringhelp.c - standard string helper functions
* Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005,
- * 2006 Free Software Foundation, Inc.
+ * 2006, 2007 Free Software Foundation, Inc.
*
* This file is part of JNLIB.
*
@@ -825,3 +825,37 @@ memrchr (const void *buffer, int c, size_t n)
return NULL;
}
#endif /*HAVE_MEMRCHR*/
+
+
+/* Percent-escape the string STR by replacing colons with '%3a'. */
+char *
+percent_escape (const char *str)
+{
+ int i = 0;
+ int j = 0;
+ char *ptr;
+
+ if (!str)
+ return NULL;
+
+ while (str[i])
+ if (str[i++] == ':')
+ j++;
+ ptr = jnlib_xmalloc (i + 2 * j + 1);
+ i = 0;
+ while (*str)
+ {
+ if (*str == ':')
+ {
+ ptr[i++] = '%';
+ ptr[i++] = '3';
+ ptr[i++] = 'a';
+ }
+ else
+ ptr[i++] = *str;
+ str++;
+ }
+ ptr[i] = '\0';
+
+ return ptr;
+}
diff --git a/jnlib/stringhelp.h b/jnlib/stringhelp.h
index 869b0f00e..fdd887bf2 100644
--- a/jnlib/stringhelp.h
+++ b/jnlib/stringhelp.h
@@ -1,6 +1,6 @@
/* stringhelp.h
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
- * 2006 Free Software Foundation, Inc.
+ * 2006, 2007 Free Software Foundation, Inc.
*
* This file is part of JNLIB.
*
@@ -117,5 +117,8 @@ isascii (int c)
#endif
#define STR2(v) STR(v)
+/* Percent-escape the string STR by replacing colons with '%3a'. */
+char *percent_escape (const char *str);
+
#endif /*LIBJNLIB_STRINGHELP_H*/