trying to get HEAD building again. If you want the code
[kai/samba-autobuild/.git] / source / nmbd / nmbd_serverlistdb.c
index fd1d8e51bab7be773b3490b67ea923685f8bdcb0..2484a7f830b630b21b4509251e43ed9258a2ff51 100644 (file)
@@ -1,6 +1,5 @@
 /* 
-   Unix SMB/Netbios implementation.
-   Version 1.9.
+   Unix SMB/CIFS implementation.
    NBT netbios routines and daemon - version 2
    Copyright (C) Andrew Tridgell 1994-1998
    Copyright (C) Luke Kenneth Casson Leighton 1994-1998
 */
 
 #include "includes.h"
-#include "smb.h"
 
 extern int ClientNMB;
 
-extern fstring global_myworkgroup;
-extern char **my_netbios_names;
-
 int updatecount = 0;
 
 /*******************************************************************
@@ -92,7 +87,7 @@ static void add_server_to_workgroup(struct work_record *work,
   Find a server in a server list.
   **************************************************************************/
 
-struct server_record *find_server_in_workgroup(struct work_record *work, char *name)
+struct server_record *find_server_in_workgroup(struct work_record *work, const char *name)
 {
   struct server_record *ret;
   
@@ -129,8 +124,8 @@ void remove_server_from_workgroup(struct work_record *work, struct server_record
   ****************************************************************************/
 
 struct server_record *create_server_on_workgroup(struct work_record *work,
-                                                 char *name,int servertype, 
-                                                 int ttl,char *comment)
+                                                 const char *name,int servertype, 
+                                                 int ttl, const char *comment)
 {
   struct server_record *servrec;
   
@@ -158,9 +153,9 @@ workgroup %s. This is a bug.\n", name, work->work_group));
  
   servrec->subnet = work->subnet;
  
-  StrnCpy(servrec->serv.name,name,sizeof(servrec->serv.name)-1);
-  StrnCpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment)-1);
-  strupper(servrec->serv.name);
+  fstrcpy(servrec->serv.name,name);
+  fstrcpy(servrec->serv.comment,comment);
+  strupper_m(servrec->serv.name);
   servrec->serv.type  = servertype;
 
   update_server_ttl(servrec, ttl);
@@ -257,7 +252,7 @@ static uint32 write_this_server_name( struct subnet_record *subrec,
 
 /*******************************************************************
  Decide if we should write out a workgroup record for this workgroup.
- We return zero if we should not. Don't write out global_myworkgroup (we've
+ We return zero if we should not. Don't write out lp_workgroup() (we've
  already done it) and also don't write out a second workgroup record
  on the unicast subnet that we've already written out on one of the
  broadcast subnets.
@@ -268,7 +263,7 @@ static uint32 write_this_workgroup_name( struct subnet_record *subrec,
 {
   struct subnet_record *ssub;
 
-  if(strequal(global_myworkgroup, work->work_group))
+  if(strequal(lp_workgroup(), work->work_group))
     return 0;
 
   /* This is a workgroup we have seen on a broadcast subnet. All
@@ -296,8 +291,8 @@ static uint32 write_this_workgroup_name( struct subnet_record *subrec,
   Write out the browse.dat file.
   ******************************************************************/
 
-void write_browse_list_entry(XFILE *fp, fstring name, uint32 rec_type,
-               fstring local_master_browser_name, fstring description)
+void write_browse_list_entry(XFILE *fp, const char *name, uint32 rec_type,
+               const char *local_master_browser_name, const char *description)
 {
        fstring tmp;
 
@@ -369,10 +364,10 @@ void write_browse_list(time_t t, BOOL force_write)
    * subnet.
    */
 
-  if((work = find_workgroup_on_subnet(FIRST_SUBNET, global_myworkgroup)) == NULL)
+  if((work = find_workgroup_on_subnet(FIRST_SUBNET, lp_workgroup())) == NULL)
   { 
     DEBUG(0,("write_browse_list: Fatal error - cannot find my workgroup %s\n",
-             global_myworkgroup));
+             lp_workgroup()));
     x_fclose(fp);
     return;
   }
@@ -389,22 +384,22 @@ void write_browse_list(time_t t, BOOL force_write)
    * once.
    */
 
-  for (i=0; my_netbios_names[i]; i++)
+  for (i=0; my_netbios_names(i); i++)
   {
     stype = 0;
     for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
     {
-      if((work = find_workgroup_on_subnet( subrec, global_myworkgroup )) == NULL)
+      if((work = find_workgroup_on_subnet( subrec, lp_workgroup() )) == NULL)
         continue;
-      if((servrec = find_server_in_workgroup( work, my_netbios_names[i])) == NULL)
+      if((servrec = find_server_in_workgroup( work, my_netbios_names(i))) == NULL)
         continue;
 
       stype |= servrec->serv.type;
     }
 
     /* Output server details, plus what workgroup they're in. */
-    write_browse_list_entry(fp, my_netbios_names[i], stype,
-        string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), global_myworkgroup);
+    write_browse_list_entry(fp, my_netbios_names(i), stype,
+        string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_workgroup());
   }
       
   for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))