#include "tftp.h"

using namespace std;
using namespace tftp_tools;

#ifndef NO_MAIN
int
main(int argc, char ** argv)
#else
extern "C" {
extern int tftp_main(int argc, char ** argv);
}
int
tftp_main(int argc, char ** argv)
#endif
{
#ifndef NO_MAIN
   WORD wVersionRequested;
   WSADATA wsaData;
   wVersionRequested = MAKEWORD(2, 2);
   WSAStartup(wVersionRequested, &wsaData);
#endif
   if(argc != 4) {
      cout << "usage: tftp PUT | GET <host> <file>" << endl;
      return 0;
   }
   tftp client(argv[2], 69);
   string file = argv[3];
   string host = argv[2];
   if(strcmp(argv[1], "GET") == 0) {
      client.get(file);
   }
   else if(strcmp(argv[1], "PUT") == 0) {
      client.put(file);
   }
#ifndef NO_MAIN
   WSACleanup();
#endif
   return 0;
}
