#include #include #include #include "fetch.h" int main( int argc, char *argv[] ) { char *urlstring; fetchIO *io; char buf[256]; ssize_t res; if( argc != 2 ) { fputs( "Usage: test1 \n", stderr ); exit( EXIT_FAILURE ); } urlstring = argv[1]; fetchTimeout = 2; io = fetchGetURL( urlstring, "" ); if( io == NULL ) { fprintf( stderr, "ERROR: %s\n", fetchLastErrString ); exit( EXIT_FAILURE ); } while( ( res = fetchIO_read( io, buf, sizeof( buf ) ) ) != 0 ) { buf[res] = '\0'; fputs( buf, stdout ); } fetchIO_close( io ); exit( EXIT_SUCCESS ); }