summaryrefslogtreecommitdiff
path: root/src/responder/nss/nsssrv_cmd.c
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2011-12-27 12:51:16 -0500
committerSimo Sorce <simo@redhat.com>2012-01-09 13:29:20 -0500
commit162858f67e8d47a9dd49d04a9f317a0315c44b0e (patch)
treefa85d46cde9b55348302dd9f34cd14e2c8e5f064 /src/responder/nss/nsssrv_cmd.c
parent029e6f1727972ffe31f97c7738a98d0efecb3e15 (diff)
downloadsssd-162858f67e8d47a9dd49d04a9f317a0315c44b0e.tar.gz
sssd-162858f67e8d47a9dd49d04a9f317a0315c44b0e.tar.bz2
sssd-162858f67e8d47a9dd49d04a9f317a0315c44b0e.zip
nsssrv: add string manipulation helper
the sized_string structure makes it easier to keep track of string lengths and makes passing around data more compat and readable.
Diffstat (limited to 'src/responder/nss/nsssrv_cmd.c')
-rw-r--r--src/responder/nss/nsssrv_cmd.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 3bc30ab8..85876d3b 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -28,6 +28,17 @@
#include "db/sysdb.h"
#include <time.h>
+/* 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;
+ }
+}
+
static int nss_cmd_send_error(struct nss_cmd_ctx *cmdctx, int err)
{
struct cli_ctx *cctx = cmdctx->cctx;