const char *empty_list[] = { NULL };
const char **null_list = NULL;
- result = str_list_copy(tctx, list);
+ result = (const char **)str_list_copy(tctx, list);
torture_assert_int_equal(tctx, str_list_length(result), 2, "list length");
torture_assert_str_equal(tctx, result[0], "foo", "element 0");
torture_assert_str_equal(tctx, result[1], "bar", "element 1");
torture_assert_str_equal(tctx, result[2], NULL, "element 2");
- result = str_list_copy(tctx, empty_list);
+ result = (const char **)str_list_copy(tctx, empty_list);
torture_assert_int_equal(tctx, str_list_length(result), 0, "list length");
torture_assert_str_equal(tctx, result[0], NULL, "element 0");
- result = str_list_copy(tctx, null_list);
+ result = (const char **)str_list_copy(tctx, null_list);
torture_assert(tctx, result == NULL, "result NULL");
return true;
#ifndef _SAMBA_UTIL_H_
#define _SAMBA_UTIL_H_
+#include "lib/charset/charset.h"
#include "../lib/util/attr.h"
-#include "charset/charset.h"
-
/* for TALLOC_CTX */
#include <talloc.h>
separator list. The separator list must contain characters less than
or equal to 0x2f for this to work correctly on multi-byte strings
*/
-_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
+_PUBLIC_ char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
/**
* build a null terminated list of strings from an argv-like input string
/**
return the number of elements in a string list
*/
-_PUBLIC_ size_t str_list_length(const char **list);
+_PUBLIC_ size_t str_list_length(const char * const *list);
/**
copy a string list
*/
-_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list);
+_PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list);
/**
Return true if all the elements of the list match exactly.
#include "includes.h"
#include "system/locale.h"
+#undef strcasecmp
+
/**
* @file
* @brief String list manipulation
separator list. The separator list must contain characters less than
or equal to 0x2f for this to work correctly on multi-byte strings
*/
-_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
+_PUBLIC_ char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
{
int num_elements = 0;
- const char **ret = NULL;
+ char **ret = NULL;
if (sep == NULL) {
sep = LIST_SEP;
}
- ret = talloc_array(mem_ctx, const char *, 1);
+ ret = talloc_array(mem_ctx, char *, 1);
if (ret == NULL) {
return NULL;
}
while (string && *string) {
size_t len = strcspn(string, sep);
- const char **ret2;
+ char **ret2;
if (len == 0) {
string += strspn(string, sep);
continue;
}
- ret2 = talloc_realloc(mem_ctx, ret, const char *, num_elements+2);
+ ret2 = talloc_realloc(mem_ctx, ret, char *, num_elements+2);
if (ret2 == NULL) {
talloc_free(ret);
return NULL;
/**
copy a string list
*/
-_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list)
+_PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list)
{
int i;
- const char **ret;
+ char **ret;
if (list == NULL)
return NULL;
- ret = talloc_array(mem_ctx, const char *, str_list_length(list)+1);
+ ret = talloc_array(mem_ctx, char *, str_list_length(list)+1);
if (ret == NULL)
return NULL;
if (state->io == NULL) goto failed;
state->wins_port = io->in.wins_port;
- state->wins_servers = str_list_copy(state, io->in.wins_servers);
+ state->wins_servers = (const char **)str_list_copy(state, io->in.wins_servers);
if (state->wins_servers == NULL ||
state->wins_servers[0] == NULL) goto failed;
- state->addresses = str_list_copy(state, io->in.addresses);
+ state->addresses = (const char **)str_list_copy(state, io->in.addresses);
if (state->addresses == NULL ||
state->addresses[0] == NULL) goto failed;
if (state->io == NULL) goto failed;
state->wins_port = io->in.wins_port;
- state->wins_servers = str_list_copy(state, io->in.wins_servers);
+ state->wins_servers = (const char **)str_list_copy(state, io->in.wins_servers);
if (state->wins_servers == NULL ||
state->wins_servers[0] == NULL) goto failed;
- state->addresses = str_list_copy(state, io->in.addresses);
+ state->addresses = (const char **)str_list_copy(state, io->in.addresses);
if (state->addresses == NULL ||
state->addresses[0] == NULL) goto failed;
../lib/util/time.o \
lib/ufc.o lib/genrand.o lib/username.o \
lib/util_pw.o lib/access.o lib/smbrun.o \
- lib/bitmap.o ../lib/crypto/crc32.o lib/dprintf.o \
- ../lib/util/xfile.o lib/wins_srv.o $(UTIL_REG_OBJ) \
+ lib/bitmap.o ../lib/crypto/crc32.o lib/dprintf.o $(UTIL_REG_OBJ) \
+ ../lib/util/xfile.o ../lib/util/util_strlist.o lib/wins_srv.o \
lib/util_str.o lib/clobber.o lib/util_sid.o lib/util_uuid.o \
lib/util_unistr.o lib/util_file.o lib/data_blob.o \
lib/util.o lib/util_sock.o lib/sock_exec.o lib/util_sec.o \
NTSTATUS nt_status;
if (lp_auth_methods()
- && !str_list_copy(talloc_tos(), &auth_method_list,
- lp_auth_methods())) {
+ && !(auth_method_list = str_list_copy(talloc_tos(),
+ lp_auth_methods()))) {
return NT_STATUS_NO_MEMORY;
}
char *binary_string(char *buf, int len);
int fstr_sprintf(fstring s, const char *fmt, ...);
char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
-bool str_list_copy(TALLOC_CTX *mem_ctx, char ***dest, const char **src);
+char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list);
bool str_list_compare(char **list1, char **list2);
-int str_list_count( const char **list );
+size_t str_list_length( const char **list );
bool str_list_sub_basic( char **list, const char *smb_name,
const char *domain_name );
bool str_list_substitute(char **list, const char *pattern, const char *insert);
#define S_LIST_ABS 16 /* List Allocation Block Size */
-char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
-{
- char **list;
- const char *str;
- char *s;
- int num, lsize;
- char *tok;
-
- if (!string || !*string)
- return NULL;
-
- list = TALLOC_ARRAY(mem_ctx, char *, S_LIST_ABS+1);
- if (list == NULL) {
- return NULL;
- }
- lsize = S_LIST_ABS;
-
- s = talloc_strdup(list, string);
- if (s == NULL) {
- DEBUG(0,("str_list_make: Unable to allocate memory"));
- TALLOC_FREE(list);
- return NULL;
- }
- if (!sep) sep = LIST_SEP;
-
- num = 0;
- str = s;
-
- while (next_token_talloc(list, &str, &tok, sep)) {
-
- if (num == lsize) {
- char **tmp;
-
- lsize += S_LIST_ABS;
-
- tmp = TALLOC_REALLOC_ARRAY(mem_ctx, list, char *,
- lsize + 1);
- if (tmp == NULL) {
- DEBUG(0,("str_list_make: "
- "Unable to allocate memory"));
- TALLOC_FREE(list);
- return NULL;
- }
-
- list = tmp;
-
- memset (&list[num], 0,
- ((sizeof(char**)) * (S_LIST_ABS +1)));
- }
-
- list[num] = tok;
- num += 1;
- }
-
- list[num] = NULL;
-
- TALLOC_FREE(s);
- return list;
-}
-
-bool str_list_copy(TALLOC_CTX *mem_ctx, char ***dest, const char **src)
-{
- char **list;
- int i, num;
-
- *dest = NULL;
- if (!src)
- return false;
-
- num = 0;
- while (src[num] != NULL) {
- num += 1;
- }
-
- list = TALLOC_ARRAY(mem_ctx, char *, num+1);
- if (list == NULL) {
- return false;
- }
-
- for (i=0; i<num; i++) {
- list[i] = talloc_strdup(list, src[i]);
- if (list[i] == NULL) {
- TALLOC_FREE(list);
- return false;
- }
- }
- list[i] = NULL;
- *dest = list;
- return true;
-}
-
/**
* Return true if all the elements of the list match exactly.
**/
return true;
}
-/******************************************************************************
- *****************************************************************************/
-
-int str_list_count( const char **list )
-{
- int i = 0;
-
- if ( ! list )
- return 0;
-
- /* count the number of list members */
-
- for ( i=0; *list; i++, list++ );
-
- return i;
-}
/******************************************************************************
version of standard_sub_basic() for string lists; uses talloc_sub_basic()
else {
/* This would be the utf8-encoded version...*/
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
- if (!(str_list_copy(talloc_tos(), &search_attrs, attrs))) {
+ if (!(search_attrs = str_list_copy(talloc_tos(), attrs))) {
rc = LDAP_NO_MEMORY;
goto done;
}
else {
/* This would be the utf8-encoded version...*/
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
- if (!(str_list_copy(talloc_tos(), &search_attrs, attrs)))
+ if (!(search_attrs = str_list_copy(talloc_tos(), attrs)))
{
DEBUG(1,("ads_do_search: str_list_copy() failed!"));
rc = LDAP_NO_MEMORY;
bool init_service_op_table( void )
{
const char **service_list = lp_svcctl_list();
- int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_count( service_list );
+ int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_length( service_list );
int i;
if ( !(svcctl_ops = TALLOC_ARRAY( NULL, struct service_control_op, num_services+1)) ) {
ret = True;
if (lp_invalid_users(snum)) {
- str_list_copy(talloc_tos(), &invalid, lp_invalid_users(snum));
+ invalid = str_list_copy(talloc_tos(), lp_invalid_users(snum));
if (invalid &&
str_list_substitute(invalid, "%S", lp_servicename(snum))) {
TALLOC_FREE(invalid);
if (ret && lp_valid_users(snum)) {
- str_list_copy(talloc_tos(), &valid, lp_valid_users(snum));
+ valid = str_list_copy(talloc_tos(), lp_valid_users(snum));
if ( valid &&
str_list_substitute(valid, "%S", lp_servicename(snum)) ) {
if (logon_workstation && workstation_list && *workstation_list) {
bool invalid_ws = true;
int i;
- const char **workstations = str_list_make(mem_ctx, workstation_list, ",");
+ const char **workstations = (const char **)str_list_make(mem_ctx, workstation_list, ",");
for (i = 0; workstations && workstations[i]; i++) {
DEBUG(10,("sam_account_ok: checking for workstation match '%s' and '%s'\n",
****************************************************************************/
static int process_command_string(struct smbclient_context *ctx, const char *cmd)
{
- const char **lines;
+ char **lines;
int i, rc = 0;
lines = str_list_make(NULL, cmd, ";");
return NULL;
}
- split_realm = str_list_make(tmp_ctx, dns_domain, ".");
+ split_realm = (const char **)str_list_make(tmp_ctx, dns_domain, ".");
if (!split_realm) {
talloc_free(tmp_ctx);
return NULL;
bool resolve_context_add_wins_method(struct resolve_context *ctx, const char **address_list, struct interface *ifaces, uint16_t nbt_port, int nbt_timeout)
{
struct resolve_wins_data *wins_data = talloc(ctx, struct resolve_wins_data);
- wins_data->address_list = str_list_copy(wins_data, address_list);
+ wins_data->address_list = (const char **)str_list_copy(wins_data, address_list);
wins_data->ifaces = talloc_reference(wins_data, ifaces);
wins_data->nbt_port = nbt_port;
wins_data->nbt_timeout = nbt_timeout;
if (NT_STATUS_IS_OK(status)) {
s = talloc_get_type(c->private_data, struct lookup_state);
- io->out.address = str_list_make(mem_ctx, s->address, NULL);
+ io->out.address = (const char **)str_list_make(mem_ctx, s->address, NULL);
NT_STATUS_HAVE_NO_MEMORY(io->out.address);
}
/* setup a wins name refresh request */
io.in.name = iname->name;
- io.in.wins_servers = str_list_make(tmp_ctx, iname->wins_server, NULL);
+ io.in.wins_servers = (const char **)str_list_make(tmp_ctx, iname->wins_server, NULL);
io.in.wins_port = lp_nbt_port(iface->nbtsrv->task->lp_ctx);
io.in.addresses = nbtd_address_list(iface, tmp_ctx);
io.in.nb_flags = iname->nb_flags;
if (separator == NULL)
separator = LIST_SEP;
- return str_list_make(ctx, p->value, separator);
+ return (const char **)str_list_make(ctx, p->value, separator);
}
int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section)
const char *value = lp_get_parametric(lp_ctx, service, type, option);
if (value != NULL)
- return str_list_make(mem_ctx, value, separator);
+ return (const char **)str_list_make(mem_ctx, value, separator);
return NULL;
}
strupper(*(char **)dest_ptr);
break;
case P_LIST:
- *(const char ***)dest_ptr = str_list_copy(pserviceDest,
+ *(const char ***)dest_ptr = (const char **)str_list_copy(pserviceDest,
*(const char ***)src_ptr);
break;
default:
}
case P_LIST:
- *(const char ***)parm_ptr = str_list_make(mem_ctx,
+ *(const char ***)parm_ptr = (const char **)str_list_make(mem_ctx,
pszParmValue, NULL);
break;
static NTSTATUS remote_op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
{
int i;
- const char **ifaces = str_list_make(dce_ctx, lp_parm_string(dce_ctx->lp_ctx, NULL, "dcerpc_remote", "interfaces"),NULL);
+ const char **ifaces = (const char **)str_list_make(dce_ctx, lp_parm_string(dce_ctx->lp_ctx, NULL, "dcerpc_remote", "interfaces"),NULL);
if (!ifaces) {
DEBUG(3,("remote_op_init_server: no interfaces configured\n"));
torture_comment(tctx, "register the name\n");
io.in.name = *name;
io.in.wins_port = lp_nbt_port(tctx->lp_ctx);
- io.in.wins_servers = str_list_make(tctx, address, NULL);
- io.in.addresses = str_list_make(tctx, myaddress, NULL);
+ io.in.wins_servers = (const char **)str_list_make(tctx, address, NULL);
+ io.in.addresses = (const char **)str_list_make(tctx, myaddress, NULL);
io.in.nb_flags = nb_flags;
io.in.ttl = 300000;
torture_comment(tctx, "refresh the name\n");
refresh.in.name = *name;
refresh.in.wins_port = lp_nbt_port(tctx->lp_ctx);
- refresh.in.wins_servers = str_list_make(tctx, address, NULL);
- refresh.in.addresses = str_list_make(tctx, myaddress, NULL);
+ refresh.in.wins_servers = (const char **)str_list_make(tctx, address, NULL);
+ refresh.in.addresses = (const char **)str_list_make(tctx, myaddress, NULL);
refresh.in.nb_flags = nb_flags;
refresh.in.ttl = 12345;
NTSTATUS wbsrv_samba3_priv_pipe_dir(struct wbsrv_samba3_call *s3call)
{
- char *path = s3call->wbconn->listen_socket->service->priv_socket_path;
+ const char *path = s3call->wbconn->listen_socket->service->priv_socket_path;
s3call->response.result = WINBINDD_OK;
s3call->response.extra_data.data = path;