#include #include #include "Action.h" #include "Handle.h" #include "HttpServ.h" #include "Socket.h" #include "config.h" #include "Message.h" #include "Menu.h" #include "Exceptions.h" #include "Form.h" #include "Confirm.h" #include "Table.h" #include "IRC.h" class InPipe : public Handle { public: InPipe(int in, int out) : Handle(in), m_out(out) { }; virtual ~InPipe() {} int GetOut(void) { return m_out; } virtual bool CanWrite(void) { return false; } virtual bool CanRead(void) { return true; } virtual String GetName(void) { return "Input pipe"; } private: int m_out; } * in; int main(int argc, char ** argv) { int p[2], c; list testlist; IRC ircclient("botalacon"); testlist.push_front("poide"); if (pipe(p)) { cerr << "Error creating pipe.\n"; exit(-1); } close(1); dup(p[1]); in = new InPipe(p[0], p[1]); String test = "poide\n", r; cout << test; cout.flush(); (*in) >> r; if (r != "poide") { cerr << "The stdout redirect has failed.\n"; exit(-1); } while ((c = getopt(argc, argv, "p:")) != EOF) { switch (c) { case 'p': break; default: cerr << "Usage: " << argv[0] << " [-p port]\n"; exit(-1); } } try { cerr << "Connecting..." << endl; if (ircclient.Connect()) { cerr << "Doing main loop..." << endl; ircclient.MainLoop(); } else { cerr << "Error connecting..." << endl; } } catch (GeneralException e) { cerr << e.GetMsg() << endl; delete in; exit(-1); } delete in; exit(0); }