diff options
author | Stef Walter <stef@thewalter.net> | 2013-07-03 10:38:19 +0200 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2013-07-03 11:49:26 +0200 |
commit | 81431ffd8cbf55175b1b9a9ed130fc67d0d4000b (patch) | |
tree | b6715f32115c537dd71a488048a9241a037024ad /common/path.c | |
parent | 1c4522e5df79bd197feab8448008fc2bf6b4ea2e (diff) |
path: Add p11_path_canon() function
Cleans up a filename with readable characters.
Diffstat (limited to 'common/path.c')
-rw-r--r-- | common/path.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/common/path.c b/common/path.c index 8362765..89d9a67 100644 --- a/common/path.c +++ b/common/path.c @@ -315,3 +315,18 @@ p11_path_prefix (const char *string, strncmp (string, prefix, b) == 0 && is_path_component_or_null (string[b]); } + +void +p11_path_canon (char *name) +{ + static const char *VALID = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_"; + int i; + + return_if_fail (name != NULL); + + for (i = 0; name[i] != '\0'; i++) { + if (strchr (VALID, name[i]) == NULL) + name[i] = '_'; + } +} |