1 | /* |
---|
2 | * This file Copyright (C) 2009-2010 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 10546 2010-04-29 13:57:58Z charles $ |
---|
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 | #if defined( WIN32 ) |
---|
21 | #define TR_PATH_DELIMITER '\\' |
---|
22 | #define TR_PATH_DELIMITER_STR "\\" |
---|
23 | #else |
---|
24 | #define TR_PATH_DELIMITER '/' |
---|
25 | #define TR_PATH_DELIMITER_STR "/" |
---|
26 | #endif |
---|
27 | |
---|
28 | #ifdef WIN32 |
---|
29 | #include <windows.h> |
---|
30 | #define MAX_PATH_LENGTH MAX_PATH |
---|
31 | #else |
---|
32 | #define MAX_PATH_LENGTH 4096 |
---|
33 | #endif |
---|
34 | |
---|
35 | /** |
---|
36 | * @addtogroup tr_session Session |
---|
37 | * @{ |
---|
38 | */ |
---|
39 | |
---|
40 | /** |
---|
41 | * @brief invoked by tr_sessionInit() to set up the locations of the resume, torrent, and clutch directories. |
---|
42 | * @see tr_getResumeDir() |
---|
43 | * @see tr_getTorrentDir() |
---|
44 | * @see tr_getWebClientDir() |
---|
45 | */ |
---|
46 | void tr_setConfigDir( tr_session * session, const char * configDir ); |
---|
47 | |
---|
48 | /** @brief return the directory where .resume files are stored */ |
---|
49 | const char * tr_getResumeDir( const tr_session * ); |
---|
50 | |
---|
51 | /** @brief return the directory where .torrent files are stored */ |
---|
52 | const char * tr_getTorrentDir( const tr_session * ); |
---|
53 | |
---|
54 | /** @brief return the directory where the Web Client's web ui files are kept */ |
---|
55 | const char * tr_getWebClientDir( const tr_session * ); |
---|
56 | |
---|
57 | /** @} */ |
---|
58 | |
---|
59 | |
---|
60 | /** |
---|
61 | * @addtogroup utils Utilities |
---|
62 | * @{ |
---|
63 | */ |
---|
64 | |
---|
65 | typedef struct tr_thread tr_thread; |
---|
66 | |
---|
67 | /** @brief Instantiate a new process thread */ |
---|
68 | tr_thread* tr_threadNew( void ( *func )(void *), void * arg ); |
---|
69 | |
---|
70 | /** @brief Return nonzero if this function is being called from `thread' |
---|
71 | @param thread the thread being tested */ |
---|
72 | int tr_amInThread( const tr_thread * ); |
---|
73 | |
---|
74 | /*** |
---|
75 | **** |
---|
76 | ***/ |
---|
77 | |
---|
78 | typedef struct tr_lock tr_lock; |
---|
79 | |
---|
80 | /** @brief Create a new thread mutex object */ |
---|
81 | tr_lock * tr_lockNew( void ); |
---|
82 | |
---|
83 | /** @brief Destroy a thread mutex object */ |
---|
84 | void tr_lockFree( tr_lock * ); |
---|
85 | |
---|
86 | /** @brief Attempt to lock a thread mutex object */ |
---|
87 | void tr_lockLock( tr_lock * ); |
---|
88 | |
---|
89 | /** @brief Unlock a thread mutex object */ |
---|
90 | void tr_lockUnlock( tr_lock * ); |
---|
91 | |
---|
92 | /** @brief return nonzero if the specified lock is locked */ |
---|
93 | int tr_lockHave( const tr_lock * ); |
---|
94 | |
---|
95 | #ifdef WIN32 |
---|
96 | void * mmap( void *ptr, long size, long prot, long type, long handle, long arg ); |
---|
97 | |
---|
98 | long munmap( void *ptr, long size ); |
---|
99 | #endif |
---|
100 | |
---|
101 | /* @} */ |
---|
102 | |
---|
103 | #endif |
---|