source: trunk/libtransmission/inout.h @ 7658

Last change on this file since 7658 was 7658, checked in by charles, 12 years ago

(trunk) update the GPL code's copyright dates

  • Property svn:keywords set to Date Rev Author Id
File size: 2.2 KB
Line 
1/*
2 * This file Copyright (C) 2008-2009 Charles Kerr <charles@transmissionbt.com>
3 *
4 * This file is licensed by the GPL version 2.  Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id: inout.h 7658 2009-01-10 23:09:07Z charles $
11 */
12
13#ifndef __TRANSMISSION__
14 #error only libtransmission should #include this header.
15#endif
16
17#ifndef TR_IO_H
18#define TR_IO_H 1
19
20struct tr_torrent;
21
22/**
23 * Reads the block specified by the piece index, offset, and length.
24 * @return 0 on success, or an errno value on failure.
25 */
26int tr_ioRead( const struct tr_torrent * tor,
27               tr_piece_index_t          pieceIndex,
28               uint32_t                  offset,
29               uint32_t                  len,
30               uint8_t *                 setme );
31
32/**
33 * Writes the block specified by the piece index, offset, and length.
34 * @return 0 on success, or an errno value on failure.
35 */
36int tr_ioWrite( const struct tr_torrent * tor,
37                tr_piece_index_t          pieceIndex,
38                uint32_t                  offset,
39                uint32_t                  len,
40                const uint8_t *           writeme );
41
42/**
43 * @brief Test to see if the piece matches its metainfo's SHA1 checksum.
44 *
45 * @param optionalBuffer if calling tr_ioTestPiece() repeatedly, you can
46 *                       get best performance by providing a buffer with
47 *                       tor->info.pieceSize bytes.
48 */
49tr_bool tr_ioTestPiece( const tr_torrent * tor,
50                        tr_piece_index_t   piece,
51                        void             * optionalBuffer,
52                        size_t             optionalBufferLen );
53
54
55/**
56 * Converts a piece index + offset into a file index + offset.
57 */
58void     tr_ioFindFileLocation( const tr_torrent * tor,
59                                tr_piece_index_t   pieceIndex,
60                                uint32_t           pieceOffset,
61                                tr_file_index_t *  fileIndex,
62                                uint64_t *         fileOffset );
63
64
65#endif
Note: See TracBrowser for help on using the repository browser.