source: branches/1.5x/libtransmission/makemeta.h @ 7664

Last change on this file since 7664 was 7664, checked in by charles, 13 years ago

(1.5x) updates from trunk: all of build system & libtransmission; bugfixes in daemon, cli, and gtk; sync tr_sessionInit() changes. NOTE: mac end needs to add request-list.[ch] to its libtransmissio rules

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