aboutsummaryrefslogtreecommitdiff
path: root/src/util/strings.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/strings.c')
-rw-r--r--src/util/strings.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/util/strings.c b/src/util/strings.c
index 479c0fcd6..86323bc83 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -1859,11 +1859,18 @@ GNUNET_STRINGS_urlencode (const char *data,
1859 if (0 == (0x80 & *i8)) 1859 if (0 == (0x80 & *i8))
1860 { 1860 {
1861 /* traditional ASCII */ 1861 /* traditional ASCII */
1862 if (isalnum (*i8) || (*i8 == '-') || (*i8 == '_') || (*i8 == '.') || 1862 if ( isalnum (*i8) ||
1863 (*i8 == '~') ) 1863 (*i8 == '-') ||
1864 GNUNET_buffer_write (&buf, (const char*) i8, 1); 1864 (*i8 == '_') ||
1865 (*i8 == '.') ||
1866 (*i8 == '~') )
1867 GNUNET_buffer_write (&buf,
1868 (const char*) i8,
1869 1);
1865 else if (*i8 == ' ') 1870 else if (*i8 == ' ')
1866 GNUNET_buffer_write (&buf, "+", 1); 1871 GNUNET_buffer_write (&buf,
1872 "+",
1873 1);
1867 else 1874 else
1868 GNUNET_buffer_write_fstr (&buf, 1875 GNUNET_buffer_write_fstr (&buf,
1869 "%%%X%X", 1876 "%%%X%X",
@@ -1952,4 +1959,36 @@ GNUNET_STRINGS_urlencode (const char *data,
1952} 1959}
1953 1960
1954 1961
1962/**
1963 * Sometimes we use the binary name to determine which specific
1964 * test to run. In those cases, the string after the last "_"
1965 * in 'argv[0]' specifies a string that determines the configuration
1966 * file or plugin to use.
1967 *
1968 * This function returns the respective substring, taking care
1969 * of issues such as binaries ending in '.exe' on W32.
1970 *
1971 * @param argv0 the name of the binary
1972 * @return string between the last '_' and the '.exe' (or the end of the string),
1973 * NULL if argv0 has no '_'
1974 */
1975char *
1976GNUNET_STRINGS_get_suffix_from_binary_name (const char *argv0)
1977{
1978 const char *ret;
1979 const char *dot;
1980
1981 ret = strrchr (argv0, '_');
1982 if (NULL == ret)
1983 return NULL;
1984 ret++; /* skip underscore */
1985 dot = strchr (ret,
1986 '.');
1987 if (NULL != dot)
1988 return GNUNET_strndup (ret,
1989 dot - ret);
1990 return GNUNET_strdup (ret);
1991}
1992
1993
1955/* end of strings.c */ 1994/* end of strings.c */