From d139f8dd6683d28670976e0c2eb2ba2fe3c1ca23 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 4 Sep 2014 14:05:00 -0700 Subject: [PATCH] rgw: gen rand lowercase string (stl string version) Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_common.cc | 11 +++++++++++ src/rgw/rgw_common.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index b5d2936116550..16458aa4741a6 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -475,6 +475,17 @@ int gen_rand_alphanumeric_lower(CephContext *cct, char *dest, int size) /* size return 0; } +int gen_rand_alphanumeric_lower(CephContext *cct, string *str, int length) +{ + char buf[length + 1]; + int ret = gen_rand_alphanumeric_lower(cct, buf, sizeof(buf)); + if (ret < 0) { + return ret; + } + *str = buf; + return 0; +} + // this is basically a modified base64 charset, url friendly static const char alphanum_table[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 26b8f76ff8d15..02713882b2527 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -189,6 +189,8 @@ extern int gen_rand_alphanumeric(CephContext *cct, char *dest, int size); extern int gen_rand_alphanumeric_lower(CephContext *cct, char *dest, int size); extern int gen_rand_alphanumeric_upper(CephContext *cct, char *dest, int size); +extern int gen_rand_alphanumeric_lower(CephContext *cct, string *str, int length); + enum RGWIntentEvent { DEL_OBJ = 0, DEL_DIR = 1, -- 2.39.5