librpc/wsp: add some helper functions needed to support AQS
authorNoel Power <noel.power@suse.com>
Mon, 17 Oct 2022 13:20:49 +0000 (14:20 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 25 Oct 2023 22:23:38 +0000 (22:23 +0000)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
librpc/wsp/wsp_util.c
librpc/wsp/wsp_util.h

index d2bebc3b92d067a84ef380cff891c51fba3116ed..6b6f358a6f4c04343e67474e5aba11e9c2c44d3e 100644 (file)
@@ -489,3 +489,34 @@ struct wsp_cfullpropspec *get_full_prop(struct wsp_crestriction *restriction)
        }
        return result;
 }
+
+void set_variant_lpwstr(TALLOC_CTX *ctx,
+                       struct wsp_cbasestoragevariant *vvalue,
+                       const char *string_val)
+{
+       vvalue->vtype = VT_LPWSTR;
+       vvalue->vvalue.vt_lpwstr.value = talloc_strdup(ctx, string_val);
+}
+
+static void fill_string_vec(TALLOC_CTX* ctx,
+                               struct wsp_cbasestoragevariant *variant,
+                               const char **strings, uint16_t elems)
+{
+       int i;
+       variant->vvalue.vt_lpwstr_v.vvector_elements = elems;
+       variant->vvalue.vt_lpwstr_v.vvector_data = talloc_zero_array(ctx,
+                                                       struct vt_lpwstr,
+                                                       elems);
+
+       for( i = 0; i < elems; i++ ) {
+               variant->vvalue.vt_lpwstr_v.vvector_data[ i ].value = talloc_strdup(ctx, strings[ i ]);
+       }
+}
+
+void set_variant_lpwstr_vector(TALLOC_CTX *ctx,
+                              struct wsp_cbasestoragevariant *variant,
+                              const char **string_vals, uint32_t elems)
+{
+        variant->vtype = VT_LPWSTR | VT_VECTOR;
+        fill_string_vec(ctx, variant, string_vals, elems);
+}
index 7b208f964254b79bc145729d5b0c2443ec47c8e7..167a6dae51a12fa5079204cee3d688b0c5133255 100644 (file)
@@ -25,6 +25,7 @@
 
 struct safearraybound;
 struct wsp_cfullpropspec;
+struct wsp_cbasestoragevariant;
 struct wsp_crestriction;
 
 struct full_propset_info {
@@ -51,5 +52,11 @@ const struct full_propset_info *get_propset_info_with_guid(
                                                const char *prop_name,
                                                struct GUID *guid);
 
+void set_variant_lpwstr(TALLOC_CTX *ctx,
+                       struct wsp_cbasestoragevariant *vvalue,
+                       const char *string_val);
+void set_variant_lpwstr_vector(TALLOC_CTX *ctx,
+                             struct wsp_cbasestoragevariant *variant,
+                             const char **string_vals, uint32_t elems);
 struct wsp_cfullpropspec *get_full_prop(struct wsp_crestriction *restriction);
 #endif /* __LIBRPC_WSP_UTIL_H__ */