1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

misc: Add ssh_match_group().

This commit is contained in:
Andreas Schneider
2011-08-22 16:16:34 +02:00
parent 90167f09d3
commit 6c03b7a9c9
3 changed files with 31 additions and 25 deletions

View File

@@ -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: */