summaryrefslogtreecommitdiffstats
path: root/src/polypcore/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/polypcore/util.c')
-rw-r--r--src/polypcore/util.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/polypcore/util.c b/src/polypcore/util.c
index a53c36bc..2ae94d25 100644
--- a/src/polypcore/util.c
+++ b/src/polypcore/util.c
@@ -1092,12 +1092,28 @@ char *pa_get_fqdn(char *s, size_t l) {
/* Returns nonzero when *s starts with *pfx */
int pa_startswith(const char *s, const char *pfx) {
size_t l;
- assert(s && pfx);
+
+ assert(s);
+ assert(pfx);
+
l = strlen(pfx);
return strlen(s) >= l && strncmp(s, pfx, l) == 0;
}
+/* Returns nonzero when *s ends with *sfx */
+int pa_endswith(const char *s, const char *sfx) {
+ size_t l1, l2;
+
+ assert(s);
+ assert(sfx);
+
+ l1 = strlen(s);
+ l2 = strlen(sfx);
+
+ return l1 >= l2 && strcmp(s+l1-l2, sfx) == 0;
+}
+
/* if fn is null return the polypaudio run time path in s (/tmp/polypaudio)
* if fn is non-null and starts with / return fn in s
* otherwise append fn to the run time path and return it in s */