view tools/cat/cat.cpp @ 463:214f03b47d4e

Socket: - New action() and condition() function to check for pending events, - More documentation, - StreamServer, StreamClient can now complete recv/send operation for OpenSSL.
author David Demelier <markand@malikania.fr>
date Wed, 04 Nov 2015 18:01:22 +0100
parents d5ec1174b707
children 94296e6bdb00
line wrap: on
line source

/*
 * cccat.cpp -- very basic cat replacement for portability
 *
 * Copyright (c) 2013-2015 David Demelier <markand@malikania.fr>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <algorithm>
#include <fstream>
#include <iostream>
#include <iterator>

using namespace std;

int main(int argc, char **argv)
{
	if (argc < 2) {
		cerr << "usage: cccat file" << endl;
		exit(1);
	}

	ifstream input(argv[1]);
	copy(istreambuf_iterator<char>(input), istreambuf_iterator<char>(), ostreambuf_iterator<char>(cout));

	return 0;
}