source: trunk/libtransmission/makemeta.h @ 8181

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

(trunk) tr_metaInfoBuilderCreate() doesn't need a tr_session* handle anymore

  • 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 8181 2009-04-08 18:47:48Z 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
49    /**
50    ***  These are set inside tr_makeMetaInfo()
51    ***  by copying the arguments passed to it,
52    ***  and cleaned up by tr_metaInfoBuilderFree()
53    **/
54
55    tr_tracker_info *  trackers;
56    int                trackerCount;
57    char *             comment;
58    char *             outputFile;
59    int                isPrivate;
60
61    /**
62    ***  These are set inside tr_makeMetaInfo() so the client
63    ***  can poll periodically to see what the status is.
64    ***  The client can also set abortFlag to nonzero to
65    ***  tell tr_makeMetaInfo() to abort and clean up after itself.
66    **/
67
68    uint32_t                   pieceIndex;
69    int                        abortFlag;
70    int                        isDone;
71    tr_metainfo_builder_err    result;
72
73    /* file in use when result was set to _IO_READ or _IO_WRITE */
74    char    errfile[2048];
75
76    /* errno encountered when result was set to _IO_READ or _IO_WRITE */
77    int    my_errno;
78
79    /**
80    ***  This is an implementation detail.
81    ***  The client should never use these fields.
82    **/
83
84    struct tr_metainfo_builder * nextBuilder;
85}
86tr_metainfo_builder;
87
88
89tr_metainfo_builder*tr_metaInfoBuilderCreate( const char * topFile );
90
91void                tr_metaInfoBuilderFree( tr_metainfo_builder* );
92
93/**
94 * @brief create a new .torrent file
95 *
96 * This is actually done in a worker thread, not the main thread!
97 * Otherwise the client's interface would lock up while this runs.
98 *
99 * It is the caller's responsibility to poll builder->isDone
100 * from time to time!  When the worker thread sets that flag,
101 * the caller must pass the builder to tr_metaInfoBuilderFree().
102 *
103 * @param outputFile if NULL, builder->top + ".torrent" will be used.
104
105 * @param trackers An array of trackers, sorted by tier from first to last.
106 *                 NOTE: only the `tier' and `announce' fields are used.
107 *
108 * @param trackerCount size of the `trackers' array
109 */
110void tr_makeMetaInfo( tr_metainfo_builder *   builder,
111                      const char *            outputFile,
112                      const tr_tracker_info * trackers,
113                      int                     trackerCount,
114                      const char *            comment,
115                      int                     isPrivate );
116
117
118#endif
Note: See TracBrowser for help on using the repository browser.