aboutsummaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-22 16:16:34 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-22 16:16:34 +0200
commit6c03b7a9c9831021207e01d51157a9ec79e570dc (patch)
treea2158883f4c1b78c7f5ba68643414456063df14b /src/misc.c
parent90167f09d3c797422a3701be8c576c92de520d8c (diff)
downloadlibssh-6c03b7a9c9831021207e01d51157a9ec79e570dc.tar.gz
libssh-6c03b7a9c9831021207e01d51157a9ec79e570dc.tar.xz
libssh-6c03b7a9c9831021207e01d51157a9ec79e570dc.zip
misc: Add ssh_match_group().
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/misc.c b/src/misc.c
index f3fcf110..c1e6ef2d 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -952,6 +952,33 @@ int ssh_timeout_update(struct ssh_timestamp *ts, int timeout){
ret = timeout - ms;
return ret >= 0 ? ret: 0;
}
+
+
+int ssh_match_group(const char *group, const char *object)
+{
+ const char *a;
+ const char *z;
+
+ z = group;
+ do {
+ a = strchr(z, ',');
+ if (a == NULL) {
+ if (strcmp(z, object) == 0) {
+ return 1;
+ }
+ return 0;
+ } else {
+ if (strncmp(z, object, a - z) == 0) {
+ return 1;
+ }
+ }
+ z = a + 1;
+ } while(1);
+
+ /* not reached */
+ return 0;
+}
+
/** @} */
/* vim: set ts=4 sw=4 et cindent: */