diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-09-26 18:16:38 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:38:59 -0500 |
commit | 7f7a2d133dc2191e0a08f6f99f3bda914a29ac44 (patch) | |
tree | ba20030594fe9bc580dffc9513b04097104f308b /source4 | |
parent | 01319b8462aa8ebf3b5be4598e7317aa08f40350 (diff) | |
download | samba-7f7a2d133dc2191e0a08f6f99f3bda914a29ac44.tar.gz samba-7f7a2d133dc2191e0a08f6f99f3bda914a29ac44.tar.bz2 samba-7f7a2d133dc2191e0a08f6f99f3bda914a29ac44.zip |
r10517: Get rid of use of next_token() in lib/samba3/
(This used to be commit 811a6e28cca1ba09a95a89c344f4640b3d1dd74e)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/samba3/group.c | 14 | ||||
-rw-r--r-- | source4/lib/samba3/winsdb.c | 44 | ||||
-rwxr-xr-x | source4/script/tests/test_s3upgrade.sh | 6 |
3 files changed, 22 insertions, 42 deletions
diff --git a/source4/lib/samba3/group.c b/source4/lib/samba3/group.c index 220f206e99..78a04b3ff8 100644 --- a/source4/lib/samba3/group.c +++ b/source4/lib/samba3/group.c @@ -24,7 +24,6 @@ #include "lib/samba3/samba3.h" #include "lib/tdb/include/tdbutil.h" #include "system/filesys.h" -#include "pstring.h" #define DATABASE_VERSION_V1 1 /* native byte format. */ #define DATABASE_VERSION_V2 2 /* le format. */ @@ -108,8 +107,8 @@ NTSTATUS samba3_read_grouptdb(const char *file, TALLOC_CTX *ctx, struct samba3_g } else if (strncmp(kbuf.dptr, MEMBEROF_PREFIX, strlen(MEMBEROF_PREFIX)) == 0) { struct samba3_alias alias; - pstring alias_string; - const char *p; + char **member_strlist; + int i; dbuf = tdb_fetch(tdb, kbuf); if (!dbuf.dptr) @@ -119,15 +118,16 @@ NTSTATUS samba3_read_grouptdb(const char *file, TALLOC_CTX *ctx, struct samba3_g alias.member_count = 0; alias.members = NULL; - p = dbuf.dptr; - while (next_token(&p, alias_string, " ", sizeof(alias_string))) { + member_strlist = str_list_make_shell(ctx, dbuf.dptr, " "); + for (i = 0; member_strlist[i]; i++) { alias.members = talloc_realloc(ctx, alias.members, struct dom_sid *, alias.member_count+1); - alias.members[alias.member_count] = dom_sid_parse_talloc(ctx, alias_string); + alias.members[alias.member_count] = dom_sid_parse_talloc(ctx, member_strlist[i]); alias.member_count++; - } + talloc_free(member_strlist); + db->aliases = talloc_realloc(ctx, db->aliases, struct samba3_alias, db->alias_count+1); db->aliases[db->alias_count] = alias; db->alias_count++; diff --git a/source4/lib/samba3/winsdb.c b/source4/lib/samba3/winsdb.c index f543ebd3f0..cd052ca437 100644 --- a/source4/lib/samba3/winsdb.c +++ b/source4/lib/samba3/winsdb.c @@ -23,7 +23,6 @@ #include "includes.h" #include "system/filesys.h" -#include "pstring.h" #include "lib/samba3/samba3.h" #define WINS_VERSION 1 @@ -44,11 +43,9 @@ NTSTATUS samba3_read_winsdb( const char *fn, TALLOC_CTX *ctx, struct samba3_wins while (!x_feof(fp)) { struct samba3_winsdb_entry entry; - pstring name_str, ip_str, ttl_str, nb_flags_str; - const char *ptr; + const char *name_str, *ttl_str, *nb_flags_str; + const char **args; char *p; - BOOL got_token; - BOOL was_ip; int i; unsigned int hash; int version; @@ -77,7 +74,7 @@ NTSTATUS samba3_read_winsdb( const char *fn, TALLOC_CTX *ctx, struct samba3_wins continue; } - ptr = line; + args = str_list_make_shell(ctx, line, NULL); /* * Now we handle multiple IP addresses per name we need @@ -86,13 +83,15 @@ NTSTATUS samba3_read_winsdb( const char *fn, TALLOC_CTX *ctx, struct samba3_wins * time to actually parse them into the ip_list array. */ - if (!next_token(&ptr,name_str,NULL,sizeof(name_str))) { + name_str = args[0]; + if (!name_str) { DEBUG(0,("initialise_wins: Failed to parse name when parsing line %s\n", line )); SAFE_FREE(line); continue; } - if (!next_token(&ptr,ttl_str,NULL,sizeof(ttl_str))) { + ttl_str = args[1]; + if (!ttl_str) { DEBUG(0,("initialise_wins: Failed to parse time to live when parsing line %s\n", line )); SAFE_FREE(line); continue; @@ -102,15 +101,7 @@ NTSTATUS samba3_read_winsdb( const char *fn, TALLOC_CTX *ctx, struct samba3_wins * Determine the number of IP addresses per line. */ entry.ip_count = 0; - do { - got_token = next_token(&ptr,ip_str,NULL,sizeof(ip_str)); - was_ip = False; - - if(got_token && strchr(ip_str, '.')) { - entry.ip_count++; - was_ip = True; - } - } while( got_token && was_ip); + for (i = 2; args[i] && strchr(args[i], '.'); i++) entry.ip_count++; if(entry.ip_count == 0) { DEBUG(0,("initialise_wins: Missing IP address when parsing line %s\n", line )); @@ -118,12 +109,6 @@ NTSTATUS samba3_read_winsdb( const char *fn, TALLOC_CTX *ctx, struct samba3_wins continue; } - if(!got_token) { - DEBUG(0,("initialise_wins: Missing nb_flags when parsing line %s\n", line )); - SAFE_FREE(line); - continue; - } - /* Allocate the space for the ip_list. */ if((entry.ips = talloc_array ( ctx, struct ipv4_addr, entry.ip_count)) == NULL) { DEBUG(0,("initialise_wins: Malloc fail !\n")); @@ -132,14 +117,12 @@ NTSTATUS samba3_read_winsdb( const char *fn, TALLOC_CTX *ctx, struct samba3_wins } /* Reset and re-parse the line. */ - ptr = line; - next_token(&ptr,name_str,NULL,sizeof(name_str)); - next_token(&ptr,ttl_str,NULL,sizeof(ttl_str)); for(i = 0; i < entry.ip_count; i++) { - next_token(&ptr, ip_str, NULL, sizeof(ip_str)); - entry.ips[i] = interpret_addr2(ip_str); + entry.ips[i] = interpret_addr2(args[i+2]); } - next_token(&ptr,nb_flags_str,NULL, sizeof(nb_flags_str)); + nb_flags_str = args[2 + entry.ip_count]; + + SMB_ASSERT(nb_flags_str); /* * Deal with SELF or REGISTER name encoding. Default is REGISTER @@ -153,9 +136,6 @@ NTSTATUS samba3_read_winsdb( const char *fn, TALLOC_CTX *ctx, struct samba3_wins continue; } - if(nb_flags_str[strlen(nb_flags_str)-1] == 'R') - nb_flags_str[strlen(nb_flags_str)-1] = '\0'; - /* Netbios name. # divides the name from the type (hex): netbios#xx */ entry.name = talloc_strdup(ctx, name_str); diff --git a/source4/script/tests/test_s3upgrade.sh b/source4/script/tests/test_s3upgrade.sh index d981d5410a..4419e37d80 100755 --- a/source4/script/tests/test_s3upgrade.sh +++ b/source4/script/tests/test_s3upgrade.sh @@ -10,6 +10,6 @@ fi mkdir -p $PREFIX rm -f $PREFIX/* -bin/smbscript ../testprogs/ejs/samba3sam -bin/smbscript ../testdata/samba3/verify ../testdata/samba3 -bin/smbscript setup/upgrade --verify --targetdir=$PREFIX ../testdata/samba3 ../testdata/samba3/smb.conf +$VALGRIND bin/smbscript ../testprogs/ejs/samba3sam +$VALGRIND bin/smbscript ../testdata/samba3/verify ../testdata/samba3 +$VALGRIND bin/smbscript setup/upgrade --verify --targetdir=$PREFIX ../testdata/samba3 ../testdata/samba3/smb.conf |