summaryrefslogtreecommitdiffstats
path: root/source/nmbd/nmbd_synclists.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/nmbd/nmbd_synclists.c')
-rw-r--r--source/nmbd/nmbd_synclists.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/source/nmbd/nmbd_synclists.c b/source/nmbd/nmbd_synclists.c
index 24adf4e69f2..c8dac82aa15 100644
--- a/source/nmbd/nmbd_synclists.c
+++ b/source/nmbd/nmbd_synclists.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 1.9.
NBT netbios routines and daemon - version 2
Copyright (C) Andrew Tridgell 1994-1998
Copyright (C) Luke Kenneth Casson Leighton 1994-1998
@@ -42,7 +43,7 @@ struct sync_record {
/* a linked list of current sync connections */
static struct sync_record *syncs;
-static XFILE *fp;
+static FILE *fp;
/*******************************************************************
This is the NetServerEnum callback.
@@ -51,7 +52,7 @@ static XFILE *fp;
static void callback(const char *sname, uint32 stype,
const char *comment, void *state)
{
- x_fprintf(fp,"\"%s\" %08X \"%s\"\n", sname, stype, comment);
+ fprintf(fp,"\"%s\" %08X \"%s\"\n", sname, stype, comment);
}
/*******************************************************************
@@ -70,11 +71,7 @@ static void sync_child(char *name, int nm_type,
uint32 local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
struct nmb_name called, calling;
- /* W2K DMB's return empty browse lists on port 445. Use 139.
- * Patch from Andy Levine andyl@epicrealm.com.
- */
-
- if (!cli_initialise(&cli) || !cli_set_port(&cli, 139) || !cli_connect(&cli, name, &ip)) {
+ if (!cli_initialise(&cli) || !cli_connect(&cli, name, &ip)) {
return;
}
@@ -104,6 +101,7 @@ static void sync_child(char *name, int nm_type,
/* All the cli_XX functions take UNIX character set. */
fstrcpy(unix_workgroup, cli.server_domain?cli.server_domain:workgroup);
+ dos_to_unix(unix_workgroup);
/* Fetch a workgroup list. */
cli_NetServerEnum(&cli, unix_workgroup,
@@ -113,6 +111,7 @@ static void sync_child(char *name, int nm_type,
/* Now fetch a server list. */
if (servers) {
fstrcpy(unix_workgroup, workgroup);
+ dos_to_unix(unix_workgroup);
cli_NetServerEnum(&cli, unix_workgroup,
local?SV_TYPE_LOCAL_LIST_ONLY:SV_TYPE_ALL,
callback, NULL);
@@ -168,7 +167,7 @@ done:
DEBUG(2,("Initiating browse sync for %s to %s(%s)\n",
work->work_group, name, inet_ntoa(ip)));
- fp = x_fopen(s->fname,O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ fp = sys_fopen(s->fname,"w");
if (!fp) {
END_PROFILE(sync_browse_lists);
_exit(1);
@@ -177,7 +176,7 @@ done:
sync_child(name, nm_type, work->work_group, ip, local, servers,
s->fname);
- x_fclose(fp);
+ fclose(fp);
END_PROFILE(sync_browse_lists);
_exit(0);
}
@@ -242,7 +241,7 @@ read the completed sync info
**********************************************************************/
static void complete_sync(struct sync_record *s)
{
- XFILE *f;
+ FILE *f;
fstring server, type_str;
unsigned type;
pstring comment;
@@ -250,16 +249,19 @@ static void complete_sync(struct sync_record *s)
char *ptr;
int count=0;
- f = x_fopen(s->fname,O_RDONLY, 0);
+ f = sys_fopen(s->fname,"r");
if (!f) return;
- while (!x_feof(f)) {
+ while (!feof(f)) {
if (!fgets_slash(line,sizeof(pstring),f)) continue;
ptr = line;
+ /* The line is written in UNIX character set. Convert to DOS codepage. */
+ unix_to_dos(line);
+
if (!next_token(&ptr,server,NULL,sizeof(server)) ||
!next_token(&ptr,type_str,NULL, sizeof(type_str)) ||
!next_token(&ptr,comment,NULL, sizeof(comment))) {
@@ -273,7 +275,7 @@ static void complete_sync(struct sync_record *s)
count++;
}
- x_fclose(f);
+ fclose(f);
unlink(s->fname);