Changeset 13824


Ignore:
Timestamp:
Jan 21, 2013, 5:48:36 PM (8 years ago)
Author:
jordan
Message:

(libT) copyediting: rename the internal tr_blocklist class 'tr_blocklistFile' to distinguish the private per-file API from the public, global API in libtransmission.h

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/blocklist-test.c

    r13667 r13824  
    4040    const char * tmpfile_bin = TEMPFILE_BIN;
    4141    struct tr_address addr;
    42     tr_blocklist * b;
     42    tr_blocklistFile * b;
    4343
    4444    remove (tmpfile_txt);
    4545    remove (tmpfile_bin);
    4646
    47     b = _tr_blocklistNew (tmpfile_bin, true);
     47    b = tr_blocklistFileNew (tmpfile_bin, true);
    4848    createTestBlocklist (tmpfile_txt);
    49     _tr_blocklistSetContent (b, tmpfile_txt);
     49    tr_blocklistFileSetContent (b, tmpfile_txt);
    5050
    5151    /* now run some tests */
    5252    check (tr_address_from_string (&addr, "216.16.1.143"));
    53     check (!_tr_blocklistHasAddress (b, &addr));
     53    check (!tr_blocklistFileHasAddress (b, &addr));
    5454    check (tr_address_from_string (&addr, "216.16.1.144"));
    55     check (_tr_blocklistHasAddress (b, &addr));
     55    check (tr_blocklistFileHasAddress (b, &addr));
    5656    check (tr_address_from_string (&addr, "216.16.1.145"));
    57     check (_tr_blocklistHasAddress (b, &addr));
     57    check (tr_blocklistFileHasAddress (b, &addr));
    5858    check (tr_address_from_string (&addr, "216.16.1.146"));
    59     check (_tr_blocklistHasAddress (b, &addr));
     59    check (tr_blocklistFileHasAddress (b, &addr));
    6060    check (tr_address_from_string (&addr, "216.16.1.147"));
    61     check (_tr_blocklistHasAddress (b, &addr));
     61    check (tr_blocklistFileHasAddress (b, &addr));
    6262    check (tr_address_from_string (&addr, "216.16.1.148"));
    63     check (_tr_blocklistHasAddress (b, &addr));
     63    check (tr_blocklistFileHasAddress (b, &addr));
    6464    check (tr_address_from_string (&addr, "216.16.1.149"));
    65     check (_tr_blocklistHasAddress (b, &addr));
     65    check (tr_blocklistFileHasAddress (b, &addr));
    6666    check (tr_address_from_string (&addr, "216.16.1.150"));
    67     check (_tr_blocklistHasAddress (b, &addr));
     67    check (tr_blocklistFileHasAddress (b, &addr));
    6868    check (tr_address_from_string (&addr, "216.16.1.151"));
    69     check (_tr_blocklistHasAddress (b, &addr));
     69    check (tr_blocklistFileHasAddress (b, &addr));
    7070    check (tr_address_from_string (&addr, "216.16.1.152"));
    71     check (!_tr_blocklistHasAddress (b, &addr));
     71    check (!tr_blocklistFileHasAddress (b, &addr));
    7272    check (tr_address_from_string (&addr, "216.16.1.153"));
    73     check (!_tr_blocklistHasAddress (b, &addr));
     73    check (!tr_blocklistFileHasAddress (b, &addr));
    7474    check (tr_address_from_string (&addr, "217.0.0.1"));
    75     check (!_tr_blocklistHasAddress (b, &addr));
     75    check (!tr_blocklistFileHasAddress (b, &addr));
    7676    check (tr_address_from_string (&addr, "255.0.0.1"));
    7777
    7878    /* cleanup */
    79     _tr_blocklistFree (b);
     79    tr_blocklistFileFree (b);
    8080    remove (tmpfile_txt);
    8181    remove (tmpfile_bin);
  • trunk/libtransmission/blocklist.c

    r13823 r13824  
    5454};
    5555
    56 struct tr_blocklist
     56struct tr_blocklistFile
    5757{
    5858  bool                   isEnabled;
     
    6565
    6666static void
    67 blocklistClose (tr_blocklist * b)
     67blocklistClose (tr_blocklistFile * b)
    6868{
    6969  if (b->rules != NULL)
     
    7979
    8080static void
    81 blocklistLoad (tr_blocklist * b)
     81blocklistLoad (tr_blocklistFile * b)
    8282{
    8383  int fd;
     
    118118
    119119static void
    120 blocklistEnsureLoaded (tr_blocklist * b)
     120blocklistEnsureLoaded (tr_blocklistFile * b)
    121121{
    122122  if (b->rules == NULL)
     
    136136
    137137static void
    138 blocklistDelete (tr_blocklist * b)
     138blocklistDelete (tr_blocklistFile * b)
    139139{
    140140  blocklistClose (b);
     
    146146***/
    147147
    148 tr_blocklist *
    149 _tr_blocklistNew (const char * filename, bool isEnabled)
    150 {
    151   tr_blocklist * b;
    152 
    153   b = tr_new0 (tr_blocklist, 1);
     148tr_blocklistFile *
     149tr_blocklistFileNew (const char * filename, bool isEnabled)
     150{
     151  tr_blocklistFile * b;
     152
     153  b = tr_new0 (tr_blocklistFile, 1);
    154154  b->fd = -1;
    155155  b->filename = tr_strdup (filename);
     
    160160
    161161const char*
    162 _tr_blocklistGetFilename (const tr_blocklist * b)
     162tr_blocklistFileGetFilename (const tr_blocklistFile * b)
    163163{
    164164  return b->filename;
     
    166166
    167167void
    168 _tr_blocklistFree (tr_blocklist * b)
     168tr_blocklistFileFree (tr_blocklistFile * b)
    169169{
    170170  blocklistClose (b);
     
    174174
    175175int
    176 _tr_blocklistExists (const tr_blocklist * b)
     176tr_blocklistFileExists (const tr_blocklistFile * b)
    177177{
    178178  struct stat st;
     
    182182
    183183int
    184 _tr_blocklistGetRuleCount (const tr_blocklist * b)
    185 {
    186   blocklistEnsureLoaded ((tr_blocklist*)b);
     184tr_blocklistFileGetRuleCount (const tr_blocklistFile * b)
     185{
     186  blocklistEnsureLoaded ((tr_blocklistFile*)b);
    187187
    188188  return b->ruleCount;
     
    190190
    191191int
    192 _tr_blocklistIsEnabled (tr_blocklist * b)
     192tr_blocklistFileIsEnabled (tr_blocklistFile * b)
    193193{
    194194  return b->isEnabled;
     
    196196
    197197void
    198 _tr_blocklistSetEnabled (tr_blocklist * b, bool isEnabled)
     198tr_blocklistFileSetEnabled (tr_blocklistFile * b, bool isEnabled)
    199199{
    200200  b->isEnabled = isEnabled ? 1 : 0;
     
    202202
    203203int
    204 _tr_blocklistHasAddress (tr_blocklist * b, const tr_address * addr)
     204tr_blocklistFileHasAddress (tr_blocklistFile * b, const tr_address * addr)
    205205{
    206206  uint32_t needle;
     
    315315
    316316int
    317 _tr_blocklistSetContent (tr_blocklist * b, const char * filename)
     317tr_blocklistFileSetContent (tr_blocklistFile * b, const char * filename)
    318318{
    319319  FILE * in;
  • trunk/libtransmission/blocklist.h

    r13625 r13824  
    1919
    2020struct tr_address;
    21 typedef struct tr_blocklist tr_blocklist;
    2221
    23 tr_blocklist* _tr_blocklistNew       (const char              * filename,
    24                                          bool                   isEnabled);
     22typedef struct tr_blocklistFile tr_blocklistFile;
    2523
    26 int           _tr_blocklistExists    (const tr_blocklist      * b);
     24tr_blocklistFile * tr_blocklistFileNew          (const char              * filename,
     25                                                 bool                      isEnabled);
    2726
    28 const char*   _tr_blocklistGetFilename (const tr_blocklist      * b);
     27int                tr_blocklistFileExists       (const tr_blocklistFile  * b);
    2928
    30 int           _tr_blocklistGetRuleCount (const tr_blocklist      * b);
     29const char *       tr_blocklistFileGetFilename  (const tr_blocklistFile  * b);
    3130
    32 void          _tr_blocklistFree      (tr_blocklist *);
     31int                tr_blocklistFileGetRuleCount (const tr_blocklistFile  * b);
    3332
    34 int           _tr_blocklistIsEnabled (tr_blocklist            * b);
     33void               tr_blocklistFileFree         (tr_blocklistFile        * b);
    3534
    36 void          _tr_blocklistSetEnabled (tr_blocklist            * b,
    37                                          bool                      isEnabled);
     35int                tr_blocklistFileIsEnabled    (tr_blocklistFile        * b);
    3836
    39 int           _tr_blocklistHasAddress (tr_blocklist            * b,
    40                                          const struct tr_address * addr);
     37void               tr_blocklistFileSetEnabled   (tr_blocklistFile        * b,
     38                                                 bool                      isEnabled);
    4139
    42 int           _tr_blocklistSetContent (tr_blocklist            * b,
    43                                          const char              * filename);
     40int                tr_blocklistFileHasAddress   (tr_blocklistFile        * b,
     41                                                 const struct tr_address * addr);
     42
     43int                tr_blocklistFileSetContent   (tr_blocklistFile        * b,
     44                                                 const char              * filename);
    4445
    4546#endif
  • trunk/libtransmission/session.c

    r13710 r13824  
    22162216                {
    22172217                    tr_list_append (&list,
    2218                                    _tr_blocklistNew (filename, isEnabled));
     2218                                   tr_blocklistFileNew (filename, isEnabled));
    22192219                    ++binCount;
    22202220                }
     
    22242224                /* strip out the file suffix, if there is one, and add ".bin"
    22252225                  instead */
    2226                 tr_blocklist * b;
     2226                tr_blocklistFile * b;
    22272227                const char *   dot = strrchr (d->d_name, '.');
    22282228                const int      len = dot ? dot - d->d_name
     
    22312231                                        "%s" TR_PATH_DELIMITER_STR "%*.*s.bin",
    22322232                                        dirname, len, len, d->d_name);
    2233                 b = _tr_blocklistNew (tmp, isEnabled);
    2234                 _tr_blocklistSetContent (b, filename);
     2233                b = tr_blocklistFileNew (tmp, isEnabled);
     2234                tr_blocklistFileSetContent (b, filename);
    22352235                tr_list_append (&list, b);
    22362236                ++newCount;
     
    22582258{
    22592259    tr_list_free (&session->blocklists,
    2260                 (TrListForeachFunc)_tr_blocklistFree);
     2260                (TrListForeachFunc)tr_blocklistFileFree);
    22612261}
    22622262
     
    22792279
    22802280    for (l = session->blocklists; l; l = l->next)
    2281         n += _tr_blocklistGetRuleCount (l->data);
     2281        n += tr_blocklistFileGetRuleCount (l->data);
    22822282    return n;
    22832283}
     
    23012301
    23022302    for (l=session->blocklists; l!=NULL; l=l->next)
    2303         _tr_blocklistSetEnabled (l->data, isEnabled);
     2303        tr_blocklistFileSetEnabled (l->data, isEnabled);
    23042304}
    23052305
     
    23172317    tr_list * l;
    23182318    int ruleCount;
    2319     tr_blocklist * b;
     2319    tr_blocklistFile * b;
    23202320    const char * defaultName = DEFAULT_BLOCKLIST_FILENAME;
    23212321    tr_sessionLock (session);
    23222322
    23232323    for (b = NULL, l = session->blocklists; !b && l; l = l->next)
    2324         if (tr_stringEndsWith (_tr_blocklistGetFilename (l->data),
     2324        if (tr_stringEndsWith (tr_blocklistFileGetFilename (l->data),
    23252325                               defaultName))
    23262326            b = l->data;
     
    23292329    {
    23302330        char * path = tr_buildPath (session->configDir, "blocklists", defaultName, NULL);
    2331         b = _tr_blocklistNew (path, session->isBlocklistEnabled);
     2331        b = tr_blocklistFileNew (path, session->isBlocklistEnabled);
    23322332        tr_list_append (&session->blocklists, b);
    23332333        tr_free (path);
    23342334    }
    23352335
    2336     ruleCount = _tr_blocklistSetContent (b, contentFilename);
     2336    ruleCount = tr_blocklistFileSetContent (b, contentFilename);
    23372337    tr_sessionUnlock (session);
    23382338    return ruleCount;
     
    23482348
    23492349    for (l = session->blocklists; l; l = l->next)
    2350         if (_tr_blocklistHasAddress (l->data, addr))
     2350        if (tr_blocklistFileHasAddress (l->data, addr))
    23512351            return true;
    23522352    return false;
Note: See TracChangeset for help on using the changeset viewer.