summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2007-12-03 00:50:33 +0000
committererdgeist <>2007-12-03 00:50:33 +0000
commit89f291566b850e86c379f485eec4a2dfea87c391 (patch)
treeaf3d3064bac5200ca35b22d8de022e97ad37ef80
parent5d18bf211caab11f3b8ac3f921a8e338e2a9724b (diff)
Drop ot_{byte,word,dword} and use uint{8,16,32}_t
-rw-r--r--ot_fullscrape.c19
-rw-r--r--ot_fullscrape.h3
2 files changed, 10 insertions, 12 deletions
diff --git a/ot_fullscrape.c b/ot_fullscrape.c
index b632cb9..8d1b1db 100644
--- a/ot_fullscrape.c
+++ b/ot_fullscrape.c
@@ -13,6 +13,7 @@
13 13
14/* Libowfat */ 14/* Libowfat */
15#include "byte.h" 15#include "byte.h"
16#include "io.h"
16#include "textcode.h" 17#include "textcode.h"
17 18
18/* Opentracker */ 19/* Opentracker */
@@ -43,7 +44,7 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
43 44
44/* Converter function from memory to human readable hex strings 45/* Converter function from memory to human readable hex strings
45 XXX - Duplicated from ot_stats. Needs fix. */ 46 XXX - Duplicated from ot_stats. Needs fix. */
46static char*to_hex(char*d,ot_byte*s){char*m="0123456789ABCDEF";char *t=d;char*e=d+40;while(d<e){*d++=m[*s>>4];*d++=m[*s++&15];}*d=0;return t;} 47static char*to_hex(char*d,uint8_t*s){char*m="0123456789ABCDEF";char *t=d;char*e=d+40;while(d<e){*d++=m[*s>>4];*d++=m[*s++&15];}*d=0;return t;}
47 48
48/* This is the entry point into this worker thread 49/* This is the entry point into this worker thread
49 It grabs tasks from mutex_tasklist and delivers results back 50 It grabs tasks from mutex_tasklist and delivers results back
@@ -96,7 +97,7 @@ static int fullscrape_increase( int *iovec_entries, struct iovec **iovector,
96#ifdef WANT_COMPRESSION_GZIP 97#ifdef WANT_COMPRESSION_GZIP
97 if( mode & TASK_FLAG_GZIP ) { 98 if( mode & TASK_FLAG_GZIP ) {
98 *re -= OT_SCRAPE_MAXENTRYLEN; 99 *re -= OT_SCRAPE_MAXENTRYLEN;
99 strm->next_out = (ot_byte*)*r; 100 strm->next_out = (uint8_t*)*r;
100 strm->avail_out = OT_SCRAPE_CHUNK_SIZE; 101 strm->avail_out = OT_SCRAPE_CHUNK_SIZE;
101 if( deflate( strm, zaction ) < Z_OK ) 102 if( deflate( strm, zaction ) < Z_OK )
102 fprintf( stderr, "deflate() failed while in fullscrape_increase().\n" ); 103 fprintf( stderr, "deflate() failed while in fullscrape_increase().\n" );
@@ -128,8 +129,8 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
128 if( mode & TASK_FLAG_GZIP ) { 129 if( mode & TASK_FLAG_GZIP ) {
129 re += OT_SCRAPE_MAXENTRYLEN; 130 re += OT_SCRAPE_MAXENTRYLEN;
130 byte_zero( &strm, sizeof(strm) ); 131 byte_zero( &strm, sizeof(strm) );
131 strm.next_in = (ot_byte*)compress_buffer; 132 strm.next_in = (uint8_t*)compress_buffer;
132 strm.next_out = (ot_byte*)r; 133 strm.next_out = (uint8_t*)r;
133 strm.avail_out = OT_SCRAPE_CHUNK_SIZE; 134 strm.avail_out = OT_SCRAPE_CHUNK_SIZE;
134 if( deflateInit2(&strm,9,Z_DEFLATED,31,8,Z_DEFAULT_STRATEGY) != Z_OK ) 135 if( deflateInit2(&strm,9,Z_DEFLATED,31,8,Z_DEFAULT_STRATEGY) != Z_OK )
135 fprintf( stderr, "not ok.\n" ); 136 fprintf( stderr, "not ok.\n" );
@@ -170,18 +171,18 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
170 break; 171 break;
171 case TASK_FULLSCRAPE_TPB_BINARY: 172 case TASK_FULLSCRAPE_TPB_BINARY:
172 memmove( r, hash, 20 ); r+=20; 173 memmove( r, hash, 20 ); r+=20;
173 *(ot_dword*)r++ = htonl( (uint32_t)peer_list->seed_count ); 174 *(uint32_t*)r++ = htonl( (uint32_t)peer_list->seed_count );
174 *(ot_dword*)r++ = htonl( (uint32_t)( peer_list->peer_count-peer_list->seed_count) ); 175 *(uint32_t*)r++ = htonl( (uint32_t)( peer_list->peer_count-peer_list->seed_count) );
175 break; 176 break;
176 case TASK_FULLSCRAPE_TPB_URLENCODED: 177 case TASK_FULLSCRAPE_TPB_URLENCODED:
177 r += fmt_urlencoded( r, (char *)*hash, 20 ); 178 r += fmt_urlencoded( r, (char *)*hash, 20 );
178 r += sprintf( r, ":%zd:%zd\n", peer_list->seed_count, peer_list->peer_count-peer_list->seed_count ); 179 r += sprintf( r, ":%zd:%zd\n", peer_list->seed_count, peer_list->peer_count-peer_list->seed_count );
179 break; 180 break;
180 } 181 }
181 182
182#ifdef WANT_COMPRESSION_GZIP 183#ifdef WANT_COMPRESSION_GZIP
183 if( mode & TASK_FLAG_GZIP ) { 184 if( mode & TASK_FLAG_GZIP ) {
184 strm.next_in = (ot_byte*)compress_buffer; 185 strm.next_in = (uint8_t*)compress_buffer;
185 strm.avail_in = r - compress_buffer; 186 strm.avail_in = r - compress_buffer;
186 if( deflate( &strm, Z_NO_FLUSH ) < Z_OK ) 187 if( deflate( &strm, Z_NO_FLUSH ) < Z_OK )
187 fprintf( stderr, "deflate() failed while in fullscrape_make().\n" ); 188 fprintf( stderr, "deflate() failed while in fullscrape_make().\n" );
@@ -206,7 +207,7 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
206 207
207#ifdef WANT_COMPRESSION_GZIP 208#ifdef WANT_COMPRESSION_GZIP
208 if( mode & TASK_FLAG_GZIP ) { 209 if( mode & TASK_FLAG_GZIP ) {
209 strm.next_in = (ot_byte*)compress_buffer; 210 strm.next_in = (uint8_t*)compress_buffer;
210 strm.avail_in = r - compress_buffer; 211 strm.avail_in = r - compress_buffer;
211 if( deflate( &strm, Z_FINISH ) < Z_OK ) 212 if( deflate( &strm, Z_FINISH ) < Z_OK )
212 fprintf( stderr, "deflate() failed while in fullscrape_make()'s endgame.\n" ); 213 fprintf( stderr, "deflate() failed while in fullscrape_make()'s endgame.\n" );
diff --git a/ot_fullscrape.h b/ot_fullscrape.h
index 22ef3cb..7666e6c 100644
--- a/ot_fullscrape.h
+++ b/ot_fullscrape.h
@@ -4,9 +4,6 @@
4#ifndef __OT_FULLSCRAPE_H__ 4#ifndef __OT_FULLSCRAPE_H__
5#define __OT_FULLSCRAPE_H__ 5#define __OT_FULLSCRAPE_H__
6 6
7#include <io.h>
8#include "ot_mutex.h"
9
10void fullscrape_init( ); 7void fullscrape_init( );
11void fullscrape_deinit( ); 8void fullscrape_deinit( );
12void fullscrape_deliver( int64 socket, ot_tasktype tasktype ); 9void fullscrape_deliver( int64 socket, ot_tasktype tasktype );