transmission/libtransmission/inout.h

66 lines
2.2 KiB
C
Raw Normal View History

/*
* This file Copyright (C) 2008-2009 Charles Kerr <charles@transmissionbt.com>
2006-07-16 19:39:23 +00:00
*
* This file is licensed by the GPL version 2. Works owned by the
* Transmission project are granted a special exemption to clause 2(b)
* so that the bulk of its code can remain under the MIT license.
* This exemption does not extend to derived works not owned by
* the Transmission project.
2006-07-16 19:39:23 +00:00
*
* $Id$
*/
2006-07-16 19:39:23 +00:00
#ifndef __TRANSMISSION__
#error only libtransmission should #include this header.
#endif
2006-07-16 19:39:23 +00:00
#ifndef TR_IO_H
#define TR_IO_H 1
struct tr_torrent;
2006-07-16 19:39:23 +00:00
/**
* Reads the block specified by the piece index, offset, and length.
2008-10-03 04:49:06 +00:00
* @return 0 on success, or an errno value on failure.
*/
2008-10-03 04:49:06 +00:00
int tr_ioRead( const struct tr_torrent * tor,
tr_piece_index_t pieceIndex,
uint32_t offset,
uint32_t len,
uint8_t * setme );
/**
* Writes the block specified by the piece index, offset, and length.
2008-10-03 04:49:06 +00:00
* @return 0 on success, or an errno value on failure.
*/
2008-10-03 04:49:06 +00:00
int tr_ioWrite( const struct tr_torrent * tor,
tr_piece_index_t pieceIndex,
uint32_t offset,
uint32_t len,
const uint8_t * writeme );
2007-01-14 12:00:21 +00:00
/**
* @brief Test to see if the piece matches its metainfo's SHA1 checksum.
*
* @param optionalBuffer if calling tr_ioTestPiece() repeatedly, you can
* get best performance by providing a buffer with
* tor->info.pieceSize bytes.
*/
tr_bool tr_ioTestPiece( const tr_torrent * tor,
tr_piece_index_t piece,
void * optionalBuffer,
size_t optionalBufferLen );
2006-07-16 19:39:23 +00:00
/**
* Converts a piece index + offset into a file index + offset.
*/
void tr_ioFindFileLocation( const tr_torrent * tor,
tr_piece_index_t pieceIndex,
uint32_t pieceOffset,
tr_file_index_t * fileIndex,
uint64_t * fileOffset );
2006-07-16 19:39:23 +00:00
#endif