summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
authorerdgeist <>2006-12-08 20:28:17 +0000
committererdgeist <>2006-12-08 20:28:17 +0000
commit898206ac7a254325a53f1a4c418ce702755de040 (patch)
treeb831d48bbbbca43d265d3e01c883ed91e786aed4 /opentracker.c
parent83e339bbe05e150c819f8e5a90ebe5d6861b4b34 (diff)
Some syntax errors removed
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/opentracker.c b/opentracker.c
index 4a421cc..c420d6f 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -14,6 +14,9 @@
14#include <stdlib.h> 14#include <stdlib.h>
15#include <errno.h> 15#include <errno.h>
16 16
17#include "trackerlogic.h"
18#include "scan_urlencoded_query.h"
19
17static void carp(const char* routine) { 20static void carp(const char* routine) {
18 buffer_puts(buffer_2,routine); 21 buffer_puts(buffer_2,routine);
19 buffer_puts(buffer_2,": "); 22 buffer_puts(buffer_2,": ");
@@ -112,9 +115,7 @@ e400:
112 } 115 }
113 else 116 else
114 { 117 {
115 char *d; 118 char *d, *data;
116 int64 fd;
117 struct stat s;
118 119
119 // expect 'GET /uri?nnbjhg HTTP/1.*' 120 // expect 'GET /uri?nnbjhg HTTP/1.*'
120 c+=4; 121 c+=4;
@@ -130,19 +131,18 @@ e400:
130 switch( scan_urlencoded_query( &c, data, SCAN_PATH ) ) { 131 switch( scan_urlencoded_query( &c, data, SCAN_PATH ) ) {
131 case 6: /* scrape ? */ 132 case 6: /* scrape ? */
132 if (!byte_diff(c,6,"scrape")) 133 if (!byte_diff(c,6,"scrape"))
133 goto 404; 134 goto e404;
134 break; 135 break;
135 case 9: 136 case 9:
136 if( !byte_diff(c,8,"announce")) 137 if( !byte_diff(c,8,"announce"))
137 goto 404; 138 goto e404;
138 else { 139 else {
139 // info_hash, left, port, numwant, compact 140 // info_hash, left, port, numwant, compact
140 struct ot_peer peer; 141 struct ot_peer peer;
141 ot_hash hash; 142 byte_copy( peer.ip, 4, h->ip );
142 byte_copy( peer.ip, h->ip, 4);
143 peer.port = 6881; 143 peer.port = 6881;
144 144
145 while( NOCHAMSCANNEN ) { 145 while( 1 ) {
146 data = c; 146 data = c;
147 switch( scan_urlencoded_query( &c, data, SCAN_SEARCHPATH_PARAM ) ) { 147 switch( scan_urlencoded_query( &c, data, SCAN_SEARCHPATH_PARAM ) ) {
148 case -1: /* error */ 148 case -1: /* error */
@@ -150,20 +150,21 @@ e400:
150 goto e404; 150 goto e404;
151 case 4: 151 case 4:
152 if(!byte_diff(c,4,"port")) 152 if(!byte_diff(c,4,"port"))
153 /* scan int */ 153 /* scan int */ c;
154 else if(!byte_diff(c,4,"left")) 154 else if(!byte_diff(c,4,"left"))
155 /* scan int */ 155 /* scan int */ c;
156 break; 156 break;
157 case 7: 157 case 7:
158 if(!byte_diff(c,7,"numwant")) 158 if(!byte_diff(c,7,"numwant"))
159 /* scan int */ 159 /* scan int */ c;
160 else if(!byte_diff(c,7,"compact")) 160 else if(!byte_diff(c,7,"compact"))
161 /* scan flag */ 161 /* scan flag */ c;
162 break; 162 break;
163 case 9: /* info_hash */ 163 case 9: /* info_hash */
164 if(!byte_diff(c,9,"info_hash")) 164 if(!byte_diff(c,9,"info_hash")) c;
165 /* scan 20 bytes */ 165 /* scan 20 bytes */
166 break; 166 break;
167 }
167 } 168 }
168 } 169 }
169 break; 170 break;
@@ -176,13 +177,13 @@ e400:
176 c+=fmt_str(c,"HTTP/1.1 Coming Up\r\nContent-Type: text/plain"); 177 c+=fmt_str(c,"HTTP/1.1 Coming Up\r\nContent-Type: text/plain");
177 c+=fmt_str(c,"\r\nContent-Length: "); 178 c+=fmt_str(c,"\r\nContent-Length: ");
178 /* ANSWER SIZE*/ 179 /* ANSWER SIZE*/
179 c+=fmt_ulonglong(c,s.st_size); 180 c+=fmt_ulonglong(c, 100 );
180 c+=fmt_str(c,"\r\nLast-Modified: "); 181 c+=fmt_str(c,"\r\nLast-Modified: ");
181 /* MODIFY DATE */ 182 /* MODIFY DATE
182 c+=fmt_httpdate(c,s.st_mtime); 183 c+=fmt_httpdate(c,s.st_mtime); */
183 c+=fmt_str(c,"\r\nConnection: close\r\n\r\n"); 184 c+=fmt_str(c,"\r\nConnection: close\r\n\r\n");
184 iob_addbuf(&h->iob,h->hdrbuf,c - h->hdrbuf); 185 iob_addbuf(&h->iob,h->hdrbuf,c - h->hdrbuf);
185 iob_addbuf(&h->iob,tracker_answer, tzracker_answer_size); 186 iob_addbuf(&h->iob,tracker_answer, tracker_answer_size);
186 } 187 }
187e404: 188e404:
188 io_dontwantread(s); 189 io_dontwantread(s);
@@ -227,7 +228,7 @@ int main()
227 if (h) 228 if (h)
228 { 229 {
229 byte_zero(h,sizeof(struct http_data)); 230 byte_zero(h,sizeof(struct http_data));
230 byte_copy(h->ip,ip,sizeof(ip)); 231 byte_copy(h->ip,sizeof(ip),ip);
231 io_setcookie(n,h); 232 io_setcookie(n,h);
232 } else 233 } else
233 io_close(n); 234 io_close(n);