RIP BOOL. Convert BOOL -> bool. I found a few interesting
[tprouty/samba.git] / source3 / nmbd / nmbd_synclists.c
index 28ad92ed108022ac277e51cd7d7c175c349f868b..df71e6db437baa7257990e9c9d6d05fd293e2997 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
 */
 
@@ -64,62 +63,74 @@ static void callback(const char *sname, uint32 stype,
 
 static void sync_child(char *name, int nm_type, 
                       char *workgroup,
-                      struct in_addr ip, BOOL local, BOOL servers,
+                      struct in_addr ip, bool local, bool servers,
                       char *fname)
 {
        fstring unix_workgroup;
-       static struct cli_state cli;
+       struct cli_state *cli;
        uint32 local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
        struct nmb_name called, calling;
+       NTSTATUS status;
 
        /* 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)) {
+       cli = cli_initialise();
+       if (!cli) {
+               return;
+       }
+
+       if (!cli_set_port(cli, 139)) {
+               return;
+       }
+
+       status = cli_connect(cli, name, &ip);
+       if (!NT_STATUS_IS_OK(status)) {
                return;
        }
 
        make_nmb_name(&calling, local_machine, 0x0);
        make_nmb_name(&called , name, nm_type);
 
-       if (!cli_session_request(&cli, &calling, &called)) {
-               cli_shutdown(&cli);
+       if (!cli_session_request(cli, &calling, &called)) {
+               cli_shutdown(cli);
                return;
        }
 
-       if (!cli_negprot(&cli)) {
-               cli_shutdown(&cli);
+       if (!cli_negprot(cli)) {
+               cli_shutdown(cli);
                return;
        }
 
-       if (!cli_session_setup(&cli, "", "", 1, "", 0, workgroup)) {
-               cli_shutdown(&cli);
+       if (!NT_STATUS_IS_OK(cli_session_setup(cli, "", "", 1, "", 0,
+                                              workgroup))) {
+               cli_shutdown(cli);
                return;
        }
 
-       if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1)) {
-               cli_shutdown(&cli);
+       if (!cli_send_tconX(cli, "IPC$", "IPC", "", 1)) {
+               cli_shutdown(cli);
                return;
        }
 
        /* All the cli_XX functions take UNIX character set. */
-       fstrcpy(unix_workgroup, cli.server_domain?cli.server_domain:workgroup);
+       fstrcpy(unix_workgroup, cli->server_domain ? cli->server_domain : workgroup);
 
        /* Fetch a workgroup list. */
-       cli_NetServerEnum(&cli, unix_workgroup,
+       cli_NetServerEnum(cli, unix_workgroup,
                          local_type|SV_TYPE_DOMAIN_ENUM, 
                          callback, NULL);
        
        /* Now fetch a server list. */
        if (servers) {
                fstrcpy(unix_workgroup, workgroup);
-               cli_NetServerEnum(&cli, unix_workgroup, 
+               cli_NetServerEnum(cli, unix_workgroup, 
                                  local?SV_TYPE_LOCAL_LIST_ONLY:SV_TYPE_ALL,
                                  callback, NULL);
        }
        
-       cli_shutdown(&cli);
+       cli_shutdown(cli);
 }
 
 /*******************************************************************
@@ -130,7 +141,7 @@ static void sync_child(char *name, int nm_type,
 
 void sync_browse_lists(struct work_record *work,
                       char *name, int nm_type, 
-                      struct in_addr ip, BOOL local, BOOL servers)
+                      struct in_addr ip, bool local, bool servers)
 {
        struct sync_record *s;
        static int counter;
@@ -138,7 +149,7 @@ void sync_browse_lists(struct work_record *work,
        START_PROFILE(sync_browse_lists);
        /* Check we're not trying to sync with ourselves. This can
           happen if we are a domain *and* a local master browser. */
-       if (ismyip(ip)) {
+       if (ismyip_v4(ip)) {
 done:
                END_PROFILE(sync_browse_lists);
                return;