Changeset 13166 for trunk/FACT++


Ignore:
Timestamp:
03/22/12 11:14:03 (13 years ago)
Author:
tbretz
Message:
Make sure that the connection is the last in the configuration; improved sanity checks in Track()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/drivectrl.cc

    r13165 r13166  
    879879    int Track(const EventImp &evt)
    880880    {
    881         if (evt.GetSize()<=17)
     881        if (evt.GetSize()<=16)
    882882        {
    883883            ostringstream msg;
     
    887887        }
    888888
    889         if (evt.Get<char>(evt.GetSize()-1)!='\0')
    890             T::Warn("Track - It seems that the string is not zero-terminated.");
    891 
    892         const double *dat = evt.Ptr<double>();
    893         const string name = evt.Ptr<char>(16);
     889        const double *dat  = evt.Ptr<double>();
     890        const char   *ptr  = evt.Ptr<char>(16);
     891        const char   *last = ptr+evt.GetSize()-16;
     892
     893        if (find(ptr, last, '\0')==last)
     894        {
     895            T::Fatal("Track - The name transmitted by dim is not null-terminated.");
     896            return false;
     897        }
     898
     899        const string name(ptr);
    894900
    895901        const sources::const_iterator it = fSources.find(name);
    896902        if (it==fSources.end())
    897             return T::Error("Source '"+name+"' not found in list.");
     903        {
     904            T::Error("Source '"+name+"' not found in list.");
     905            return false;
     906        }
    898907
    899908        const double &ra  = it->second.first;
     
    12081217    int EvalOptions(Configuration &conf)
    12091218    {
    1210         SetEndpoint(conf.Get<string>("addr"));
    1211 
    12121219        fDrive.SetVerbose(!conf.Get<bool>("quiet"));
    12131220
     
    12491256        if (conf.Has("source-database"))
    12501257            ReadDatabase(conf.Get<string>("source-database"));
     1258
     1259        // The possibility to connect should be last, so that
     1260        // everything else is already initialized.
     1261        SetEndpoint(conf.Get<string>("addr"));
    12511262
    12521263        return -1;
Note: See TracChangeset for help on using the changeset viewer.