diff options
Diffstat (limited to 'common/gvfsutils.c')
-rw-r--r-- | common/gvfsutils.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/common/gvfsutils.c b/common/gvfsutils.c new file mode 100644 index 00000000..87718f30 --- /dev/null +++ b/common/gvfsutils.c @@ -0,0 +1,42 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2014 Ross Lagerwall + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * <http://www.gnu.org/licenses/>. + */ + +#include <config.h> + +#include <string.h> +#include <glib.h> +#include "gvfsutils.h" + +/** + * gvfs_randomize_string: + * @str: the string to randomize + * @len: the length of the string + * + * Takes a string and fills it with @len random chars. + **/ +void +gvfs_randomize_string (char *str, + int len) +{ + int i; + const char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + + for (i = 0; i < len; i++) + str[i] = chars[g_random_int_range (0, strlen(chars))]; +} |