예제 #1
0
파일: compile.c 프로젝트: mlafeldt/xp2cc
int backend(AST *tree, char *filename)
{
	FILE *fp = NULL;
	u8 *bin = NULL;
	u32 binlen;
	u32 p2mlen;

	printf("*** Compiler back end ***\n");

	if (mode & MODE_SORT) {
		printf("Sorting by game title... ");
		sortTree(tree);
		printf("Done.\n");
	}

	printf("Translating to BIN... ");

	if ((bin = translateTree(tree)) == NULL) {
		fprintf(stderr, "Failed.\n");
		return -1;
	}

	binlen = *(u32*) bin + 8;

	printf("Done (%s).\n", sizeToStr(binlen));
	printf("%s file '%s'... ", mode & MODE_BIN ? "Writing to" : "Creating P2M", filename);

	if ((fp = fopen(filename, "wb")) == NULL) {
		fprintf(stderr, "Failed.\n");
		return -2;
	}

	if ((mode & MODE_BIN ? writeToFile(fp, bin, 0, binlen) : createP2mFile(fp, bin, binlen, &p2mlen)) < 0) {
		fprintf(stderr, "Failed.\n");
		return -3;
	}

	free(bin);
	fclose(fp);

	if (mode & MODE_BIN) printf("Done.\n");
	else printf("Done (%s).\n", sizeToStr(p2mlen));

	return 0;
}
예제 #2
0
파일: Scanner.cpp 프로젝트: ADTRAN/ipfixcol
/**
 * \brief Main loop
 */
void Scanner::loop()
{
	prctl(PR_SET_NAME, "fbitexp:Scanner\0", 0, 0, 0);
	
	std::mutex mtx;
	std::unique_lock<std::mutex> lock(mtx);
	
	MSG_DEBUG(msg_module, "started");
	
	while (!_done) {
		/* 
		 * This is before waiting because we want to check size on startup before 
		 * any scan or add requests
		 */
		if (totalSize() > _max_size) {
			removeDirs();
		}
		
		MSG_DEBUG(msg_module, "Total size: %s, Max: %s, Watermark: %s", 
			sizeToStr(totalSize()).c_str(), sizeToStr(_max_size).c_str(), sizeToStr(_watermark).c_str());
		_cv.wait(lock, [&]{ return scanCount() > 0 || addCount() > 0 || _done || totalSize() > _max_size; });
		
		if (_done) {
			break;
		}
		
		/* Add dirs from queue */
		if (addCount() > 0) {
			addNewDirs();
		}
		
		/* Scan dirs in queue */
		if (scanCount() > 0) {
			rescanDirs();
		}
	}
	
	MSG_DEBUG(msg_module, "closing thread");
}
예제 #3
0
QString QGeoTileFetcherNokia::getRequestString(const QGeoTileSpec &spec)
{
    static const QString http("http://");
    static const QString path("/maptiler/v2/maptile/newest/");
    static const QChar slash('/');

    QString requestString = http;

    requestString += m_uriProvider->getCurrentHost();
    requestString += path;

    requestString += mapIdToStr(spec.mapId());
    requestString += slash;
    requestString += QString::number(spec.zoom());
    requestString += slash;
    requestString += QString::number(spec.x());
    requestString += slash;
    requestString += QString::number(spec.y());
    requestString += slash;
    requestString += sizeToStr(m_tileSize);
    static const QString slashpng("/png8");
    requestString += slashpng;

    if (!m_token.isEmpty() && !m_applicationId.isEmpty()) {
        requestString += "?token=";
        requestString += m_token;

        requestString += "&app_id=";
        requestString += m_applicationId;
    }

    requestString += "&lg=";
    requestString += getLanguageString();

    return requestString;
}