Changeset 4426

Show
Ignore:
Timestamp:
01/25/07 15:46:44 (2 years ago)
Author:
morris
Message:

Update for libwired

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wired/trunk/wired/accounts.c

    r4403 r4426  
    4848 
    4949 
    50 static int                                                    _wd_accounts_delete_from_file(wi_file_t *, wi_string_t *); 
     50static wi_boolean_t                                   _wd_accounts_delete_from_file(wi_file_t *, wi_string_t *); 
    5151static void                                                     _wd_accounts_reload_user(wi_string_t *); 
    5252static void                                                     _wd_accounts_reload_group(wi_string_t *); 
     
    521521#pragma mark - 
    522522 
    523 static int _wd_accounts_delete_from_file(wi_file_t *file, wi_string_t *name) { 
     523static wi_boolean_t _wd_accounts_delete_from_file(wi_file_t *file, wi_string_t *name) { 
    524524        wi_file_t               *tmpfile; 
    525525        wi_array_t              *array; 
     
    746746        wi_file_t               *file; 
    747747        wi_string_t             *string; 
    748         uint32_t              index; 
     748        wi_uinteger_t index; 
    749749 
    750750        wi_lock_lock(wd_users_lock); 
     
    779779        wi_file_t               *file; 
    780780        wi_string_t             *string; 
    781         uint32_t              index; 
     781        wi_uinteger_t index; 
    782782 
    783783        wi_lock_lock(wd_groups_lock); 
     
    818818 
    819819wd_account_t * wd_account_init_user_with_array(wd_account_t *account, wi_array_t *array) { 
    820         uint32_t      count; 
     820        wi_uinteger_t count; 
    821821         
    822822        count                                           = wi_array_count(array); 
     
    855855 
    856856wd_account_t * wd_account_init_group_with_array(wd_account_t *account, wi_array_t *array) { 
    857         uint32_t      count; 
     857        wi_uinteger_t count; 
    858858         
    859859        count                                           = wi_array_count(array); 
  • wired/trunk/wired/banlist.c

    r4403 r4426  
    9090        wd_tempban_t            *tempban; 
    9191        wi_time_interval_t      interval; 
    92         uint32_t                      i, count; 
     92        wi_uinteger_t         i, count; 
    9393         
    9494        count = wi_array_count(wd_tempbans); 
  • wired/trunk/wired/clients.h

    r4403 r4426  
    7171        wi_string_t                                                     *ip; 
    7272        wi_string_t                                                     *host; 
    73         uint32_t                                                      port; 
     73        wi_uinteger_t                                         port; 
    7474        wi_string_t                                                     *version; 
    7575        wi_string_t                                                     *status; 
     
    7878         
    7979        char                                                            *buffer; 
    80         uint32_t                                                      buffer_size; 
    81         uint32_t                                                      buffer_offset; 
     80        wi_uinteger_t                                         buffer_size; 
     81        wi_uinteger_t                                         buffer_offset; 
    8282 
    8383        wi_time_interval_t                                      login_time; 
  • wired/trunk/wired/commands.c

    r4403 r4426  
    5555 
    5656        /* minimum number of arguments required */ 
    57         uint32_t                                      args; 
     57        wi_uinteger_t                         args; 
    5858 
    5959        /* activates idle clients? */ 
     
    6666 
    6767static void                                             wd_parse_command(wi_string_t *); 
    68 static uint32_t                                       wd_command_index(wi_string_t *); 
     68static wi_uinteger_t                  wd_command_index(wi_string_t *); 
    6969 
    7070static void                                             wd_cmd_ban(wi_array_t *); 
     
    219219 
    220220void wd_control_thread(wi_runtime_instance_t *argument) { 
    221         wi_pool_t               *pool; 
    222         wd_client_t             *client = argument; 
    223         wi_string_t             *string; 
    224         uint32_t               i = 0
    225         int                            state
     221        wi_pool_t                      *pool; 
     222        wd_client_t                    *client = argument; 
     223        wi_string_t                    *string; 
     224        wi_socket_state_t      state
     225        wi_uinteger_t          i = 0
    226226         
    227227        pool = wi_pool_init(wi_pool_alloc()); 
     
    237237                        do { 
    238238                                state = wi_socket_wait(client->socket, 0.1); 
    239                         } while(state == 0 && client->state <= WD_CLIENT_STATE_LOGGED_IN); 
     239                        } while(state == WI_SOCKET_TIMEOUT && client->state <= WD_CLIENT_STATE_LOGGED_IN); 
    240240                         
    241241                        if(client->state > WD_CLIENT_STATE_LOGGED_IN) { 
     
    244244                        } 
    245245 
    246                         if(state < 0) { 
     246                        if(state == WI_SOCKET_ERROR) { 
    247247                                if(wi_error_code() == EINTR) { 
    248248                                        /* got a signal */ 
     
    308308        wi_array_t              *arguments; 
    309309        wi_string_t             *command; 
    310         uint32_t              index; 
     310        wi_uinteger_t index; 
    311311         
    312312        wi_parse_wired_command(buffer, &command, &arguments); 
     
    344344 
    345345 
    346 static uint32_t                wd_command_index(wi_string_t *command) { 
     346static wi_uinteger_t wd_command_index(wi_string_t *command) { 
    347347        const char              *cstring; 
    348         uint32_t              i, min, max; 
    349         int32_t                       cmp; 
     348        wi_uinteger_t i, min, max; 
     349        int                           cmp; 
    350350 
    351351        cstring = wi_string_cstring(command); 
     
    12421242        wd_chat_t               *chat; 
    12431243        wd_cid_t                cid; 
    1244         uint32_t              i, count; 
     1244        wi_uinteger_t i, count; 
    12451245 
    12461246        cid = wi_string_uint32(WI_ARRAY(arguments, 0)); 
     
    15851585        wd_chat_t               *chat; 
    15861586        wd_cid_t                cid; 
    1587         uint32_t              i, count; 
     1587        wi_uinteger_t i, count; 
    15881588 
    15891589        cid = wi_string_uint32(WI_ARRAY(arguments, 0)); 
  • wired/trunk/wired/files.c

    r4403 r4426  
    8181static wi_rwlock_t                                                      *wd_files_index_lock; 
    8282static wi_lock_t                                                        *wd_files_indexer_lock; 
    83 static uint32_t                                                               wd_files_index_level; 
     83static wi_uinteger_t                                          wd_files_index_level; 
    8484static wi_set_t                                                         *wd_files_index_set; 
    8585 
    86 uint32_t                                                                      wd_files_count, wd_files_unique_count; 
    87 uint32_t                                                                      wd_directories_count, wd_directories_unique_count; 
     86wi_uinteger_t                                                         wd_files_count, wd_files_unique_count; 
     87wi_uinteger_t                                                         wd_directories_count, wd_directories_unique_count; 
    8888wi_file_offset_t                                                        wd_files_size, wd_files_unique_size; 
    8989 
     
    122122        wd_files_fts_action_t   action; 
    123123        struct stat                             sb; 
    124         uint32_t                              pathlength; 
    125         int                                             err
     124        wi_uinteger_t                 pathlength; 
     125        int                                             error
    126126        wi_boolean_t                    root, upload; 
    127127         
     
    146146                wd_reply_error(); 
    147147 
    148                 goto err
     148                goto error
    149149        } 
    150150         
     
    156156        while((p = wi_fts_read(fts))) { 
    157157                /* skip item? */ 
    158                 action = wd_files_fts_action(p, &err); 
     158                action = wd_files_fts_action(p, &error); 
    159159                 
    160160                switch(action) { 
     
    174174                        case WD_FILES_FTS_ERROR: 
    175175                                wi_log_warn(WI_STR("Could not list %s: %s"), 
    176                                         p->fts_path, strerror(err)); 
     176                                        p->fts_path, strerror(error)); 
    177177 
    178178                                continue; 
     
    266266                         available); 
    267267 
    268 err
     268error
    269269        if(fts) 
    270270                wi_fts_close(fts); 
     
    278278        wi_file_offset_t                count = 0; 
    279279        wd_files_fts_action_t   action; 
    280         int                                             err
     280        int                                             error
    281281         
    282282        fts = wd_files_fts_open(path); 
     
    292292        while((p = wi_fts_read(fts))) { 
    293293                /* skip item? */ 
    294                 action = wd_files_fts_action(p, &err); 
     294                action = wd_files_fts_action(p, &error); 
    295295                 
    296296                switch(action) { 
     
    534534        wd_file_type_t                  type; 
    535535        struct stat                             sb; 
    536         uint32_t                              pathlength; 
    537         int                                             err
     536        wi_uinteger_t                 pathlength; 
     537        int                                             error
    538538        wi_boolean_t                    alias, recurse; 
    539539 
     
    557557        while((p = wi_fts_read(fts))) { 
    558558                /* skip item? */ 
    559                 action = wd_files_fts_action(p, &err); 
     559                action = wd_files_fts_action(p, &error); 
    560560                 
    561561                switch(action) { 
     
    575575                        case WD_FILES_FTS_ERROR: 
    576576                                wi_log_warn(WI_STR("Could not search %s: %s"), 
    577                                         p->fts_path, strerror(err)); 
     577                                        p->fts_path, strerror(error)); 
    578578 
    579579                                continue; 
     
    662662        wi_string_t             *string; 
    663663        wi_range_t              range; 
    664         uint32_t              i = 0, pathlength, index; 
     664        wi_uinteger_t i = 0, pathlength, index; 
    665665         
    666666        wi_rwlock_rdlock(wd_files_index_lock); 
     
    757757        wi_string_t                     *path, *realpath; 
    758758        wi_time_interval_t      interval; 
    759         uint32_t                      count, capacity; 
     759        wi_uinteger_t         count, capacity; 
    760760         
    761761        pool = wi_pool_init(wi_pool_alloc()); 
     
    839839        wd_files_fts_action_t   action; 
    840840        struct stat                             sb; 
    841         int                                             err
    842         uint32_t                              i = 0, pathlength; 
     841        int                                             error
     842        wi_uinteger_t                 i = 0, pathlength; 
    843843        wi_boolean_t                    alias, recurse; 
    844844         
     
    871871                 
    872872                /* skip item? */ 
    873                 action = wd_files_fts_action(p, &err); 
     873                action = wd_files_fts_action(p, &error); 
    874874                 
    875875                switch(action) { 
     
    889889                        case WD_FILES_FTS_ERROR: 
    890890                                wi_log_warn(WI_STR("Skipping index of %s: %s"), 
    891                                         p->fts_path, strerror(err)); 
     891                                        p->fts_path, strerror(error)); 
    892892 
    893893                                continue; 
     
    10991099        wi_string_t             *name, *dirpath, *realdirpath, *metapath, *commentpath; 
    11001100        wi_string_t             *string, *eachname, *eachcomment; 
    1101         uint32_t              comments = 0; 
     1101        wi_uinteger_t comments = 0; 
    11021102         
    11031103        name            = wi_string_last_path_component(path); 
     
    12321232        wi_array_t              *array; 
    12331233        wd_file_type_t  type; 
    1234         uint32_t              i, count; 
     1234        wi_uinteger_t i, count; 
    12351235        wi_boolean_t    result = false; 
    12361236         
  • wired/trunk/wired/files.h

    r4403 r4426  
    7575 
    7676 
    77 extern uint32_t                                                       wd_files_count, wd_files_unique_count; 
    78 extern uint32_t                                                       wd_folders_count, wd_folders_unique_count; 
     77extern wi_uinteger_t                                  wd_files_count, wd_files_unique_count; 
     78extern wi_uinteger_t                                  wd_folders_count, wd_folders_unique_count; 
    7979extern wi_file_offset_t                                 wd_files_size, wd_files_unique_size; 
    8080 
  • wired/trunk/wired/main.c

    r4403 r4426  
    7373wi_lock_t                                               *wd_status_lock; 
    7474wi_date_t                                               *wd_start_date; 
    75 uint32_t                                              wd_current_users, wd_total_users; 
    76 uint32_t                                              wd_current_downloads, wd_total_downloads; 
    77 uint32_t                                              wd_current_uploads, wd_total_uploads; 
     75wi_uinteger_t                                 wd_current_users, wd_total_users; 
     76wi_uinteger_t                                 wd_current_downloads, wd_total_downloads; 
     77wi_uinteger_t                                 wd_current_uploads, wd_total_uploads; 
    7878wi_file_offset_t                                wd_downloads_traffic, wd_uploads_traffic; 
    7979 
     
    419419void wd_signal_thread(wi_runtime_instance_t *arg) { 
    420420        wi_pool_t               *pool; 
    421         uint32_t              i = 0; 
     421        wi_uinteger_t i = 0; 
    422422        int                             signal; 
    423423 
  • wired/trunk/wired/main.h

    r3551 r4426  
    4242extern wi_lock_t                                        *wd_status_lock; 
    4343extern wi_date_t                                        *wd_start_date; 
    44 extern unsigned int                                   wd_current_users, wd_total_users; 
    45 extern unsigned int                                   wd_current_downloads, wd_total_downloads; 
    46 extern unsigned int                                   wd_current_uploads, wd_total_uploads; 
    47 extern unsigned long long                     wd_downloads_traffic, wd_uploads_traffic; 
     44extern wi_uinteger_t                          wd_current_users, wd_total_users; 
     45extern wi_uinteger_t                          wd_current_downloads, wd_total_downloads; 
     46extern wi_uinteger_t                          wd_current_uploads, wd_total_uploads; 
     47extern wi_file_offset_t                               wd_downloads_traffic, wd_uploads_traffic; 
    4848 
    4949#endif /* WD_MAIN_H */ 
  • wired/trunk/wired/news.c

    r4403 r4426  
    8080        wi_file_t               *file, *tmpfile = NULL; 
    8181        wi_string_t             *string, *separator, *post = NULL; 
    82         uint32_t              i = 0; 
     82        wi_uinteger_t i = 0; 
    8383        wi_boolean_t    first = true; 
    8484         
  • wired/trunk/wired/server.c

    r4403 r4426  
    272272        wi_string_t                     *ip; 
    273273        wd_client_t                     *client; 
    274         uint32_t                      i = 0; 
     274        wi_uinteger_t         i = 0; 
    275275         
    276276        pool = wi_pool_init(wi_pool_alloc()); 
     
    326326        wi_string_t                     *ip, *string, *command; 
    327327        wd_transfer_t           *transfer; 
    328         uint32_t                      i = 0; 
     328        wi_uinteger_t         i = 0; 
    329329         
    330330        pool = wi_pool_init(wi_pool_alloc()); 
  • wired/trunk/wired/settings.h

    r4403 r4426  
    4545        wi_boolean_t                                    banner_changed; 
    4646        wi_array_t                                              *address; 
    47         uint32_t                                              port; 
     47        wi_uinteger_t                                 port; 
    4848 
    4949        uid_t                                                   user; 
     
    5252        wi_time_interval_t                              idletime; 
    5353        wi_time_interval_t                              bantime; 
    54         uint32_t                                              newslimit; 
     54        wi_uinteger_t                                 newslimit; 
    5555 
    5656        wi_string_t                                             *files; 
     
    6767        wi_array_t                                              *tracker; 
    6868        wi_string_t                                             *url; 
    69         uint32_t                                              bandwidth; 
     69        wi_uinteger_t                                 bandwidth; 
    7070 
    71         uint32_t                                              totaldownloads; 
    72         uint32_t                                              totaluploads; 
    73         uint32_t                                              clientdownloads; 
    74         uint32_t                                              clientuploads; 
    75         uint32_t                                              totaldownloadspeed; 
    76         uint32_t                                              totaluploadspeed; 
     71        wi_uinteger_t                                 totaldownloads; 
     72        wi_uinteger_t                                 totaluploads; 
     73        wi_uinteger_t                                 clientdownloads; 
     74        wi_uinteger_t                                 clientuploads; 
     75        wi_uinteger_t                                 totaldownloadspeed; 
     76        wi_uinteger_t                                 totaluploadspeed; 
    7777 
    7878        wi_string_t                                             *controlcipher; 
  • wired/trunk/wired/trackers.c

    r4403 r4426  
    124124        wi_address_t            *address; 
    125125        wd_tracker_t            *tracker; 
    126         uint32_t                      port; 
     126        wi_uinteger_t         port; 
    127127         
    128128        wi_array_wrlock(wd_trackers); 
     
    419419        wi_socket_t                     *socket; 
    420420        wi_string_t                     *string = NULL; 
     421        wi_integer_t            bytes; 
    421422        uint32_t                        guest, download; 
    422         int                                     bytes; 
    423423         
    424424        guest = (wd_trackers_guest_account != NULL); 
     
    484484static wi_boolean_t wd_tracker_write(wd_tracker_t *tracker, wi_string_t *fmt, ...) { 
    485485        wi_string_t             *string; 
    486         int                           bytes; 
     486        wi_integer_t  bytes; 
    487487        va_list                 ap; 
    488488 
  • wired/trunk/wired/transfers.c

    r4403 r4426  
    102102        wi_time_interval_t      interval; 
    103103        wi_boolean_t            update = false; 
    104         uint32_t                      i, count; 
     104        wi_uinteger_t         i, count; 
    105105         
    106106        wi_array_wrlock(wd_transfers); 
     
    225225wi_boolean_t wd_transfers_can_queue(wd_transfer_type_t type) { 
    226226        wd_client_t             *client = wd_client(); 
    227         uint32_t              i, count, limit; 
     227        wi_uinteger_t i, count, limit; 
    228228         
    229229        limit = (type == WD_TRANSFER_DOWNLOAD) ? wd_settings.clientdownloads : wd_settings.clientuploads; 
     
    253253 
    254254 
    255 uint32_t wd_transfers_count_of_client(wd_client_t *client, wd_transfer_type_t type) { 
     255wi_uinteger_t wd_transfers_count_of_client(wd_client_t *client, wd_transfer_type_t type) { 
    256256        wd_transfer_t   *transfer; 
    257         uint32_t              i, count, clientcount = 0; 
     257        wi_uinteger_t i, count, clientcount = 0; 
    258258         
    259259        wi_array_rdlock(wd_transfers); 
     
    280280        wd_transfer_t   *transfer; 
    281281        wi_boolean_t    update = false; 
    282         uint32_t              i, count; 
     282        wi_uinteger_t i, count; 
    283283 
    284284        wi_array_wrlock(wd_transfers); 
     
    319319wd_transfer_t * wd_transfers_transfer_with_hash(wi_string_t *hash) { 
    320320        wd_transfer_t   *transfer, *value = NULL; 
    321         uint32_t              i, count; 
     321        wi_uinteger_t i, count; 
    322322 
    323323        wi_array_rdlock(wd_transfers); 
     
    348348        wd_transfer_t       *transfer; 
    349349        wd_client_t         *client; 
    350         uint32_t                      position_downloads, position_uploads; 
    351         uint32_t                      client_downloads, client_uploads; 
    352         uint32_t                      all_downloads, all_uploads; 
    353         uint32_t                      position; 
    354         uint32_t                      i, count; 
     350        wi_uinteger_t         position_downloads, position_uploads; 
     351        wi_uinteger_t         client_downloads, client_uploads; 
     352        wi_uinteger_t         all_downloads, all_uploads; 
     353        wi_uinteger_t         position; 
     354        wi_uinteger_t         i, count; 
    355355 
    356356        wi_array_rdlock(wd_transfers); 
     
    541541 
    542542static inline void wd_transfer_limit_download_speed(wd_transfer_t *transfer, ssize_t bytes, wi_time_interval_t now, wi_time_interval_t then) { 
    543         uint32_t      limit, totallimit; 
     543        wi_uinteger_t limit, totallimit; 
    544544         
    545545        if(transfer->client->account->download_speed > 0 || wd_settings.totaldownloadspeed > 0) { 
     
    569569 
    570570static inline void wd_transfer_limit_upload_speed(wd_transfer_t *transfer, ssize_t bytes, wi_time_interval_t now, wi_time_interval_t then) { 
    571         uint32_t      limit, totallimit; 
     571        wi_uinteger_t limit, totallimit; 
    572572         
    573573        if(transfer->client->account->upload_speed > 0 || wd_settings.totaluploadspeed > 0) { 
     
    627627        char                                    buffer[WD_TRANSFER_BUFFER_SIZE]; 
    628628        wi_time_interval_t              interval, speedinterval, statusinterval; 
     629        wi_socket_state_t               state; 
    629630        ssize_t                                 bytes, speedbytes, statsbytes; 
    630         uint32_t                              i = 0; 
    631         int                                             fd, sd, state
     631        wi_uinteger_t                 i = 0; 
     632        int                                             fd, sd
    632633 
    633634        pool = wi_pool_init(wi_pool_alloc()); 
     
    675676                do { 
    676677                        state = wi_socket_wait_descriptor(sd, 0.1, false, true); 
    677                 } while(state == 0 && transfer->state == WD_TRANSFER_RUNNING); 
     678                } while(state == WI_SOCKET_TIMEOUT && transfer->state == WD_TRANSFER_RUNNING); 
    678679 
    679680                if(transfer->state != WD_TRANSFER_RUNNING)  { 
     
    682683                } 
    683684 
    684                 if(state < 0) { 
     685                if(state == WI_SOCKET_ERROR) { 
    685686                        if(wi_error_code() == EINTR) { 
    686687                                /* got a signal */ 
     
    763764        char                                    buffer[WD_TRANSFER_BUFFER_SIZE]; 
    764765        wi_time_interval_t              interval, speedinterval, statusinterval; 
     766        wi_socket_state_t               state; 
    765767        ssize_t                                 bytes, speedbytes, statsbytes; 
    766         uint32_t                              i = 0; 
    767         int                                             sd, fd, state
     768        wi_uinteger_t                 i = 0; 
     769        int                                             sd, fd
    768770 
    769771        pool = wi_pool_init(wi_pool_alloc()); 
     
    803805                do { 
    804806                        state = wi_socket_wait_descriptor(sd, 0.1, true, false); 
    805                 } while(state == 0 && transfer->state == WD_TRANSFER_RUNNING); 
     807                } while(state == WI_SOCKET_TIMEOUT && transfer->state == WD_TRANSFER_RUNNING); 
    806808 
    807809                if(transfer->state != WD_TRANSFER_RUNNING)  { 
     
    810812                } 
    811813 
    812                 if(state < 0) { 
     814                if(state == WI_SOCKET_ERROR) { 
    813815                        if(wi_error_code() == EINTR) { 
    814816                                /* got a signal */ 
  • wired/trunk/wired/transfers.h

    r4403 r4426  
    6969        wd_transfer_type_t                                      type; 
    7070 
    71         unsigned int                                          queue; 
     71        uint32_t                                                      queue; 
    7272        wi_time_interval_t                                      queue_time; 
    7373 
     
    7575        wi_file_offset_t                                        size; 
    7676        wi_file_offset_t                                        transferred; 
    77         unsigned int                                          speed; 
     77        uint32_t                                                      speed; 
    7878}; 
    7979typedef struct _wd_transfer                             wd_transfer_t; 
     
    8686void                                                                    wd_transfers_queue_upload(wi_string_t *, wi_file_offset_t, wi_string_t *); 
    8787wi_boolean_t                                                    wd_transfers_can_queue(wd_transfer_type_t); 
    88 unsigned int                                                  wd_transfers_count_of_client(wd_client_t *, wd_transfer_type_t); 
     88wi_uinteger_t                                                 wd_transfers_count_of_client(wd_client_t *, wd_transfer_type_t); 
    8989void                                                                    wd_transfers_remove_client(wd_client_t *); 
    9090wd_transfer_t *                                                 wd_transfers_transfer_with_hash(wi_string_t *);