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:
27
src/misc.c
27
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: */
|
||||
|
||||
Reference in New Issue
Block a user