/* * Copyright 2003,2004,2005 Kevin Smathers, All Rights Reserved * * This file may be used or modified without the need for a license. * * Redistribution of this file in either its original form, or in an * updated form may be done under the terms of the GNU GENERAL * PUBLIC LICENSE. If this license is unacceptable to you then you * may not redistribute this work. * * See the file COPYING for details. */ /* btcheck.c */ #include "config.h" #include #include #include #include #include #include #include #include #if !WIN32 #include #if HAVE_IO_H #include #endif #if HAVE_UNISTD_H #include #endif #endif #include #include /* libbt */ #include "types.h" #include "benc.h" #include "util.h" #include "segmenter.h" #include "context.h" #include "bitset.h" /* globals */ btContext context; /* functions */ int main(int argc, char **argv) { int result=0; int dlid; char *filename; btStream *bts; struct btContext *ctx = &context; /* main */ if(argc!=2) goto usage; if(argv[1][0]=='-') goto usage; filename=argv[1]; if(!(bts=bts_create_filestream(filename, BTS_INPUT))) { perror(filename); return 1; } /* load tracker file */ if((dlid=ctx_loadfile(bts, ctx, 0))<0) { errno=-dlid; /* ctx_loadfile() returns the error */ perror(filename); return 1; } result=!bs_isFull(&ctx->downloads[dlid]->fileset.completed); ctx_closedownload(ctx, dlid); bts_destroy(bts); btContext_destroy(ctx); return result; usage: fprintf(stderr, "Usage: %s torrentfile\n", argv[0]); fprintf(stderr, "Version: %.2f\n", VERSION); return 1; }