From a831beb6c80957606967d8f34b9046ed8178a0b2 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 26 Jan 2008 17:24:43 +0200 Subject: [PATCH] const in BitTorrent --- src/protocol/bittorrent/bencoding.c | 12 +++++++----- src/protocol/bittorrent/common.c | 2 +- src/protocol/bittorrent/common.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/protocol/bittorrent/bencoding.c b/src/protocol/bittorrent/bencoding.c index cf8821e0a..7f0b320d2 100644 --- a/src/protocol/bittorrent/bencoding.c +++ b/src/protocol/bittorrent/bencoding.c @@ -327,7 +327,7 @@ check_bencoding_dictionary_entry(struct scanner *scanner, static off_t parse_bencoding_integer(struct scanner_token *token) { - unsigned char *string = token->string; + const unsigned char *string = token->string; int pos = 0, length = token->length; off_t integer = 0; int sign = 1; @@ -356,7 +356,8 @@ parse_bencoding_integer(struct scanner_token *token) } static unsigned char * -normalize_bencoding_path(unsigned char *path, int pathlen, int *malicious) +normalize_bencoding_path(const unsigned char *path, int pathlen, + int *malicious) { struct string string; @@ -739,7 +740,7 @@ parse_bittorrent_metafile(struct bittorrent_meta *meta, struct string *metafile) case BENCODING_TOKEN_INFO: { - unsigned char *start = value->string; + const unsigned char *start = value->string; struct scanner_token *token; enum bittorrent_state state; @@ -885,8 +886,9 @@ parse_bencoding_peers_string(struct bittorrent_connection *bittorrent, struct scanner *scanner) { struct scanner_token *token = get_scanner_token(scanner); - unsigned char *pos; - unsigned char *last_peer_info_start = token->string + token->length - 6; + const unsigned char *pos; + const unsigned char *last_peer_info_start + = token->string + token->length - 6; enum bittorrent_state state = BITTORRENT_STATE_OK; assert(get_scanner_token(scanner)->type == BENCODING_TOKEN_STRING); diff --git a/src/protocol/bittorrent/common.c b/src/protocol/bittorrent/common.c index d9fe3ecb1..a0a9ec1ca 100644 --- a/src/protocol/bittorrent/common.c +++ b/src/protocol/bittorrent/common.c @@ -213,7 +213,7 @@ get_peer_from_bittorrent_pool(struct bittorrent_connection *bittorrent, enum bittorrent_state add_peer_to_bittorrent_pool(struct bittorrent_connection *bittorrent, bittorrent_id_T id, int port, - unsigned char *ip, int iplen) + const unsigned char *ip, int iplen) { struct bittorrent_peer *peer; diff --git a/src/protocol/bittorrent/common.h b/src/protocol/bittorrent/common.h index 5ea507e1e..9d44b7615 100644 --- a/src/protocol/bittorrent/common.h +++ b/src/protocol/bittorrent/common.h @@ -368,7 +368,7 @@ bittorrent_id_is_known(struct bittorrent_connection *bittorrent, enum bittorrent_state add_peer_to_bittorrent_pool(struct bittorrent_connection *bittorrent, bittorrent_id_T id, int port, - unsigned char *ip, int iplen); + const unsigned char *ip, int iplen); struct bittorrent_peer * get_peer_from_bittorrent_pool(struct bittorrent_connection *bittorrent,