summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-02-21 23:34:50 +0000
committerLennart Poettering <lennart@poettering.net>2006-02-21 23:34:50 +0000
commit6169bd81aa405a4ef2632b6ceb26a7225118f7d9 (patch)
tree8aca83e1198cae9a90b3f883d8584065dcf932f8 /src
parent13b421327483e6f97e5c6541815195f13778dbf2 (diff)
add new utility function pa_endswith()
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@555 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src')
-rw-r--r--src/polypcore/util.c18
-rw-r--r--src/polypcore/util.h1
2 files changed, 18 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 */
diff --git a/src/polypcore/util.h b/src/polypcore/util.h
index 14f763a3..af4e14c8 100644
--- a/src/polypcore/util.h
+++ b/src/polypcore/util.h
@@ -88,6 +88,7 @@ char *pa_hexstr(const uint8_t* d, size_t dlength, char *s, size_t slength);
size_t pa_parsehex(const char *p, uint8_t *d, size_t dlength);
int pa_startswith(const char *s, const char *pfx);
+int pa_endswith(const char *s, const char *sfx);
char *pa_runtime_path(const char *fn, char *s, size_t l);