Example #1
0
int main(int argc, char **argv) {
    int i;
    int files = 0;

    if (argc <= 1) {
	usage(argv[0]);
	return(1);
    }
    LIBXML_TEST_VERSION
    for (i = 1; i < argc ; i++) {
	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
	    debug++;
	else if ((!strcmp(argv[i], "-dump")) || (!strcmp(argv[i], "--dump")))
	    dump++;
	else if ((!strcmp(argv[i], "-count")) || (!strcmp(argv[i], "--count")))
	    count++;
	else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid")))
	    valid++;
	else if ((!strcmp(argv[i], "-noent")) ||
	         (!strcmp(argv[i], "--noent")))
	    noent++;
    }
    if (noent != 0) xmlSubstituteEntitiesDefault(1);
    for (i = 1; i < argc ; i++) {
	if (argv[i][0] != '-') {
	    handleFile(argv[i]);
	    files ++;
	}
    }
    xmlCleanupParser();
    xmlMemoryDump();

    return(0);
}
Example #2
0
void process(int argc, char **argv) {
    FILE * fin;
    sqlite3 * db;
    int i, rc;
    char sqlstmt[1024];
    char *error;
    rc = sqlite3_open("dict.db", &db);
    if (rc) {
        printf("Cannot open database dict.db.\n");
        sqlite3_close(db);
        return;
    }
    strcpy(sqlstmt, "CREATE TABLE English (word VARCHAR(24) PRIMARY KEY);");
    rc = sqlite3_exec(db, sqlstmt, NULL, 0, &error);
    if (rc != SQLITE_OK) {
        printf("SQL error:%s.\n", error);
        sqlite3_free(error);
    }
    for (i = 1; i < argc; ++i) {
        fin = fopen(argv[i], "rb");
        if (fin == NULL) {
            printf("Cannot open file %s.\n", argv[i]);
        }
        else {
            printf("Process file %s...\n", argv[i]);
            handleFile(db, fin);
            fclose(fin);
        }
    }
    sqlite3_close(db);
}
Example #3
0
void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) {
	_vm->_screen->loadRawPalette(res->_stream);
	if (_setPaletteFlag)
		_vm->_screen->setPalette();
	_setPaletteFlag = true;

	// The remainder of the file after the palette may be separately compressed,
	// so call handleFile to handle it if it is
	res->_size -= res->_stream->pos();
	handleFile(res);

	if (dest != _vm->_screen)
		dest->w = _vm->_screen->w;

	if (dest->w == dest->pitch) {
		res->_stream->read((byte *)dest->getPixels(), dest->w * dest->h);
	} else {
		for (int y = 0; y < dest->h; ++y) {
			byte *pDest = (byte *)dest->getBasePtr(0, y);
			res->_stream->read(pDest, dest->w);
		}
	}

	if (dest == _vm->_screen)
		_vm->_screen->addDirtyRect(Common::Rect(0, 0, dest->w, dest->h));
}
Example #4
0
int main(int argc, char **argv) {
	int f, x;
	char fileName[1024];
	char *realName;
	struct stat statBuf;
	int serr;
	int rate;
	int err=0;
	int compType=1; //default compression type - heatshrink
	int compLvl=-1;

	for (x=1; x<argc; x++) {
		if (strcmp(argv[x], "-c")==0 && argc>=x-2) {
			compType=atoi(argv[x=1]);
			x++;
		} else if (strcmp(argv[x], "-l")==0 && argc>=x-2) {
			compLvl=atoi(argv[x=1]);
			if (compLvl<1 || compLvl>9) err=1;
			x++;
		} else {
			err=1;
		}
	}

	if (err) {
		fprintf(stderr, "%s - Program to create espfs images\n", argv[0]);
		fprintf(stderr, "Usage: \nfind | %s [-c compressor] [-l compression_level] > out.espfs\n", argv[0]);
		fprintf(stderr, "Compressors:\n0 - None\n1 - Heatshrink(defautl\n");
		fprintf(stderr, "Compression level: 1 is worst but low RAM usage, higher is better compression \nbut uses more ram on decompression. -1 = compressors default.\n");
		exit(0);
	}

	while(fgets(fileName, sizeof(fileName), stdin)) {
		//Kill off '\n' at the end
		fileName[strlen(fileName)-1]=0;
		//Only include files
		serr=stat(fileName, &statBuf);
		if ((serr==0) && S_ISREG(statBuf.st_mode)) {
			//Strip off './' or '/' madness.
			realName=fileName;
			if (fileName[0]=='.') realName++;
			if (realName[0]=='/') realName++;
			f=open(fileName, O_RDONLY);
			if (f>0) {
				rate=handleFile(f, realName, compType, compLvl);
				fprintf(stderr, "%s (%d%%)\n", realName, rate);
				close(f);
			} else {
				perror(fileName);
			}
		} else {
			if (serr!=0) {
				perror(fileName);
			}
		}
	}
	finishArchive();
	return 0;
}
Example #5
0
Resource *FileManager::loadFile(int fileNum, int subfile) {
	Resource *res = new Resource();
	setAppended(res, fileNum);
	gotoAppended(res, subfile);

	handleFile(res);
	return res;
}
Example #6
0
void FileBrowserTreeWidget::openInNewInstrumentTrack( TrackContainer* tc )
{
	if( m_contextMenuItem->handling() == FileItem::LoadAsPreset ||
		m_contextMenuItem->handling() == FileItem::LoadByPlugin )
	{
		InstrumentTrack * it = dynamic_cast<InstrumentTrack *>(
				Track::create( Track::InstrumentTrack, tc ) );
		handleFile( m_contextMenuItem, it );
	}
}
Example #7
0
int main(int argc, char * argv[])
{
    if ((argc < 3)) {
        usage();
        return 0;
    }

	handleFile(argv[1], 86.064, 10.764, argv[2]);

}
Example #8
0
Resource *FileManager::loadFile(const Common::String &filename) {
	Resource *res = new Resource();

	// Open the file
	openFile(res, filename);

	// Set up stream for the entire file
	res->_size = res->_file.size();
	res->_stream = res->_file.readStream(res->_size);

	handleFile(res);
	return res;
}
Example #9
0
void FileBrowserTreeWidget::activateListItem(QTreeWidgetItem * item,
								int column )
{
	FileItem * f = dynamic_cast<FileItem *>( item );
	if( f == NULL )
	{
		return;
	}

	if( f->handling() == FileItem::LoadAsProject ||
		f->handling() == FileItem::ImportAsProject )
	{
		handleFile( f, NULL );
	}
	else if( f->handling() != FileItem::NotSupported )
	{
		InstrumentTrack * it = dynamic_cast<InstrumentTrack *>(
				Track::create( Track::InstrumentTrack,
					Engine::getBBTrackContainer() ) );
		handleFile( f, it );
	}
}
Example #10
0
File: cut.c Project: jarn0x/Escape
int main(int argc,const char **argv) {
	int first = 1,last = -1;
	char *fields = NULL;
	char *delim = (char*)"\t";
	const char **args;

	int res = ca_parse(argc,argv,0,"f=s* d=s",&fields,&delim);
	if(res < 0) {
		printe("Invalid arguments: %s",ca_error(res));
		usage(argv[0]);
	}
	if(ca_hasHelp())
		usage(argv[0]);

	parseFields(fields,&first,&last);

	args = ca_getFree();
	if(args[0] == NULL)
		handleFile(stdin,delim,first,last);
	else {
		FILE *f;
		while(*args) {
			if(isdir(*args)) {
				printe("'%s' is a directory!",*args);
				continue;
			}
			f = fopen(*args,"r");
			if(!f) {
				printe("Unable to open '%s'",*args);
				continue;
			}
			handleFile(f,delim,first,last);
			fclose(f);
			args++;
		}
	}
	return EXIT_SUCCESS;
}
void UBWebPluginWidget::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData)
{
    Q_UNUSED(pSuccess);
    Q_UNUSED(pContentTypeHeader);

    QString tempFile = UBFileSystemUtils::createTempDir("UBWebPluginTemplate") + "/" + QFileInfo(sourceUrl.path()).fileName();
    QFile pdfFile(tempFile);
    pdfFile.open(QIODevice::WriteOnly);
    pdfFile.write(pData);
    pdfFile.close();
    handleFile(tempFile);
    mLoadingProgressBar.hide();
    update();
}
//performs operations according to HTTP Message Header
void Reciever::performOperations(Socket &socket_,Message m,std::string command, std::string mapCommand, std::map<std::string, std::string> map)
{
	std::string fileName = map["FileName"];
	
	if ((mapCommand == "0" || mapCommand == "1") && fileName.size() >0)//if the contents from binary/text file is received
	{
		handleFile(socket_, map);
	}
	else if (mapCommand == "4")//if the file or string is uploaded by client
	{
		Display::displayString("File: '" + map["FileName"] + "' is uploaded by Client");
		queue_.enQ("File: " + map["FileName"] + " uploaded at Path: " + map["Category"] +  "\\" +map["FileName"]);
	}
	else if (mapCommand == "5")
	{
		Display::displayString("File is downloaded at '" + FileSystem::Path::getFullFileSpec(map["FileName"]) + "' by Client");
		queue_.enQ("File: " + map["FileName"] + " downloaded at Path: " + FileSystem::Path::getFullFileSpec(map["Category"] + map["FileName"]));
	}
	else if ((mapCommand == "6" || mapCommand == "9") && fileName.length() > 0)
	{
		fileAndTextSearching(map);
	}
	else if (mapCommand == "7")
	{
		ackFileSearch(m, map);
	}
	else if (mapCommand == "8")
	{
		Message m("DOWNLOAD", "localhost", "localhost", 0, stoi(map["SourcePort"]), stoi(map["DestinationPort"]), map["FileName"], map["Category"]);
		queue_.enQ(m.makeHeader());
	}
	else if (mapCommand == "10" || mapCommand == "11")
	{
		handleFile(socket_, map);
	}
}
QNetworkRequest TwitterRequest::createPostMessageRequest(const QString &text,
                                                         const QUrl &fileUrl,
                                                         QByteArray *retContent)
{
    QByteArray content;
    QNetworkRequest req;

    if (!fileUrl.isEmpty()) {
        // Status update with a picture included.
        QString file = fileUrl.toLocalFile();
        QFileInfo fileInfo(file);
        QByteArray fileData = handleFile(file);
        const QString bound = "WaB33xxDoEd";    // Just some random string.

        // Create the request body content with an internal helper function.
        content = createImageUploadContent(
                    bound, text, fileInfo.fileName(), fileInfo.suffix(), fileData);

        // Create the request with the OAuth Authorization. The image POSTs have
        // only the oauth_* -fields in the signature.
        req = createRequest(QUrl(UPDATE_WITH_MEDIA_URL), HTTP_POST);
        req.setRawHeader(HTTP_HEADER_HOST, HTTP_HEADER_VALUE_TWITTER_UPLOAD);
        req.setRawHeader(HTTP_HEADER_CONTENT_TYPE,
                         HTTP_HEADER_VALUE_FORM_DATA_BOUNDARY + bound.toAscii());
        req.setRawHeader(HTTP_HEADER_CONTENT_LENGTH,
                         QString::number(content.length()).toAscii());
    }
    else {
        // Normal status update (without any files).
        QVariantMap params;
        params.insert(TWITTER_STATUS_UPDATE, text);

        QByteArray encodedMsg = QUrl::toPercentEncoding(
                    text.normalized(QString::NormalizationForm_C));
        content = QByteArray(TWITTER_STATUS_UPDATE).append("=").append(encodedMsg);

        // Create the request. The message has to be part of the signature.
        req = createRequest(QUrl(UPDATE_URL), HTTP_POST, params);
        req.setRawHeader(HTTP_HEADER_HOST, HTTP_HEADER_VALUE_TWITTER_API);
        req.setRawHeader(HTTP_HEADER_CONTENT_TYPE, HTTP_HEADER_VALUE_FORM_URLENCODED);
    }

    *retContent = content;
    return req;
}
Example #14
0
void
handleHtdb(void)
{
    FILE *htdbFile;
    int c;

    htdbFile = fopen(htdbFName, "r");
    if (htdbFile == NULL)
        badDB();

    while ((c = getc(htdbFile)) != EOF) {
        if (c != '\t')
            badDB();
        ungetc(c, htdbFile);

        handleFile(htdbFile);
    }
    fclose(htdbFile);
}
Example #15
0
void FileBrowserTreeWidget::sendToActiveInstrumentTrack( void )
{
	// get all windows opened in the workspace
	QList<QMdiSubWindow*> pl =
			Engine::mainWindow()->workspace()->
				subWindowList( QMdiArea::StackingOrder );
	QListIterator<QMdiSubWindow *> w( pl );
	w.toBack();
	// now we travel through the window-list until we find an
	// instrument-track
	while( w.hasPrevious() )
	{
		InstrumentTrackWindow * itw =
			dynamic_cast<InstrumentTrackWindow *>(
						w.previous()->widget() );
		if( itw != NULL && itw->isHidden() == false )
		{
			handleFile( m_contextMenuItem, itw->model() );
			break;
		}
	}
}
void ConfigWidget::makeConnections()
{
    // networkPage Connections
    connect(networkPage, SIGNAL(ipChanged(QString)), udpClient, SLOT(setOtherNodeAddress(QString)));
    connect(networkPage, SIGNAL(portChanged(int)), udpClient, SLOT(setOtherNodePort(int)));

    // settingsPage Connections
    connect(settingsPage, SIGNAL(connectClicked()), udpClient, SLOT(startSocket()));
    connect(settingsPage, SIGNAL(sendClicked(QString)), udpClient, SLOT(sendUserCommand(QString)));
    connect(settingsPage, SIGNAL(disconnectClicked()), udpClient, SLOT(stopSocket()));
    connect(settingsPage, SIGNAL(configFileSelected(QString)), ConfigFileHandler::instance(), SLOT(handleFile(QString)));

    // consolePage Connections
    connect(consolePage, SIGNAL(startClicked()), this, SLOT(startConsoleStream()));
    connect(consolePage, SIGNAL(stopClicked()), this, SLOT(stopConsoleStream()));

    // ConfigFileHandler Connections
    connect(ConfigFileHandler::instance(), SIGNAL(commandFromFile(QString)), udpClient, SLOT(sendUserCommand(QString)));

    // udpClient Connection
    connect(udpClient, SIGNAL(dataReplyReceived(QString)), settingsPage, SLOT(addToViewer(QString)));
    connect(udpClient, SIGNAL(connectionChanged(bool)), networkPage, SLOT(adjustToConnection(bool)));
    connect(udpClient, SIGNAL(connectionChanged(bool)), settingsPage, SLOT(adjustToConnection(bool)));
    connect(udpClient, SIGNAL(connectionChanged(bool)), consolePage, SLOT(adjustToConnection(bool)));
}
Example #17
0
int main(int argc, char **argv) {
	int f, x;
	char fileName[1024];
	char *realName;
	struct stat statBuf;
	int serr;
	int rate;
	int err=0;
	int compType;  //default compression type - heatshrink
	int compLvl=-1;
#ifdef __MINGW32__
/* Switch to binary mode */
_setmode(_fileno(stdout),_O_BINARY);
#endif

#ifdef ESPFS_HEATSHRINK
	compType = COMPRESS_HEATSHRINK;
#else
	compType = COMPRESS_NONE;
#endif

	for (x=1; x<argc; x++) {
		if (strcmp(argv[x], "-c")==0 && argc>=x-2) {
			compType=atoi(argv[x+1]);
			x++;
		} else if (strcmp(argv[x], "-l")==0 && argc>=x-2) {
			compLvl=atoi(argv[x+1]);
			if (compLvl<1 || compLvl>9) err=1;
			x++;
#ifdef ESPFS_GZIP
		} else if (strcmp(argv[x], "-g")==0 && argc>=x-2) {
			if (!parseGzipExtensions(argv[x+1])) err=1;
			x++;
#endif
		} else {
			err=1;
		}
	}

#ifdef ESPFS_GZIP
	if (gzipExtensions == NULL) {
		parseGzipExtensions(strdup("html,css,js"));
	}
#endif

	if (err) {
		fprintf(stderr, "%s - Program to create espfs images\n", argv[0]);
		fprintf(stderr, "Usage: \nfind | %s [-c compressor] [-l compression_level] ", argv[0]);
#ifdef ESPFS_GZIP
		fprintf(stderr, "[-g gzipped_extensions] ");
#endif
		fprintf(stderr, "> out.espfs\n");
		fprintf(stderr, "Compressors:\n");
#ifdef ESPFS_HEATSHRINK
		fprintf(stderr, "0 - None\n1 - Heatshrink(default)\n");
#else
		fprintf(stderr, "0 - None(default)\n");
#endif
		fprintf(stderr, "\nCompression level: 1 is worst but low RAM usage, higher is better compression \nbut uses more ram on decompression. -1 = compressors default.\n");
#ifdef ESPFS_GZIP
		fprintf(stderr, "\nGzipped extensions: list of comma separated, case sensitive file extensions \nthat will be gzipped. Defaults to 'html,css,js'\n");
#endif
		exit(0);
	}

	while(fgets(fileName, sizeof(fileName), stdin)) {
		//Kill off '\n' at the end
		fileName[strlen(fileName)-1]=0;
		//Only include files
		serr=stat(fileName, &statBuf);
		if ((serr==0) && S_ISREG(statBuf.st_mode)) {
			//Strip off './' or '/' madness.
			realName=fileName;
			if (fileName[0]=='.') realName++;
			if (realName[0]=='/') realName++;
			f=open(fileName, O_RDONLY);
			if (f>0) {
				char *compName = "unknown";
				rate=handleFile(f, realName, compType, compLvl, &compName);
				fprintf(stderr, "%s (%d%%, %s)\n", realName, rate, compName);
				close(f);
			} else {
				perror(fileName);
			}
		} else {
			if (serr!=0) {
				perror(fileName);
			}
		}
	}
	finishArchive();
	return 0;
}