Google
Web alhem.net

inject.cpp

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <unistd.h>
00004 #include <map>
00005 #include <string>
00006 #include <Base64.h>
00007 #include <SocketHandler.h>
00008 #include <StdoutLog.h>
00009 #include "RobotXMLFile.h"
00010 #include "InjectSocket.h"
00011 #include "RowoHandler.h"
00012 #include "CodeTool.h"
00013 
00014 
00015 int main(int argc,char *argv[])
00016 {
00017         if (argc < 2)
00018         {
00019                 printf("Usage: %s <.xml file>\n",*argv);
00020                 exit(-1);
00021         }
00022         RowoHandler h;
00023         StdoutLog log;
00024         h.RegStdLog(&log);
00025         for (int i = 1; i < argc; i++)
00026         {
00027                 RobotXMLFile x(argv[i]);
00028                 if (x.IsOk())
00029                 {
00030                         std::string robot_name = x.GetString("name");
00031                         std::string owner_uid = x.GetString("owner");
00032 //              std::string codestr64 = x.GetString("code");
00033 
00034                         printf("Robot: %s\n",robot_name.c_str());
00035                         printf("Created by: %s\n",owner_uid.c_str());
00036 //                      printf("Codestr64: %s\n",codestr64.c_str());
00037                         // code sanity check
00038                         CodeTool ct(x);
00039                         if (ct.Sane())
00040                         {
00041                                 // send file
00042                                 InjectSocket *p = new InjectSocket(h);
00043                                 p -> SetDeleteByHandler();
00044                                 p -> SetFilename(argv[i]);
00045                                 p -> Open("localhost",32766);
00046                                 h.Add(p);
00047                                 h.Select(1,0);
00048                         }
00049                         else
00050                         {
00051                                 printf("Insane code\n");
00052                         }
00053                 }
00054         }
00055         while (h.GetCount())
00056         {
00057                 h.Select(1,0);
00058         }
00059 }
00060 
00061 

Generated for Robot World by doxygen 1.3.6

Page, code, and content Copyright (C) 2004 by Anders Hedström