[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
[samba.git] / source / libsmb / clidgram.c
index 819616105edc9d274a76fd26bf0f4fb76d8a6ef9..f170834fa923725f44a52c275f91875409c5f2cd 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/>.
 */
 
 #include "includes.h"
@@ -26,7 +25,8 @@
  * cli_send_mailslot, send a mailslot for client code ...
  */
 
-BOOL cli_send_mailslot(BOOL unique, const char *mailslot,
+BOOL cli_send_mailslot(struct messaging_context *msg_ctx,
+                      BOOL unique, const char *mailslot,
                       uint16 priority,
                       char *buf, int len,
                       const char *srcname, int src_type, 
@@ -44,9 +44,6 @@ BOOL cli_send_mailslot(BOOL unique, const char *mailslot,
                return False;
        }
 
-       if (!message_init())
-               return False;
-
        memset((char *)&p, '\0', sizeof(p));
 
        /*
@@ -85,7 +82,10 @@ BOOL cli_send_mailslot(BOOL unique, const char *mailslot,
        SSVAL(ptr,smb_vwv16,2);
        p2 = smb_buf(ptr);
        fstrcpy(p2,mailslot);
-       p2 = skip_string(p2,1);
+       p2 = skip_string(ptr,MAX_DGRAM_SIZE,p2);
+       if (!p2) {
+               return False;
+       }
 
        memcpy(p2,buf,len);
        p2 += len;
@@ -101,8 +101,10 @@ BOOL cli_send_mailslot(BOOL unique, const char *mailslot,
        DEBUGADD(4,("to %s IP %s\n", nmb_namestr(&dgram->dest_name),
                    inet_ntoa(dest_ip)));
 
-       return message_send_pid(nmbd_pid, MSG_SEND_PACKET, &p, sizeof(p),
-                               False);
+       return NT_STATUS_IS_OK(messaging_send_buf(msg_ctx,
+                                                 pid_to_procid(nmbd_pid),
+                                                 MSG_SEND_PACKET,
+                                                 (uint8 *)&p, sizeof(p)));
 }
 
 /*
@@ -129,7 +131,8 @@ BOOL cli_get_response(const char *mailslot, char *buf, int bufsiz)
 
 static char cli_backup_list[1024];
 
-int cli_get_backup_list(const char *myname, const char *send_to_name)
+int cli_get_backup_list(struct messaging_context *msg_ctx,
+                       const char *myname, const char *send_to_name)
 {
        pstring outbuf;
        char *p;
@@ -156,7 +159,7 @@ int cli_get_backup_list(const char *myname, const char *send_to_name)
        SIVAL(p, 0, 1); /* The sender's token ... */
        p += 4;
 
-       cli_send_mailslot(True, "\\MAILSLOT\\BROWSE", 1, outbuf, 
+       cli_send_mailslot(msg_ctx, True, "\\MAILSLOT\\BROWSE", 1, outbuf, 
                          PTR_DIFF(p, outbuf), myname, 0, send_to_name, 
                          0x1d, sendto_ip);
 
@@ -175,16 +178,18 @@ int cli_get_backup_list(const char *myname, const char *send_to_name)
  * cli_get_backup_server: Get the backup list and retrieve a server from it
  */
 
-int cli_get_backup_server(char *my_name, char *target, char *servername, int namesize)
+int cli_get_backup_server(struct messaging_context *msg_ctx,
+                         char *my_name, char *target, char *servername,
+                         int namesize)
 {
 
   /* Get the backup list first. We could pull this from the cache later */
 
-  cli_get_backup_list(my_name, target);  /* FIXME: Check the response */
+  cli_get_backup_list(msg_ctx, my_name, target);  /* FIXME: Check the response */
 
   if (!cli_backup_list[0]) { /* Empty list ... try again */
 
-    cli_get_backup_list(my_name, target);
+    cli_get_backup_list(msg_ctx, my_name, target);
 
   }