示例#1
0
void TcpClient::runTcpClient() {
    logTrace(name_ + " TcpClient start");
    while (continueRunning_) {
        try {
            boost::asio::io_service ioService;
            tcp::socket s(ioService);
            tcp::resolver resolver(ioService);
            boost::asio::connect(s, resolver.resolve(endpoint_));
            try {
                while (continueRunning_) {
                    this->update(s);
                    boost::this_thread::sleep(boost::posix_time::milliseconds(1));
                }
            } catch (const boost::system::system_error& e) {
                if (e.code() == boost::asio::error::eof) {
                    logWarning("Connection closed");
                    break;
                } else {
                    throw;
                }
            } catch (const std::exception& e) {
                logWarning(e.what());
            }
        } catch (const std::exception& e) {
            if (!ignoreErrors_) {
                throw;
            }
            logWarning(e.what());
            boost::this_thread::sleep(boost::posix_time::seconds(10));
        }
    }
    logTrace(name_ + " TcpClient stop");
}
示例#2
0
int dropPrivileges(const char *usr, const char *group) {

	if(!getuid()) {

		uid_t uid;
		gid_t gid;

		if(!getUser(&uid, usr) && !getGroup(&gid, group)) {

#if !defined(_WIN32) && defined(PIDFILE) && defined(HAVE_ATEXIT) && defined(HAVE_CHOWN)

			if(chown(PIDFILE, uid, gid)) logWarning(NetMauMau::Common::Logger::time(TIMEFORMAT)
														<< "Couldn't change ownership of "
														<< PIDFILE);

			if(chmod(PIDFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)) {
				logWarning(NetMauMau::Common::Logger::time(TIMEFORMAT) << "Couldn't change mode of "
						   << PIDFILE);
			}

#endif

			if(!setegid(gid) && !seteuid(uid)) {
				return 0;
			} else {
				dpErr = std::strerror(errno);
			}
		}

	} else {
		return 0;
	}

	return -1;
}
示例#3
0
void UIWidget::addChild(const UIWidgetPtr& child)
{
    if(!child) {
        logWarning("attempt to add a null child into a UIWidget");
        return;
    }

    if(hasChild(child)) {
        logWarning("attempt to add a child again into a UIWidget");
        return;
    }

    m_children.push_back(child);
    child->setParent(asUIWidget());

    // create default layout
    if(!m_layout)
        m_layout = UIAnchorLayoutPtr(new UIAnchorLayout(asUIWidget()));

    // add to layout and updates it
    m_layout->addWidget(child);

    // update new child states
    child->updateStates();
    updateChildrenIndexStates();
}
示例#4
0
unsigned long getLinuxVersionCode()
{
	struct utsname uts;

	// cleared in case sscanf() < 3
	unsigned x = 0;
	unsigned y = 0;
	unsigned z = 0;

	// failure most likely implies impending death
	if(uname(&uts) == -1)
	{
		logError("uname() failed [%d]\n", __LINE__);
	}

	if(sscanf(uts.release, "%u.%u.%u", &x, &y, &z) < 3)
	{
		logWarning(
			"Non-standard uts for running kernel:\nrelease %s=%u.%u.%u gives version code %d\n",
			uts.release, x, y, z, LINUX_VERSION_CODE(x,y,z)
		);
	}

	if(LINUX_VERSION_CODE(x, y, z) >= LINUX_VERSION_CODE(2, 6, 0) && !hasSysFS())
	{
		logWarning("You're running a 2.6 kernel without /sys. You should mount it [%d]\n", __LINE__);
	}

    return LINUX_VERSION_CODE(x, y, z);
}
static int iniAnnotationFuncExpressCalc(IniContext *context,
        struct ini_annotation_entry *annotation, const IniItem *item,
        char **pOutValue, int max_values)
{
    int count;
    int result;
    char cmd[512];
    static char output[256];

    count = 0;
    sprintf(cmd, "echo \'%s\' | bc -l", item->value);
    if ((result=getExecResult(cmd, output, sizeof(output))) != 0)
    {
        logWarning("file: "__FILE__", line: %d, "
                "exec %s fail, errno: %d, error info: %s",
                __LINE__, cmd, result, STRERROR(result));
        return count;
    }
    if (*output == '\0')
    {
        logWarning("file: "__FILE__", line: %d, "
                "empty reply when exec: %s", __LINE__, item->value);
    }
    pOutValue[count++] = fc_trim(output);
    return count;
}
/**
    This method loads the choam section of the INI file
*/
void INIMapEditorLoader::loadChoam()
{
    INIFile::KeyIterator iter;

    for(iter = inifile->begin("CHOAM"); iter != inifile->end("CHOAM"); ++iter) {
        std::string UnitStr = iter->getKeyName();

        Uint32 unitID = getItemIDByName(UnitStr);
        if((unitID == ItemID_Invalid) || !isUnit(unitID)) {
            logWarning(iter->getLineNumber(), "Invalid unit string: '" + UnitStr + "'");
            continue;
        }

        int num = iter->getIntValue(-2);
        if(num == -2) {
            logWarning(iter->getLineNumber(), "Invalid choam number!");
            continue;

        }

        if(num == -1) {
            num = 0;
        }

        pMapEditor->getChoam()[unitID] = num;
    }
}
示例#7
0
void UIWidget::insertChild(int index, const UIWidgetPtr& child)
{
    if(!child) {
        logWarning("attempt to insert a null child into a UIWidget");
        return;
    }

    if(hasChild(child)) {
        logWarning("attempt to insert a child again into a UIWidget");
        return;
    }

    index = index <= 0 ? (m_children.size() + index) : index-1;

    assert(index >= 0 && (uint)index <= m_children.size());

    // retrieve child by index
    auto it = m_children.begin() + index;
    m_children.insert(it, child);
    child->setParent(asUIWidget());

    // create default layout if needed
    if(!m_layout)
        m_layout = UIAnchorLayoutPtr(new UIAnchorLayout(asUIWidget()));

    // add to layout and updates it
    m_layout->addWidget(child);

    // update new child states
    child->updateStates();
    updateChildrenIndexStates();
}
示例#8
0
grid::Container* grid::Grid::TypeSelector<Container, Level, TypeList>
	::createContainer(Grid &grid)
{
	typedef typename TypeList::Head Head;
	typedef typename TypeList::Tail Tail;

	if (Head* type = dynamic_cast<Head*>(grid.m_type)) {
		// Time dimension
		int timeDimension = grid.param("TIME_DIMENSION", -1);

		// Value position
		std::string strValuePos = grid.param("VALUE_POSITION", "CELL_CENTERED");
		ValuePosition valuePos;
		if (strValuePos == "VERTEX_CENTERED")
			valuePos = VERTEX_CENTERED;
		else {
			valuePos = CELL_CENTERED;
			if (strValuePos != "CELL_CENTERED") {
				logWarning(grid.m_comm.rank()) << "ASAGI: Unknown value position:" << strValuePos;
				logWarning(grid.m_comm.rank()) << "ASAGI: Assuming CELL_CENTERED";
			}
		}

		// Create the container
		return new Container<Level<Head>, Head>(grid.m_comm, grid.m_numa,
				*type, timeDimension, valuePos);
	}

	return TypeSelector<Container, Level, Tail>::createContainer(grid);
}
示例#9
0
bool consolidate_gpos_single(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
                             const otfcc_Options *options) {
	subtable_gpos_single *subtable = &(_subtable->gpos_single);
	gpos_single_hash *h = NULL;
	for (glyphid_t k = 0; k < subtable->length; k++) {
		if (!GlyphOrder.consolidateHandle(font->glyph_order, &subtable->items[k].target)) {
			logWarning("[Consolidate] Ignored missing glyph /%s.\n", subtable->items[k].target.name);
			continue;
		}
		gpos_single_hash *s;
		int fromid = subtable->items[k].target.index;
		HASH_FIND_INT(h, &fromid, s);
		if (s) {
			logWarning("[Consolidate] Detected glyph double-mapping about /%s.\n", subtable->items[k].target.name);
		} else {
			NEW(s);
			s->fromid = subtable->items[k].target.index;
			s->fromname = sdsdup(subtable->items[k].target.name);
			s->v = subtable->items[k].value;
			HASH_ADD_INT(h, fromid, s);
		}
	}

	HASH_SORT(h, gpos_by_from_id);
	iSubtable_gpos_single.clear(subtable);

	gpos_single_hash *s, *tmp;
	HASH_ITER(hh, h, s, tmp) {
		iSubtable_gpos_single.push(subtable,
		                           ((otl_GposSingleEntry){
		                               .target = Handle.fromConsolidated(s->fromid, s->fromname), .value = s->v,
		                           }));
示例#10
0
void scenario::diffusionequation::CornerPointField::CornerPointPillar::addLayerData( double permeability, double cellsUpperLayer, double cellsLowerLayer, bool sortLayersIfNecessary) {
  logTraceInWith4Arguments( "CornerPointPillar::addLayerData(...)", permeability, cellsUpperLayer, cellsLowerLayer, toString() );

  if (sortLayersIfNecessary && cellsUpperLayer<cellsLowerLayer) {
    double tmp = cellsUpperLayer;
    cellsUpperLayer = cellsLowerLayer;
    cellsLowerLayer = tmp;
  }

  if (tarch::la::greater(permeability,0.0) && tarch::la::greater(cellsUpperLayer,cellsLowerLayer)) {
    if (cellsUpperLayer>0.0) {
      logWarning( "CornerPointPillar::addLayerData(...)", "upper layer of cell segmented is greater than 0.0, i.e. model perhaps is not a subsurface model. upper layer-depth=" << cellsUpperLayer );
    }
    if (cellsLowerLayer>0.0) {
      logWarning( "CornerPointPillar::addLayerData(...)", "lower layer of cell segmented is greater than 0.0, i.e. model perhaps is not a subsurface model. lower layer-depth=" << cellsLowerLayer );
    }

    Cell newCell;
    newCell._permeability    = permeability;
    newCell._cellsLowerLayer = cellsLowerLayer;
    newCell._cellsUpperLayer = cellsUpperLayer;

    std::vector<Cell>::iterator p = _cells.begin();

    while (p!=_cells.end() && p->_cellsLowerLayer>=newCell._cellsUpperLayer) {
      p++;
    }

    _cells.insert(p,newCell);
  }

  logTraceOutWith1Argument( "CornerPointPillar::addLayerData(...)", toString() );
}
示例#11
0
bool seissol::checkpoint::mpio::Wavefield::validate(MPI_File file) const
{
	if (setHeaderView(file) != 0) {
		logWarning() << "Could not set checkpoint header view";
		return false;
	}

	int result = true;

	if (rank() == 0) {
		Header header;

		// Check the header
		MPI_File_read(file, &header, 1, headerType(), MPI_STATUS_IGNORE);

		if (header.identifier != identifier()) {
			logWarning() << "Checkpoint identifier does match";
			result = false;
		} else if (header.partitions != partitions()) {
			logWarning() << "Number of partitions in checkpoint does not match";
			result = false;
		}
	}

	// Make sure everybody knows the result of the validation
	MPI_Bcast(&result, 1, MPI_INT, 0, comm());

	return result;
}
示例#12
0
CacheChange_t* RTPSWriter::new_change(ChangeKind_t changeKind,InstanceHandle_t handle)
{
	const char* const METHOD_NAME = "new_change";
	logInfo(RTPS_WRITER,"Creating new change");
	CacheChange_t* ch = nullptr;

	if(!mp_history->reserve_Cache(&ch))
	{
		logWarning(RTPS_WRITER,"Problem reserving Cache from the History");
		return nullptr;
	}

	ch->kind = changeKind;
	if(m_att.topicKind == WITH_KEY && !handle.isDefined())
	{
		logWarning(RTPS_WRITER,"Changes in KEYED Writers need a valid instanceHandle");
		//		if(mp_type->m_isGetKeyDefined)
		//		{
		//			mp_type->getKey(data,&ch->instanceHandle);
		//		}
		//		else
		//		{
		//			logWarning(RTPS_WRITER,"Get key function not defined";);
		//		}
	}
	ch->instanceHandle = handle;
	ch->writerGUID = m_guid;
	return ch;
}
示例#13
0
/// This function is required to have two arguments in order to be a proper
/// virtual function, however, it does not make use any of them.
/// Therefore, they are never named.
void FQ_Variable::loadIndex(const char*, int) const throw () {
    if (! isValid("FQ_Variable::loadIndex")) return;

    writeLock lock(this, "loadIndex");
    if (idx == 0 && thePart->nRows() > 0) {
        try { // if an index is not available, create one
            if (ibis::gVerbose > 7) {
                std::string fname = indexFile.getFileName();
                logMessage("loadIndex", "loading an index from %s",
                           fname.c_str());
            }
            if (idx == 0) {
	    	// try to read index first
	    	bool readOnly = true;
		std::auto_ptr<FQ_IndexBinned>
		    binnedIdx(new FQ_IndexBinned(this, "", readOnly));
		if (binnedIdx.get() != 0 && binnedIdx->getStatus() >= 0 ) {
		    idx = binnedIdx.release();
		}
		else {
		    std::auto_ptr<FQ_IndexUnbinned>
			unbinnedIdx(new FQ_IndexUnbinned(this, readOnly));
		    if (unbinnedIdx.get() != 0 &&
			unbinnedIdx->getStatus() >= 0) {
			idx = unbinnedIdx.release();
		    }
#ifdef FQ_ALWAYS_INDEX
		    else { // allow a new index to be created
			readOnly = false;
			idx = new FQ_IndexUnbinned(this, readOnly);
		    }
#endif
		}
            }
	    if (idx == 0) {
		logWarning("loadIndex", "failed to create an index object");
	    }
            else if (ibis::gVerbose > 8) {
                ibis::util::logger lg;
                idx->print(lg());
            }
        }
        catch (const char *s) {
            logWarning("loadIndex", "ibis::index::ceate(%s) throw "
                       "the following exception\n%s", name(), s);
            idx = 0;
        }
        catch (const std::exception& e) {
            logWarning("loadIndex", "ibis::index::create(%s) failed "
                       "to create a new index -- %s", name(), e.what());
            idx = 0;
        }
        catch (...) {
            logWarning("loadIndex", "ibis::index::create(%s) failed "
                       "to create a new index -- unknown error", name());
            idx = 0;
        }
    }
} // FQ_Variable::loadIndex
void tarch::logging::CommandLineLogger::printFilterListToWarningDevice() const {
  if (_filterlist.empty()) {
    logWarning( "printFilterListToWarningDevice()", "filter list is empty" );
  }
  else {
    logWarning( "printFilterListToWarningDevice()", "filter list is not empty and contains " << _filterlist.size() << " entries" );
    for (FilterList::const_iterator p = _filterlist.begin(); p!=_filterlist.end(); p++ ) {
      logWarning( "printFilterListToWarningDevice()", p->toString() );
    }
  }
}
/**
    This method loads the reinforcements from the [REINFORCEMENTS] section.
*/
void INIMapEditorLoader::loadReinforcements()
{
    INIFile::KeyIterator iter;

    for(iter = inifile->begin("REINFORCEMENTS"); iter != inifile->end("REINFORCEMENTS"); ++iter) {
		std::string strHouseName;
		std::string strUnitName;
		std::string strDropLocation;
		std::string strTime;
		std::string strPlus;

        if(splitString(iter->getStringValue(), 4, &strHouseName, &strUnitName, &strDropLocation, &strTime) == false) {
            if(splitString(iter->getStringValue(), 5, &strHouseName, &strUnitName, &strDropLocation, &strTime, &strPlus) == false) {
                logWarning(iter->getLineNumber(), "Invalid reinforcement string: " + iter->getKeyName() + " = " + iter->getStringValue());
                continue;
            }
        }

        int houseID = getHouseID(strHouseName);
        if(houseID == HOUSE_UNUSED) {
            // skip reinforcement for unused house
            continue;
        } else if(houseID == HOUSE_INVALID) {
            logWarning(iter->getLineNumber(), "Invalid house string: '" + strHouseName + "'!");
            continue;
        }

        Uint32 unitID = getItemIDByName(strUnitName);
        if((unitID == ItemID_Invalid) || !isUnit(unitID)) {
            logWarning(iter->getLineNumber(), "Invalid unit string: '" + strUnitName + "'!");
            continue;
        }

        DropLocation dropLocation = getDropLocationByName(strDropLocation);
        if(dropLocation == Drop_Invalid) {
            logWarning(iter->getLineNumber(), "Invalid drop location string: '" + strDropLocation + "'!");
            dropLocation = Drop_Homebase;
        }

        Uint32 droptime;
        if(!parseString(strTime, droptime)) {
            logWarning(iter->getLineNumber(), "Invalid drop time string: '" + strTime + "'!");
            continue;
        }

        bool bRepeat = (strTime.rfind('+') == (strTime.length() - 1)) || (strPlus == "+");

        pMapEditor->getReinforcements().push_back(ReinforcementInfo(houseID, unitID, dropLocation, droptime, bRepeat));
	}
}
示例#16
0
void tarch::plotter::griddata::unstructured::vtk::VTKTextFileWriter::validateDataWriterIdentifier( const std::string& identifier ) const {
    if (identifier.empty()) {
        logWarning(
            "validateDataWriterIdentifier(string)",
            "identifier for vtk file is empty. Spaces are not allowed for vtk data field identifiers and some vtk visualisers might crash."
        );
    }
    if (identifier.find(' ')!=std::string::npos) {
        logWarning(
            "validateDataWriterIdentifier(string)",
            "identifier \"" << identifier << "\" contains spaces. Spaces are not allowed for vtk data field identifiers and some vtk visualisers might crash."
        );
    }
}
示例#17
0
Message*
MessageInflater::inflate(const UninflatedMessage& inSource)
{
	Message* theResult = NULL;
	
	MessageInflaterMap::iterator i = mMap.find(inSource.inflatedType());
	if(i != mMap.end())
	{
		try
		{
			theResult = i->second->clone();
			if(theResult != NULL)
			{
				bool successfulInflate = theResult->inflateFrom(inSource);
				if(!successfulInflate)
				{
					logWarning("inflate failed of message type %i", inSource.inflatedType());
					throw 1;
				}
			} else {
				logWarning("clone() failed message type %i", inSource.inflatedType());
			}
		}
		catch(...)
		{
			logWarning("exception caught in inflated() message type %i", inSource.inflatedType());
			delete theResult;
			theResult = NULL;
		}
	} else {
		logAnomaly("do not know how to inflate message type %i", inSource.inflatedType());
	}

	if(theResult == NULL)
	{
		// We should end up here in any of the following circumstances:
		// 1. No entry in map
		// 2. clone() returned NULL
		// 3. exception thrown in clone()
		// 4. inflateFrom() returned "false" meaning "unsuccessful inflate"
		// 5. exception thrown in inflateFrom()

		// In any of these cases, we were unable to inflate the message, so we return
		// a new copy of the uninflated message.
		theResult = inSource.clone();
	}

	return theResult;
}
示例#18
0
void daemon_init(bool bCloseFiles)
{
#ifndef WIN32
    pid_t pid;
    int i;

    if((pid=fork()) != 0)
    {
        exit(0);
    }

    setsid();

    if((pid=fork()) != 0)
    {
        exit(0);
    }

#ifdef DEBUG_FLAG
#define MAX_CORE_FILE_SIZE  (256 * 1024 * 1024)
    if (set_rlimit(RLIMIT_CORE, MAX_CORE_FILE_SIZE) != 0)
    {
        logWarning("file: "__FILE__", line: %d, " \
                   "set max core dump file size to %d MB fail, " \
                   "errno: %d, error info: %s", \
                   __LINE__, MAX_CORE_FILE_SIZE / (1024 * 1024), \
                   errno, STRERROR(errno));
    }
#else
    if (chdir("/") != 0)
    {
        logWarning("file: "__FILE__", line: %d, " \
                   "change directory to / fail, " \
                   "errno: %d, error info: %s", \
                   __LINE__, errno, STRERROR(errno));
    }
#endif

    if (bCloseFiles)
    {
        for(i=0; i<=2; i++)
        {
            close(i);
        }
    }
#endif

    return;
}
示例#19
0
/*
 *brief: 首先检查用户出入解析结果是否正确,
 *       检查数据空间中, 是否有对应的键
 *              有对应的键, 如果类型正确, 修改键值
 *              如果类型错误, 返回出错
 *       无对应的键, 设置值, 返回成功
 *
 */
int SetCommand::operator()(Client *client) const {
    ServerClient *serverClient = (ServerClient *)client;
    //check user resolved input
    const vector<string> &argv = client->getReceiveArgv();
    if (argv.size() != (unsigned int)(this->commandArgc() + 1)) {
        logWarning("set command receive error number of argv! argv_len[%d]", argv.size());
        client->initReplyHead(1);
        client->appendReplyBody(string("set no complete yet"));
        return CABINET_ERR;
    }

    const string &keyName = argv[1];
    const string &newValue = argv[2];
    //check key existence
    DataBase *db = serverClient->getDataBase();
    ValueObj *value = nullptr;
    //1. key exist
    if ((value = db->getValue(keyName)) != nullptr) {
        logDebug("set exist key, key[%s]", keyName.c_str());
        //check key type
        if (value->getValueType() != ValueObj::STRING_TYPE) {
            logDebug("set command execute in wrong type of value, key[%s] value_type[%d]", keyName.c_str(), value->getValueType());
            client->initReplyHead(1);
            client->appendReplyBody(string("I'm not string type."));
            return CABINET_OK;
        }
        logDebug("set string value, key[%s], new_value[%s]", keyName.c_str(), newValue.c_str());
        ((StringObj *)value)->set(newValue);
        client->initReplyHead(1);
        client->appendReplyBody(string("ok"));
        return CABINET_OK;
    }
    //2. key does not exist
    else {
        logDebug("set no-exist key, key[%s]", keyName.c_str());
        //to-do, insert new thing in dataspace
        ValueObj *newObj = new StringObj(newValue);
        if (db->insertKey(keyName, newObj) == CABINET_ERR) {
            logWarning("set command, insert key into dataspace error, key[%s]", keyName.c_str());
            client->initReplyHead(1);
            client->appendReplyBody(string("Set Error"));
            return CABINET_ERR;
        }
        client->initReplyHead(1);
        client->appendReplyBody(string("ok"));
        return CABINET_OK;
    }
}
示例#20
0
long FQ_Variable::indexSize() const{
    if (! isValid("FQ_Variable::indexSize")) return 0;

    std::string path = varInfo.getPath();
    if (! useAll) {
    	path += varSpace.getText();
    }
    uint64_t size = 0;
    int mpi_idx = -1;
#ifndef FQ_NOMPI
    mpi_idx = varSpace.getMpiIdx();
#endif
    bool berr = indexFile.getBitmapLength(path, &size, mpi_idx);

    if (ibis::gVerbose > 3) {
        if (!berr || size<=0)
            logWarning("indexSize", "failed to determine the bitmap length "
                       "for variable %s in file %s", name(),
                       indexFile.getFileName().c_str());

        else
            logMessage("indexSize", "found bitmap length "
                       "for variable %s in file %s to be %lu",
                       name(), indexFile.getFileName().c_str(), size);
    }
    return size;
} // FQ_Variable::indexSize
bool MixedContentChecker::canRunInsecureContentInternal(SecurityOrigin* securityOrigin, const KURL& url, const MixedContentType type) const
{
    // Check the top frame if it differs from MixedContentChecker's m_frame.
    if (!m_frame->tree().top()->isLocalFrame()) {
        // FIXME: We need a way to access the top-level frame's MixedContentChecker when that frame
        // is in a different process from the current frame. Until that is done, we always allow
        // loads in remote frames.
        return false;
    }
    Frame* top = m_frame->tree().top();
    if (top != m_frame && !toLocalFrame(top)->loader().mixedContentChecker()->canRunInsecureContent(toLocalFrame(top)->document()->securityOrigin(), url))
        return false;

    // Then check the current frame:
    if (!isMixedContent(securityOrigin, url))
        return true;

    Settings* settings = m_frame->settings();
    bool allowedPerSettings = settings && (settings->allowRunningOfInsecureContent() || ((type == WebSocket) && settings->allowConnectingInsecureWebSocket()));
    bool allowed = client()->allowRunningInsecureContent(allowedPerSettings, securityOrigin, url);
    logWarning(allowed, url, type);

    if (allowed)
        client()->didRunInsecureContent(securityOrigin, url);

    return allowed;
}
示例#22
0
/// ----------------------------------------------------------------------------
///                               CONVERTER
/// ----------------------------------------------------------------------------
Converter::Converter(const tConfigPtr& config)
    : LogSource("converter")
    , config_(config)
#ifdef SECURITY_ENABLED
    , security_(config)
#endif
{
    logWarning(logger(), "Working in PRECISE MODE. GOOD");
    wantUtf8Text_ = config_->getBool("app.saveAlsoAsUTF8", false);

    initialize(
        config_->getString("input.folder", ""),
        config_->getString("output.folder", ""),
        config_->getString("mapping.folder", "")
    );

    specialChars_ += (wchar_t)1;     /// footnote
    specialChars_ += (wchar_t)2;     /// footnote
    specialChars_ += (wchar_t)7;     /// table indicators
    specialChars_ += (wchar_t)9;     /// 
    specialChars_ += (wchar_t)11;     /// 
    specialChars_ += (wchar_t)12;     /// 
    specialChars_ += (wchar_t)13;    /// paragraph ending
    specialChars_ += (wchar_t)21;    /// paragraph ending
    specialChars_ += (wchar_t)47;    /// 

    specialCharsArafi_ = specialChars_;
    specialCharsArafi_.pop_back();
}
示例#23
0
unsigned long long getScaled(const char* buffer, const char* key)
{
	const char*			ptr = buffer;
	char*				next;
	unsigned long long	value;

	if(key)
	{
		if((ptr = strstr(buffer, key))) ptr += strlen(key);
		else
		{
			logWarning("Could not read key '%s' in buffer '%s' [%d]\n", key, buffer, __LINE__);
			return 0;
		}
	}

	value = strtoull(ptr, &next, 0);

	for( ; *next; ++next)
	{
		if(*next == 'k')
		{
			value *= 1024;
			break;
		}
		else if(*next == 'M')
		{
			value *= 1024 * 1024;
			break;
		}
	}

	return value;
}
示例#24
0
// Look up an attribute in an ad, optionally fall back to an alternate
// and/or log errors
bool
adLookup( const char *ad_type,
		  const ClassAd *ad,
		  const char *attrname,
		  const char *attrold,
		  MyString &string,
		  bool log = true )
{
	char	buf[256];
	bool	rval = true;

    if ( !ad->LookupString( attrname, buf, sizeof(buf) ) ) {
		if ( log ) {
			logWarning( ad_type, attrname, attrold );
		}

		if ( !attrold ) {
			buf[0] = '\0';
			rval = false;
		} else {
			if ( !ad->LookupString( attrold, buf, sizeof(buf) ) ) {
				if ( log ) {
					logError( ad_type, attrname, attrold );
				}
				buf[0] = '\0';
				rval = false;
			}
		}
	}

	string = buf;

	return rval;
}
void peano::applications::diffusionequation::explicittimestepping::configurations::AbstractTimeSteppingConfiguration::parseAttributes( tarch::irr::io::IrrXMLReader* xmlReader ) {
  if ( xmlReader->getAttributeValue("initial-time-step-size")!=0 ) {
    _initialTimeStepSize = xmlReader->getAttributeValueAsDouble("initial-time-step-size");
  }

  if ( xmlReader->getAttributeValue("max-time-step-difference")!=0 ) {
    _timeStepSizeMaxDifference = xmlReader->getAttributeValueAsDouble("max-time-step-difference");
  }

  if ( xmlReader->getAttributeValue("snapshot-delta")!=0 ) {
    _snapshotDelta = xmlReader->getAttributeValueAsDouble("snapshot-delta");
    if (_snapshotDelta==0.0) {
      logWarning( "parseAttributes(...)", "snapshot-delta is set to 0, i.e. no output data is written" );
    }
  }

  if ( xmlReader->getAttributeValue("plot-input-geometry-to-vtk-file")!=0 ) {
    _plotInputGeometryToVTKFile = xmlReader->getAttributeValue("plot-input-geometry-to-vtk-file");
  }
  else {
    logError( "parseAttributes(...)", "attribute \"plot-input-geometry-to-vtk-file\" is missing" );
    _isValid = false;
  }

  if ( xmlReader->getAttributeValue("total-time")!=0 ) {
    _totalTime = xmlReader->getAttributeValueAsDouble("total-time");
  }
}
示例#26
0
MainWindow::MainWindow(Logger* log, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    pLogger = log;

    ui->statusBar->showMessage("Ready to be used");

    // Récupération des valeur possibles pour le calcul des voies depuis l'énumération
    for (int i = 0; i < WayMethods::numMethods; i++) {
        ui->methodComboBox->addItem(WayMethods::MethodeVoies_name[i]);
    }
    ui->methodComboBox->setCurrentIndex(WayMethods::ANGLE_MIN); // valeur par défaut

    // Connexion des messages émis depuis le logger ou la database
    connect(pLogger,SIGNAL(information(QString)),this,SLOT(logInformation(QString)));
    connect(pLogger,SIGNAL(debug(QString)),this,SLOT(logDebug(QString)));
    connect(pLogger,SIGNAL(warning(QString)),this,SLOT(logWarning(QString)));
    connect(pLogger,SIGNAL(fatal(QString)),this,SLOT(logFatal(QString)));

    connect(ui->calculatePushButton,SIGNAL(clicked()),this,SLOT(calculate()));
    connect(ui->modifyPushButton,SIGNAL(clicked()),this,SLOT(modify()));

    connect(ui->browsePushButton, SIGNAL(clicked()), this, SLOT(browse()));

    connect(ui->classificationRadioButton, SIGNAL(toggled(bool)), this, SLOT(optionsModification(bool)));

}
示例#27
0
void fpeHandler(int sig)
{
    std::lock_guard<std::mutex> lock(mutex);

    initLoggingSystem();

    logWarning("SIGFPE\nBacktrace:\n");

    unsigned int depth = 0;
    const char **backtrace = getBacktrace(depth);

    for (size_t i = 0; i < depth-1; ++i)
    {
        logWarning("    %s\n", backtrace[i]);
    }
}
示例#28
0
文件: read.c 项目: anthrotype/otfcc
otl_Subtable *otl_read_chaining(const font_file_pointer data, uint32_t tableLength, uint32_t offset,
                                const otfcc_Options *options) {
	uint16_t format = 0;
	subtable_chaining *subtable = iSubtable_chaining.create();
	subtable->type = otl_chaining_poly;

	checkLength(offset + 2);
	format = read_16u(data + offset);
	if (format == 1) {
		return (otl_Subtable *)readChainingFormat1(subtable, data, tableLength, offset);
	} else if (format == 2) {
		return (otl_Subtable *)readChainingFormat2(subtable, data, tableLength, offset);
	} else if (format == 3) {
		// Chaining Contextual Substitution Subtable, Coverage based.
		// This table has exactly one rule within it, and i love it.
		subtable->rulesCount = 1;
		NEW(subtable->rules, 1);
		subtable->rules[0] = GeneralReadChainingRule(data, tableLength, offset + 2, 0, false, format3Coverage, NULL);
		return (otl_Subtable *)subtable;
	}
FAIL:
	logWarning("Unsupported format %d.\n", format);
	iSubtable_chaining.free(subtable);
	return NULL;
}
void RemoteThreadInjector::Release()
{
	if (!CloseHandle(m_hProcess))
	{
		logWarning(L"Couldn't close process handle", GetLastError());
	}
}
示例#30
0
void logTest()
{
  logDebug("Debug");
  logInfo("Info");
  logWarning("Warning");
  logError("Error");
}