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: platform.h 13696 2012-12-27 19:39:44Z jordan $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef __TRANSMISSION__ |
---|
14 | #error only libtransmission should #include this header. |
---|
15 | #endif |
---|
16 | |
---|
17 | #ifndef TR_PLATFORM_H |
---|
18 | #define TR_PLATFORM_H |
---|
19 | |
---|
20 | #define TR_PATH_DELIMITER '/' |
---|
21 | #define TR_PATH_DELIMITER_STR "/" |
---|
22 | |
---|
23 | /** |
---|
24 | * @addtogroup tr_session Session |
---|
25 | * @{ |
---|
26 | */ |
---|
27 | |
---|
28 | /** |
---|
29 | * @brief invoked by tr_sessionInit () to set up the locations of the resume, torrent, and clutch directories. |
---|
30 | * @see tr_getResumeDir () |
---|
31 | * @see tr_getTorrentDir () |
---|
32 | * @see tr_getWebClientDir () |
---|
33 | */ |
---|
34 | void tr_setConfigDir (tr_session * session, const char * configDir); |
---|
35 | |
---|
36 | /** @brief return the directory where .resume files are stored */ |
---|
37 | const char * tr_getResumeDir (const tr_session *); |
---|
38 | |
---|
39 | /** @brief return the directory where .torrent files are stored */ |
---|
40 | const char * tr_getTorrentDir (const tr_session *); |
---|
41 | |
---|
42 | /** @brief return the directory where the Web Client's web ui files are kept */ |
---|
43 | const char * tr_getWebClientDir (const tr_session *); |
---|
44 | |
---|
45 | /** If the disk quota is enabled and readable, this returns how much is available in the quota. |
---|
46 | Otherwise, it returns how much is available on the disk, or -1 on error. */ |
---|
47 | int64_t tr_getFreeSpace (const char * path); |
---|
48 | |
---|
49 | |
---|
50 | /** @} */ |
---|
51 | |
---|
52 | |
---|
53 | /** |
---|
54 | * @addtogroup utils Utilities |
---|
55 | * @{ |
---|
56 | */ |
---|
57 | |
---|
58 | typedef struct tr_thread tr_thread; |
---|
59 | |
---|
60 | /** @brief Instantiate a new process thread */ |
---|
61 | tr_thread* tr_threadNew (void (*func)(void *), void * arg); |
---|
62 | |
---|
63 | /** @brief Return nonzero if this function is being called from `thread' |
---|
64 | @param thread the thread being tested */ |
---|
65 | bool tr_amInThread (const tr_thread *); |
---|
66 | |
---|
67 | /*** |
---|
68 | **** |
---|
69 | ***/ |
---|
70 | |
---|
71 | typedef struct tr_lock tr_lock; |
---|
72 | |
---|
73 | /** @brief Create a new thread mutex object */ |
---|
74 | tr_lock * tr_lockNew (void); |
---|
75 | |
---|
76 | /** @brief Destroy a thread mutex object */ |
---|
77 | void tr_lockFree (tr_lock *); |
---|
78 | |
---|
79 | /** @brief Attempt to lock a thread mutex object */ |
---|
80 | void tr_lockLock (tr_lock *); |
---|
81 | |
---|
82 | /** @brief Unlock a thread mutex object */ |
---|
83 | void tr_lockUnlock (tr_lock *); |
---|
84 | |
---|
85 | /** @brief return nonzero if the specified lock is locked */ |
---|
86 | int tr_lockHave (const tr_lock *); |
---|
87 | |
---|
88 | #ifdef WIN32 |
---|
89 | void * mmap (void *ptr, long size, long prot, long type, long handle, long arg); |
---|
90 | |
---|
91 | long munmap (void *ptr, long size); |
---|
92 | #endif |
---|
93 | |
---|
94 | /* @} */ |
---|
95 | |
---|
96 | #endif |
---|