Esempio n. 1
0
void VictoryWindow::draw() {
	m_height = 134 + 32 * m_itemsNb;
	
	m_y = 319 / 2 - m_height / 2; // GameWindow::main->height() - 319 = ActorStatsWindow->height()
	
	Window::draw();
	
	Interface::defaultFont->printCentered(_t("Victory").c_str(), m_x, m_y + 20, m_width, 21, FONT_LARGE);
	printStat(20, 52, _t("EXP"), m_battle->exp(), 60, 180);
	printStat(20, 84, _t("Gold"), m_battle->gold(), 60, 180);
	
	u16 i = 0;
	for(u16 j = 0 ; j < m_inventory.nbItems() ; j++) {
		printItem(m_inventory.getItem(j), m_inventory.getItemCount(j), 20, 116 + i * 32, 175);
		i++;
	}
	for(u16 j = 0 ; j < m_inventory.nbArmors() ; j++) {
		printItem(m_inventory.getArmor(j), m_inventory.getArmorCount(j), 20, 116 + i * 32, 175);
		i++;
	}
	for(u16 j = 0 ; j < m_inventory.nbWeapons() ; j++) {
		printItem(m_inventory.getWeapon(j), m_inventory.getWeaponCount(j), 20, 116 + i * 32, 175);
		i++;
	}
}
Esempio n. 2
0
void AgiEngine::selectItems(int n) {
	int fsel = 0;
	bool exit_select = false;

	while (!exit_select && !(shouldQuit() || _restartGame)) {
		if (n > 0)
			printItem(fsel, STATUS_BG, STATUS_FG);

		switch (waitAnyKey()) {
		case KEY_ENTER:
			setvar(vSelItem, _intobj[fsel]);
			exit_select = true;
			break;
		case KEY_ESCAPE:
			setvar(vSelItem, 0xff);
			exit_select = true;
			break;
		case KEY_UP:
			if (fsel >= 2)
				fsel -= 2;
			break;
		case KEY_DOWN:
			if (fsel + 2 < n)
				fsel += 2;
			break;
		case KEY_LEFT:
			if (fsel % 2 == 1)
				fsel--;
			break;
		case KEY_RIGHT:
			if (fsel % 2 == 0 && fsel + 1 < n)
				fsel++;
			break;
		case BUTTON_LEFT:{
				int i = findItem();
				if (i >= 0 && i < n) {
					setvar(vSelItem, _intobj[fsel = i]);
					debugC(6, kDebugLevelInventory, "item found: %d", fsel);
					showItems();
					printItem(fsel, STATUS_BG, STATUS_FG);
					_gfx->doUpdate();
					exit_select = true;
				}
				break;
			}
		default:
			break;
		}

		if (!exit_select) {
			showItems();
			_gfx->doUpdate();
		}
	}

	debugC(6, kDebugLevelInventory, "selected: %d", fsel);
}
Esempio n. 3
0
void EZUI_Menu::printPage(EZUI *UI){
	LiquidCrystal_I2C *LCD = UI->LCD;
	UI->LCD->clear();
	
	#if defined(SERIAL_VERBOSE) && (SERIAL_VERBOSE>2)
		Serial.print(F("  Menu-currentItem:"));
		Serial.println(currentItem);
		Serial.print(F("  Menu-CursorLocation:"));
		Serial.println(cursorLine);
		Serial.print(F("  ItemCount:"));
		Serial.println(itemCount);
	#endif
		
	//print the items 
	if(cursorLine == 0){
		//If cursor is at line0, print the current item first
		int ln = 0;
		for(int i=currentItem; i<min(itemCount,currentItem+4); i++){
			printItem( UI, ln, i);
			ln++;
		}
	}else if(cursorLine == 3){
		//If cursor is at line3, print the current item last
		if( itemCount > 3){
			int ln = 3;
			for(int i=currentItem; i>=max(0,currentItem-3); i--){
				printItem( UI, ln, i);
				ln--;
			}
		}else{
			//This shouldnt happen, so try and recover
			cursorLine = itemCount-1;
			int ln = cursorLine;
			for(int i=currentItem; i--; i>0){
				printItem( UI, ln, i);
				ln--;
			}
		}
	}else{
		//Were somewhere in between, so figure out first item to print and go from there
		int firstItemToPrint = currentItem - cursorLine ;
		int ln = 0;
		for( int i = firstItemToPrint; i<min(itemCount, firstItemToPrint+4); i++){
			printItem( UI, ln, i);
			ln++;
		}
	}
	
	
	
}
Esempio n. 4
0
int monthReport(struct Node *node){
  
  int i;
  struct Node nextNode;

  for (i = 0; i < node->count; i++){

    if (node->offsets[0] != -1){
      if(node->offsets[i] != -1){
        getNode(node->offsets[i], &nextNode);
        monthReport(&nextNode);
      }
    }

    printItem(node, i);

  }

  if (node->offsets[0] != -1){
    if(node->offsets[i] != -1){
      getNode(node->offsets[i], &nextNode);
      monthReport(&nextNode);
    }
  }

  saveNode(node);

  return 0;
}
Esempio n. 5
0
int AgiEngine::showItems() {
	unsigned int x, i;

	for (x = i = 0; x < _game.numObjects; x++) {
		if (objectGetLocation(x) == EGO_OWNED) {
			// add object to our list!
			_intobj[i] = x;
			printItem(i, STATUS_FG, STATUS_BG);
			i++;
		}
	}

	if (i == 0) {
		switch (getLanguage()) {
		case Common::RU_RUS:
			printText(NOTHING_MSG_RU, 0, NOTHING_X_RU, NOTHING_Y_RU, 40, STATUS_FG, STATUS_BG);
			break;
		default:
			printText(NOTHING_MSG, 0, NOTHING_X, NOTHING_Y, 40, STATUS_FG, STATUS_BG);
			break;
		}
	}

	return i;
}
Esempio n. 6
0
void printSubjPubKeyInfo(
	const DERItem *content,
	int verbose)
{
	DERReturn drtn;
	DERSubjPubKeyInfo pubKeyInfo;
	DERRSAPubKeyPKCS1 pkcs1Key;
	DERItem bitStringContents;
	DERByte numUnused;
	
	drtn = DERParseSequence(content,
		DERNumSubjPubKeyInfoItemSpecs, DERSubjPubKeyInfoItemSpecs,
		&pubKeyInfo, sizeof(pubKeyInfo));
	if(drtn) {
		DERPerror("DERParseSequenceContent(pubKeyInfo)", drtn);
		return;
	}
	printItem("algId", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &pubKeyInfo.algId);
	incrIndent();
	printAlgId(&pubKeyInfo.algId, verbose);
	decrIndent();

	printItem("pubKey", IT_Branch, verbose, ASN1_BIT_STRING, &pubKeyInfo.pubKey);
	
	/* 
	 * The contents of that bit string are a PKCS1 format RSA key. 
	 */
	drtn = DERParseBitString(&pubKeyInfo.pubKey, &bitStringContents, &numUnused);
	if(drtn) {
		DERPerror("DERParseBitString(pubKeyInfo.pubKey)", drtn);
		decrIndent();
		return;
	}
	drtn = DERParseSequence(&bitStringContents,
		DERNumRSAPubKeyPKCS1ItemSpecs, DERRSAPubKeyPKCS1ItemSpecs,
		&pkcs1Key, sizeof(pkcs1Key));
	if(drtn) {
		DERPerror("DERParseSequenceContent(pubKeyBits)", drtn);
		decrIndent();
		return;
	}
	incrIndent();
	printItem("modulus", IT_Leaf, verbose, ASN1_INTEGER, &pkcs1Key.modulus);
	printItem("pubExponent", IT_Leaf, verbose, ASN1_INTEGER, &pkcs1Key.pubExponent);
	
	decrIndent();
}
Esempio n. 7
0
/* 
 * This is a SEQUENCE OF so we use the low-level DERDecodeSeq* routines to snag one entry 
 * at a time.
 */
static void	printRevokedCerts(
	DERItem *revokedCerts, 
	int verbose)
{
	DERReturn drtn;
	DERDecodedInfo currItem;
	DERSequence seq;
	unsigned certNum;
	DERRevokedCert revoked;
	
	drtn = DERDecodeSeqContentInit(revokedCerts, &seq);
	if(drtn) {
		DERPerror("DERDecodeSeqContentInit(revokedCerts)", drtn);
		return;
	}
	
	for(certNum=0; ; certNum++) {
		drtn = DERDecodeSeqNext(&seq, &currItem);
		switch(drtn) {
			case DR_EndOfSequence:
				/* normal termination */
				return;
			default:
				DERPerror("DERDecodeSeqNext", drtn);
				return;
			case DR_Success:
				doIndent();
				printf("revoked cert %u\n", certNum);
				incrIndent();
				drtn = DERParseSequenceContent(&currItem.content, 
					DERNumRevokedCertItemSpecs, DERRevokedCertItemSpecs,
					&revoked, sizeof(revoked));
				if(drtn) {
					DERPerror("DERParseSequenceContent(RevokedCert)", drtn);
					decrIndent();
					return;
				}
				printItem("serialNum", IT_Leaf, verbose, ASN1_INTEGER, &revoked.serialNum);
				decodePrintItem("revocationDate",  IT_Leaf, verbose, &revoked.revocationDate);
				printItem("extensions", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &revoked.extensions);
				decrIndent();
		}
	}
}
Esempio n. 8
0
	//prints data from vector of SItem
	void showData(const std::vector<SItem>& data) {
		std::vector<SItem>::const_iterator it;
		int d_counter=0;
		for(it=data.begin(); it!=data.end(); ++it){
			std::cout << "Element Number: " 
				<< d_counter << std::endl;
			d_counter++;
			printItem(*it);
		}
	}
Esempio n. 9
0
void ItemWindow::drawItem(u8 pos) {
	s16 x, y, width;
	
	width = m_width / m_columnMax - 32;
	
	x = 22 + pos % m_columnMax * (width + 32);
	y = 21 + pos / m_columnMax * 32 - m_scroll * 32;
	
	printItem(m_inventory->getItem(pos), m_inventory->getItemCount(pos), x, y, width);
}
Esempio n. 10
0
void printList (link ls) {
  link curr = ls;
  while (! isEmptyList (curr)) {
    printf ("->[");
    printItem (getItem (curr));
    printf ("]");
    curr = getNext (curr);
  }
  printf ("->[X]\n");
}
Esempio n. 11
0
void printAlgId(
	const DERItem *content,
	int verbose)
{
	DERReturn drtn;
	DERAlgorithmId algId;
	
	drtn = DERParseSequenceContent(content,
		DERNumAlgorithmIdItemSpecs, DERAlgorithmIdItemSpecs,
		&algId, sizeof(algId));
	if(drtn) {
		DERPerror("DERParseSequenceContent(algId)", drtn);
		return;
	}
	printItem("alg", IT_Leaf, verbose, ASN1_OBJECT_ID, &algId.oid);
	if(algId.params.data) {
		printItem("params", IT_Leaf, verbose, algId.params.data[0], &algId.params);
	}
}
Esempio n. 12
0
void KexiProjectNavigator::slotPrintObject()
{
#ifndef KEXI_NO_QUICK_PRINTING
    if (!d->printAction)
        return;
    KexiPart::Item* item = selectedPartItem();
    if (item)
        emit printItem(item);
#endif
}
Esempio n. 13
0
bool Console::Cmd_GiveItem(int argc, const char **argv) {
	if (argc != 2) {
		debugPrintf("Usage: %s <ID | name>\n", argv[0]);
		return true;
	}

	Common::List<Item>::iterator item;

	char *end;
	uint id = strtoul(argv[1], &end, 0);

	if (*end != 0) {
		Common::Array<Item *> matches;

		Common::String name = toAppleWord(argv[1]);

		if (!_engine->_nouns.contains(name)) {
			debugPrintf("Item '%s' not found\n", argv[1]);
			return true;
		}

		byte noun = _engine->_nouns[name];

		for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item) {
			if (item->noun == noun)
				matches.push_back(&*item);
		}

		if (matches.size() == 0) {
			debugPrintf("Item '%s' not found\n", argv[1]);
			return true;
		}

		if (matches.size() > 1) {
			debugPrintf("Multiple matches found, please use item ID:\n");
			for (uint i = 0; i < matches.size(); ++i)
				printItem(*matches[i]);
			return true;
		}

		matches[0]->room = IDI_ANY;
		debugPrintf("OK\n");
		return true;
	}

	for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item)
		if (item->id == id) {
			item->room = IDI_ANY;
			debugPrintf("OK\n");
			return true;
		}

	debugPrintf("Item %i not found\n", id);
	return true;
}
Esempio n. 14
0
bool Console::Cmd_Items(int argc, const char **argv) {
	if (argc != 1) {
		debugPrintf("Usage: %s\n", argv[0]);
		return true;
	}

	Common::List<Item>::const_iterator item;

	for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item)
		printItem(*item);

	return true;
}
Esempio n. 15
0
void Menu::display() {
    uint8_t lines = LCD_LINES;
    for(uint8_t i = 0; i < lines; i++) {
        lcdSetCursor(0, i);
        lcdPrintChar(i == pos_ ? '>' : ' ');
        if(i + begin_ < size_) {
            printItem(i + begin_);
        }
        lcdPrintSpaces();
    }
    debug();
    render_ = false;
}
Esempio n. 16
0
void Console::evaluate(const QString &expression)
{
    if (m_scriptEvaluator) {
        m_consoleItemModel->shiftEditableRow();
        m_scriptEvaluator(expression);
    } else {
        auto item = new ConsoleItem(ConsoleItem::ErrorType,
               QCoreApplication::translate(
                        "Debugger::Internal::Console",
                        "Can only evaluate during a debug session."));
        m_consoleItemModel->shiftEditableRow();
        printItem(item);
    }
}
Esempio n. 17
0
/* decode one item and print it */
void decodePrintItem(
	const char *label,
	ItemType itemType,
	int verbose,
	DERItem *derItem)
{
	DERDecodedInfo decoded;
	DERReturn drtn;
	
	drtn = DERDecodeItem(derItem, &decoded);
	if(drtn) {
		DERPerror("DERDecodeItem()", drtn);
		return;
	}
	printItem(label, IT_Leaf, 0, decoded.tag, &decoded.content);
}
int printBill(Customer *c)
{
    
    if(c==NULL)
    {
                         printf("Error: No customer to process.");
                         return -1;
    }
    
    int i;
    time_t invoiceTime;
    basketItem *b;
    Stack *temp=newStack();
    
    stackInit(temp);
    
    clearScreen();
    
    time(&invoiceTime);
    
    printf("\n\tInvoice id: %s\n\n\tDate/Time: %s\n\n", c->id, ctime(&invoiceTime));
    
    printf("\t| Code\t Item\t\t Price\t Qty.\t Subtotal\t\n");
    printLine();
    
    while(stackIsEmpty(c->basket)==0)
    {
             
                                     b=stackPop(c->basket);
                                     if(b!=NULL)
                                     {
                                         printItem(b);
                                         c->total+=subTotal(b);
                                         stackPush(temp, b);
                                     }
    }
    printf("\n\tTotal number of items: %d", c->quantity);
    printf("\n\n\tTotal Payable: %0.2f\n", c->total);
    printLine();
    
    while(stackIsEmpty(temp)==0)
                                stackPush(c->basket, stackPop(temp));
                                
    return 0;
}
Esempio n. 19
0
void printTable(Table &t)
{
	std::map<std::string, itemList>::iterator i = t.begin();

	for (; i != t.end(); i++)
	{
		if (i->second.empty())
		{
			continue;
		}
		for (itemList::iterator j = i->second.begin(); j != i->second.end(); j++)
		{
			std::cout << i->first << ", ";
			printItem(*j);
		}
	}
	return;
}
Esempio n. 20
0
int main(int argc, char **argv)
{
	unsigned char *crlData = NULL;
	unsigned crlDataLen = 0;
	DERSignedCertCrl signedCrl;
	DERTBSCrl tbs;
	DERReturn drtn;
	DERItem item;
	int verbose = 0;
	extern char *optarg;
	int arg;
	extern int optind;
	
	if(argc < 2) {
		usage(argv);
	}
	if(readFile(argv[1], &crlData, &crlDataLen)) {
		printf("***Error reading CRL from %s. Aborting.\n", argv[1]);
		exit(1);
	}

	optind = 2;
	while ((arg = getopt(argc, argv, "vh")) != -1) {
		switch (arg) {
			case 'v':
				verbose = 1;
				break;
			case 'h':
				usage(argv);
		}
	}
	if(optind != argc) {
		usage(argv);
	}

	/* Top level decode of signed CRL into 3 components */
	item.data = crlData;
	item.length = crlDataLen;
	drtn = DERParseSequence(&item, DERNumSignedCertCrlItemSpecs, DERSignedCertCrlItemSpecs,
		&signedCrl, sizeof(signedCrl));
	if(drtn) {
		DERPerror("DERParseSequence(SignedCrl)", drtn);
		exit(1);
	}
	printItem("TBSCrl", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &signedCrl.tbs);
	
	incrIndent();
	
	/* decode the TBSCrl - it was saved in full DER form */
	drtn = DERParseSequence(&signedCrl.tbs, 
		DERNumTBSCrlItemSpecs, DERTBSCrlItemSpecs,
		&tbs, sizeof(tbs));
	if(drtn) {
		DERPerror("DERParseSequenceContent(TBSCrl)", drtn);
		exit(1);
	}
	if(tbs.version.data) {
		printItem("version", IT_Leaf, verbose, ASN1_INTEGER, &tbs.version);
	}
	
	printItem("tbsSigAlg", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &tbs.tbsSigAlg);
	incrIndent();
	printAlgId(&tbs.tbsSigAlg, verbose);
	decrIndent();
	
	printItem("issuer", IT_Leaf, verbose, ASN1_CONSTR_SEQUENCE, &tbs.issuer);
	
	decodePrintItem("thisUpdate",  IT_Leaf, verbose, &tbs.thisUpdate);
	decodePrintItem("nextUpdate",  IT_Leaf, verbose, &tbs.nextUpdate);
	
	if(tbs.revokedCerts.data) {
		printItem("version", IT_Leaf, verbose, ASN1_CONSTR_SEQUENCE, &tbs.revokedCerts);
		incrIndent();
		printRevokedCerts(&tbs.revokedCerts, verbose);
		decrIndent();
	}
	
	if(tbs.extensions.data) {
		printItem("extensions", IT_Leaf, verbose, ASN1_CONSTRUCTED | ASN1_CONTEXT_SPECIFIC | 3, 
			&tbs.extensions);
	}
	
	printItem("sigAlg", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &signedCrl.sigAlg);
	incrIndent();
	printAlgId(&signedCrl.sigAlg, verbose);
	decrIndent();

	printItem("sig", IT_Leaf, verbose, ASN1_BIT_STRING, &signedCrl.sig);
	
	return 0;
}
Esempio n. 21
0
void main ()
{	
	startDay(sFile2);
	populateTextfile(sFile1);

	int i;

	do
	{
		printf("----------------------------------------------------\n");
		printf("Push 1 to sell item.\n");
		printf("Push 2 to return item.\n");
		printf("Push 3 to search stock on system.\n");
		printf("Push 4 to update stock.\n");
		printf("Push 5 to print all stock to screen.\n");
		printf("Push 6 to see cash in till for today only.\n");
		printf("Push 7 or higher to quit the program.\n");
		printf("?: ");
		scanf("%d", &i);

		switch (i)
		{
		case 1:
			printf("\n----------------------------------------------------\n");
			sellItem(sFile1, sFile2);
			printf("----------------------------------------------------\n\n");
			break;

		case 2:
			printf("\n----------------------------------------------------\n");
			returnBook (sFile1, sFile2);
			printf("----------------------------------------------------\n\n");
			break;
			
		case 3:
			printf("\n----------------------------------------------------\n");
			stockSwitch();
			printf("----------------------------------------------------\n\n");
			break;
			
		case 4:
			printf("\n----------------------------------------------------\n");
			updateStock();
			printf("----------------------------------------------------\n");
			break;
		
		case 5:
			printf("\n----------------------------------------------------\n");
			printItem(sFile1);
			printf("----------------------------------------------------\n\n");
			break;

		case 6:
			printf("\n----------------------------------------------------\n");
			cash(sFile2);
			printf("----------------------------------------------------\n\n");
			break;

		case 9:
			rofl();
			break;
		}
	}
	while (i<7 && i!=9);
	populateTextfile(sFile1);
	endStatement(sFile2);
}
Esempio n. 22
0
void printNode (link ls) {
  printf (" ");
  printItem (ls->item);
  printf (" ");
  return;
}
Esempio n. 23
0
int main(int argc, char **argv)
{
	unsigned char *certData = NULL;
	unsigned certDataLen = 0;
	DERSignedCertCrl signedCert;
	DERTBSCert tbs;
	DERReturn drtn;
	DERItem item;
	int verbose = 0;
	extern char *optarg;
	int arg;
	extern int optind;
	
	if(argc < 2) {
		usage(argv);
	}
	if(readFile(argv[1], &certData, &certDataLen)) {
		printf("***Error reading cert from %s. Aborting.\n", argv[1]);
		exit(1);
	}

	optind = 2;
	while ((arg = getopt(argc, argv, "vh")) != -1) {
		switch (arg) {
			case 'v':
				verbose = 1;
				break;
			case 'h':
				usage(argv);
		}
	}
	if(optind != argc) {
		usage(argv);
	}

	/* Top level decode of signed cert into 3 components */
	item.data = certData;
	item.length = certDataLen;
	drtn = DERParseSequence(&item, DERNumSignedCertCrlItemSpecs, DERSignedCertCrlItemSpecs,
		&signedCert, sizeof(signedCert));
	if(drtn) {
		DERPerror("DERParseSequence(SignedCert)", drtn);
		exit(1);
	}
	printItem("TBSCert", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &signedCert.tbs);
	
	incrIndent();
	
	/* decode the TBSCert - it was saved in full DER form */
	drtn = DERParseSequence(&signedCert.tbs, 
		DERNumTBSCertItemSpecs, DERTBSCertItemSpecs,
		&tbs, sizeof(tbs));
	if(drtn) {
		DERPerror("DERParseSequenceContent(TBSCert)", drtn);
		exit(1);
	}
	if(tbs.version.data) {
		/* unwrap the explicitly tagged integer.... */
		decodePrintItem("version", IT_Leaf, verbose, &tbs.version);
	}
	printItem("serialNum", IT_Leaf, verbose, ASN1_INTEGER, &tbs.serialNum);
	
	printItem("tbsSigAlg", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &tbs.tbsSigAlg);
	incrIndent();
	printAlgId(&tbs.tbsSigAlg, verbose);
	decrIndent();
	
	printItem("issuer", IT_Leaf, verbose, ASN1_CONSTR_SEQUENCE, &tbs.issuer);
	printItem("subject", IT_Leaf, verbose, ASN1_CONSTR_SEQUENCE, &tbs.subject);
	
	printItem("validity", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &tbs.validity);
	incrIndent();
	printValidity(&tbs.validity, verbose);
	decrIndent();
	
	printItem("subjectPubKey", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, 
		&tbs.subjectPubKey);
	incrIndent();
	printSubjPubKeyInfo(&tbs.subjectPubKey, verbose);
	decrIndent();
	
	if(tbs.issuerID.data) {
		/* found tag is implicit context specific: tell printItem what it really is */
		printItem("issuerID", IT_Leaf, verbose, ASN1_BIT_STRING, &tbs.issuerID);
	}
	if(tbs.subjectID.data) {
		printItem("subjectID", IT_Leaf, verbose, ASN1_BIT_STRING, &tbs.subjectID);
	}
	if(tbs.extensions.data) {
		printItem("extensions", IT_Leaf, verbose, ASN1_CONSTRUCTED | ASN1_CONTEXT_SPECIFIC | 3, 
			&tbs.extensions);
	}
	decrIndent();
	
	printItem("sigAlg", IT_Branch, verbose, ASN1_CONSTR_SEQUENCE, &signedCert.sigAlg);
	incrIndent();
	printAlgId(&signedCert.sigAlg, verbose);
	decrIndent();

	printItem("sig", IT_Leaf, verbose, ASN1_BIT_STRING, &signedCert.sig);
	
	return 0;
}
Esempio n. 24
0
int main(int argc, char *argv[])
{
  FILE * file;
  int i, indirectCount, indirectNode;
  int zoneCount = 0;
  int partitionOffset = 0;

  SUPERBLOCK *diskinfo;
  INODE *node, *tempNode;
  DIRECT *direct;
  ARGSP *argsp;

  diskinfo = malloc(sizeof(SUPERBLOCK));
  node = malloc(sizeof(INODE));
  tempNode = malloc(sizeof(INODE));
  direct = malloc(sizeof(DIRECT));
  argsp = malloc(sizeof(ARGSP));

  /* Grab Args */
  getArgs(argsp, argc, argv);  
  if(argsp->hflag) {
    printUsage();
    exit(1);
  }
  
  /* Open File */
  file = fopen(argsp->image, "r");
  if (file == NULL) {
    perror("Some Error:");
    exit (1);
  }

  /* Grab Partition offset */
  if((partitionOffset = getPartition(file, argsp)) < 0) {
    fputs("Bad partition\n",stderr);
    exit(1);
  }  

  /* Grab node for file */
  if(!(node = minInitialize(file, diskinfo, argsp, partitionOffset))) {
    fputs("File not found\n",stderr);
    exit(1);
  }
  
    
  /* current node should be the matching diretory or file */
  if((node->mode & FILEMASK & DIRECTORYMASK)) {

    zoneCount = 0; 
    indirectCount = 0;  

    printf("%s:\n", argsp->path);    
    fseek(file, partitionOffset + diskinfo->zonesize 
      * node->zone[zoneCount], SEEK_SET);

    for(i = 0; i < node->size / sizeof(DIRECT); i++) {
      fread(direct, sizeof(DIRECT), 1, file);

      if(direct->inode) {
        getNode(tempNode, file, diskinfo, direct->inode, partitionOffset);
        printItem(tempNode, direct->name);
      }

      /* check to see if we are at the end of a zone 
         and need to move to next zone*/
      if(((i+1) * sizeof(DIRECT) % diskinfo->zonesize) == 0) {

        if (zoneCount < REGULAR_ZONES-1) {
          zoneCount++;
          fseek(file, partitionOffset + diskinfo->zonesize 
            * node->zone[zoneCount], SEEK_SET);
        } else {
        
          /* jump to indirect block plus offset */
          fseek(file, partitionOffset + diskinfo->zonesize 
            * node->zoneindirect 
            + (sizeof(uint32_t) * indirectCount), SEEK_SET);
          indirectCount++;
          
          /* grab new zone value */
          fread(&indirectNode, sizeof(uint32_t), 1, file);           
          
          /* set filepointer to new indirect zone */
          fseek(file, partitionOffset +  diskinfo->zonesize 
            * indirectNode, SEEK_SET);
        }
      }
      
    }
  } else {
    printItem(node, argsp->path);
  }
      
  freeArgs(argsp);
  free(argsp);
  free(direct);
  free(tempNode);
  free(node);
  free(diskinfo);
  fclose(file);
  
  exit(0);
}
Esempio n. 25
0
/*
 * oprintf()
 *
 * Opcode printf
 */
static void oprintf(disasm_t *d, const char *format)
{
    uint32_t	i	= 0;
    const char 	*fstart, *fend;

    if (format == NULL)
        return;

    fstart	= fend	= format;

    while (*fend) {
        if (*fend != '%') {
            i++;
            fend++;
        } else {
            if (i)
                fprintf(d->fp, "%.*s", i, fstart);

            /* Skip past % */
            fend++;

            switch (*fend) {
            case 'b':
                fprintf(d->fp, "%d", d->code->buf[d->offset++]);
                break;
            case 'B':	/* Bigpic image */
                printBigpic(d->fp, d->code->buf[d->offset++]);
                break;
            case 'c':	/* Class */
                printClass(d);
                break;
            case 'C':	/* Spell */
                printSpell(d->fp, d->code->buf[d->offset++]);
                break;
            case 'D':	/* Direction */
            {
                uint8_t		dir;

                dir = d->code->buf[d->offset++];

                if (dir == 0) {
                    fprintf(d->fp, "north");
                } else if (dir == 1) {
                    fprintf(d->fp, "east");
                } else if (dir == 2) {
                    fprintf(d->fp, "south");
                } else if (dir == 3) {
                    fprintf(d->fp, "west");
                } else {
                    fprintf(d->fp, "unknown");
                }
                break;
            }
            case 'f':	/* Flag */
            {
                uint8_t		flag;
                uint8_t		mask;

                flag	= d->code->buf[d->offset] >> 3;
                mask	= d->code->buf[d->offset] & 7;
                fprintf(d->fp, "%d", (flag * 8) + mask);
                d->offset++;
                break;
            }
            case 'I':	/* Item */
                printItem(d->fp, d->code->buf[d->offset++]);
                break;
            case 'L':
                printLiquid(d->fp, d->code->buf[d->offset++]);
                break;
            case 'M':	/* Monster */
                printMonster(d->fp, d->code->buf[d->offset++]);
                break;
            case 'O':	/* String at offset */
            {
                uint16_t	savedOffset;
                range_t		*r;

                r = (range_t *)xzalloc(sizeof(range_t));

                savedOffset = d->offset + 2;

                d->offset = str_read16le(&d->code->buf[d->offset]) - currentLevel.dataStartOffset;
                r->start	= d->offset;
                printPackedString(d);
                r->end		= d->offset;
                gl_list_add_last(rangeSkipList, r);
                d->offset	= savedOffset;
                break;
            }
            case 'o':	/* offset */
                fprintf(d->fp, "%04x",
                        str_read16le(&d->code->buf[d->offset])
                       );
                d->offset += 2;
                break;
            case 'S':	/* Masked String */
                fprintf(d->fp, "\"");
                fflush(d->fp);
                printMaskedString(d);
                fprintf(d->fp, "\"");
                break;
            case 's':	/* Packed String */
                fprintf(d->fp, "\"");
                printPackedString(d);
                fprintf(d->fp, "\"");
                break;
            case 'w':	/* Word */
                fprintf(d->fp, "%d",
                        str_read16le(&d->code->buf[d->offset])
                       );
                d->offset	+= 2;
                break;
            case 'x':	/* Hex byte */
                fprintf(d->fp, "0x%02x", d->code->buf[d->offset++]);
                break;
            }

            fend++;
            fstart	= fend;
            i	= 0;
        }
    }

    if (i)
        fprintf(d->fp, "%.*s", i, fstart);
}
Esempio n. 26
0
/*****************************************************************************
 * @fn        menuWriteBuffer
 *
 * @brief     Writes the provided pMenu to the LCD Buffer
 *
 * input parameters
 *
 * @param     pMenu   - The menu to be shown on the display
 */
void menuWriteBuffer(const menu_t *pMenu)
{
  
  /* Print the header on the first line/page on the LCD if not reserved */
  if(!(pMenu->reservedAreas & 1))
  {
    lcdBufferClearPage(0,eLcdPage0);
    printHeader(pMenu);
  }
  
  /* Which screen and which item is the current on */
  int8 nCurrentItem = pMenu->nCurrentItem;
  int8 screen = pMenu->nScreen;

  /* Finding first item on screen */
  uint8 itemsPerScreen = determineItemsPerScreen(pMenu);
  uint8 nItem = screen*itemsPerScreen;
  menuItem_t *pItem = &(pMenu->pItems[nItem]);
 
  /* Iterating through items, printing one by one */
  tLcdPage page=(tLcdPage)getNextPage(pMenu,0);   /* finds first page */
  while(nItem<pMenu->nMenuItems && page)
  {
    /* write the current item */
    lcdBufferClearPage(0,page);
    printItem(pMenu,nItem,page,0);
    
    
    /* Invert region around item if the item is selected */
    if(pItem==&(pMenu->pItems[nCurrentItem]))
    {
      lcdBufferSetHLine(0,0,LCD_COLS-1,page*LCD_PAGE_ROWS-1);
      lcdBufferInvertPage(0,0,LCD_COLS-1,page);
    }
    else
    {
      if(pMenu->reservedAreas & (1<<(page-1)))
      {
        /* if the previous page is reserved, and this page isn't marked,
         * make sure horizontal line doesn't stick.
         */
        lcdBufferClearHLine(0,0,LCD_COLS-1,page*LCD_PAGE_ROWS-1);
      }
    }
    /* NOTE: if the page over this (marked) item is reserved, the item will
     * still use 9 pixels of height for the invertion area so that it "steals"
     * 1 px of height from the reserved page.
     */
        
    
    /* If this is a dummy item, invert the region around it if the
     * master item is selected
     */
    if(pItem->flags & M_EXTEND){
      int8 masterNumber = nItem - 1;
      while(pMenu->pItems[masterNumber].flags & M_EXTEND)
      {
        masterNumber--;
      }
      if(masterNumber==nCurrentItem)
      {
        lcdBufferInvert(0,0,page*LCD_PAGE_ROWS,LCD_COLS-1,(page+1)*LCD_PAGE_ROWS-1);
      }
    }
   
    /* Iterate */
    page = (tLcdPage)getNextPage(pMenu,page);
    nItem++;
    pItem = &(pMenu->pItems[nItem]);
  }
  
  /* clearing unused pages that's not reserved */
  while(page)
  {
    lcdBufferClearPage(0,page);
    if(pMenu->reservedAreas & (1<<(page-1)))
    {
      /* if the previous page is reserved, and this page is empty,
       * make sure horizontal line doesn't stick.
       */
      lcdBufferClearHLine(0,0,LCD_COLS-1,page*LCD_PAGE_ROWS-1);
    }
    page = (tLcdPage)getNextPage(pMenu,page);
  }
  
}
Esempio n. 27
0
void Console::printItem(ConsoleItem::ItemType itemType, const QString &text)
{
    printItem(new ConsoleItem(itemType, text));
}
Esempio n. 28
0
static int printStackTrace(JNIEnv *env, jobject sobj, StackTrace tr) {
  bfd *abfd;
  long storage_needed;
  asymbol **symbol_table;
  symtab_entry *symtab;
  long number_of_symbols;
  long number_of_text_symbols;
  long i, j;
  StackTrace curr;
    
  bfd_init();
  abfd = bfd_openr(name_of_binary, "default");
  bfd_set_format(abfd, bfd_object);
  
  if (!bfd_check_format(abfd, bfd_object)) {
    printf("Error(1) in printStackTrace\n"); return(1);
  }
  
  storage_needed = bfd_get_symtab_upper_bound(abfd);
    
  if (storage_needed < 0) {
    printf("Error(2) in printStackTrace\n"); return(2);
  }
  if (storage_needed == 0) {
    printf("Error(3) no symbols\n"); return(3);
  }

  symbol_table = (asymbol **) xmalloc (storage_needed);
  number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);

  if (number_of_symbols < 0) {
    printf("Error(4) in printStackTrace\n"); return(4);
  } 

  /* count number of symbols in text segment */
  for (i = number_of_text_symbols = 0; i < number_of_symbols; i++)
    if (bfd_decode_symclass(symbol_table[i]) == 'T') 
      number_of_text_symbols++;

  if (number_of_text_symbols < 0) {
    printf("Error(5) in printStackTrace\n"); return(5);
  }
  if (number_of_text_symbols == 0) {
    printf("Error(6) No symbols in text segment.\n"); return(6);
  }

  symtab = (symtab_entry *) 
    malloc(number_of_text_symbols * sizeof(symtab_entry));
  
  for (i = j = 0; i < number_of_symbols; i++) {
    symbol_info si;
    bfd_symbol_info(symbol_table[i], &si);
    if (bfd_decode_symclass(symbol_table[i]) == 'T') {
      if (j >= number_of_text_symbols) {
	printf("Error(7) in printStackTrace\n"); return(7);
      }
      (symtab+j)->value = (unsigned long)si.value;
      (symtab+j)->name  = si.name;
      j++;
    }
  }

  qsort(symtab, number_of_text_symbols, sizeof(symtab_entry),
	compare_symtab_entry);
  
  curr = tr;

  while(curr != NULL) {
    symtab_entry *found = 
      bsearch_symtab((symvalue)curr->retaddr, symtab, number_of_text_symbols);
    printItem(env, sobj, found, curr);
    curr = curr->next;
  }

  /* clean up */
  free(symtab);
  bfd_close(abfd);
  return(0);
}