2
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4
// This program is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 3 of the License, or
7
// (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
#include "gnashconfig.h"
22
#include "NetworkAdapter.h"
25
#include <memory> // for auto_ptr
32
const char* post = NULL;
37
dump_curl(const char* url, ostream& os)
39
std::auto_ptr<gnash::IOChannel> reader;
42
reader.reset( gnash::NetworkAdapter::make_stream(url, post) );
46
reader.reset( gnash::NetworkAdapter::make_stream(url) );
53
while (size_t read = reader->read(buf, CHUNK_SIZE) )
55
for (size_t i=0; i<read; i++) {
63
dump_tu_file(const char* url, ostream& os)
65
tu_file* reader = new tu_file(url, "r");
67
if (reader->bad()) return;
71
while ( size_t read = reader->read(buf, CHUNK_SIZE) )
73
for (size_t i=0; i<read; i++) {
84
dump_file(const char* url, ostream& os)
86
FILE* f = fopen(url, "r");
91
while ( size_t read=fread(buf, 1, CHUNK_SIZE, f) )
93
for (size_t i=0; i<read; i++) {
101
main(int argc, char** argv)
103
const char* input = INPUT; // Should be the path to this file
107
cerr << "Usage: " << argv[0] << " <url> [<postdata>]" << endl;
111
if ( argc > 1 ) input = argv[1];
113
if ( argc > 2 ) post = argv[2];
115
cout << "input: " << input << endl;
116
if ( post ) cout << "post data: " << post << endl;
119
cout << "FILE" << endl;
120
dump_file(input, cout);
121
cout << "TU_FILE" << endl;
122
dump_tu_file(input, cout);
124
cout << "CURL" << endl;
125
dump_curl(input, cout);