コード例 #1
0
ファイル: login.c プロジェクト: demonslab/CGI_Website_In_C
/*
 * The login page. 
 * If error evaluates to true, show the user that the login failed
 */
void loginPage(int error){
    //Start of the page
    printHeader();
    printNavbar();
    startBody();
    divClass("centered");
    printBanner();
    
    //begin sign in display
    printf("<h1>Please sign in below to view the temperature recordings.</h1>\n");
    divClass("frame"); divClass("inFrame");
    
    if (error) //If Login Failed
        printf("<font color=\"#990000\">There was an error, try again.</font>");
    
    printf("<form action=\"\" method=\"get\" onSubmit=\"window.location.reload()\">\n" );
    input("text", "user", "Username");
    br();
    input("password" ,"pass", "Password");
    br();br();

    printf ("<input type=\"submit\" value=\"Sign In!\" class=\"btn\">\n");
    button("./temp-cgi/login.cgi", "float-right", "Sign Up!");
    printf("</form>\n");
    
    //End login form and fill out the rest of the page
    endDiv(); endDiv();
    endDiv();
    endBody();
    printFooter();
}
コード例 #2
0
ファイル: gerbergenerator.cpp プロジェクト: LibrePCB/LibrePCB
void GerberGenerator::generate() {
  mOutput.clear();
  printHeader();
  printApertureList();
  printContent();
  printFooter();
}
コード例 #3
0
ファイル: login.c プロジェクト: demonslab/CGI_Website_In_C
/*
 * The temperature page, takes a linked list of structs as input
 * Should be generated from the JSON
 */
void tempPage(struct tempList *temps){    //take temp list as parameter
    //Set up the html file for the table
    printHeader();
    printNavbar();
    printAccountNav();
    startBody();
    divClass("centered");
    divClass("content");
    
    //start table
    printf("<table><caption>");
    printf("Recorded temperature measurements for the past 24 hours.");
    printf("</caption>\n");
    
    //Insert the header row of the table
    printf("<tr>\n");
    printf("<th scope=\"col\">Time Recorded</th>\n");
    printf("<th scope=\"col\">Temperature Recorded</th>\n");
    printf("</tr>\n");
    
    //Fill the rows of the table with the temperature val
    while (temps!=NULL){
        tableRow(temps->tempTime, temps->tempVal);
        temps = temps -> next;
    }
    
    //close the table and the rest of the page
    printf("</table>\n");
    endDiv();
    endDiv();
    endBody();
    printFooter();
}
コード例 #4
0
ファイル: utils.c プロジェクト: FloThinksPi/Autobahn.C
int isValidAutobahnName(char *Name){// Ist der Autobahnname Erlaubt(von den zeichen her)

    char* buffer= malloc(sizeof(char)*1000);

    if(isdigit(Name[0])){
        puts(" ");
        sprintf(buffer,"  Fehler , Der Autobahn Name muss mit einem Buchstaben beginnen");
        printMenuHeader(buffer);

        free(buffer);
        return 1;
    }

    for(int i=0;i< CountUTF8String(Name);i++){

        if(isalnum((int)Name[i])==0 && Name[i]!='_' && Name[i]!='.'){

            sprintf(buffer,"  Fehler , Der Autobahn Name enthält '%c' , ein Verbotenes Zeichen",Name[i]);
            printMenuHeader(buffer);
            printMenuItem("Erlaubte zeichen [A-Z] [a-z] [0-9] '_' '.' ");
            printFooter();

            free(buffer);
            return 1;
        }

    }

    free(buffer);
    return 0;
}
コード例 #5
0
ファイル: logread.c プロジェクト: KevinCooper/buildit
void whyIsTheHTMLFormatDifferent_S(logread_args* args) {
	Node* temp_E = peopleHead;
	Node* temp_G = peopleHead;
	columns(temp_E, temp_G);
	uint32_t currRoom;
	printSetup_S_2();
	uint32_t isFirst;
	for (currRoom = 0; currRoom <= highestRoomNum; currRoom++) {
		isFirst = 1;
		Node* temp = peopleHead;
		while (temp) {
			person* tempP = (person *) (temp->data);
			if (tempP->roomID == currRoom) {
				if (isFirst)
					printf("<tr>\n\t<td>%d</td>\n\t<td>", currRoom);
				if (!isFirst)
					printf(",");
				isFirst = 0;
				printf("%s", tempP->name);

			}
			temp = temp->next;
		}
		if (!isFirst)
			printf("</td>\n</tr>\n");
	}

	printFooter();

}
コード例 #6
0
void writeParamsToStr(char* tgt)
{
	printTitleLine(tgt,"optic flow frontend");
	showParamLinef(tgt,active_param,'a',"Smoothness weight alpha",&alpha);
	showParamLinef(tgt,active_param,'E',"Diffusivity param Data",&epsilon_d);
	showParamLinei(tgt,active_param,'i',"Number inner iterations",&num_iterations_inner);
	showParamLinei(tgt,active_param,'I',"Number outer iterations",&num_iterations_outer);
	showParamLineStr(tgt,active_param,'d',"Diffusivity type Data",diffusivity_names[diffusivity_type_d]);
	showParamLinef(tgt,active_param,'O',"Overrelaxation omega",&omega);
	showParamLinef(tgt,active_param,'e',"Warping eta",&warp_eta);
	showParamLinei(tgt,active_param,'m',"Maximum number warping levels",&max_warp_levels);
	showParamLinef(tgt,active_param,'l',"Maximal length displacement",&max_displacement);
	printFooter(tgt);
	showParamLinef(tgt,active_param,' ',"Average Angular  Error",&aae);
	showParamLinef(tgt,active_param,' ',"Average Endpoint Error",&al2e);
	printFooter(tgt);
}
コード例 #7
0
ファイル: scs.c プロジェクト: tkelman/scs
idxint scs_solve(Work * w, Data * d, Cone * k, Sol * sol, Info * info) {
	idxint i;
	timer solveTimer;
	struct residuals r;
	if (!d || !k || !sol || !info || !w || !d->b || !d->c) {
		scs_printf("ERROR: NULL input\n");
		return FAILURE;
	}
	tic(&solveTimer);
	info->statusVal = 0; /* not yet converged */
	updateWork(d, w, sol);
	if (d->VERBOSE)
		printHeader(d, w, k);
	/* scs: */
	for (i = 0; i < d->MAX_ITERS; ++i) {
		memcpy(w->u_prev, w->u, (d->n + d->m + 1) * sizeof(pfloat));

		if (projectLinSys(d, w, i) < 0) return failureDefaultReturn(d, w, sol, info, "error in projectLinSys");
		if (projectCones(d, w, k, i) < 0) return failureDefaultReturn(d, w, sol, info, "error in projectCones");
		updateDualVars(d, w);

		if ((info->statusVal = converged(d, w, &r, i)) != 0)
			break;

		if (i % PRINT_INTERVAL == 0) {
			if (d->VERBOSE) {
				printSummary(i, &r, &solveTimer);
#ifdef EXTRAVERBOSE
				 scs_printf("Norm u = %4f, ", calcNorm(w->u, d->n + d->m + 1));
				 scs_printf("Norm u_t = %4f, ", calcNorm(w->u_t, d->n + d->m + 1));
				 scs_printf("Norm v = %4f, ", calcNorm(w->v, d->n + d->m + 1));
				 scs_printf("tau = %4f, ", w->u[d->n + d->m]);
				 scs_printf("kappa = %4f, ", w->v[d->n + d->m]);
				 scs_printf("|u - u_prev| = %4f, ", calcNormDiff(w->u, w->u_prev, d->n + d->m + 1));
				 scs_printf("|u - u_t| = %4f\n", calcNormDiff(w->u, w->u_t, d->n + d->m + 1));
#endif
			}
		}
	}
	if (d->VERBOSE) {
		printSummary(i, &r, &solveTimer);
	}
	setSolution(d, w, sol, info);
	/* populate info */
	info->iter = i;
	getInfo(d, w, sol, info);
	info->solveTime = tocq(&solveTimer);

	if (d->VERBOSE)
		printFooter(d, w, info);
	/* un-normalize sol, b, c but not A */
	if (d->NORMALIZE)
		unNormalizeSolBC(d, w, sol);
	return info->statusVal;
}
コード例 #8
0
ファイル: assembler.c プロジェクト: leandromgr/compiler
void avengersAssemble(AST_NODE* astTree, TAC* tacList)
{
    DEST_ASM = fopen("assembly.s", "w");
    printHeaders();
    parseGlobalVariables(astTree);
    parseStrings();
    fprintf(DEST_ASM, "\t.text\n");
    parseTAC(tacList);
    printFooter();
    fclose(DEST_ASM);
}
コード例 #9
0
ファイル: CReport.cpp プロジェクト: jonasfoe/COPASI
void CReport::finish()
{
  mState = FooterFooter;

  printFooter();

  pdelete(mpHeader);
  pdelete(mpBody);
  pdelete(mpFooter);

  mState = Invalid;
}
コード例 #10
0
ファイル: PrintTreeWidget.cpp プロジェクト: gottafixthat/tacc
/**
 * print()
 *
 * Initiates the actual printing of the list.
 */
void PrintTreeWidget::print()
{
    QPrinter        prn(QPrinter::PrinterResolution);
    QPainter        *p;
    QBrush          bbrush;
    
    int         pageNo = 1;
    int         totPages = 1;
    int         totLines = 0;
    
    prn.setPageSize(QPrinter::Letter);
    prn.setDocName("List Print");
    prn.setCreator("Total Accountability");
    
    // Initialize the printer device.
    if (!prn.setup()) return;
    // prn.setOutputFileName("/tmp/Report.ps");
    // prn.setOutputToFile(TRUE);
    QApplication::setOverrideCursor(Qt::waitCursor);
    
    p = new QPainter();
    p->begin(&prn);
    
    // Count the children.
    totLines = myTree->topLevelItemCount();
    for (int i = 0; i < myTree->topLevelItemCount(); ++i) {
        totLines += countChildren(myTree->topLevelItem(i));
    }
    totPages = (totLines / 50) + 1;
    // fprintf(stderr, "The total number of pages is: %d\n", totPages);

    // Print the report...
    // FIXME:  This should print children as well, but it doesn't.
    for (pageNo = 1; pageNo < totPages + 1; pageNo++) {
        int sItem = ((pageNo -1) * 50);
        int eItem = sItem + 50;
        if (eItem > myTree->topLevelItemCount()) eItem = myTree->topLevelItemCount();
        printHeader(p);
        printRows(p, sItem, eItem);
        printFooter(p, pageNo, totPages);
        if (pageNo < totPages) prn.newPage();
        //progress.setProgress(pageNo);
        //if (progress.wasCancelled()) pageNo = totPages + 1;
    }
    //progress.setProgress(totPages);
    
    // We're all done.  Close the printer device.
    p->end();
    delete(p);
    QApplication::restoreOverrideCursor();
}
コード例 #11
0
int main(void)
{
	/* Load the numbers to be stored in the array to a data linked list */
	unsigned int noToStore;
	dataListElement *unsortedList;
	noToStore = datlCreateFromFile(DATA_FILENAME, &unsortedList);

	/* Allocate an array big enough to store all the items */
	array mainArray;
	mainArray = aryCreate(noToStore);

	/* Copy the linked list input to the array */
	aryFromList(mainArray, unsortedList);

	/* We're now finished with the input linked list */
	datlFree(unsortedList);

	/* Sort the array with selection sort */
	runtimeStats storeStats;
	storeStats = arySelSort(mainArray, setNoReps(NO_REPS_FOR_SIZE_1, noToStore));
	
	/* Load the numbers to search into a linked list */
	unsigned int noToSearch;
	dataListElement *searchList;
	noToSearch = datlCreateFromFile(SEARCH_FILENAME, &searchList);

	/* Search for the items in the array using binary search */
	runtimeStats searchStats;
	debugList searchMessages = {NULL,NULL};
	searchStats = aryBinSearchList(mainArray, searchList, &searchMessages);

	/* We're now finished with the search list and array */
	datlFree(searchList);
	aryFree(&mainArray);

	/* Print the reults */
	printHeader(stdout, "Binary Search", DATA_FILENAME, SEARCH_FILENAME, storeStats.processed, searchStats.attempted, searchStats.processed);
	printAryBody(stdout, storeStats.comparisons, storeStats.swaps, searchMessages);
	deblFree(&searchMessages);
	printFooter(stdout, storeStats.duration, searchStats.duration);


	/* Append the stats to a text file */
	#ifdef OUTPUT_TO_FILE
	printAddToFile(OUTPUT_FILENAME, storeStats.processed, searchStats.attempted, searchStats.processed, storeStats.duration, searchStats.duration);
	#endif

	return(EXIT_SUCCESS);
}
コード例 #12
0
void getHumidity() {

    float hum = dht.readHumidity();

    if (isnan(hum)) {
        Serial.println("Failed to read from DHT");
    } else {

        dtostrf(hum,8, 2, humBuffer);

        printHeader();
        printChaveValorJson("HUMIDADE", humBuffer);
        printFooter();
    }
}
コード例 #13
0
void getTemperature() {

    float temp = dht.readTemperature();

    if (isnan(temp)) {
        Serial.println("Failed to read from DHT");
    } else {

        dtostrf(temp,8, 2, tempBuffer);

        printHeader();
        printChaveValorJson("TEMPERATURA (CELSaIUS)", tempBuffer);
        printFooter();
    }
}
コード例 #14
0
ファイル: utils.c プロジェクト: FloThinksPi/Autobahn.C
int isValidAutobahnKM(char *KM){// Ist AutobahnKM eine Gueltige zahl(z.b. 9stellen 2nachkommastellen)

    char* buffer= malloc(sizeof(char)*1000);
    double f = atof(KM);
    sprintf(buffer, "%.2f", f);

    while (buffer[strlen(buffer) - 1] == '0' || buffer[strlen(buffer) - 1] == '.') {//Loescht zuviele 0-en
        if (buffer[strlen(buffer) - 1] == '.') {
            chop(buffer);
            break;
        } else {
            chop(buffer);
        }
    }

    if (strcmp(buffer, KM) == 0) {//Sind Buchstaben drin oder weicht die zahl ab von Atof

        if (f >= 1000000000 || f <= -1000000000) {//Maximal und minimal Groese
            puts("");
            printMenuHeader("Fehler , AutobahnKM dürfen maximal 9 stellig mit 2 Nachkommastellen sein");
            printFooter();
            free(buffer);
            return 1;
        }

    } else {
        puts("");
        printMenuHeader("Fehler , AutobahnKM ist keine Gültige Zahl [Kommazeichen ist ein Punkt z.b 12.32]");
        printFooter();
        free(buffer);
        return 1;
    }

    free(buffer);
    return 0;
}
コード例 #15
0
ファイル: CReport.cpp プロジェクト: jonasfoe/COPASI
void CReport::output(const Activity & activity)
{
  switch (activity)
    {
      case COutputInterface::BEFORE:
        printHeader();
        break;

      case COutputInterface::DURING:
        printBody();
        break;

      case COutputInterface::AFTER:
        printFooter();
        break;
    }
}
コード例 #16
0
void getCronometragem() {

  Serial.println("pegando a cronometragem...");
  long result = (long) millis() - inicial;
  
  int days = elapsedDays(result);
  int hours = numberOfHours(result);
  int minutes = numberOfMinutes(result);
  int seconds = numberOfSeconds(result);

  // digital clock display of current time
  Serial.print(days,DEC);  
  printDigits(hours);  
  printDigits(minutes);
  printDigits(seconds);
  Serial.println();  
  
  printHeader();
  printChaveValorJson("TEMPO TOTAL", (String) result);
  printFooter();
  
}
コード例 #17
0
ファイル: Printer.cpp プロジェクト: evertlammerts/ipfixcol
bool Printer::print(TableManager &tm)
{
	/* if there is nothing to print, return */
	if (conf.getColumns().size() == 0) {
		return true;
	}

	this->tableManager = &tm;


	/* print table header */
	if (!conf.getQuiet()) {

		printHeader();
	}

	const Cursor *cursor;
	TableManagerCursor *tmc = tm.createCursor();
	if (tmc == NULL) {
		/* no tables, no rows */
		return true;
	}

	uint64_t numPrinted = 0;
	while (tmc->next()) {
		cursor = tmc->getCurrentCursor();
		printRow(cursor);
		numPrinted++;
	}

	delete(tmc);

	if (!conf.getQuiet()) {
		printFooter(numPrinted);
	}

	return true;
}
コード例 #18
0
ファイル: trans.cpp プロジェクト: zhoujun06/usc_cs570
void TransRecord::output()
{
    printHeader();
    printRecord();
    printFooter();
}
コード例 #19
0
ファイル: dine.c プロジェクト: lancewboettcher/CPE453
int main(int argc, char *argv[]) {
   int i;
   int id[NUM_PHILOSOPHERS];
   pthread_t childid[NUM_PHILOSOPHERS];

   /* Seed random with time since epoch */ 
   srandom(time(0));

   /* Set the number of eat-think cycles */    
   if (argc > 1) {
      /* Non Default Cycles */ 
      numCycles = atoi(argv[1]);

      if (numCycles == 0) {
         /* Error with atoi or 0 */ 
         numCycles = DEFAULT_CYCLES;
      }
   }
   else {
      /* No command line argument, use default */ 
      numCycles = DEFAULT_CYCLES;
   }

   printHeader();

   initLocks();

   for (i = 0; i < NUM_PHILOSOPHERS; i++) {
      /* Initialize philosopher IDs */ 
      id[i] = i;	 

      /* Initialize printing array */ 
      printForks[i] = FORK_DOWN;

      /* Initialize philosopher states, they all start hungry */ 
      state[i] = CHANGING;
   }

   /* Spawn the philosophers */ 
   for (i = 0; i < NUM_PHILOSOPHERS; i++) {
      int res;
      res = pthread_create(
      	            &childid[i], 
                     NULL, 
                     philosopher, 
                     (void *) (&id[i]));

      if (res == -1) {
      	fprintf(stderr, "Error spawning child %i: %s\n", 
               i, strerror(errno));
      	exit(-1);
      }                       
   }

   /* Wait for all the philosophers */ 
   for (i = 0; i < NUM_PHILOSOPHERS; i++) {
      if (pthread_join(childid[i], NULL) != 0) {
         fprintf(stderr, "P thread error joining child \n");
         exit(-1);
      }
   }

   destroyLocks();

   printFooter();

   return 0;
}
コード例 #20
0
ファイル: CollReport.cpp プロジェクト: gottafixthat/tacc
void CollReport::printReport(long CustID)
{
    QDate       theDate;
    QPrinter    prn(QPrinter::PrinterResolution);
    QPainter    p;
    QRect       rect;
    ADBTable    cust;
    ADBTable    cont;
    ADB         DB;
    QString     tmpSt;
    QDate       tmpDate1;
    char        tmpStr[1024];
    char        tStr[1024];
    int         yPos;
    int         pageNo = 1;
    float       Balance = 0.00;
    float       EndingBalance;
    CustomersDB CDB;
    AddressesDB addrDB;
    char        transFont[1024];
    strcpy(transFont, "b&h lucida");
    
    CDB.get(CustID);
    addrDB.get(REF_CUSTOMER, CustID, "Billing");
    
    theDate = QDate::currentDate();
    
    sprintf(tStr, "/tmp/collreport-%09ld.ps", CustID);
    // prn.setPrintProgram("ghostview");
    //prn.setPrinterName("PostScript");
    //prn.setOutputFileName(tStr);
    prn.setOutputToFile(false);
    prn.setPageSize(QPrinter::Letter);
    prn.setFullPage(true);
    prn.setDocName("Collections Report");
    prn.setCreator("Total Accountability");
    
    p.begin(&prn);
    
    EndingBalance = DB.sumFloat("select SUM(Amount) from AcctsRecv where CustomerID = %ld", CustID);
    
    // Put the Blarg header and contact information on the page.
    printHeader(&p, &CDB, &addrDB, EndingBalance);
    
    // Put the register header on the page.
    registerHeader(&p);
    
    // Now, get the register information from the database.
    DB.query("select TransDate, DueDate, LoginID, Memo, Amount from AcctsRecv where CustomerID = %ld order by TransDate, LoginID", CustID);
    
    yPos = 165;
    p.setFont(QFont(transFont, 8, QFont::Normal));
    QFontMetrics fm(p.fontMetrics());
    while (DB.getrow()) {
        //int Lines = (int) (strlen(DB.curRow["Memo"]) / 52) + 1;
        //int RowHeight = 15 * Lines;
        int Lines = (int) (fm.width(DB.curRow["Memo"]) / (descriptionX2 - descriptionX1 - 2)) + 1;
        int RowHeight = (fm.height()+2) * Lines;
        
        // Check to see if we have enough room on the page left for this
        // line.
        if (yPos+RowHeight >= 740) {
            printFooter(&p, pageNo++);
            prn.newPage();
            printHeader(&p, &CDB, &addrDB, EndingBalance);
            registerHeader(&p);
            yPos = 165;
            p.setFont(QFont(transFont, 8, QFont::Normal));
        } 
    
        // The transaction date.
        myDatetoQDate(DB.curRow["TransDate"], &tmpDate1);
        sprintf(tmpStr, "%02d/%02d/%02d", tmpDate1.month(), tmpDate1.day(), tmpDate1.year()%100);
        rect.setCoords(transDateX1, yPos, transDateX2, yPos + RowHeight-1);
        p.drawRect(rect);
        p.drawText(rect, Qt::AlignVCenter|Qt::AlignHCenter, tmpStr);
        
        // The Due Date
        myDatetoQDate(DB.curRow["DueDate"], &tmpDate1);
        sprintf(tmpStr, "%02d/%02d/%02d", tmpDate1.month(), tmpDate1.day(), tmpDate1.year()%100);
        rect.setCoords(dueDateX1, yPos, dueDateX2, yPos + RowHeight-1);
        p.drawRect(rect);
        p.drawText(rect, Qt::AlignVCenter|Qt::AlignHCenter, tmpStr);
        
        // The Login ID
        /*
        rect.setCoords(140, yPos, 199, yPos + RowHeight);
        p.drawRect(rect);
        p.drawText(rect, Qt::AlignVCenter|Qt::AlignHCenter, DB.curRow["LoginID"]);
        */
        
        // The description...
        //fprintf(stderr, "descriptionX1 = %d, descriptionX2 = %d\n", descriptionX1, descriptionX2);
        //fprintf(stderr, "description = '%s'\n", DB.curRow["Memo"]);
        rect.setCoords(descriptionX1, yPos, descriptionX2, yPos + RowHeight-1);
        p.drawRect(rect);
        rect.setCoords(descriptionX1+1, yPos, descriptionX2, yPos + RowHeight);
        p.drawText(rect, Qt::WordBreak|Qt::AlignLeft|Qt::AlignVCenter, DB.curRow["Memo"]);
        
        // The amount.
        rect.setCoords(amountX1, yPos, amountX2, yPos + RowHeight-1);
        p.drawRect(rect);
        p.drawText(rect, Qt::AlignRight|Qt::AlignVCenter, DB.curRow["Amount"]);
        
        // The balance.
        Balance += atof(DB.curRow["Amount"]);
        sprintf(tStr, "%.2f", Balance);
        if (Balance == 0.0) strcpy(tStr, "0.00");
        rect.setCoords(balanceX1, yPos, balanceX2, yPos + RowHeight-1);
        p.drawRect(rect);
        p.drawText(rect, Qt::AlignRight|Qt::AlignVCenter, tStr);
        
        yPos += RowHeight;
    }

    // Put the footer on the page.
    printFooter(&p, pageNo);
    
    // prn.newPage();
    
    // p.drawText(300, 600, "Page 2");
    
    p.end();
}
コード例 #21
0
int main(int argc, char *argv[])
{
    double resU, resP, resT, continuityEr;
    #include "setRootCase.H"
    #include "createTime.H"

    regionProperties rp(runTime);

    #include "createFluidMeshes.H"
    #include "createSolidMeshes.H"

    #include "createFluidFields.H"
    #include "createSolidFields.H"

    #include "initContinuityErrs.H"

    #include "readTimeControls.H"
    #include "readSolidTimeControls.H"


    #include "compressibleMultiRegionCourantNo.H"
    #include "solidRegionDiffusionNo.H"
    #include "setInitialMultiRegionDeltaT.H"


    while (runTime.run())
    {
        #include "readTimeControls.H"
        #include "readSolidTimeControls.H"
        #include "readSIMPLEControls.H"
        #include "initConvergenceCheck.H"


        #include "compressibleMultiRegionCourantNo.H"
        #include "solidRegionDiffusionNo.H"
        //#include "setMultiRegionDeltaT.H"
        cout.precision(5);
        runTime++;
        lduMatrix::debug = debugLevel;
        Info.level = debugLevel;
        if(Pstream::master())
            printHeader(resPrint, runTime.value(), runTime.deltaT().value());
        Info<< "Time = " << runTime.timeName() << nl << endl;
        forAll(fluidRegions, i){
                #include "setRegionFluidFields.H"
                p.storePrevIter();
                rho.storePrevIter();
            }
        for(int solidCorrections=0; solidCorrections<nSolidCorrections; solidCorrections++){
            forAll(fluidRegions, i){
                #include "setRegionFluidFields.H"
                #include "solveFluid.H"
                #include "convergenceCheck.H"
            }
            forAll(solidRegions, i){
                #include "setRegionSolidFields.H"
                #include "readSolidMultiRegionPISOControls.H"
                #include "solveSolid.H"
            }
            if(Pstream::master())
                printResiduals(resPrint, solidCorrections, resP, resU, resT);
        }
        runTime.write();
        if(Pstream::master())
            printFooter(resPrint, runTime.elapsedCpuTime(),runTime.elapsedClockTime(),continuityEr);
        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }
コード例 #22
0
ファイル: ucm2cp.c プロジェクト: BrzVlad/mono
int main(int argc, char *argv[])
{
	char *progname = argv[0];
	FILE *file;
	int len;

	/* Process the command-line options */
	while(argc > 1 && argv[1][0] == '-')
	{
		if(!strcmp(argv[1], "--page") && argc > 2)
		{
			codePage = atoi(argv[2]);
			++argv;
			--argc;
		}
		else if(!strcmp(argv[1], "--wpage") && argc > 2)
		{
			windowsCodePage = atoi(argv[2]);
			++argv;
			--argc;
		}
		else if(!strcmp(argv[1], "--region") && argc > 2)
		{
			region = argv[2];
			++argv;
			--argc;
		}
		else if(!strcmp(argv[1], "--name") && argc > 2)
		{
			name = argv[2];
			++argv;
			--argc;
		}
		else if(!strcmp(argv[1], "--webname") && argc > 2)
		{
			webName = argv[2];
			++argv;
			--argc;
		}
		else if(!strcmp(argv[1], "--headername") && argc > 2)
		{
			headerName = argv[2];
			++argv;
			--argc;
		}
		else if(!strcmp(argv[1], "--bodyname") && argc > 2)
		{
			bodyName = argv[2];
			++argv;
			--argc;
		}
		else if(!strcmp(argv[1], "--no-browser-display"))
		{
			isBrowserDisplay = 0;
		}
		else if(!strcmp(argv[1], "--no-browser-save"))
		{
			isBrowserSave = 0;
		}
		else if(!strcmp(argv[1], "--no-mailnews-display"))
		{
			isMailNewsDisplay = 0;
		}
		else if(!strcmp(argv[1], "--no-mailnews-save"))
		{
			isMailNewsSave = 0;
		}
		++argv;
		--argc;
	}

	/* Make sure that we have sufficient options */
	if(!region || !codePage || !name || !webName || argc != 2)
	{
		usage(progname);
		return 1;
	}

	/* Set defaults for unspecified options */
	if(!headerName)
	{
		headerName = webName;
	}
	if(!bodyName)
	{
		bodyName = webName;
	}
	if(!windowsCodePage)
	{
		windowsCodePage = codePage;
	}

	/* Open the UCM or TXT file */
	file = fopen(argv[1], "r");
	if(!file)
	{
		perror(argv[1]);
		return 1;
	}
	filename = argv[1];
	len = strlen(filename);
	while(len > 0 && filename[len - 1] != '/' && filename[len - 1] != '\\')
	{
		--len;
	}
	filename += len;

	/* Load the character maps from the input file */
	loadCharMaps(file);

	/* Print the output header */
	printHeader();

	/* Print the byte->char conversion table */
	printByteToChar();

	/* Output the char->byte conversion methods */
	printCharToByte();

	/* Print the output footer */
	printFooter();

	/* Clean up and exit */
	fclose(file);
	return 0;
}
コード例 #23
0
ファイル: main_old.c プロジェクト: M-ike/llvmwork
int main(int argc, char **argv) {
//void main() {

	FILE     *output; //keypoint output (text)
	Image    *sourceImage, *sourceImage2;
	Image    *doubledImage;
	Image    *currentImage;
	Octave   *octavesList;
	Octave   *temp, *current;
	KeyPoint *peaks;
	KeyPoint *counter, *prevPoint;
	KeyPoint *keypoints, *keyCounter;
	int      candidates = 0;
	double   scale;
	double   ***mags, ***directions;
	int      octaveCount;
	int      tempHeight, tempWidth, tempDepth;
	int      totalKeypoints = 0;
	double   imageSigma;
	char     fileName[32] = {'\0'};
	FILE     *candidateOutput;
	FILE     *trashOutput;
	FILE     *filteredOutput;
/*
	if(argc < 2) {
		printf("Usage: sift dat_file\n");
		return 0;
	}
*/
	/* read input */
	//sourceImage = readPGMFile(argv[1]);
	sourceImage = readDATFile("./image.dat");
	if(sourceImage == NULL) {
		printf("file was not read\n");
		return 1;
	}
	scale = START_SCALE;

	/* print constants used */
	printf("Constants:\n");
	printf("START_SIGMA=%f\n", START_SIGMA);
	printf("OCTAVE_LIMIT=%d\n", OCTAVE_LIMIT);
	printf("IMAGES_PER_OCTAVE=%d\n", IMAGES_PER_OCTAVE);
	printf("SKIP_OCTAVES=%d\n", SKIP_OCTAVES);
	printf("MIN_SIZE=%d\n", MIN_SIZE);
	printf("MAX_ADJ_STEPS=%d\n", MAX_ADJ_STEPS);
	printf("EDGE_RATIO=%f\n", EDGE_RATIO);
	printf("CONTRAST_THRESH=%f\n", CONTRAST_THRESH);
	printf("CAP=%f\n", CAP);

	/* double image to save data */
	doubledImage = doubleImage(sourceImage);
	if(doubledImage == NULL) {
		return 1;
	}
	scale /= 2.0;
	printf("\nImage doubled\n");

	/* preprocessing smoothing*/
	printf("Preprocessing smoothing\n");
	doubledImage = gaussianConvolution2DFast(doubledImage, 1.0);
//	doubledImage = gaussianConvolution2DFast(sourceImage, 1.0);

	/* build octaves of scalespace */
	printf("Octave pyramid construction\n");
	currentImage = doubledImage;
	octavesList = NULL;
	octaveCount = 0;
	while(octaveCount < OCTAVE_LIMIT && currentImage->width >= MIN_SIZE && currentImage->height >= MIN_SIZE) {
		if(currentImage == NULL) {
			printf("  ***Current image null. Exiting.\n");
			return 1;
		}

		/* create octave pointer wrapper */
		printf("  Octave for pic %d %d (%d)\n", currentImage->width, currentImage->height, octaveCount);
		temp = (Octave *) malloc(sizeof(Octave));
		if(temp == NULL) {
			printf("  ***Out of memory. Exiting.\n");
			return 1;
		}
		/* build scale space L(x,y,sigma) */
		printf("    Gaussian Scale Space\n");
		if(octaveCount == 0)
			imageSigma = 1.0; //blur of the first image is 1.0
		else
			imageSigma = START_SIGMA;
		temp->gaussianSpace = buildScaleSpaceOctave(currentImage, scale, imageSigma);

		/* build diff space D(x,y,sigma) */
		printf("    Diff Gaussian Space\n");
		temp->diffGaussianSpace = buildDifferences(temp->gaussianSpace);

		/* store and go on */
		octavesList = link(octavesList, temp);
		currentImage = halveImage(getLastImage(temp->gaussianSpace));
		scale *= 2.0;
		++octaveCount;
		printf("    Image halved\n");
	}
	--octaveCount; /* one extra */

	/* generate keypoints from each octave of scalespace */
	printf("Keypoint generation\n");
	candidateOutput = fopen("output_candidates.txt", "w"); //helpful output file
	trashOutput = fopen("output_trash.txt", "w"); //helpful output file
	filteredOutput = fopen("output_filtered.txt", "w"); //helpful output file
	
	histOutput = fopen("output_histogram.txt", "w"); //outputs histograms
	histOutput2 = fopen("output_histogram2.txt", "w"); //turn on/off in scalespace.c
	
	keypoints = NULL;
	sourceImage2 = cloneImage(sourceImage);
	for(current = octavesList; current != NULL && octaveCount >= SKIP_OCTAVES; current = current->next, --octaveCount) {
		printf("  Octave %d\n", octaveCount);
		fprintf(histOutput, "Octave %d\n", octaveCount);
		fprintf(histOutput, "---------\n");
		fprintf(histOutput2, "Octave %d\n", octaveCount);
		fprintf(histOutput2, "---------\n");

		/* find keypoint candidates */
		printf("    Looking for peaks\n");
		peaks = getPeaks(current);
		/* temporary output */
		scale = current->diffGaussianSpace->imageScale;
		printPoints(candidateOutput, peaks, scale, octaveCount);
		markImageSPoint(peaks, sourceImage2, scale); //output candidates
		if(peaks != NULL)
			printf("      found %d candidates\n", peaks->count);
		else
			printf("      found 0 candidates\n");

		/* filter peaks for contrast and edge-iness and localize them */
		printf("    Filtering and localizing\n");
		trash = NULL;
		peaks = filterAndLocalizePeaks(current->diffGaussianSpace, current->gaussianSpace, peaks);

		/* temporary output */
		printPoints(filteredOutput, peaks, scale, octaveCount);
		printTrashed(trashOutput, trash, scale, octaveCount);
		if(peaks != NULL)
			printf("      have %d candidates remaining\n", peaks->count);
		else
			printf("      have 0 candidates remaining\n");

		/* precompute magnitudes and orientations */
		printf("    Generating magnitudes and orientations\n");
		tempHeight = current->gaussianSpace->imgHeight;
		tempWidth = current->gaussianSpace->imgWidth;
		tempDepth = current->gaussianSpace->imageCount - 2;
		current->gaussianSpace->magnitudes = allocate3D(tempHeight, tempWidth, tempDepth);
		current->gaussianSpace->directions = allocate3D(tempHeight, tempWidth, tempDepth);
		getMagnitudesAndOrientations(current->gaussianSpace);

		/* assign orientation(s) */
		printf("    Assigning orientation(s)\n");
		generateKeypoints(current->gaussianSpace, peaks);

		/* generate descriptors*/
		printf("    Calculating descriptors\n");
		createDescriptors(current->gaussianSpace, peaks);

		/* multiply by imgScale to get real values */
		for(counter = peaks; counter != NULL; counter = counter->next) {
			counter->finalX *= counter->imgScale;
			counter->finalY *= counter->imgScale;
			//also multiply x,y?
			counter->scale *= counter->imgScale;
		}

		/* merge lists */
		if(peaks != NULL) {
			if(keypoints != NULL) {
				keypoints->listRear->next = peaks;
				keypoints->listRear = peaks->listRear;
			}
			else
				keypoints = peaks;
		}

		/* deallocate memory */
		deallocate3D(current->gaussianSpace->magnitudes, tempHeight, tempWidth);
		deallocate3D(current->gaussianSpace->directions, tempHeight, tempWidth);

		/* deallocate trashed points */
		counter = trash;
		prevPoint = NULL;
		while(counter != NULL) {
			prevPoint = counter;
			counter = counter->next;
			free(prevPoint);
		}
	}

	fclose(histOutput);
	fclose(histOutput2);

	/* write footer to each file */
	printFooter(candidateOutput);
	fclose(candidateOutput);
	printFooter(trashOutput);
	fclose(trashOutput);
	printFooter(filteredOutput);
	fclose(filteredOutput);

	/* output keypoint descriptors */
	printf("Output\n");
	output = fopen("output.txt", "w");
	for(keyCounter = keypoints; keyCounter != NULL; keyCounter=keyCounter->next) {
		++totalKeypoints;
	}
	fprintf(output, "%d %d\n", totalKeypoints, 128);
	for(keyCounter = keypoints; keyCounter != NULL; keyCounter=keyCounter->next) {
		printKeyPoint(keyCounter, output);
	}
	fclose(output);

	/* output keypoints on image*/
	markImage(keypoints, sourceImage);
	writeDATFile(sourceImage, "./output/keypoints.dat");

	/* output initial candidates on image */
	writeDATFile(sourceImage2, "./output/keypoints_all.dat");
	printf("Done. %d keypoints found.\n", totalKeypoints);

	free(sourceImage);
	free(sourceImage2);
	free(doubledImage);
	//free octaves - should put it here
	return 0;
}
コード例 #24
0
ファイル: cs2123p4.c プロジェクト: gopoomemsl/Portfolio
/**************************** runSimulation ************************************
void runSimulation(Simulation sim, int iTimeLimit)
Purpose:
	Goes through a list of events in a Simulation and run them as they are 
	encountered.
Parameters:
	I	Simulation sim		The simulation variable containing the list of 
							events.
	I	int iTimeLimit		A time limit upon which the simulation will terminate 
							if it is reached before all of the events are ran.
Returns:
Notes:
*******************************************************************************/
void runSimulation(Simulation sim, int iTimeLimit)
{	
	//Variables
	Event event;
	Server server1, server2;
	Queue queue1, queue2;
	
	//create servers and queues
	server1 = newServer("Server 1");
	queue1 = newQueue("Queue 1");
	if (sim->cRunType == 'A')
	{
		server2 = newServer("Server 2");
		queue2 = newQueue("Queue 2");	
	}

	//begin simulation
	printHeader(sim);
	while (removeLL(sim->eventList, &event)) 
	{	
		if (event.iTime > iTimeLimit)
		{
			printFooter(sim, queue1, queue2);	
			freeServersAndQueues(sim, server1, server2, queue1, queue2);	
			ErrExit(ERR_BAD_INPUT, "Event time (%d) is out of simulation bounds (%d)\n", 
					event.iTime, iTimeLimit);
		}

		sim->iClock = event.iTime;
		switch (event.iEventType)
		{
			case EVT_ARRIVAL:
				arrival(sim, &event.widget);
				queueUp(sim, &event.widget, queue1);
				seize(sim, queue1, server1);
				break;

			case EVT_SERVER1_COMPLETE:
				release(sim, queue1, server1);
				if (sim->cRunType == 'A') //Alternative A follows up with server 2
				{
					queueUp(sim, &event.widget, queue2);
					seize(sim, queue2, server2);
				}
				else //Alternative B and Current leave after server 1
				{
					leaveSystem(sim, &event.widget);
				}
				break;

			case EVT_SERVER2_COMPLETE:
				release(sim, queue2, server2);
				leaveSystem(sim, &event.widget);
				break;
		
			default:
				ErrExit(ERR_ALGORITHM, "Unknown event type: %d\n", event.iEventType);
		}
	}
	
	printFooter(sim, queue1, queue2);	
	freeServersAndQueues(sim, server1, server2, queue1, queue2);	
}
コード例 #25
0
ファイル: logread.c プロジェクト: KevinCooper/buildit
void doBadThings(logread_args* args) {
	sortLinkedList_Names(peopleHead);
	int32_t currRoom;
	uint32_t isFirst = 1;
	if (args->currentState) {
		if (args->inHTML) {
			whyIsTheHTMLFormatDifferent_S(args);
			return;
		}
		Node* temp = peopleHead;
		while (temp) {
			person* tempP = (person *) (temp->data);
			if (tempP->isEmployee && tempP->inBuilding) {
				if (!isFirst)
					printf(",");
				isFirst = 0;
				printf("%s", tempP->name);
			}
			temp = temp->next;

		}
		isFirst = 1;
		temp = peopleHead;
		printf("\n");
		while (temp) {
			person* tempP = (person *) (temp->data);
			if (!tempP->isEmployee && tempP->inBuilding) {
				if (!isFirst)
					printf(",");
				isFirst = 0;
				printf("%s", tempP->name);
			}
			temp = temp->next;
		}
		printf("\n");
		for (currRoom = 0; currRoom <= highestRoomNum; currRoom++) {
			isFirst = 1;
			Node* temp = peopleHead;
			while (temp) {
				person* tempP = (person *) (temp->data);
				if (tempP->roomID == currRoom && tempP->inBuilding) {
					if (isFirst)
						printf("%d: ", currRoom);
					if (!isFirst)
						printf(",");
					isFirst = 0;
					printf("%s", tempP->name);

				}
				temp = temp->next;
			}
			if (!isFirst)
				printf("\n");
		}

	} else if (args->listAllRooms_R) {
		person* blahzz;
		if (args->employeeName != NULL) {
			blahzz = ht_get(allMahHashes_employees, args->employeeName);
		} else {
			blahzz = ht_get(allMahHashes_guests, args->guestName);
		}
		Node* temp = blahzz == NULL ? NULL : blahzz->rooms;
		if (temp)
			reverse(&temp);
		uint32_t isFirst = 1;
		if (args->inHTML)
			printHeader();
		while (temp) {
			int32_t* num = (int32_t*) (temp->data);
			if (args->inHTML) {
				if (isFirst)
					init_R();
				print_R_element(num);
			} else {
				if (!isFirst)
					printf(",");

				printf("%d", *num);
			}
			isFirst = 0;
			temp = temp->next;
		}
		if (args->inHTML)
			printFooter();
	} else if (args->totalTime) {

		if (args->inHTML)
			invalid_check(args);
		person* blahzz;
		if (args->employeeName != NULL) {
			blahzz = ht_get(allMahHashes_employees, args->employeeName);
		} else {
			blahzz = ht_get(allMahHashes_guests, args->guestName);
		}

		int32_t timespent;
		if (blahzz != NULL && blahzz->leaveTime == -1) {
			timespent = lastTime - blahzz->enterTime;
		} else {
			timespent = blahzz->leaveTime - blahzz->enterTime;
		}
		if (blahzz != NULL)
			printf("%d", timespent);

	} else if (args->listEmployeesWithTime
			&& args->bounds->upper > args->bounds->lower) {
		Node* temp = peopleHead;
		if (args->inHTML) {
			printHeader();
			printf("<tr>\n<th>Employees</th>\n</tr>\n");
		}
		while (temp) {
			person* tempP = (person *) (temp->data);
			if (tempP->isEmployee
					&& (tempP->enterTime <= args->bounds->upper
							&& (tempP->leaveTime >= args->bounds->lower
									|| tempP->leaveTime == -1))) {
				if (!isFirst && !args->inHTML) {
					printf(",");
				}

				isFirst = 0;
				if (!args->inHTML) {
					printf("%s", tempP->name);
				} else {
					print_AB_element(tempP->name);
				}

			}
			temp = temp->next;

		}
		if (args->inHTML)
			printFooter();
	} else if (args->listEmployeesWithoutTime
			&& args->bounds->upper > args->bounds->lower
			&& args->bounds->upper1 > args->bounds->lower1) {
		Node* temp = peopleHead;
		if (args->inHTML) {
			printHeader();
			printf("<tr>\n<th>Employees</th>\n</tr>\n");
		}
		while (temp) {
			person* tempP = (person *) (temp->data);
			if (tempP->isEmployee
					&& (tempP->enterTime <= args->bounds->upper
							&& (tempP->leaveTime >= args->bounds->lower
									|| tempP->leaveTime == -1))
					&& ((tempP->enterTime > args->bounds->upper1
							&& tempP->leaveTime > args->bounds->upper1)
							|| (tempP->leaveTime < args->bounds->lower1
									&& tempP->enterTime < args->bounds->lower1))) {
				if (!isFirst && !args->inHTML) {
					printf(",");
				}

				isFirst = 0;
				if (!args->inHTML) {
					printf("%s", tempP->name);
				} else {
					print_AB_element(tempP->name);
				}

			}
			temp = temp->next;

		}
		if (args->inHTML)
			printFooter();
	} else if (args->printSpecificRooms_I) {
		Node * temp = args->peoples_I;
		Node * roomList = NULL;
		Node * oldList = NULL;
		while (temp) {
			person * tempPerson = (person *) temp->data;
			person* currPerson =
					tempPerson->isEmployee ?
							ht_get(allMahHashes_employees, tempPerson->name) :
							ht_get(allMahHashes_guests, tempPerson->name);

			if (currPerson) {
				if (isFirst) {
					roomList = currPerson->rooms;
					sortLinkedList_Nums(roomList);
				} else {
					oldList = roomList;
					roomList = NULL;
					while (oldList && currPerson->rooms) {
						int32_t * tempAA = oldList->data;
						int32_t * tempBB = currPerson->rooms->data;
						if (*tempAA == *tempBB) {
							int32_t * tempNum = calloc(1, sizeof(int32_t));
							*tempNum = *tempAA;
							stack_push(&roomList, tempNum);
							oldList = oldList->next;
							currPerson->rooms = currPerson->rooms->next;
						} else if (*tempAA < *tempBB) {
							oldList = oldList->next;
						} else {
							currPerson->rooms = currPerson->rooms->next;
						}
					}
				}
			}
			temp = temp->next;
		}
		isFirst = 1;
		if (args->inHTML) {
			printHeader();
			printf("<tr>\n<th>Rooms</th>\n</tr>\n");
		}
		while (roomList) {
			if (!isFirst && !args->inHTML)
				printf(",");
			int32_t * tempNum = roomList->data;
			if (!args->inHTML) {
				printf("%d", *tempNum);
			} else {
				print_I_element(tempNum);
			}

			isFirst = 0;
			roomList = roomList->next;
		}
		if (args->inHTML)
			printFooter();
	}
	fflush(stdout);

}