From 96fa1b7327b35cdeca6c77f2fdde906cabc437d8 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 24 Oct 2026 20:30:30 +0200 Subject: Replace custom int64 with its standardized int64_t type --- opentracker.c | 16 ++++++++-------- ot_fullscrape.c | 2 +- ot_fullscrape.h | 2 +- ot_http.c | 16 ++++++++-------- ot_http.h | 6 +++--- ot_livesync.c | 4 ++-- ot_livesync.h | 2 +- ot_mutex.c | 10 +++++----- ot_mutex.h | 14 +++++++------- ot_stats.c | 2 +- ot_stats.h | 2 +- ot_sync.c | 2 +- ot_sync.h | 4 +++- ot_udp.c | 6 +++--- ot_udp.h | 6 ++++-- proxy.c | 26 +++++++++++++------------- 16 files changed, 62 insertions(+), 58 deletions(-) diff --git a/opentracker.c b/opentracker.c index 8a39bde..af336aa 100644 --- a/opentracker.c +++ b/opentracker.c @@ -156,7 +156,7 @@ static ssize_t header_complete(char *request, ssize_t byte_count) { return 0; } -static void handle_dead(const int64 sock) { +static void handle_dead(const int64_t sock) { struct http_data *cookie = io_getcookie(sock); if (cookie) { size_t i; @@ -171,7 +171,7 @@ static void handle_dead(const int64 sock) { io_close(sock); } -static void handle_read(const int64 sock, struct ot_workstruct *ws) { +static void handle_read(const int64_t sock, struct ot_workstruct *ws) { struct http_data *cookie = io_getcookie(sock); ssize_t byte_count = io_tryread(sock, ws->inbuf, G_INBUF_SIZE); @@ -215,7 +215,7 @@ static void handle_read(const int64 sock, struct ot_workstruct *ws) { } } -static void handle_write(const int64 sock) { +static void handle_write(const int64_t sock) { struct http_data *cookie = io_getcookie(sock); size_t i; int chunked = 0; @@ -227,7 +227,7 @@ static void handle_write(const int64 sock) { for (i = 0; i < cookie->batches; ++i) { if (cookie->batch[i].bytesleft) { - int64 res = iob_send(sock, cookie->batch + i); + int64_t res = iob_send(sock, cookie->batch + i); if (res == -3) { handle_dead(sock); @@ -250,9 +250,9 @@ static void handle_write(const int64 sock) { handle_dead(sock); } -static void handle_accept(const int64 serversocket) { +static void handle_accept(const int64_t serversocket) { struct http_data *cookie; - int64 sock; + int64_t sock; ot_ip6 ip; uint16 port; tai6464 t; @@ -305,7 +305,7 @@ static void *server_mainloop(void *args) { random_bytes(ws.rand48_state, sizeof(ws.rand48_state)); for (;;) { - int64 sock; + int64_t sock; io_wait(); @@ -339,7 +339,7 @@ static void *server_mainloop(void *args) { } static int64_t ot_try_bind(ot_ip6 ip, uint16_t port, PROTO_FLAG proto) { - int64 sock = proto == FLAG_TCP ? socket_tcp6() : socket_udp6(); + int64_t sock = proto == FLAG_TCP ? socket_tcp6() : socket_udp6(); #ifdef _DEBUG { diff --git a/ot_fullscrape.c b/ot_fullscrape.c index 3d0e2f1..9dcbe68 100644 --- a/ot_fullscrape.c +++ b/ot_fullscrape.c @@ -82,7 +82,7 @@ void fullscrape_deinit(void) { pthread_cancel( thread_id ); } -void fullscrape_deliver( int64 sock, ot_tasktype tasktype ) { +void fullscrape_deliver( int64_t sock, ot_tasktype tasktype ) { mutex_workqueue_pushtask( sock, tasktype ); } diff --git a/ot_fullscrape.h b/ot_fullscrape.h index 843e039..0e7690c 100644 --- a/ot_fullscrape.h +++ b/ot_fullscrape.h @@ -12,7 +12,7 @@ void fullscrape_init(void); void fullscrape_deinit(void); -void fullscrape_deliver(int64 sock, ot_tasktype tasktype); +void fullscrape_deliver(int64_t sock, ot_tasktype tasktype); #else diff --git a/ot_http.c b/ot_http.c index fca9176..46ca5a9 100644 --- a/ot_http.c +++ b/ot_http.c @@ -44,7 +44,7 @@ ssize_t g_stats_path_len; enum { SUCCESS_HTTP_HEADER_LENGTH = 80, SUCCESS_HTTP_SIZE_OFF = 17 }; -static void http_senddata(const int64 sock, struct ot_workstruct *ws) { +static void http_senddata(const int64_t sock, struct ot_workstruct *ws) { struct http_data *cookie = io_getcookie(sock); ssize_t written_size; @@ -124,7 +124,7 @@ static void http_senddata(const int64 sock, struct ot_workstruct *ws) { #define HTTPERROR_403_IP return http_issue_error(sock, ws, CODE_HTTPERROR_403_IP) #define HTTPERROR_404 return http_issue_error(sock, ws, CODE_HTTPERROR_404) #define HTTPERROR_500 return http_issue_error(sock, ws, CODE_HTTPERROR_500) -ssize_t http_issue_error(const int64 sock, struct ot_workstruct *ws, int code) { +ssize_t http_issue_error(const int64_t sock, struct ot_workstruct *ws, int code) { char *error_code[] = {"302 Found", "400 Invalid Request", "400 Invalid Request", "400 Invalid Request", "402 Payment Required", "403 Not Modest", "403 Access Denied", "404 Not Found", "500 Internal Server Error"}; char *title = error_code[code]; @@ -144,7 +144,7 @@ ssize_t http_issue_error(const int64 sock, struct ot_workstruct *ws, int code) { return ws->reply_size = -2; } -ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial) { +ssize_t http_sendiovecdata(const int64_t sock, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial) { struct http_data *cookie = io_getcookie(sock); io_batch *current; char *header; @@ -243,7 +243,7 @@ ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, size_t io return 0; } -static ssize_t http_handle_stats(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { +static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, char *read_ptr) { static const ot_keywords keywords_main[] = {{"mode", 1}, {"format", 2}, {"info_hash", 3}, {NULL, -3}}; static const ot_keywords keywords_mode[] = {{"peer", TASK_STATS_PEERS}, {"conn", TASK_STATS_CONNS}, @@ -368,7 +368,7 @@ typedef struct { #endif #ifdef WANT_FULLSCRAPE -static ssize_t http_handle_fullscrape(const int64 sock, struct ot_workstruct *ws) { +static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct *ws) { struct http_data *cookie = io_getcookie(sock); int format = 0; tai6464 t; @@ -438,7 +438,7 @@ static ssize_t http_handle_fullscrape(const int64 sock, struct ot_workstruct *ws } #endif -static ssize_t http_handle_scrape(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { +static ssize_t http_handle_scrape(const int64_t sock, struct ot_workstruct *ws, char *read_ptr) { static const ot_keywords keywords_scrape[] = {{"info_hash", 1}, {NULL, -3}}; ot_hash *multiscrape_buf = (ot_hash *)ws->request; @@ -517,7 +517,7 @@ static ot_keywords keywords_announce[] = {{"port", 1}, {"left", 2}, {"event", #endif {"peer_id", 9}, {NULL, -3}}; static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; -static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { +static ssize_t http_handle_announce(const int64_t sock, struct ot_workstruct *ws, char *read_ptr) { size_t numwant; int tmp, scanon; unsigned short port = 0; @@ -695,7 +695,7 @@ static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct * return ws->reply_size; } -ssize_t http_handle_request(const int64 sock, struct ot_workstruct *ws) { +ssize_t http_handle_request(const int64_t sock, struct ot_workstruct *ws) { ssize_t reply_off, len; char *read_ptr = ws->request, *write_ptr; diff --git a/ot_http.h b/ot_http.h index e53accc..004d710 100644 --- a/ot_http.h +++ b/ot_http.h @@ -25,9 +25,9 @@ struct http_data { STRUCT_HTTP_FLAG flag; }; -ssize_t http_handle_request(const int64 s, struct ot_workstruct *ws); -ssize_t http_sendiovecdata(const int64 s, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial); -ssize_t http_issue_error(const int64 s, struct ot_workstruct *ws, int code); +ssize_t http_handle_request(const int64_t s, struct ot_workstruct *ws); +ssize_t http_sendiovecdata(const int64_t s, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial); +ssize_t http_issue_error(const int64_t s, struct ot_workstruct *ws, int code); extern char *g_stats_path; extern ssize_t g_stats_path_len; diff --git a/ot_livesync.c b/ot_livesync.c index f6bb28b..8b2dee6 100644 --- a/ot_livesync.c +++ b/ot_livesync.c @@ -40,10 +40,10 @@ enum { OT_SYNC_PEER4, OT_SYNC_PEER6 }; static void *livesync_worker(void *args); /* For outgoing packets */ -static int64 g_socket_in = -1; +static int64_t g_socket_in = -1; /* For incoming packets */ -static int64 g_socket_out = -1; +static int64_t g_socket_out = -1; static pthread_mutex_t g_outbuf_mutex = PTHREAD_MUTEX_INITIALIZER; typedef struct { diff --git a/ot_livesync.h b/ot_livesync.h index ed710f0..6eca479 100644 --- a/ot_livesync.h +++ b/ot_livesync.h @@ -62,7 +62,7 @@ void livesync_tell(struct ot_workstruct *ws); void livesync_ticker(void); /* Handle an incoming live sync packet */ -void handle_livesync(const int64 sock); +void handle_livesync(const int64_t sock); #else diff --git a/ot_mutex.c b/ot_mutex.c index affec6b..2a8cbf5 100644 --- a/ot_mutex.c +++ b/ot_mutex.c @@ -62,7 +62,7 @@ size_t mutex_get_torrent_count(void) { return g_torrent_count; } struct ot_task { ot_taskid taskid; ot_tasktype tasktype; - int64 sock; + int64_t sock; size_t iovec_entries; struct iovec *iovec; struct ot_task *next; @@ -73,7 +73,7 @@ static struct ot_task *tasklist; static pthread_mutex_t tasklist_mutex; static pthread_cond_t tasklist_being_filled; -int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype) { +int mutex_workqueue_pushtask(int64_t sock, ot_tasktype tasktype) { struct ot_task **tmptask, *task; task = malloc(sizeof(struct ot_task)); @@ -102,7 +102,7 @@ int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype) { return 0; } -void mutex_workqueue_canceltask(int64 sock) { +void mutex_workqueue_canceltask(int64_t sock) { struct ot_task **task; /* Want exclusive access to tasklist */ @@ -227,9 +227,9 @@ int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec) { return task ? 0 : -1; } -int64 mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovec, int *is_partial) { +int64_t mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovec, int *is_partial) { struct ot_task **task; - int64 sock = -1; + int64_t sock = -1; *is_partial = 0; diff --git a/ot_mutex.h b/ot_mutex.h index ab1cf59..b5af96e 100644 --- a/ot_mutex.h +++ b/ot_mutex.h @@ -69,12 +69,12 @@ typedef enum { typedef unsigned long ot_taskid; -int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype); -void mutex_workqueue_canceltask(int64 sock); -void mutex_workqueue_pushsuccess(ot_taskid taskid); -ot_taskid mutex_workqueue_poptask(ot_tasktype *tasktype); -int mutex_workqueue_pushresult(ot_taskid taskid, size_t iovec_entries, struct iovec *iovector); -int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec); -int64 mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovector, int *is_partial); +int mutex_workqueue_pushtask(int64_t sock, ot_tasktype tasktype); +void mutex_workqueue_canceltask(int64_t sock); +void mutex_workqueue_pushsuccess(ot_taskid taskid); +ot_taskid mutex_workqueue_poptask(ot_tasktype *tasktype); +int mutex_workqueue_pushresult(ot_taskid taskid, size_t iovec_entries, struct iovec *iovector); +int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec); +int64_t mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovector, int *is_partial); #endif diff --git a/ot_stats.c b/ot_stats.c index 62c59c9..7945f4e 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -750,7 +750,7 @@ static void *stats_worker(void *args) { return NULL; } -void stats_deliver(int64 sock, int tasktype) { mutex_workqueue_pushtask(sock, tasktype); } +void stats_deliver(int64_t sock, int tasktype) { mutex_workqueue_pushtask(sock, tasktype); } static pthread_t thread_id; void stats_init(void) { diff --git a/ot_stats.h b/ot_stats.h index 8ed2b1e..203831c 100644 --- a/ot_stats.h +++ b/ot_stats.h @@ -42,7 +42,7 @@ enum { }; void stats_issue_event(ot_status_event event, PROTO_FLAG proto, uintptr_t event_data); -void stats_deliver(int64 sock, int tasktype); +void stats_deliver(int64_t sock, int tasktype); void stats_cleanup(void); size_t return_stats_for_tracker(char *reply, int mode, int format); size_t stats_return_tracker_version(char *reply); diff --git a/ot_sync.c b/ot_sync.c index fa6bb8b..dc71ddd 100644 --- a/ot_sync.c +++ b/ot_sync.c @@ -163,7 +163,7 @@ void sync_deinit( ) { pthread_cancel( thread_id ); } -void sync_deliver( int64 socket ) { +void sync_deliver( int64_t socket ) { mutex_workqueue_pushtask( socket, TASK_SYNC_OUT ); } diff --git a/ot_sync.h b/ot_sync.h index 0fe0739..b6964fa 100644 --- a/ot_sync.h +++ b/ot_sync.h @@ -6,12 +6,14 @@ #ifndef OT_SYNC_H__ #define OT_SYNC_H__ +#include + #ifdef WANT_SYNC_BATCH enum { SYNC_IN, SYNC_OUT }; void sync_init(); void sync_deinit(); -void sync_deliver(int64 socket); +void sync_deliver(int64_t socket); int add_changeset_to_tracker(uint8_t *data, size_t len); #else diff --git a/ot_udp.c b/ot_udp.c index d17f3ff..8e056db 100644 --- a/ot_udp.c +++ b/ot_udp.c @@ -71,7 +71,7 @@ static void udp_make_connectionid(uint32_t connid[2], const ot_ip6 remoteip, int } /* UDP implementation according to http://xbtt.sourceforge.net/udp_tracker_protocol.html */ -int handle_udp6(int64 serversocket, struct ot_workstruct *ws) { +int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { ot_ip6 remoteip; uint32_t *inpacket = (uint32_t *)ws->inbuf; uint32_t *outpacket = (uint32_t *)ws->outbuf; @@ -203,7 +203,7 @@ int handle_udp6(int64 serversocket, struct ot_workstruct *ws) { } static void *udp_worker(void *args) { - int64 sock = (int64)args; + int64_t sock = (int64_t)args; struct ot_workstruct ws; memset(&ws, 0, sizeof(ws)); @@ -229,7 +229,7 @@ static void *udp_worker(void *args) { return NULL; } -void udp_init(int64 sock, unsigned int worker_count) { +void udp_init(int64_t sock, unsigned int worker_count) { pthread_t thread_id; if (!g_rijndael_round_key[0]) udp_generate_rijndael_round_key(); diff --git a/ot_udp.h b/ot_udp.h index db48696..c670175 100644 --- a/ot_udp.h +++ b/ot_udp.h @@ -6,8 +6,10 @@ #ifndef OT_UDP_H__ #define OT_UDP_H__ -void udp_init(int64 sock, unsigned int worker_count); +#include + +void udp_init(int64_t sock, unsigned int worker_count); void udp_kickoff(void); -int handle_udp6(int64 serversocket, struct ot_workstruct *ws); +int handle_udp6(int64_t serversocket, struct ot_workstruct *ws); #endif diff --git a/proxy.c b/proxy.c index 784e2a1..c2dc417 100644 --- a/proxy.c +++ b/proxy.c @@ -63,11 +63,11 @@ enum { OT_SYNC_PEER4, OT_SYNC_PEER6 }; enum { FLAG_SERVERSOCKET = 1 }; /* For incoming packets */ -static int64 g_socket_in = -1; +static int64_t g_socket_in = -1; static uint8_t g_inbuffer[LIVESYNC_INCOMING_BUFFSIZE]; /* For outgoing packets */ -static int64 g_socket_out = -1; +static int64_t g_socket_out = -1; static uint8_t g_peerbuffer_start[LIVESYNC_OUTGOING_BUFFSIZE_PEERS]; static uint8_t *g_peerbuffer_pos; static uint8_t *g_peerbuffer_highwater = g_peerbuffer_start + LIVESYNC_OUTGOING_BUFFSIZE_PEERS - LIVESYNC_OUTGOING_WATERMARK_PEERS; @@ -249,7 +249,7 @@ typedef struct { uint8_t indata[8192 * 16]; /* Any data not processed yet */ size_t indata_length; /* Length of unprocessed data */ uint32_t tracker_id; /* How the other end greeted */ - int64 fd; /* A file handle, if connected, <= 0 is disconnected (0 initially, -1 else) */ + int64_t fd; /* A file handle, if connected, <= 0 is disconnected (0 initially, -1 else) */ io_batch outdata; /* The iobatch containing our sync data */ size_t packet_tcount; /* Number of unprocessed torrents in packet we currently receive */ @@ -283,7 +283,7 @@ static void handle_reconnects(void) { size_t i; for (i = 0; i < g_connection_count; ++i) if (PROXYPEER_NEEDSCONNECT(g_connections[i].state)) { - int64 newfd = socket_tcp6(); + int64_t newfd = socket_tcp6(); fprintf(stderr, "(Re)connecting to peer..."); if (newfd < 0) continue; /* No socket for you */ @@ -308,10 +308,10 @@ static void handle_reconnects(void) { } /* Handle incoming connection requests, check against whitelist */ -static void handle_accept(int64 serversocket) { - int64 newfd; - ot_ip6 ip; - uint16 port; +static void handle_accept(int64_t serversocket) { + int64_t newfd; + ot_ip6 ip; + uint16 port; while ((newfd = socket_accept6(serversocket, ip, &port, NULL)) != -1) { @@ -351,9 +351,9 @@ static void handle_accept(int64 serversocket) { } /* New sync data on the stream */ -static void handle_read(int64 peersocket) { +static void handle_read(int64_t peersocket) { int i; - int64 datalen; + int64_t datalen; uint32_t tracker_id; proxy_peer *peer = io_getcookie(peersocket); @@ -420,7 +420,7 @@ static void handle_read(int64 peersocket) { } /* Can write new sync data to the stream */ -static void handle_write(int64 peersocket) { +static void handle_write(int64_t peersocket) { proxy_peer *peer = io_getcookie(peersocket); if (!peer) { @@ -472,7 +472,7 @@ static void handle_write(int64 peersocket) { } static void server_mainloop() { - int64 sock; + int64_t sock; uint32_t packet_type; /* inlined livesync_init() */ @@ -515,7 +515,7 @@ static void panic(const char *routine) { } static int64_t ot_try_bind(ot_ip6 ip, uint16_t port) { - int64 sock = socket_tcp6(); + int64_t sock = socket_tcp6(); if (socket_bind6_reuse(sock, ip, port, 0) == -1) panic("socket_bind6_reuse"); -- cgit v1.3