libwbclient: add wbcAddNamedBlob.
authorGünther Deschner <gd@samba.org>
Wed, 24 Sep 2008 23:31:12 +0000 (01:31 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 10 Oct 2008 13:36:09 +0000 (15:36 +0200)
Guenther

source3/nsswitch/libwbclient/wbc_util.c
source3/nsswitch/libwbclient/wbclient.h

index 5aea8842724bdfe21937b9e3278fdd07db3cb3e2..b4868748aec9d108e1d1412e3ba4463052f0d5a4 100644 (file)
@@ -689,3 +689,48 @@ wbcErr wbcLookupDomainControllerEx(const char *domain,
 done:
        return wbc_status;
 }
+
+/** @brief Initialize a named blob and add to list of blobs
+ *
+ * @param[in,out] num_blobs     Pointer to the number of blobs
+ * @param[in,out] blobs         Pointer to an array of blobs
+ * @param[in]     name          Name of the new named blob
+ * @param[in]     flags         Flags of the new named blob
+ * @param[in]     data          Blob data of new blob
+ * @param[in]     length        Blob data length of new blob
+ *
+ * @return #wbcErr
+ *
+ **/
+
+wbcErr wbcAddNamedBlob(size_t *num_blobs,
+                      struct wbcNamedBlob **blobs,
+                      const char *name,
+                      uint32_t flags,
+                      uint8_t *data,
+                      size_t length)
+{
+       wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+       struct wbcNamedBlob blob;
+
+       *blobs = talloc_realloc(NULL, *blobs, struct wbcNamedBlob,
+                               *(num_blobs)+1);
+       BAIL_ON_PTR_ERROR(*blobs, wbc_status);
+
+       blob.name               = talloc_strdup(*blobs, name);
+       BAIL_ON_PTR_ERROR(blob.name, wbc_status);
+       blob.flags              = flags;
+       blob.blob.length        = length;
+       blob.blob.data          = (uint8_t *)talloc_memdup(*blobs, data, length);
+       BAIL_ON_PTR_ERROR(blob.blob.data, wbc_status);
+
+       (*(blobs))[*num_blobs] = blob;
+       *(num_blobs) += 1;
+
+       wbc_status = WBC_ERR_SUCCESS;
+done:
+       if (!WBC_ERROR_IS_OK(wbc_status) && blobs) {
+               wbcFreeMemory(*blobs);
+       }
+       return wbc_status;
+}
index 5f6e3be9664650bb1a7418aecdd70ace11ab8dfd..5c184ebe46750adf2c9d9825a70c74ec30b5da1b 100644 (file)
@@ -627,6 +627,14 @@ wbcErr wbcResolveWinsByIP(const char *ip, char **name);
  */
 wbcErr wbcCheckTrustCredentials(const char *domain,
                                struct wbcAuthErrorInfo **error);
-
+/*
+ * Helper functions
+ */
+wbcErr wbcAddNamedBlob(size_t *num_blobs,
+                      struct wbcNamedBlob **blobs,
+                      const char *name,
+                      uint32_t flags,
+                      uint8_t *data,
+                      size_t length);
 
 #endif      /* _WBCLIENT_H */