Exemplo n.º 1
0
void
ReceiveListenerSet::data_received(const ReceivedDataSample& sample,
                                  const RepoIdSet& incl_excl,
                                  ConstrainReceiveSet constrain)
{
  DBG_ENTRY_LVL("ReceiveListenerSet", "data_received", 6);
  OPENDDS_VECTOR(RcHandle<TransportReceiveListener>) handles;
  {
    GuardType guard(this->lock_);
    for (MapType::iterator itr = map_.begin(); itr != map_.end(); ++itr) {
      if (constrain == ReceiveListenerSet::SET_EXCLUDED) {
        if (itr->second && incl_excl.count(itr->first) == 0) {
          handles.push_back(itr->second);
        }
      } else if (constrain == ReceiveListenerSet::SET_INCLUDED) { //SET_INCLUDED
        if (itr->second && incl_excl.count(itr->first) != 0) {
          handles.push_back(itr->second);
        }
      } else {
        ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: ReceiveListenerSet::data_received - NOTHING\n"));
      }
    }
  }

  for (size_t i = 0; i < handles.size(); ++i) {
    if (i < handles.size() - 1 && sample.sample_) {
      // demarshal (in data_received()) updates the rd_ptr() of any of
      // the message blocks in the chain, so give it a duplicated chain.
      ReceivedDataSample rds(sample);
      handles[i]->data_received(rds);
    } else {
      handles[i]->data_received(sample);
    }
  }
}
Exemplo n.º 2
0
	// recursively delete a dir
	const bool rds(const char* p) {
		path top(p);
		if (top.isndir()) return false;
		list<str> files=top.files();
		uint l=files.size(); 
		for_n(i, l) if (!rm((top / files[i]).tocstr())) return false;
		list<str> dirs=top.dirs();
		l=dirs.size();
		for_n(i, l) if (!rds((top / dirs[i]).tocstr())) return false;
		return rd(p);
	}
Exemplo n.º 3
0
 /**
  * Implementation that updates result with the matching parts in source
  * Relies on the fact that getMember returns a C++ reference to each part of \a result, which is then updated
  * with a property found in source.
  */
 virtual bool composeTypeImpl(const PropertyBag& source,  typename internal::AssignableDataSource<T>::reference_t result) const {
     // The default implementation decomposes result and refreshes it with source.
     TypeInfoRepository::shared_ptr tir = Types();
     internal::ReferenceDataSource<T> rds(result);
     rds.ref(); // prevent dealloc.
     PropertyBag decomp;
     // only try refreshProperties if decomp's type is equal to source type.
     // update vs refresh: since it is intentional that the decomposition leads to references to parts of result,
     // only refreshProperties() is meaningful (ie we have a one-to-one mapping). In case of sequences, this would
     // of course not match, so this is struct specific.
     return typeDecomposition( &rds, decomp, false) && ( tir->type(decomp.getType()) == tir->type(source.getType()) ) && refreshProperties(decomp, source);
 }
Exemplo n.º 4
0
int main(int argc, char *argv[]){
      	struct stat buf;
        void *start;
        char *point;
        char *point1;
      	if (argc != 3) {
	        fprintf(stderr, "Error input \n");
	        exit(EXIT_FAILURE);
      	}
       	int imgfile = open(argv[1], O_RDONLY);
        char *filename=argv[2];
       	if (imgfile < 0){
            fprintf(stderr, "Error no such file \n");
	          exit(EXIT_FAILURE);
      	}
        fstat(imgfile, &buf);
        start = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, imgfile, 0);
     
        if(start == MAP_FAILED) 
        return;
        
        point=start;
        point1=start;
        block_size=blocksize(point);
        int rd_s=rds(point);
        int rd_b=rdb(point);
        int n=0;
        ss=block_size*rd_s;
        point=point+block_size*rd_s;
        while(point[0]!=0x00){
        readfile(point);

        n++;
        point=point+64;
        }
      //  printf("%d",n);
        getfile(point1,filename,n);


        

//info end

        munmap(start, buf.st_size);
        close(imgfile);

return 0;

}
Exemplo n.º 5
0
TEST(mock_MeterS0, basic_non_blocking_read)
{
	mock_S0hwif *hwif = new mock_S0hwif();
	std::list<Option> opt;
	opt.push_back(Option("send_zero", true));

	EXPECT_CALL(*hwif, _open()).Times(1).WillRepeatedly(Return(true));
	EXPECT_CALL(*hwif, _close()).Times(1).WillOnce(Return(true));
	EXPECT_CALL(*hwif, is_blocking()).Times(2).WillRepeatedly(Return(false));
	EXPECT_CALL(*hwif, status()).Times(AtLeast(1)).WillRepeatedly(Return(0));
	MeterS0 m(opt, hwif);
	ASSERT_EQ(SUCCESS, m.open());
	std::vector<Reading> rds(4);
	ASSERT_EQ(m.read(rds, 4), 4);

	m.close(); // this might be called and should not cause problems
}
Exemplo n.º 6
0
  path& path::m_normalize()
  {
    if (m_pathname.empty()) return *this;
      
    path temp;
    iterator start(begin());
    iterator last(end());
    iterator stop(last--);
    for (iterator itr(start); itr != stop; ++itr)
    {
      // ignore "." except at start and last
      if (itr->native().size() == 1
        && (itr->native())[0] == dot
        && itr != start
        && itr != last) continue;

      // ignore a name and following ".."
      if (!temp.empty()
        && itr->native().size() == 2
        && (itr->native())[0] == dot
        && (itr->native())[1] == dot) // dot dot
      {
        string_type lf(temp.filename().native());  
        if (lf.size() > 0  
          && (lf.size() != 1
            || (lf[0] != dot
              && lf[0] != separator))
          && (lf.size() != 2 
            || (lf[0] != dot
              && lf[1] != dot
#             ifdef BOOST_WINDOWS_API
              && lf[1] != colon
#             endif
               )
             )
          )
        {
          temp.remove_filename();
          // if not root directory, must also remove "/" if any
          if (temp.m_pathname.size() > 0
            && temp.m_pathname[temp.m_pathname.size()-1]
              == separator)
          {
            string_type::size_type rds(
              root_directory_start(temp.m_pathname, temp.m_pathname.size()));
            if (rds == string_type::npos
              || rds != temp.m_pathname.size()-1) 
              { temp.m_pathname.erase(temp.m_pathname.size()-1); }
          }

          iterator next(itr);
          if (temp.empty() && ++next != stop
            && next == last && *last == dot_path) temp /= dot_path;
          continue;
        }
      }

      temp /= *itr;
    };

    if (temp.empty()) temp /= dot_path;
    m_pathname = temp.m_pathname;
    return *this;
  }
Exemplo n.º 7
0
int main(int argc, char **argv)
{
	int c, option_index;

	if (argc < 2)
		print_help(argv[0], -1);

	while (1) {
		option_index = 0;

		c = getopt_long(argc, argv,
#if PCIMAXFM_ENABLE_TX_TOGGLE
				"t::"
#endif /* PCIMAXFM_ENABLE_TX_TOGGLE */
				"f::p::s::"
#if PCIMAXFM_ENABLE_RDS
#if PCIMAXFM_ENABLE_RDS_TOGGLE
				"g::"
#endif /* PCIMAXFM_ENABLE_RDS_TOGGLE */
				"r:"
#endif /* PCIMAXFM_ENABLE_RDS */
				"d::vqehH",
				long_options, &option_index);

		if (c == -1)
			break;

		switch (c) {
#if PCIMAXFM_ENABLE_TX_TOGGLE
			case 't':
				tx(optarg);
				break;
#endif /* PCIMAXFM_ENABLE_TX_TOGGLE */
			case 'f':
				freq(optarg);
				break;
			case 'p':
				power(optarg);
				break;
			case 's':
				stereo(optarg);
				break;
#if PCIMAXFM_ENABLE_RDS
#if PCIMAXFM_ENABLE_RDS_TOGGLE
			case 'g':
				rds_signal(optarg);
				break;
#endif /* PCIMAXFM_ENABLE_RDS_TOGGLE */
			case 'r':
				rds(optarg);
				break;
#endif /* PCIMAXFM_ENABLE_RDS */
			case 'd':
				device(optarg);
				break;
			case 'v':
				verbosity = 1;
				DEBUG_MSG("Verbose output.");
				break;
			case 'q':
				verbosity = -1;
				break;
			case 'e':
				print_version(argv[0]);
			case 'h':
				print_help(argv[0], 0);
#if PCIMAXFM_ENABLE_RDS
			case 'H':
				print_help_rds(0);
#endif /* PCIMAXFM_ENABLE_RDS */
			default:
				exit(1);
		}
	}

	dev_close();

	return 0;
}
nsresult
nsSafariProfileMigrator::SetDownloadHandlers(void* aTransform, nsIPrefBranch* aBranch)
{
  PrefTransform* xform = (PrefTransform*)aTransform;
  if (!xform->boolValue) {
    // If we're not set to auto-open safe downloads, we need to clear out the
    // mime types list which contains default handlers.

    nsCOMPtr<nsIProperties> fileLocator(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
    nsCOMPtr<nsILocalFile> mimeRegistryFile;
    fileLocator->Get(NS_APP_USER_MIMETYPES_50_FILE, NS_GET_IID(nsILocalFile),
                     getter_AddRefs(mimeRegistryFile));

    nsCOMPtr<nsIIOService> ioService(do_GetService("@mozilla.org/network/io-service;1"));
    nsCOMPtr<nsIProtocolHandler> ph;
    ioService->GetProtocolHandler("file", getter_AddRefs(ph));
    nsCOMPtr<nsIFileProtocolHandler> fph(do_QueryInterface(ph));

    nsCOMPtr<nsIRDFService> rdfService(do_GetService("@mozilla.org/rdf/rdf-service;1"));
    nsCOMPtr<nsIRDFDataSource> mimeTypes;

    nsCAutoString dsURL;
    fph->GetURLSpecFromFile(mimeRegistryFile, dsURL);
    rdfService->GetDataSourceBlocking(dsURL.get(), getter_AddRefs(mimeTypes));

    nsCOMPtr<nsIRDFResource> overridesListResource;
    rdfService->GetResource(NS_LITERAL_CSTRING("urn:mimetypes:root"),
                            getter_AddRefs(overridesListResource));

    nsCOMPtr<nsIRDFContainer> overridesList(do_CreateInstance("@mozilla.org/rdf/container;1"));
    overridesList->Init(mimeTypes, overridesListResource);

    nsCOMPtr<nsIRDFResource> handlerPropArc, externalApplicationArc;
    rdfService->GetResource(NC_URI(handlerProp), getter_AddRefs(handlerPropArc));
    rdfService->GetResource(NC_URI(externalApplication),
                            getter_AddRefs(externalApplicationArc));

    PRInt32 count;
    overridesList->GetCount(&count);
    for (PRInt32 i = count; i >= 1; --i) {
      nsCOMPtr<nsIRDFNode> currOverrideNode;
      overridesList->RemoveElementAt(i, false, getter_AddRefs(currOverrideNode));
      nsCOMPtr<nsIRDFResource> currOverride(do_QueryInterface(currOverrideNode));

      nsCOMPtr<nsIRDFNode> handlerPropNode;
      mimeTypes->GetTarget(currOverride, handlerPropArc, true,
                           getter_AddRefs(handlerPropNode));
      nsCOMPtr<nsIRDFResource> handlerPropResource(do_QueryInterface(handlerPropNode));

      if (handlerPropResource) {
        nsCOMPtr<nsIRDFNode> externalApplicationNode;
        mimeTypes->GetTarget(handlerPropResource, externalApplicationArc,
                             true, getter_AddRefs(externalApplicationNode));
        nsCOMPtr<nsIRDFResource> externalApplicationResource(do_QueryInterface(externalApplicationNode));

        // Strip the resources down so that the datasource is completely flushed.
        if (externalApplicationResource)
          CleanResource(mimeTypes, externalApplicationResource);

        CleanResource(mimeTypes, handlerPropResource);
      }
      CleanResource(mimeTypes, currOverride);
    }

    nsCOMPtr<nsIRDFRemoteDataSource> rds(do_QueryInterface(mimeTypes));
    if (rds)
      rds->Flush();
  }
  return NS_OK;
}