source: trunk/libtransmission/fdlimit.h @ 11709

Last change on this file since 11709 was 11709, checked in by jordan, 11 years ago

Update the copyright year in the source code comments.

The Berne Convention says that the copyright year is moot, so instead of adding another year to each file as in previous years, I've removed the year altogether from the source code comments in libtransmission, gtk, qt, utils, daemon, and cli.

Juliusz's copyright notice in tr-dht and Johannes' copyright notice in tr-lpd have been left alone; it didn't seem appropriate to modify them.

  • Property svn:keywords set to Date Rev Author Id
File size: 3.6 KB
Line 
1/*
2 * This file Copyright (C) Mnemosyne LLC
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: fdlimit.h 11709 2011-01-19 13:48:47Z jordan $
11 */
12
13#ifndef __TRANSMISSION__
14 #error only libtransmission should #include this header.
15#endif
16
17#include "transmission.h"
18#include "net.h"
19
20/**
21 * @addtogroup file_io File IO
22 * @{
23 */
24
25void tr_fdSetFileLimit( tr_session * session, int limit );
26
27int tr_fdGetFileLimit( tr_session * session );
28
29void tr_fdSetGlobalPeerLimit( tr_session * session, int limit );
30
31/***
32****
33***/
34
35void tr_set_file_for_single_pass( int fd );
36
37int tr_open_file_for_scanning( const char * filename );
38
39int tr_open_file_for_writing( const char * filename );
40
41void tr_close_file( int fd );
42
43ssize_t tr_pread(int fd, void *buf, size_t count, off_t offset);
44ssize_t tr_pwrite(int fd, const void *buf, size_t count, off_t offset);
45int tr_prefetch(int fd, off_t offset, size_t count);
46
47
48/**
49 * Returns an fd to the specified filename.
50 *
51 * A small pool of open files is kept to avoid the overhead of
52 * continually opening and closing the same files when downloading
53 * piece data.
54 *
55 * - if doWrite is true, subfolders in torrentFile are created if necessary.
56 * - if doWrite is true, the target file is created if necessary.
57 *
58 * on success, a file descriptor >= 0 is returned.
59 * on failure, a -1 is returned and errno is set.
60 *
61 * @see tr_fdFileClose
62 */
63int  tr_fdFileCheckout( tr_session             * session,
64                        int                      torrentId,
65                        tr_file_index_t          fileNum,
66                        const char             * fileName,
67                        tr_bool                  doWrite,
68                        tr_preallocation_mode    preallocationMode,
69                        uint64_t                 desiredFileSize );
70
71int tr_fdFileGetCached( tr_session             * session,
72                        int                      torrentId,
73                        tr_file_index_t          fileNum,
74                        tr_bool                  doWrite );
75
76/**
77 * Closes a file that's being held by our file repository.
78 *
79 * If the file isn't checked out, it's closed immediately.
80 * If the file is currently checked out, it will be closed upon its return.
81 *
82 * @see tr_fdFileCheckout
83 */
84void tr_fdFileClose( tr_session        * session,
85                     const tr_torrent  * tor,
86                     tr_file_index_t     fileNo );
87
88
89/**
90 * Closes all the files associated with a given torrent id
91 */
92void tr_fdTorrentClose( tr_session * session, int torrentId );
93
94
95/***********************************************************************
96 * Sockets
97 **********************************************************************/
98int      tr_fdSocketCreate( tr_session * session, int domain, int type );
99
100int      tr_fdSocketAccept( tr_session  * session,
101                            int           listening_sockfd,
102                            tr_address  * addr,
103                            tr_port     * port );
104
105void     tr_fdSocketClose( tr_session * session, int s );
106
107/***********************************************************************
108 * tr_fdClose
109 ***********************************************************************
110 * Frees resources allocated by tr_fdInit.
111 **********************************************************************/
112void     tr_fdClose( tr_session * session );
113
114
115void     tr_fdSetPeerLimit( tr_session * session, int n );
116
117int      tr_fdGetPeerLimit( const tr_session * );
118
119/* @} */
Note: See TracBrowser for help on using the repository browser.