source: trunk/libtransmission/makemeta.h @ 8182

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

(trunk libT) make libtransmission/makemeta.h C++-safe

  • Property svn:keywords set to Date Rev Author Id
File size: 3.5 KB
Line 
1/*
2 * This file Copyright (C) 2007-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: makemeta.h 8182 2009-04-08 20:57:47Z charles $
11 */
12
13#ifndef TR_MAKEMETA_H
14#define TR_MAKEMETA_H 1
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20typedef struct tr_metainfo_builder_file
21{
22    char *      filename;
23    uint64_t    size;
24}
25tr_metainfo_builder_file;
26
27typedef enum
28{
29    TR_MAKEMETA_OK,
30    TR_MAKEMETA_URL,
31    TR_MAKEMETA_CANCELLED,
32    TR_MAKEMETA_IO_READ,   /* see builder.errfile, builder.errno */
33    TR_MAKEMETA_IO_WRITE   /* see builder.errfile, builder.errno */
34}
35tr_metainfo_builder_err;
36
37
38typedef struct tr_metainfo_builder
39{
40    /**
41    ***  These are set by tr_makeMetaInfoBuilderCreate()
42    ***  and cleaned up by tr_metaInfoBuilderFree()
43    **/
44
45    char *                      top;
46    tr_metainfo_builder_file *  files;
47    uint64_t                    totalSize;
48    uint32_t                    fileCount;
49    uint32_t                    pieceSize;
50    uint32_t                    pieceCount;
51    int                         isSingleFile;
52
53    /**
54    ***  These are set inside tr_makeMetaInfo()
55    ***  by copying the arguments passed to it,
56    ***  and cleaned up by tr_metaInfoBuilderFree()
57    **/
58
59    tr_tracker_info *  trackers;
60    int                trackerCount;
61    char *             comment;
62    char *             outputFile;
63    int                isPrivate;
64
65    /**
66    ***  These are set inside tr_makeMetaInfo() so the client
67    ***  can poll periodically to see what the status is.
68    ***  The client can also set abortFlag to nonzero to
69    ***  tell tr_makeMetaInfo() to abort and clean up after itself.
70    **/
71
72    uint32_t                   pieceIndex;
73    int                        abortFlag;
74    int                        isDone;
75    tr_metainfo_builder_err    result;
76
77    /* file in use when result was set to _IO_READ or _IO_WRITE */
78    char    errfile[2048];
79
80    /* errno encountered when result was set to _IO_READ or _IO_WRITE */
81    int    my_errno;
82
83    /**
84    ***  This is an implementation detail.
85    ***  The client should never use these fields.
86    **/
87
88    struct tr_metainfo_builder * nextBuilder;
89}
90tr_metainfo_builder;
91
92
93tr_metainfo_builder*tr_metaInfoBuilderCreate( const char * topFile );
94
95void                tr_metaInfoBuilderFree( tr_metainfo_builder* );
96
97/**
98 * @brief create a new .torrent file
99 *
100 * This is actually done in a worker thread, not the main thread!
101 * Otherwise the client's interface would lock up while this runs.
102 *
103 * It is the caller's responsibility to poll builder->isDone
104 * from time to time!  When the worker thread sets that flag,
105 * the caller must pass the builder to tr_metaInfoBuilderFree().
106 *
107 * @param outputFile if NULL, builder->top + ".torrent" will be used.
108
109 * @param trackers An array of trackers, sorted by tier from first to last.
110 *                 NOTE: only the `tier' and `announce' fields are used.
111 *
112 * @param trackerCount size of the `trackers' array
113 */
114void tr_makeMetaInfo( tr_metainfo_builder *   builder,
115                      const char *            outputFile,
116                      const tr_tracker_info * trackers,
117                      int                     trackerCount,
118                      const char *            comment,
119                      int                     isPrivate );
120
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif
Note: See TracBrowser for help on using the repository browser.