return ctx->ops->create_share(ctx, servicename);
}
+/**
+ * create and set the definition for a new share (service).
+ */
+sbcErr smbconf_create_set_share(struct smbconf_ctx *ctx,
+ const char *servicename,
+ struct smbconf_service *service)
+{
+ if ((servicename != NULL) && smbconf_share_exists(ctx, servicename)) {
+ return SBC_ERR_FILE_EXISTS;
+ }
+
+ return ctx->ops->create_set_share(ctx, servicename, service);
+}
+
/**
* get a definition of a share (service) from configuration.
*/
*/
sbcErr smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename);
+/**
+ * @brief create and set the definition for a new service.
+ *
+ * @param[in] ctx The smbconf context to use.
+ *
+ * @param[in] servicename The name of the service to add.
+ *
+ * @param[in] service The definition for the added service.
+ *
+ * @return SBC_ERR_OK on success, a corresponding sbcErr if an
+ * error occured.
+ */
+sbcErr smbconf_create_set_share(struct smbconf_ctx *ctx,
+ const char *servicename,
+ struct smbconf_service *service);
+
/**
* @brief Get a definition of a share (service) from configuration.
*
char ***share_names);
bool (*share_exists)(struct smbconf_ctx *ctx, const char *service);
sbcErr (*create_share)(struct smbconf_ctx *ctx, const char *service);
+ sbcErr (*create_set_share)(struct smbconf_ctx *ctx,
+ const char *servicename,
+ struct smbconf_service *service);
sbcErr (*get_share)(struct smbconf_ctx *ctx,
TALLOC_CTX *mem_ctx,
const char *servicename,
return SBC_ERR_NOT_SUPPORTED;
}
+/**
+ * create and set the definition for a new share (service).
+ */
+static sbcErr smbconf_txt_create_set_share(struct smbconf_ctx *ctx,
+ const char *servicename,
+ struct smbconf_service *service)
+{
+ return SBC_ERR_NOT_SUPPORTED;
+}
+
/**
* get a definition of a share (service) from configuration.
*/
.get_share_names = smbconf_txt_get_share_names,
.share_exists = smbconf_txt_share_exists,
.create_share = smbconf_txt_create_share,
+ .create_set_share = smbconf_txt_create_set_share,
.get_share = smbconf_txt_get_share,
.delete_share = smbconf_txt_delete_share,
.set_parameter = smbconf_txt_set_parameter,
return err;
}
+/**
+ * create and set the definition for a new share (service).
+ */
+static sbcErr smbconf_reg_create_set_share(struct smbconf_ctx *ctx,
+ const char *servicename,
+ struct smbconf_service *service)
+{
+ sbcErr err;
+ struct registry_key *key = NULL;
+ int i;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+
+ err = smbconf_reg_create_service_key(tmp_ctx, ctx,
+ servicename, &key);
+ if (!SBC_ERROR_IS_OK(err)) {
+ goto done;
+ }
+
+ for (i = 0; i < service->num_params; i++) {
+ err = smbconf_reg_set_value(key, service->param_names[i],
+ service->param_values[i]);
+ if (!SBC_ERROR_IS_OK(err)) {
+ goto done;
+ }
+ }
+
+done:
+ talloc_free(tmp_ctx);
+ return err;
+}
+
/**
* get a definition of a share (service) from configuration.
*/
.get_share_names = smbconf_reg_get_share_names,
.share_exists = smbconf_reg_share_exists,
.create_share = smbconf_reg_create_share,
+ .create_set_share = smbconf_reg_create_set_share,
.get_share = smbconf_reg_get_share,
.delete_share = smbconf_reg_delete_share,
.set_parameter = smbconf_reg_set_parameter,