1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

r10517: Get rid of use of next_token() in lib/samba3/

(This used to be commit 811a6e28cc)
This commit is contained in:
Jelmer Vernooij 2005-09-26 18:16:38 +00:00 committed by Gerald (Jerry) Carter
parent 01319b8462
commit 7f7a2d133d
3 changed files with 22 additions and 42 deletions

View File

@ -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++;

View File

@ -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);

View File

@ -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