// CS 305, Computer Algorithms I
// Fall 2003
//
// Example solution to Assignment 1a.

#include <cstdlib>
#include <iostream>
#include "get.h"

int main(int argc, char * argv[]) {

  // Dump the resource associated with the single command-line url to std-out.
  // Die with an error message if anything goes wrong.

  if (argc != 2) {
    std::cerr << "Command format is \"" << argv[0] << " url\".\n";
    exit(EXIT_FAILURE);
    }

  resource document;
  const std::string emsg = get(argv[1], document);
  if (not emsg.empty()) {
    std::cerr << "Error during url get, " << emsg << ".\n";
    exit(EXIT_FAILURE);
    }
  else
    std::cout.write(document.data, document.size);

  delete [] document.data;
  }


syntax highlighted by Code2HTML, v. 0.9