r15279: Fix dependencies when using static libraries
[samba.git] / source / libcli / clireadwrite.c
index 7b47281e2c2bb6281cf5b174471b75c3a0b6c617..afffeadeff88ecc810a1b6672bb17427d67d0bac 100644 (file)
 */
 
 #include "includes.h"
+#include "libcli/raw/libcliraw.h"
 
 /****************************************************************************
   Read size bytes at offset offset using SMBreadX.
 ****************************************************************************/
-ssize_t cli_read(struct cli_tree *tree, int fnum, char *buf, off_t offset, 
+ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, void *_buf, off_t offset, 
                 size_t size)
 {
+       uint8_t *buf = _buf;
        union smb_read parms;
        int readsize;
        ssize_t total = 0;
@@ -36,14 +38,13 @@ ssize_t cli_read(struct cli_tree *tree, int fnum, char *buf, off_t offset,
        }
 
        parms.readx.level = RAW_READ_READX;
-       parms.readx.in.fnum = fnum;
+       parms.readx.in.file.fnum = fnum;
 
        /*
         * Set readsize to the maximum size we can handle in one readX,
         * rounded down to a multiple of 1024.
         */
-       readsize = (tree->session->transport->negotiate.max_xmit - 
-                   (MIN_SMB_SIZE+32)) & ~1023;
+       readsize = (tree->session->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32));
        if (readsize > 0xFFFF) readsize = 0xFFFF;
 
        while (total < size) {
@@ -55,6 +56,7 @@ ssize_t cli_read(struct cli_tree *tree, int fnum, char *buf, off_t offset,
                parms.readx.in.mincnt    = readsize;
                parms.readx.in.maxcnt    = readsize;
                parms.readx.in.remaining = size - total;
+               parms.readx.in.read_for_execute = False;
                parms.readx.out.data     = buf + total;
                
                status = smb_raw_read(tree, &parms);
@@ -82,12 +84,13 @@ ssize_t cli_read(struct cli_tree *tree, int fnum, char *buf, off_t offset,
               0x0004 use raw named pipe protocol
               0x0008 start of message mode named pipe protocol
 ****************************************************************************/
-ssize_t cli_write(struct cli_tree *tree,
-                 int fnum, uint16 write_mode,
-                 const char *buf, off_t offset, size_t size)
+ssize_t smbcli_write(struct smbcli_tree *tree,
+                    int fnum, uint16_t write_mode,
+                    const void *_buf, off_t offset, size_t size)
 {
+       const uint8_t *buf = _buf;
        union smb_write parms;
-       int block = (tree->session->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32)) & ~1023;
+       int block = (tree->session->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32));
        ssize_t total = 0;
 
        if (size == 0) {
@@ -98,7 +101,7 @@ ssize_t cli_write(struct cli_tree *tree,
 
 
        parms.writex.level = RAW_WRITE_WRITEX;
-       parms.writex.in.fnum = fnum;
+       parms.writex.in.file.fnum = fnum;
        parms.writex.in.wmode = write_mode;
        parms.writex.in.remaining = 0;
        
@@ -128,9 +131,10 @@ ssize_t cli_write(struct cli_tree *tree,
 /****************************************************************************
   write to a file using a SMBwrite and not bypassing 0 byte writes
 ****************************************************************************/
-ssize_t cli_smbwrite(struct cli_tree *tree,
-                    int fnum, char *buf, off_t offset, size_t size1)
+ssize_t smbcli_smbwrite(struct smbcli_tree *tree,
+                    int fnum, const void *_buf, off_t offset, size_t size1)
 {
+       const uint8_t *buf = _buf;
        union smb_write parms;
        ssize_t total = 0;
 
@@ -141,7 +145,7 @@ ssize_t cli_smbwrite(struct cli_tree *tree,
                size_t size = MIN(size1, tree->session->transport->negotiate.max_xmit - 48);
                if (size > 0xFFFF) size = 0xFFFF;
                
-               parms.write.in.fnum = fnum;
+               parms.write.in.file.fnum = fnum;
                parms.write.in.offset = offset;
                parms.write.in.count = size;
                parms.write.in.data = buf + total;