summaryrefslogtreecommitdiffstats
path: root/src/plugins/locate/python/python.exports
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2011-05-25 21:45:40 +0000
committerGreg Hudson <ghudson@mit.edu>2011-05-25 21:45:40 +0000
commitea4708b37bf26700cf317353cadecd35784e699c (patch)
tree14ac5ca582a8f835ccb6ec6dca60559d5c56fe02 /src/plugins/locate/python/python.exports
parent32d2c5270e03c3b3a12f39aecb27669a322eabf3 (diff)
Don't assume principal components are C strings in klist -s
ticket: 6915 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24944 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/plugins/locate/python/python.exports')
0 files changed, 0 insertions, 0 deletions
19 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
/* 
   Unix SMB/CIFS implementation.
   client file read/write routines
   Copyright (C) Andrew Tridgell 1994-1998
   Copyright (C) James Myers 2003
   
   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 3 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   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, see <http://www.gnu.org/licenses/>.
*/

#include "includes.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/raw/raw_proto.h"
#include "libcli/libcli.h"

/****************************************************************************
  Read size bytes at offset offset using SMBreadX.
****************************************************************************/
ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, void *_buf, off_t offset, 
		 size_t size)
{
	uint8_t *buf = (uint8_t *)_buf;
	union smb_read parms;
	int readsize;
	ssize_t total = 0;
	
	if (size == 0) {
		return 0;
	}

	parms.readx.level = RAW_READ_READX;
	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));
	if (readsize > 0xFFFF) readsize = 0xFFFF;

	while (total < size) {
		NTSTATUS status;

		readsize = MIN(readsize, size-total);

		parms.readx.in.offset    = 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);
		
		if (!NT_STATUS_IS_OK(status)) {
			return -1;
		}

		total += parms.readx.out.nread;
		offset += parms.readx.out.nread;

		/* If the server returned less than we asked for we're at EOF */
		if (parms.readx.out.nread < readsize)
			break;
	}

	return total;
}


/****************************************************************************
  write to a file
  write_mode: 0x0001 disallow write cacheing
              0x0002 return bytes remaining
              0x0004 use raw named pipe protocol
              0x0008 start of message mode named pipe protocol
****************************************************************************/
ssize_t smbcli_write(struct smbcli_tree *tree,
		     int fnum, uint16_t write_mode,
		     const void *_buf, off_t offset, size_t size)