Beispiel #1
0
int main(int argc, char const *argv[]) {
    std::ios::sync_with_stdio(false);
    if(argc != 2) {
        std::cerr << "Filename required" << std::endl;
        return EXIT_FAILURE;
    }
    // Input file name.
    std::string in_name = argv[1];
    // filehandler.
    std::ifstream in(in_name,std::ios::in);
    if(in) {
        generateIndex(in);
    }else {
        std::cerr << "File does not exist" << std::endl;
        return EXIT_FAILURE;
    }
    in.close();
    return EXIT_SUCCESS;
}
Beispiel #2
0
bool ScummDiskImage::openSubFile(const Common::String &filename) {
	assert(isOpen());

	const char *ext = strrchr(filename.c_str(), '.');
	char resNum[3];
	int res;

	// We always have file name in form of XX.lfl
	resNum[0] = ext[-2];
	resNum[1] = ext[-1];
	resNum[2] = 0;

	res = atoi(resNum);

	if (res == 0) {
		return generateIndex();
	} else {
		return generateResource(res);
	}

	return true;
}
Beispiel #3
0
void ReportDialog::doShowReport()
{
    logMessage("ReportDialog::doShowReport()");

    QDir(tempProblemDir()).mkdir("report");

    QFile::remove(QString("%1/report/template.html").arg(tempProblemDir()));
    QFile::remove(QString("%1/report/style.css").arg(tempProblemDir()));
    bool fileTemplateOK = QFile::copy(QString(txtTemplate->text()),
                                      QString("%1/report/template.html").arg(tempProblemDir()));
    bool fileStyleOK = QFile::copy(QString(txtStyleSheet->text()),
                                      QString("%1/report/style.css").arg(tempProblemDir()));
    if (!fileTemplateOK)
        QMessageBox::critical(QApplication::activeWindow(), tr("Error"), tr("Report template could not be copied."));
    else if (!fileStyleOK)
        QMessageBox::critical(QApplication::activeWindow(), tr("Error"), tr("Template style could not be copied."));
    else
    {
        generateFigures();
        generateIndex();

        QDesktopServices::openUrl(QUrl::fromLocalFile(tempProblemDir() + "/report/report.html"));
    }
}
/* opens the provided txtfile, and compares each letter with a table of letters from the base string. 
The function keeps track of whether or not the word is formable. Then when a tokenizer is found the 
word counter updates, and so does the formable word counter, depernding on its status */
void processTokensFromFile(char** base_array, const char** fname_array, const unsigned int num_inputs, const unsigned int* length_array, \
    const unsigned int max_length, const unsigned char silence, const unsigned char tare_setup, const size_t buckets)
 {
    unsigned int char_count, word_count, formable_count, buff_index;
    FILE *input_file;
    char *c_buff=NULL;
    int c;                                             //character returned from fgetc
    Table *base_table, *comparison_table;
    unsigned char is_formable;                 
    unsigned int* index;

    c_buff= calloc(max_length+1, sizeof(char));     //used to build word tokens as read from the provided file
    if (c_buff==NULL){
        printf("Memory allocation failed: char pointer c_buff\n");
        exit(0);
    }

    base_table=tableCreate(TABLE_SIZE);
    comparison_table=tableCreate(TABLE_SIZE);

    fillTable(base_table, base_array[0]);
    index=generateIndex(base_table);                         //used to rebuild only the necessary parts of the table
    copyTableFromIndex(comparison_table, base_table, index);

    
    if (!tare_setup) {
        for(unsigned int i=0; i<num_inputs; ++i) {
            char_count=0, word_count=0, formable_count=0, buff_index=0;
            is_formable=1;                                //assume token is formable until checkChar returns otherwise  
            
            input_file= fopen(fname_array[i], "r");                 
            if(input_file==NULL) {                          //Prevents seg fault crash if there is a problem with the provided file
                printf("Improper file name: %s\n",fname_array[i]);
                continue;
            }

            if(!silence) {
                displayIntro(i+1,fname_array[i]);
            }

            do{
                c = fgetc(input_file);                       //gets next character
                if(isTokenizer(c) || c==EOF) {          
                    if(buff_index != 0){                        //non-negative index + reaching a tokenizer means c_buff contains a token
                        ++word_count;
                        char_count += buff_index+1;         // +1 to account for the tokenizing character causing termination of token reading
                        if(is_formable) {            
                            ++formable_count;
                            if (!silence) {printf("\t%s\n",c_buff);}
                        } 
                        //reset params for next loop and next token
                        buff_index=0, is_formable=1;           
                        copyTableFromIndex(comparison_table, base_table,index);    
                        memset(&c_buff[0],0,(buff_index < max_length) ? buff_index : max_length);        
                    }
                    else {
                        ++char_count;       // A tokenizer char has been found, but no token is being formed
                    }          
                }
                else
                {
                    if(is_formable) { 
                        if(checkChar(c,comparison_table)) {  
                            c_buff[buff_index]=c; 
                        } else {
                            is_formable=0;
                        }    
                    } 
                    ++buff_index;
                }

            } while(c!=EOF);
            --char_count;       //correct for EOF being read for a char
            fclose(input_file);
            reportResults(length_array[0],char_count, word_count, formable_count);
        }
    }    

    tableDestroy(base_table);
    tableDestroy(comparison_table);
    indexDestroy(index);
    free(c_buff);

}
Beispiel #5
0
KHTMLSearchConfig::KHTMLSearchConfig(QWidget *parent, const char *name)
  : KCModule(parent, name), indexProc(0)
{
  QVBoxLayout *vbox = new QVBoxLayout(this, 5);


  QGroupBox *gb = new QGroupBox(i18n("ht://dig"), this);
  vbox->addWidget(gb);

  QGridLayout *grid = new QGridLayout(gb, 3,2, 6,6);

  grid->addRowSpacing(0, gb->fontMetrics().lineSpacing());

  QLabel *l = new QLabel(i18n("The fulltext search feature makes use of the "
                  "ht://dig HTML search engine. "
                  "You can get ht://dig at the"), gb);
  l->setAlignment(QLabel::WordBreak);
  l->setMinimumSize(l->sizeHint());
  grid->addMultiCellWidget(l, 1, 1, 0, 1);
  QWhatsThis::add( gb, i18n( "Information about where to get the ht://dig package." ) );

  KURLLabel *url = new KURLLabel(gb);
  url->setURL("http://www.htdig.org");
  url->setText(i18n("ht://dig home page"));
  url->setAlignment(QLabel::AlignHCenter);
  grid->addMultiCellWidget(url, 2,2, 0, 1);
  connect(url, SIGNAL(leftClickedURL(const QString&)),
      this, SLOT(urlClicked(const QString&)));

  gb = new QGroupBox(i18n("Program Locations"), this);

  vbox->addWidget(gb);
  grid = new QGridLayout(gb, 4,2, 6,6);
  grid->addRowSpacing(0, gb->fontMetrics().lineSpacing());

  htdigBin = new KURLRequester(gb);
  l = new QLabel(htdigBin, i18n("ht&dig"), gb);
  l->setBuddy( htdigBin );
  grid->addWidget(l, 1,0);
  grid->addWidget(htdigBin, 1,1);
  connect(htdigBin->lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(configChanged()));
  QString wtstr = i18n( "Enter the path to your htdig program here, e.g. /usr/local/bin/htdig" );
  QWhatsThis::add( htdigBin, wtstr );
  QWhatsThis::add( l, wtstr );

  htsearchBin = new KURLRequester(gb);
  l = new QLabel(htsearchBin, i18n("ht&search"), gb);
  l->setBuddy( htsearchBin );
  grid->addWidget(l, 2,0);
  grid->addWidget(htsearchBin, 2,1);
  connect(htsearchBin->lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(configChanged()));
  wtstr = i18n( "Enter the path to your htsearch program here, e.g. /usr/local/bin/htsearch" );
  QWhatsThis::add( htsearchBin, wtstr );
  QWhatsThis::add( l, wtstr );

  htmergeBin = new KURLRequester(gb);
  l = new QLabel(htmergeBin, i18n("ht&merge"), gb);
  l->setBuddy( htmergeBin );
  grid->addWidget(l, 3,0);
  grid->addWidget(htmergeBin, 3,1);
  connect(htmergeBin->lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(configChanged()));
  wtstr = i18n( "Enter the path to your htmerge program here, e.g. /usr/local/bin/htmerge" );
  QWhatsThis::add( htmergeBin, wtstr );
  QWhatsThis::add( l, wtstr );

  QHBoxLayout *hbox = new QHBoxLayout(vbox);

  gb = new QGroupBox(i18n("Scope"), this);
  hbox->addWidget(gb);
  QWhatsThis::add( gb, i18n( "Here you can select which parts of the documentation should be included in the fulltext search index. Available options are the KDE Help pages, the installed man pages, and the installed info pages. You can select any number of these." ) );

  QVBoxLayout *vvbox = new QVBoxLayout(gb, 6,2);
  vvbox->addSpacing(gb->fontMetrics().lineSpacing());

  indexKDE = new QCheckBox(i18n("&KDE help"), gb);
  vvbox->addWidget(indexKDE);
  connect(indexKDE, SIGNAL(clicked()), this, SLOT(configChanged()));

  indexMan = new QCheckBox(i18n("&Man pages"), gb);
  vvbox->addWidget(indexMan);
  indexMan->setEnabled(false),
  connect(indexMan, SIGNAL(clicked()), this, SLOT(configChanged()));

  indexInfo = new QCheckBox(i18n("&Info pages"), gb);
  vvbox->addWidget(indexInfo);
  indexInfo->setEnabled(false);
  connect(indexInfo, SIGNAL(clicked()), this, SLOT(configChanged()));

  gb = new QGroupBox(i18n("Additional Search Paths"), this);
  hbox->addWidget(gb);
  QWhatsThis::add( gb, i18n( "Here you can add additional paths to search for documentation. To add a path, click on the <em>Add...</em> button and select the folder from where additional documentation should be searched. You can remove folders by clicking on the <em>Delete</em> button." ) );

  grid = new QGridLayout(gb, 4,3, 6,2);
  grid->addRowSpacing(0, gb->fontMetrics().lineSpacing());

  addButton = new QPushButton(i18n("Add..."), gb);
  grid->addWidget(addButton, 1,0);

  delButton = new QPushButton(i18n("Delete"), gb);
  grid->addWidget(delButton, 2,0);

  searchPaths = new KListBox(gb);
  grid->addMultiCellWidget(searchPaths, 1,3, 1,1);
  grid->setRowStretch(2,2);

  gb = new QGroupBox(i18n("Language Settings"), this);
  vbox->addWidget(gb);
  QWhatsThis::add(gb, i18n("Here you can select the language you want to create the index for."));
  language = new KLanguageCombo(gb);
  l = new QLabel(language, i18n("&Language"), gb);
  vvbox = new QVBoxLayout(gb, 6,2);
  vvbox->addSpacing(gb->fontMetrics().lineSpacing());
  hbox = new QHBoxLayout(vvbox, 6);
  hbox->addWidget(l);
  hbox->addWidget(language,1);
  hbox->addStretch(1);

  loadLanguages();

  vbox->addStretch(1);

  runButton = new QPushButton(i18n("Generate Index..."), this);
  QWhatsThis::add( runButton, i18n( "Click this button to generate the index for the fulltext search." ) );
  runButton->setFixedSize(runButton->sizeHint());
  vbox->addWidget(runButton, AlignRight);
  connect(runButton, SIGNAL(clicked()), this, SLOT(generateIndex()));

  connect(addButton, SIGNAL(clicked()), this, SLOT(addClicked()));
  connect(delButton, SIGNAL(clicked()), this, SLOT(delClicked()));
  connect(searchPaths, SIGNAL(highlighted(const QString &)),
      this, SLOT(pathSelected(const QString &)));

  checkButtons();

  load();
}
Beispiel #6
0
int main() {
	
	char pseudo[100], ratio[100], nb_mots_txt[100];
	char *readSav = NULL;
	int choix = 0;
	t_context *menu = NULL, *popup = NULL;
	
	memset(pseudo, 0, sizeof(pseudo));
	//strcpy(pseudo, "NoName");
	savegame = SDL_initProfil("crossword.sav");
	
	readSav = SDL_readParam(savegame, "username");
	if (!readSav) {
		strcpy(pseudo, "NoName");
	}else{
		strcpy(pseudo, readSav);
	}
	
	// Aléatoirité
	srand(time(NULL));
	
	SDL_initWindow(800, 600, 0, "CrossWords ESDL", NULL, 1, "global.ttf", 20, 1); //800x600 +tff_support +audio_support
	
	
	generateIndex();
	
	menu = SDL_newContext("CrossWords SDL", 0, 0, 800, 600);
	SDL_newImage(menu, NULL, "APP_BG_SAMPLE.png", 0, 0);
	
	SDL_newObj(menu, NULL, 0, "Nouvelle partie", ALIGN_CENTER, NULL, NONE, 50, 550);
	SDL_newObj(menu, NULL, 0, "Options", ALIGN_CENTER, NULL, NONE, 280, 550);
	SDL_newObj(menu, NULL, 0, "Quitter", ALIGN_CENTER, NULL, NONE, 510, 550);
	SDL_newText(menu, NULL, pseudo, colorBlack, 550, 40);
	sprintf(ratio, "Score : %i d'XP", EXP_J1);
	SDL_newText(menu, NULL, ratio, colorRed, 550, 60);
	
	while (1) {
		
		sprintf(ratio, "Score : %i d'XP", EXP_J1);
		SDL_editText(menu, 0, pseudo, colorBlack, 550, 40);
		SDL_editText(menu, 1, ratio, colorRed, 550, 60);
		
		choix = SDL_generate(menu);
		
		switch (choix) {
			case 0:
				
				popup = SDL_newContext("Mon compte", 200, 200, 500, 250);
				memset(nb_mots_txt,0,sizeof(nb_mots_txt));
				SDL_newImage(popup, NULL, "popup.png", 0, 0);
				SDL_newText(popup, NULL, "Preciser le nombre de mots (de 10 a 40)", colorWhite, 10, 40);
				SDL_newObj(popup, NULL, 1, "Mots", ALIGN_LEFT, nb_mots_txt, NUMERIC, 70, 70);
				
				SDL_newObj(popup, NULL, 0, "Generer", ALIGN_CENTER, NULL , NONE, 150, 200);
				
				SDL_generate(popup);
				SDL_freeContext(popup);
				
				if (atoi(nb_mots_txt) >= 10 && atoi(nb_mots_txt) <= 40) {
					limite_mots = atoi(nb_mots_txt);
					generateGrille();
					ingame();
				}
				
				break;
			case 1:
				//Options
				popup = SDL_newContext("Mon compte", 200, 200, 500, 250);
				
				SDL_newImage(popup, NULL, "popup.png", 0, 0);
				SDL_newText(popup, NULL, "Voici le recapitulatif de votre session", colorWhite, 10, 40);
				SDL_newObj(popup, NULL, 1, "Pseudo", ALIGN_LEFT, pseudo, NONE, 70, 70);
				
				SDL_newText(popup, NULL, ratio, colorWhite, 80, 110);
				SDL_newObj(popup, NULL, 0, "Fermer", ALIGN_CENTER, NULL , NONE, 150, 200);
				
				SDL_generate(popup);
				SDL_freeContext(popup);
				
				SDL_writeParam(savegame, "username", pseudo);
				break;
			case 2:
				SDL_freeContext(menu);
				flushIndex();
				SDL_saveProfil(savegame);
				SDL_freeProfil(savegame);
				exit(0);
				break;
		}
		
	}
	
	SDL_saveProfil(savegame);
	SDL_freeProfil(savegame);
	SDL_freeContext(menu);
	flushIndex();
	
	return 0;
	
}