diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-18 11:14:24 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-23 08:31:33 -0500 |
commit | 01171ddb20034578c616d0ba07f0268ab71809da (patch) | |
tree | 7cc945c4d21115ff16fd1ea0689f1158eb290b62 /src/util | |
parent | 355fe74d2eaab2e021d75437a6b997fd24b9c4e5 (diff) | |
download | sssd-01171ddb20034578c616d0ba07f0268ab71809da.tar.gz sssd-01171ddb20034578c616d0ba07f0268ab71809da.tar.bz2 sssd-01171ddb20034578c616d0ba07f0268ab71809da.zip |
Move sized_string declaration to utils
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/util.c | 11 | ||||
-rw-r--r-- | src/util/util.h | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c index f525c915..ff55fdd7 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -598,3 +598,14 @@ sss_escape_ip_address(TALLOC_CTX *mem_ctx, int family, const char *addr) return family == AF_INET6 ? talloc_asprintf(mem_ctx, "[%s]", addr) : talloc_strdup(mem_ctx, addr); } + +/* out->len includes terminating '\0' */ +void to_sized_string(struct sized_string *out, const char *in) +{ + out->str = in; + if (out->str) { + out->len = strlen(out->str) + 1; + } else { + out->len = 0; + } +} diff --git a/src/util/util.h b/src/util/util.h index 5428f0af..30413d9c 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -512,4 +512,12 @@ sss_tc_utf8_str_tolower(TALLOC_CTX *mem_ctx, const char *s); uint8_t * sss_tc_utf8_tolower(TALLOC_CTX *mem_ctx, const uint8_t *s, size_t len, size_t *_nlen); +/* len includes terminating '\0' */ +struct sized_string { + const char *str; + size_t len; +}; + +void to_sized_string(struct sized_string *out, const char *in); + #endif /* __SSSD_UTIL_H__ */ |