Example #1
0
pbbool be_ClientImplementation::Open(const DDS_StdString& mainFilename)
{
   if (be_Source::Open (mainFilename))
   {
      BE_Globals::CFileOpen = pbtrue;
      os << "//******************************************************************\n"
         << "// \n"
         << "//  Generated by IDL to C++ Translator\n"
         << "//  \n"
         << "//  File name: " << BE_Globals::ClientImplFilename << "\n"
         << "//  Source: " << idl_global->main_filename()->get_string() << "\n"
         << "//  Generated: " << CreationTime() << "\n"
         << "//  OpenSplice " << VERSION << "\n"
         << "//  \n"
         << "//******************************************************************\n";
      os << nl;

      if (DDSRealIncludeFiles::includes[FindFilename(BE_Globals::ClientHeaderFilename)].length() == 0)
      {
         if (BE_Globals::collocated_direct)
         {
            os << "#include \""
               << (const char*)BE_Globals::ServerHeaderFilename
               << "\"" << nl;
         }
         else
         {
            os << "#include \""
               << (const char*)BE_Globals::ClientHeaderFilename
               << "\"" << nl;
         }
      }
      else
      {
         if (BE_Globals::collocated_direct)
         {
            os << "#include \""
               << (const char*)DDSRealIncludeFiles::includes[FindFilename(BE_Globals::ServerHeaderFilename)]
               << "\"" << nl;
         }
         else
         {
            os << "#include \""
               << (const char*)DDSRealIncludeFiles::includes[FindFilename(BE_Globals::ClientHeaderFilename)]
               << "\""
               << nl;
         }
      }

      os << nl;

      return pbtrue;
   }
   else
   {
      return pbfalse;
   }
}
Example #2
0
CEsmFile* CMWEditApp::FindMaster (const TCHAR *pPathname) {
  const TCHAR*	pFilename = FindFilename(pPathname);
  CEsmFile*	pFile;
  int		Index;

  for (Index = 0; Index < m_EsmMasters.GetSize(); Index++) {
    pFile = m_EsmMasters.GetAt(Index);
    if (TSTRICMP(FindFilename(pFile->GetFilename()), pFilename) == 0) return (pFile);
   }

  return (NULL);
 }
Example #3
0
pbbool be_ServerImplementation::Open (const DDS_StdString & mainFilename)
{
   if (be_Source::Open (mainFilename))
   {
      os << "//******************************************************************\n"
      << "// \n"
      << "//  Generated by IDL to C++ Translator\n"
      << "//  \n"
      << "//  File name: " << BE_Globals::ServerImplFilename << "\n"
      << "//  Source: " << idl_global->main_filename()->get_string() << "\n"
      << "//  Generated: " << CreationTime() << "\n"
      << "//  OpenFusion V" << OSPL_VERSION_STR << "\n"
      << "//  \n"
      << "//******************************************************************\n";

      if (DDSRealIncludeFiles::includes[FindFilename(BE_Globals::ServerHeaderFilename)].length() == 0)
      {
         if (!BE_Globals::gen_onefile)
         {
            os << "#include \"" << (const char*)BE_Globals::ServerHeaderFilename << "\"" << nl;
         }
      }
      else
      {
         if (!BE_Globals::gen_onefile)
         {
            os << "#include \"" << (const char*)DDSRealIncludeFiles::includes[FindFilename(BE_Globals::ServerHeaderFilename)] << "\"" << nl;
         }
      }

      os << nl;

      return pbtrue;
   }
   else
   {
      return pbfalse;
   }
}
bool VFSHandle_ZIP::Open(char *filename, bool create)
{
	OpenLocation(filename,create);

	FindFilename();

	if(IsFile(m_file) == false){
		if(create == true){
			Createfile(m_file);
		}else{
			return false;
		}
	}

	Length();
	return true;
}
Example #5
0
pbbool be_ServerHeader::Open(const DDS_StdString& mainFilename)
{
   if (be_Source::Open(mainFilename))
   {
      if (!BE_Globals::gen_onefile)
      {

         os << "//******************************************************************\n"
         << "// \n"
         << "//  Generated by IDL to C++ Translator\n"
         << "//  \n"
         << "//  File name: " << BE_Globals::ServerHeaderFilename << "\n"
         << "//  Source: " << idl_global->main_filename()->get_string() << "\n"
         << "//  Generated: " << CreationTime() << "\n"
         << "//  OpenFusion V" << VERSION << "\n"
         << "//  \n"
         << "//******************************************************************\n";
      }

      if (BE_Globals::gen_onefile)
      {
         ndefname = Ifndefize(BE_Globals::ServerHeaderFilename);
      }
      else
      {
         ndefname = Ifndefize(BE_Globals::ServerHeaderFilename);
      }

      os << "#ifndef " << (const char*)ndefname << nl;
      os << "#define " << (const char*)ndefname << nl << nl;
      os << nl;

      os << "#include \"eOrb/idl_s.h\"" << nl;

      if (DDSRealIncludeFiles::includes[FindFilename(BE_Globals::ClientHeaderFilename)].length() == 0)
      {
         if (!BE_Globals::gen_onefile)
         {
            os << "#include \"" << (const char*)BE_Globals::ClientHeaderFilename << "\"" << nl;
         }
      }
      else
      {
         if (!BE_Globals::gen_onefile)
         {
            os << "#include \"" << (const char*)DDSRealIncludeFiles::includes[FindFilename(BE_Globals::ClientHeaderFilename)] << "\"" << nl;
         }
      }

      String_map::iterator it;

      for (it = idlIncludes.begin() ; it != idlIncludes.end(); it++)
      {
                 DDS_StdString file(it.value() + BE_Globals::ServerExtension + "." + BE_Globals::hExtension);

         if (DDSRealIncludeFiles::includes[file].length() == 0)
         {
            os << "#include \"" << (const char*)file << "\"" << nl;
         }
         else
         {
            os << "#include \"" << (const char*)DDSRealIncludeFiles::includes[file] << "\"" << nl;
         }
      }

      os << nl;

      return pbtrue;
   }
   else
   {
      return pbfalse;
   }
}
//Uses ssh to transfer a data file.
//I took most of this code from the example file scp_write.c in the libssh2 examples.
//!!!! This could really be generalized... !!!!
int SendFilesTo51(char* loclfile,char* serverlocation)
{
    int error_code = 0;

#if defined(HAVE_LIBSSH2)
	char filename[1024];	
	if(FindFilename(loclfile,filename))
	{
		printf("Error: Bad filename for hydrograph file. (%s)\n",loclfile);
		return 1;
	}

	char scppath[1024];
	sprintf(scppath,"%s/%s",serverlocation,filename);
	//sprintf(scppath,"/data/ifc_01_hydro/%s",filename);

	//Uh, yeah, probably not very secure...
	char *username = "******",*password = "******";

	//Check out the file info
	struct stat fileinfo;
	stat(loclfile,&fileinfo);
	FILE* local = fopen(loclfile, "rb");
	if(!local)
	{
		printf("Can't open local file %s\n", loclfile);
		return -1;
	}

	//Init ssh stuff
	long unsigned int hostaddr = inet_addr("128.255.26.166");
	if(hostaddr < 0)
	{
		printf("Bad host address.\n");
		return 1;
	}
	int rc = libssh2_init(0);
	if(rc)
	{
		printf("Problem initializing libssh2 (%i)\n",rc);
		return 1;
	}
	int sock = socket(AF_INET,SOCK_STREAM,0);
	if(-1 == sock)
	{
		printf("Failed to create socket\n");
		return 1;
	}

	struct sockaddr_in sin;
	sin.sin_family = AF_INET;
	sin.sin_port = htons(22);
	sin.sin_addr.s_addr = hostaddr;
	if(connect(sock,(struct sockaddr*)(&sin),sizeof(struct sockaddr_in)) != 0)
	{
		printf("Failed to connect!\n");
		return 1;
	}

	//Create session instance and start it
	LIBSSH2_SESSION *session;
	session = libssh2_session_init();
	if(!session)	return 1;
	rc = libssh2_session_handshake(session, sock);
	if(rc)
	{
		printf("Failure establishing SSH session %i\n",rc);
		return 1;
	}

	//Authenticate
	const char* fingerprint = libssh2_hostkey_hash(session,LIBSSH2_HOSTKEY_HASH_SHA1);
	if(libssh2_userauth_password(session, username, password))
	{
		printf("Authentication by password failed.\n");
		error_code = 1;
		goto shutdown;
        }

	//Copy file
	LIBSSH2_CHANNEL *channel = libssh2_scp_send(session,scppath,fileinfo.st_mode & 0777,(unsigned long)fileinfo.st_size);
	if(!channel)
	{
		char *errmsg;
		int errlen;
		int err = libssh2_session_last_error(session, &errmsg, &errlen, 0);

		printf("Unable to open a session: (%d) %s\n", err, errmsg);
		error_code = 1;
		goto shutdown;
	}

	char mem[1024],*ptr;
	size_t nread;
	do
	{
		nread = fread(mem, 1, sizeof(mem), local);
		if (nread <= 0)
		{
			// end of file
			break;
		}
		ptr = mem;

		do
		{
			// write the same data over and over, until error or completion 
			rc = libssh2_channel_write(channel, ptr, nread);

			if (rc < 0)
			{
				printf("ERROR %d\n", rc);
				break;
			}
			else
			{
				// rc indicates how many bytes were written this time
				ptr += rc;
				nread -= rc;
			}
		} while(nread);
	} while(1);

	//Tell server we are done
	libssh2_channel_send_eof(channel);
	libssh2_channel_wait_eof(channel);
	libssh2_channel_wait_closed(channel);

	//Clean up
	libssh2_channel_free(channel);
	channel = NULL;

	shutdown:
	if(session)
	{
	 	libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
		libssh2_session_free(session);
	}
	close(sock);
	if(local)	fclose(local);
	if(!error_code && remove(loclfile))
		printf("[%i]: Error deleting file %s.\n",my_rank,loclfile);
	libssh2_exit();

	if(!error_code)	printf("File %s uploaded!\n",loclfile);
#endif 
	return error_code;
}
Example #7
0
void be_root::Generate (be_ClientHeader & source)
{
   be_CppFwdDecl::GenerateAllWithinScope (source, be_CppEnclosingScope());

   ostream& os = source.Stream ();
   TList<be_Type *>::iterator bit;
   TList<be_exception *>::iterator git;

   for (bit = fwdDecls.begin(); bit != fwdDecls.end(); bit++)
   {
      (*bit)->GenerateFwdDecls(source);
   }

   os << nl;
   GenerateGlobalTypes (source);
   GenerateGlobalDecls (source);

   g_generatorList.GenerateGlobal (source);

   if (BE_Globals::gen_externalization)
   {
      os << nl;

      for (bit = streamOps.begin(); bit != streamOps.end(); bit++)
      {
         (*bit)->GenerateStreamOps(source);
      }
   }

   os << nl;

   for (git = globalDecls.begin(); git != globalDecls.end(); git++)
   {
      (*git)->GenerateGlobalDecls (source);
   }

   os << nl;

   for (bit = typedefs.begin(); bit != typedefs.end(); bit++)
   {
      (*bit)->GenerateGlobalTypedef (source);
   }

   os << nl;

   if(BE_Globals::isocpp_test_methods)
   {
      //Generate file to stop missing file error
      DDS_StdString BaseFilename;
      BaseFilename = StripExtension(source.Filename());
      BaseFilename += "_testmethod.h";
      be_Source testsource;
      if(!testsource.Open(BaseFilename))
        cerr << "Cannot open: " << BaseFilename << endl;
      testsource.Close();

      //os << nl << "#ifndef " << Ifndefize(BE_Globals::ClientHeaderFilename + "DCPS");
      os << nl << "#ifndef " << Ifndefize(StripExtension(FindFilename(source.Filename())) + "DCPS.h");
      os << nl << "#ifndef " << Ifndefize(StripExtension(FindFilename(source.Filename())) + "_testmethod.h");
      os << nl << "#define " << Ifndefize(StripExtension(FindFilename(source.Filename())) + "_testmethod.h");
      os << nl << "#include \"" << StripExtension(FindFilename(source.Filename())) + "_testmethod.h" << "\"";
      os << nl << "#endif " << nl << "#endif" << nl;

   }

   if (BE_Globals::lite)
   {
       DDS_StdString BaseFilename;
       BaseFilename = StripExtension(source.Filename());

       os << "\n#include \"" << BaseFilename << "-lite.h" << "\"" << nl;
   }

   os << nl << "#endif" << nl;
   source.Close();
}