Пример #1
0
void calculate()
{
    GtkWidget *dialog = gtk_dialog_new();
    float mo=0, temp;
    int k = 0, j = 0;
    struct lesson less[LESSONS_PER_DIR];

    while ( j < LESSONS_PER_DIR) {
        if (gtk_widget_get_sensitive(lessons[j].entry) == TRUE) {
            less[k].title = lessons[j].title;
            less[k].DM = lessons[j].DM;
            less[k].checkbtn = lessons[j].checkbtn;
            less[k].entry = lessons[j].entry;
            k++;
        }
        j++;
    }

    if (i != LESSONS_TO_END) {
        dialog = gtk_message_dialog_new (GTK_WINDOW(main_window), 0,  GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Λάθος αριθμός μαθημάτων. Ελέγξτε ξανά το πλήθος των μαθημάτων επιλογής.");
        gtk_dialog_run(GTK_DIALOG(dialog));
    } else {
        if (checkTable(less) == 0) {
            for (k=0; k<i; k++) {
                temp = atof(gtk_entry_get_text(GTK_ENTRY(less[k].entry)));
                mo += (float) less[k].DM * temp / 230; /* sinolo didaktikwn monadwn : 230 */
            }
            dialog = gtk_message_dialog_new (GTK_WINDOW(main_window), 0,  GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Ο βαθμός του πτυχίου σου είναι %2.2f", mo);
            gtk_dialog_run(GTK_DIALOG(dialog));
        }
    }
    gtk_widget_destroy (dialog);
}
Пример #2
0
void parse_Factor() {
  printf("Enter Factor\n");
  if (nextToken == T_ID) { 
    /* 右辺値変数 or 関数呼び出しの判断をしなければならない */
    if (checkTable(yytext)) {  /* 関数名テーブルにあった場合の処理 */ 
      printf("Enter Func\n");
      nextToken = getToken();
      if (nextToken != T_LPAR) pl0parse_error("not (");
      else {
        nextToken = getToken();
        parse_FuncArgList();
        if (nextToken != T_RPAR) pl0parse_error("not )");
      }
    } else { /* 関数名テーブルになかったら変数/定数のはず */
    }
    nextToken = getToken();
  } else if (nextToken == T_NUMBER) { 
    /* ここで数字の処理 */
    nextToken = getToken();
  } else if (nextToken == T_LPAR) {
    nextToken = getToken();
    parse_Expression();
    if (nextToken != T_RPAR) pl0parse_error("not )");
    nextToken = getToken();
  } else {
    pl0parse_error("not factor");
  }
}
Пример #3
0
void checkDbTables(char *database, char *composite, struct hash *mdbHash, struct hash *allBbiNames)
// search the database for tables that begin with composite and call checkTable
{
struct sqlConnection *conn = sqlConnect(database);
char buffer[10 * 1024];

verbose(1, "----------------------------------------------\n");
verbose(1, "Checking that tables starting with composite in db are in metaDb\n (also checks dummy table and the bbi symlink and its target)\n");
verbose(1, "----------------------------------------------\n");
sqlSafef(buffer, sizeof buffer, "show tables like '%s%%'", composite);

struct sqlResult *sr;
sr = sqlGetResult(conn, buffer);
char **row;
struct slName *list = NULL;
while ((row = sqlNextRow(sr)) != NULL)
    {
    struct slName *el = slNameNew(row[0]);
    slAddHead(&list, el);
    }
sqlFreeResult(&sr);

for(; list; list = list->next)
    checkTable(conn, list->name, mdbHash, allBbiNames);
sqlDisconnect(&conn);
}
Пример #4
0
int
main(int argc, char *argv[])
{

    processArgs(argc, argv);

    cout << " NumIters " << NumIters << ","
         << " NumEntries " <<  NumEntries << endl;

    if (LockType == FallbackLock::MUTEX_LOCK) {
        GLock = new MutexFallbackLock(PmxLock);
		cout << "Allocated Pthread Mutex lock" << endl;
    } else if (LockType == FallbackLock::SPIN_LOCK) {
        GLock = new SpinFallbackLock(PspLock);
		cout << "Allocated Pthread Spin lock" << endl;
    } else if (LockType == FallbackLock::HLE_LOCK) {
        GLock = new HLELock();
		cout << "Allocated HLE Spin lock" << endl;
    } else if (LockType == FallbackLock::CUSTOM_LOCK) {
        GLock = new CustomSpinLock();
		cout << "Allocated Custom Spin lock" << endl;
    } else {
        cerr << "Error: invalid lock type specified, exiting..." << LockType;
    }

    SharedTable = new KaLib::HashTable<int>(
        NumEntries * NumThreads, GLock);
    for (int ec = NumThreads * NumEntries; ec > 0; --ec) {
        int v = rand();

       	SharedTable->insert(ec, v);
    }

    ThreadWorker_t worker = executeThreadLoopSimple;
	Timer coreTimer("Workers");

	coreTimer.Start();

    createWorkerThreads(NumThreads, worker);
    waitForThreads(NumThreads);

	coreTimer.Stop();

	Timer checker("VerifyHashTable");
	checker.Start();

    checkTable(*SharedTable, NumThreads, NumEntries);

	checker.Stop();

    delete SharedTable;

	coreTimer.PrintElapsedTime("RESULT: Filling up the hash table finished in ");

    checker.PrintElapsedTime("Verification of Hash table done in ");

    return 0;
}
Пример #5
0
/*Подтверждение коннекта*/
void confirmedConnect(void *buf, int serverID)
{
    int *clID = (int *)buf;
    int IDforName = getNameToID(*clID);
    int num = checkTable(*clID);
    inofList[num].countPlayer++;
    (inofList[num].countPlayer == 4) ? (inofList[num].status = FULL) : (inofList[num].status = SLEEP);
    strncpy(room.tables[num].players[inofList[num].countPlayer], IdName[IDforName].name, MAX_NAME_LENGTH);
}
Пример #6
0
int addTable(char *funcName) {
  /* 関数名が被らないか調べる */
  if (checkTable(funcName)) return -1; /* 関数名がかぶったら-1を返す */
  if (tableIndex == TABLEMAX) return -1; /* これ以上関数名テーブルに追加できない */

  /* 関数名をテーブルに追加 */
  strcpy(funcTable[tableIndex], funcName);
  tableIndex++;
  return 0;
}
Пример #7
0
/*Соединение к столу*/
void connectTable(void *buf)
{
    struct newPlayer_t newPlayer;
    struct selectRequest_t *request = (struct selectRequest_t *) buf;
    struct selectResponce_t responce;
    int check, id;
    /*Проверка id стола*/
    if ((check = checkTable(request->tableID)) == -1) {
        responce.status = STATUS_BAD;
        strcpy(responce.error, "Incorrectly table id");
        printf("[logic]User send incorrectly table id\n");
        send_message(CURRENT, 0, CONNECT_TO_TABLE, sizeof(struct selectResponce_t), &responce);
        return;
    }
    /*Проверка колличества игроков на столе*/
    if (checkFull(check) == -1) {
        responce.status = STATUS_BAD;
        strcpy(responce.error, "Table full");
        printf("[logic]User try connect to full table\n");
        send_message(CURRENT, 0, CONNECT_TO_TABLE, sizeof(struct selectResponce_t), &responce);
        return;
    }

    id = getIDtoName(request->name);
    /*Нет id*/
    if (id == -1) {
        responce.status = STATUS_BAD;
        strcpy(responce.error, "Incorrectly id");
        printf("[logic]User with incorrectly id\n");
        send_message(CURRENT, 0, CREATE_TABLE, sizeof(struct selectResponce_t), &responce);
        return;
    }
    ++countCurrentTables;
    int newSessison = getSession();
    newPlayer.session = newSessison;
    newPlayer.money = 1000;

    strncpy(newPlayer.name, request->name, MAX_NAME_LENGTH);
    responce.status = STATUS_OK;
    responce.session = newSessison;
    responce.port = inofList[check].port;

    send_message(GAME_SERVER, tableID, INTERNAL_NEW_PLAYER, sizeof(struct newPlayer_t), (void *) &newPlayer);
    send_message(CURRENT, 0, CONNECT_TO_TABLE, sizeof(struct selectResponce_t), (void *) &responce);
    close_current_client_connection();
    printf("[Logic]User connect o table\n");
}
void engineTimeVaryingUniformFixedValueFvPatchField<sphericalTensor>::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

    checkTable();

    operator==
    (
        interpolateXY
        (
//            this->db().time().value(),
            engineDB_.theta(),
            timeDataPtr_().x(),
            timeDataPtr_().y()
        )*sphericalTensor::I
    );

    fixedValueFvPatchField<sphericalTensor>::updateCoeffs();
}
void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

    checkTable();

    // Interpolate between the sampled data

    Type wantedAverage;

    if (endSampleTime_ == -1)
    {
        // only start value
        if (debug)
        {
            Pout<< "updateCoeffs : Sampled, non-interpolated values"
                << " from start time:"
                << sampleTimes_[startSampleTime_].name() << nl;
        }

        this->operator==(startSampledValues_);
        wantedAverage = startAverage_;
    }
    else
    {
        scalar start = sampleTimes_[startSampleTime_].value();
        scalar end = sampleTimes_[endSampleTime_].value();

        scalar s = (this->db().time().value()-start)/(end-start);

        if (debug)
        {
            Pout<< "updateCoeffs : Sampled, interpolated values"
                << " between start time:"
                << sampleTimes_[startSampleTime_].name()
                << " and end time:" << sampleTimes_[endSampleTime_].name()
                << " with weight:" << s << endl;
        }

        this->operator==((1-s)*startSampledValues_ + s*endSampledValues_);
        wantedAverage = (1-s)*startAverage_ + s*endAverage_;
    }

    // Enforce average. Either by scaling (if scaling factor > 0.5) or by
    // offsetting.
    if (setAverage_)
    {
        const Field<Type>& fld = *this;

        Type averagePsi = gAverage(fld);

        if (debug)
        {
            Pout<< "updateCoeffs :"
                << " actual average:" << averagePsi
                << " wanted average:" << wantedAverage
                << endl;
        }

        if (mag(averagePsi) < VSMALL)
        {
            // Field too small to scale. Offset instead.
            const Type offset = wantedAverage - averagePsi;
            if (debug)
            {
                Pout<< "updateCoeffs :"
                    << " offsetting with:" << offset << endl;
            }
            this->operator==(fld+offset);
        }
        else
        {
            const scalar scale = mag(wantedAverage)/mag(averagePsi);

            if (debug)
            {
                Pout<< "updateCoeffs :"
                    << " scaling with:" << scale << endl;
            }
            this->operator==(scale*fld);
        }
    }

    // apply offset to mapped values
    if (offset_.valid())
    {
        const scalar t = this->db().time().timeOutputValue();
        this->operator==(*this + offset_->value(t));
    }

    if (debug)
    {
        Pout<< "updateCoeffs : set fixedValue to min:" << gMin(*this)
            << " max:" << gMax(*this)
            << " avg:" << gAverage(*this) << endl;
    }

    fixedValuePointPatchField<Type>::updateCoeffs();
}
Пример #10
0
int playGame() //simulates 1 game
{
	int table[7][20];
	int deck[52];
	int founds[4][13];
	int i,j,h;
	int wastePos;
	int win;
	
	//clear table
	for(i=0;i<7;i++){ 
		for(j=0;j<20;j++){
			table[i][j]=0;
		}
	}
	//clear foundations
	for(i=0;i<4;i++){ 
		for(j=0;j<13;j++){
			founds[i][j]=0;
		}
	}
	shuffleDeck(deck);
	layTable(table,deck);
	if(DEBUG >= 10) 
	{
		printf("Table at start of game:\n");
		printTable(table);
	}

	//solve
	for(i=0;i<20;i++){
		checkTable(table,founds);
		checkTable(table,founds);
		for(wastePos=0; wastePos<52; wastePos++) //check waste cards
		{
			if(deck[wastePos]!=99) checkWaste(table,deck, wastePos, founds);
		}
		
		//check for win
		win=1;
		for(j=0;j<4;j++){
			if(founds[j][12] == 0) win = 0;
		}
		if(win)
		{
			if(DEBUG >= 10) printf("Win after %d cycles", i);
			return 1;
		}
	}
	
	//print results
	if(DEBUG >= 10)
	{
		printf("\nFoundations at finish:\n");
		printFounds(founds);
		printf("\nTable at finish:\n");
		printTable(table);
	}

	if(DEBUG >= 10)
	{
		printf("\nRemaining cards in waste:\n");
		for(i=0;i<52;i++)
		{
			if(deck[i]!=99)
			{
				printCard(deck[i]);
				printf("\n");
			}
			//printf("%d\n",deck[i]%13);
		}
	}
	return 0;
}
Пример #11
0
void decrypt(char* key, char* tableFileName, char* fileName)
{
	//Check whether the tablefile is valid.
	int isTableFileInvalid = checkTable(tableFileName);
	if(isTableFileInvalid==1){return;}

	//Check if inputfile is accessible
	FILE *file = fopen(fileName, "rb");
	if(strlen(fileName)!=0 && file==NULL)
	{
		fprintf(stderr, "Unable to open %s.\n", fileName);
		return;
	}
	if(strlen(fileName)==0)
		file = stdin;

	//Declare all tables required
	int IP[64];
	int E[48];
	int P[32];
	int S1[4][16], S2[4][16], S3[4][16], S4[4][16], S5[4][16], S6[4][16], S7[4][16], S8[4][16];
	int V[16];
	int PC1[56], PC2[48];

	//read from tablefile
	fetchTables(tableFileName, IP, E, P, S1, S2, S3, S4, S5, S6, S7, S8, V, PC1, PC2);

	//convert key from hexstring to binary
	unsigned long long keyBytes = 0;
	convertKeyToBinary(key, &keyBytes);

	//calculate IP^-1 (inverse permutation)
	int IP_inv[64];
	computeInversePerm(IP, IP_inv);

	//generate round keys
	unsigned long long roundKeys[16]; //16 rounds, 48-bit keys per round
	keySchedulerForDecrypt(keyBytes, roundKeys, PC1, PC2, V);

	unsigned char buffer[8];
	unsigned char cipherText[9];
	cipherText[8]='\0';
	int bytesRead = -1, i=0;
	unsigned long long msgStream = 0, cipherStream = 0;
	unsigned int L0 = 0, R0 = 0, L_in = 0, R_in = 0, L_out = 0, R_out = 0;
	int blockNumber = 0;

	while(bytesRead != 0)
	{
		blockNumber++;

		for(i=0; i<8; i++)
			buffer[i] = 0;

		bytesRead = fread(buffer, sizeof(char), 8, file);
		if(bytesRead == 0) break;

		//convert char array into stream of bytes
		msgStream = convertCharArrayToBinary(buffer);

		//INITIAL PERMUTATION
		applyIP(IP, msgStream, &L0, &R0);
		if(blockNumber == 1)
			fprintf(stderr, "(L0,R0)=%08x%08x\n", L0, R0);

		//16 ROUNDS OF FIESTEL CIPHER
		L_in = L0;
		R_in = R0;
		for(i=0; i<16; i++)
		{
			fiestelCipher(L_in, R_in, &L_out, &R_out, roundKeys[i], P, S1, S2, S3, S4, S5, S6, S7, S8, E);

			//print Li, Ri for 1st 8-byte block only.
			if(blockNumber == 1)
				fprintf(stderr, "(L%d,R%d)=%08x%08x\n", (i+1), (i+1), L_out, R_out);

			//Initialize L_in and R_in for next round.
			L_in = L_out;
			R_in = R_out;
		}

		//INVERSE PERMUTATION
		cipherStream = applyIPinv(IP_inv, L_out, R_out);

		//convert binary to 8-byte character array
		convertBinaryToCharArray(cipherStream, cipherText);

		//print ciphertext
		for(i=0; i<8; i++)
			printf("%c", cipherText[i]);
	}
}
Пример #12
0
int main(int argc, char *argv[])
{
	//skip argv[0]
	argc--;
	argv++;

	if(argc <= 0) //No arguments provided
	{
		fprintf(stderr, "Please enter command line arguments.\n");
		printUsage();
		return EXIT_FAILURE;
	}

	//tablecheck
	if(strcmp(*argv, "tablecheck") == 0)
	{
		if(argc-1 < 1 || argc-1 > 1)
		{
			fprintf(stderr, "Malformed command.\n");
			printUsage();
			return EXIT_FAILURE;
		}

		char* tablefile = malloc(100*sizeof(char));

		for(argc--; argc>0; argc--)
		{
			argv++;

			if(strlen(*argv) < 4)
			{
				fprintf(stderr, "Malformed command.\n");
				printUsage();
				return EXIT_FAILURE;
			}

			//tablefile
			if(argv[0][0]=='-' && argv[0][1]=='t' && argv[0][2]=='=')
			{
				//Get tablefile from argv
				int i=0;
				for(i=3; i<strlen(*argv); i++)
				{
					tablefile[i-3] = argv[0][i];
				}
				tablefile[i-3] = '\0';
			}

			else
			{
				fprintf(stderr, "Malformed command.\n");
				printUsage();
				return EXIT_FAILURE;
			}
		}

		checkTable(tablefile);
	}

	//modprod
	else if(strcmp(*argv, "modprod") == 0)
	{
		//Get hold of arguments
		char* poly1 = malloc(100*sizeof(char));
		char* poly2 = malloc(100*sizeof(char));

		//No, less or extra parameters for modprod
		if(argc-1 < 2 || argc-1 > 2)
		{
			fprintf(stderr, "Malformed command.\n");
			printUsage();
			return EXIT_FAILURE;
		}

		for(argc--; argc>0; argc--)
		{
			argv++;

			if(strlen(*argv) < 5)
			{
				fprintf(stderr, "Malformed command.\n");
				printUsage();
				return EXIT_FAILURE;
			}

			//poly1
			if(argv[0][0]=='-' && argv[0][1]=='p' && argv[0][2]=='1' && argv[0][3]=='=')
			{
				//Get poly1 from argv
				int i=0;
				for(i=4; i<strlen(*argv); i++)
				{
					poly1[i-4] = argv[0][i];
				}
				poly1[i-4] = '\0';
			}

			//poly2
			else if(argv[0][0]=='-' && argv[0][1]=='p' && argv[0][2]=='2' && argv[0][3]=='=')
			{
				//Get poly2 from argv
				int i=0;
				for(i=4; i<strlen(*argv); i++)
				{
					poly2[i-4] = argv[0][i];
				}
				poly2[i-4] = '\0';
			}

			else
			{
				fprintf(stderr, "Malformed command.\n");
				printUsage();
				return EXIT_FAILURE;
			}
		}

		if(strlen(poly1) == 0 || strlen(poly2) == 0)
		{
			fprintf(stderr, "Malformed command.\n");
			printUsage();
			return EXIT_FAILURE;
		}

		computeModprod(poly1, poly2);

		free(poly1);
		free(poly2);
	}

	//keyexpand
	else if(strcmp(*argv, "keyexpand") == 0)
	{
		//Get hold of arguments
		char* key = malloc(100*sizeof(char));
		char* tablefileName = malloc(100*sizeof(char));

		//No, less or extra parameters for keyexpand
		if(argc-1 < 2 || argc-1 > 2)
		{
			fprintf(stderr, "Malformed command.\n");
			printUsage();
			return EXIT_FAILURE;
		}

		for(argc--; argc>0; argc--)
		{
			argv++;

			if(strlen(*argv) < 4)
			{
				fprintf(stderr, "Malformed command.\n");
				printUsage();
				return EXIT_FAILURE;
			}

			//key
			if(argv[0][0]=='-' && argv[0][1]=='k' && argv[0][2]=='=')
			{
				//Get key from argv
				int i=0;
				for(i=3; i<strlen(*argv); i++)
				{
					key[i-3] = argv[0][i];
				}
				key[i-3] = '\0';
			}

			//tablefile
			else if(argv[0][0]=='-' && argv[0][1]=='t' && argv[0][2]=='=')
			{
				//Get tablefile from argv
				int i=0;
				for(i=3; i<strlen(*argv); i++)
				{
					tablefileName[i-3] = argv[0][i];
				}
				tablefileName[i-3] = '\0';
			}

			else
			{
				fprintf(stderr, "Malformed command.\n");
				printUsage();
				return EXIT_FAILURE;
			}
		}

		if(strlen(key) == 0 || strlen(tablefileName) == 0)
		{
			fprintf(stderr, "Malformed command.\n");
			printUsage();
			return EXIT_FAILURE;
		}

		expandKey(key, tablefileName);

		free(key);
		free(tablefileName);
	}

	//Encrypt - Decrypt
	else if(strcmp(*argv, "encrypt") == 0 || strcmp(*argv, "decrypt") == 0)
	{
		char command[10]="";
		if(strcmp(*argv, "encrypt") == 0)strcpy(command, "encrypt");
		if(strcmp(*argv, "decrypt") == 0)strcpy(command, "decrypt");

		//Get hold of arguments
		char* key = malloc(100*sizeof(char));
		char* tableFileName = malloc(100*sizeof(char));
		char* file = malloc(100*sizeof(char));
		*file='\0';

		//No, less or extra parameters
		if(argc-1 < 2 || argc-1 > 3)
		{
			fprintf(stderr, "Malformed command.\n");
			printUsage();
			return EXIT_FAILURE;
		}

		for(argc--; argc>0; argc--)
		{
			argv++;

			//Commanldine option encountered
			if(argv[0][0] == '-')
			{
				if(strlen(*argv) < 4)
				{
					fprintf(stderr, "Malformed command.\n");
					printUsage();
					return EXIT_FAILURE;
				}

				//key
				if(argv[0][0]=='-' && argv[0][1]=='k' && argv[0][2]=='=')
				{
					//Get key from argv
					int i=0;
					for(i=3; i<strlen(*argv); i++)
					{
						key[i-3] = argv[0][i];
					}
					key[i-3] = '\0';
				}
				else if(argv[0][0]=='-' && argv[0][1]=='t' && argv[0][2]=='=')
				{
					//Get tableFileName from argv
					int i=0;
					for(i=3; i<strlen(*argv); i++)
					{
						tableFileName[i-3] = argv[0][i];
					}
					tableFileName[i-3] = '\0';
				}
				else
				{
					fprintf(stderr, "Malformed command.\n");
					printUsage();
					return EXIT_FAILURE;
				}
			}

			//file
			else if(strlen(*argv) > 0)
			{
				//Get file from argv
				int i=0;
				for(i=0; i<strlen(*argv); i++)
				{
					file[i] = argv[0][i];
				}
				file[i] = '\0';
			}
		}

		//Check for errors
		if(strlen(key)==0 || strlen(tableFileName)==0)
		{
			fprintf(stderr, "Malformed command.\n");
			printUsage();
			return EXIT_FAILURE;
		}
		else
		{
			if(strcmp(command, "encrypt")==0 || strcmp(command, "decrypt")==0)
			{
				//CHECK FORMAT OF KEY

				/*if(strlen(key)!=16)
				{
					fprintf(stderr, "Key should be 8-bytes long, in hexstring format.\n");
					printUsage();
					return EXIT_FAILURE;
				}
				else if(strlen(key)==16)
				{
					int k=0;
					for(k=0; k<16; k++)
					{
						if(key[k] < 48 || (key[k] > 57 && key[k] < 97) || key[k] > 102)
						{
							fprintf(stderr, "Key is not in hexstring format.\n");
							printUsage();
							return EXIT_FAILURE;
						}
					}
				}*/
			}
		}

		if(strlen(key) == 0 || strlen(tableFileName) == 0)
		{
			fprintf(stderr, "Malformed command.\n");
			printUsage();
			return EXIT_FAILURE;
		}

		if(strcmp(command, "encrypt") == 0) performEncrypt(key, tableFileName, file);
		if(strcmp(command, "decrypt") == 0) performDecrypt(key, tableFileName, file);

		free(key);
		free(tableFileName);
		free(file);
	}

	//inverse
	else if(strcmp(*argv, "inverse") == 0)
	{
		if(argc-1 < 1 || argc-1 > 1)
		{
			fprintf(stderr, "Malformed command.\n");
			printUsage();
			return EXIT_FAILURE;
		}

		char* poly = malloc(100*sizeof(char));

		for(argc--; argc>0; argc--)
		{
			argv++;

			if(strlen(*argv) < 4)
			{
				fprintf(stderr, "Malformed command.\n");
				printUsage();
				return EXIT_FAILURE;
			}

			//poly
			if(argv[0][0]=='-' && argv[0][1]=='p' && argv[0][2]=='=')
			{
				//Get tablefile from argv
				int i=0;
				for(i=3; i<strlen(*argv); i++)
				{
					poly[i-3] = argv[0][i];
				}
				poly[i-3] = '\0';
			}
		}

		if(strlen(poly) == 0)
		{
			fprintf(stderr, "Malformed command.\n");
			printUsage();
			return EXIT_FAILURE;
		}

		computeInverse(poly);
	}

	else
	{
		fprintf(stderr, "Malformed command.\n");
		printUsage();
		return EXIT_FAILURE;
	}

	return EXIT_SUCCESS;
}
void engineTimeVaryingTotalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up)
{
    if (updated())
    {
        return;
    }

    checkTable();

    p0_=
    (
        interpolateXY
        (
            engineDB_.theta(),
            timeDataPtr_().x(),
            timeDataPtr_().y()
        )
    );

    const fvsPatchField<scalar>& phip =
        lookupPatchField<surfaceScalarField, scalar>(phiName_);

    if (psiName_ == "none" && rhoName_ == "none")
    {
        operator==(p0_ - 0.5*(1.0 - pos(phip))*magSqr(Up));
    }
    else if (rhoName_ == "none")
    {
        const fvPatchField<scalar>& psip =
            lookupPatchField<volScalarField, scalar>(psiName_);

        if (gamma_ > 1.0)
        {
            scalar gM1ByG = (gamma_ - 1.0)/gamma_;

            operator==
            (
                p0_
               /pow
                (
                    (1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)),
                    1.0/gM1ByG
                )
            );
        }
        else
        {
            operator==(p0_/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up)));
        }
    }
    else if (psiName_ == "none")
    {
        const fvPatchField<scalar>& rho =
            lookupPatchField<volScalarField, scalar>(rhoName_);

        operator==(p0_ - 0.5*rho*(1.0 - pos(phip))*magSqr(Up));
    }
    else
    {
        FatalErrorIn
        (
            "engineTimeVaryingTotalPressureFvPatchScalarField::updateCoeffs()"
        )   << " rho or psi set inconsitently, rho = " << rhoName_
            << ", psi = " << psiName_ << '.' << nl
            << "    Set either rho or psi or neither depending on the "
               "definition of total pressure." << nl
            << "    Set the unused variables to 'none'."
            << "\n    on patch " << this->patch().name()
            << " of field " << this->dimensionedInternalField().name()
            << " in file " << this->dimensionedInternalField().objectPath()
            << exit(FatalError);
    }

    fixedValueFvPatchScalarField::updateCoeffs();
}