static void print_method(outputStream* str, Method* mo, bool with_class=true) {
  ResourceMark rm;
  if (with_class) {
    str->print("%s.", mo->klass_name()->as_C_string());
  }
  print_slot(str, mo->name(), mo->signature());
}
Exemple #2
0
void add_builtin_function(VM *vm) {


    if(debug_level > 0)
        printf("------ BUILT IN FUNCTION: -------\n");
    uint64_t f = to_builtin( (builtin_fn) builtin_println);

    if(debug_level > 0)
        print_slot(f);
    if(debug_level > 0)
        printf("\n------ BUILT IN FUNCTION: -------\n");
    add_symbol_table_pair(vm,"println",f);
}
Exemple #3
0
static int process_slot(struct cache_slot *slot)
{
	int err;

	err = open_slot(slot);
	if (!err && slot->match) {
		if (is_expired(slot)) {
			if (!lock_slot(slot)) {
				/* If the cachefile has been replaced between
				 * `open_slot` and `lock_slot`, we'll just
				 * serve the stale content from the original
				 * cachefile. This way we avoid pruning the
				 * newly generated slot. The same code-path
				 * is chosen if fill_slot() fails for some
				 * reason.
				 *
				 * TODO? check if the new slot contains the
				 * same key as the old one, since we would
				 * prefer to serve the newest content.
				 * This will require us to open yet another
				 * file-descriptor and read and compare the
				 * key from the new file, so for now we're
				 * lazy and just ignore the new file.
				 */
				if (is_modified(slot) || fill_slot(slot)) {
					unlock_slot(slot, 0);
					close_lock(slot);
				} else {
					close_slot(slot);
					unlock_slot(slot, 1);
					slot->cache_fd = slot->lock_fd;
				}
			}
		}
		if ((err = print_slot(slot)) != 0) {
			cache_log("[cgit] error printing cache %s: %s (%d)\n",
				  slot->cache_name,
				  strerror(err),
				  err);
		}
		close_slot(slot);
		return err;
	}

	/* If the cache slot does not exist (or its key doesn't match the
	 * current key), lets try to create a new cache slot for this
	 * request. If this fails (for whatever reason), lets just generate
	 * the content without caching it and fool the caller to belive
	 * everything worked out (but print a warning on stdout).
	 */

	close_slot(slot);
	if ((err = lock_slot(slot)) != 0) {
		cache_log("[cgit] Unable to lock slot %s: %s (%d)\n",
			  slot->lock_name, strerror(err), err);
		slot->fn();
		return 0;
	}

	if ((err = fill_slot(slot)) != 0) {
		cache_log("[cgit] Unable to fill slot %s: %s (%d)\n",
			  slot->lock_name, strerror(err), err);
		unlock_slot(slot, 0);
		close_lock(slot);
		slot->fn();
		return 0;
	}
	// We've got a valid cache slot in the lock file, which
	// is about to replace the old cache slot. But if we
	// release the lockfile and then try to open the new cache
	// slot, we might get a race condition with a concurrent
	// writer for the same cache slot (with a different key).
	// Lets avoid such a race by just printing the content of
	// the lock file.
	slot->cache_fd = slot->lock_fd;
	unlock_slot(slot, 1);
	if ((err = print_slot(slot)) != 0) {
		cache_log("[cgit] error printing cache %s: %s (%d)\n",
			  slot->cache_name,
			  strerror(err),
			  err);
	}
	close_slot(slot);
	return err;
}
Exemple #4
0
int main(int argc, char *argv[])
{
	// open the output data stream
	Q3TextStream out(stdout, QIODevice::WriteOnly);

	const char* header =
		"Content-type: text/html; charset=iso-8859-1\n\n"
		"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n"
		"<HTML>\n"
		"  <HEAD>\n"
		"    <TITLE>ShowEQ Item Display</TITLE>\n"
		"    <style type=\"text/css\">\n"
		"      <!--\n"
		"          table { border: black 2px solid }\n"
		"          td { border: black 1px solid }\n"
		"          th { border: black 1px solid }\n"
		"          span.head { color: black }\n"
		"          span.known1 { color: green }\n"
		"          span.known2 { color: blue }\n"
		"          span.varies { color: purple }\n"
		"          span.unknown { color: red }\n"
		"          b.warning { color: red }\n"
		"      -->\n"
		"    </style>\n"
		"  </HEAD>\n"
		"  <BODY>\n";

	/* Print HTML header */
	out << header;

	const char* footer =
		"  </BODY>\n"
		"</HTML>\n";

	// number of item to display
	QString itemNumber;

	// should binary data be displayed (default = false)
	bool displayBinaryData = false;

	// should the icon be displayed
	bool displayIcon = DISPLAY_ICONS;

	// CGI Convenience class
	CGI cgiconv;

	// process any CGI data
	cgiconv.processCGIData();

	// If there are form parameters use them
	if (cgiconv.getParamCount() != 0)
	{
		itemNumber = cgiconv.getParamValue("item");

		if (cgiconv.getParamValue("displayBinary") == "y")
			displayBinaryData = true;
		else if (cgiconv.getParamValue("displayBinary") == "n")
			displayBinaryData = false;

		if (cgiconv.getParamValue("showIcon") == "y")
			displayIcon = true;
		else if (cgiconv.getParamValue("hideIcon") == "y")
			displayIcon = false;
	}
	else if (argc == 2)
	{
		// use argument for item number
		itemNumber = argv[1];

	}
	else if (argc > 2)
	{
		out << "<H1>Error: " << argv[0] << " called with " << argc
			<< " arguments!</H1>\n";
		out << "Format: " << argv[0] << "?<ItemID>\n";
		out << footer;
		exit(-1);
	}

	if (itemNumber.isNull())
		itemNumber = "";

	// check for browser type
	QString userAgent = cgiconv.getHTTPUserAgent();
	out << "    <!-- Output for UserAgent: " << userAgent << "-->\n";

	// beware Netscape4 style sheet brain death
	bool isNetscape4 = false;
	if ((userAgent.contains("Mozilla/4.") == 1) &&
		(userAgent.contains("MSIE") == 0))
		isNetscape4 = true;

	// display form to allow user to select an item or display the binary data
	out << "    <FORM method=\"POST\" action=\"" << cgiconv.getScriptName()
		<< "\">\n";

	if (isNetscape4)
		out << "      <TABLE border cellspacing=0 cellpadding=2>\n";
	else
		out << "      <TABLE cellspacing=0 cellpadding=2>\n";

	out <<
		"        <TR><TH>Item ID:</TH><TH>Binary Data</TH><TH>Icon</TH>"
		"<TD><INPUT type=\"reset\" value=\"Reset\"/></TD></TR>\n"
		"        <TR>\n";

	out << "          <TD><INPUT type=\"text\" name=\"item\" value=\""
		<< itemNumber
		<< "\" size=\"5\"/></TD>\n";

	out <<
		"          <TD>"
		"<INPUT type=\"checkbox\" name=\"displayBinary\" value=\"y\"";

	if (displayBinaryData)
		out << " checked";
	out << "/>Display</TD>\n";

	out <<
		"          <TD>";

	if (displayIcon)
		out << "<INPUT type=\"checkbox\" name=\"hideIcon\" value=\"y\" unchecked>"
		<< "Hide</TD>\n";
	else
		out << "<INPUT type=\"hidden\" name=\"hideIcon\" value=\"y\">"
		<< "<INPUT type=\"checkbox\" name=\"showIcon\" value=\"y\" unchecked>"
		<< "Show</TD>\n";


	// Submission button
	out <<
		"          <TD>"
		"<INPUT type=\"submit\" value=\"Search\"/></TD>\n";

	out << "        </TR>\n";
	out << "      </TABLE>\n";
	out << "    </FORM>\n";


	// if no item number was passed in, then just return
	if (itemNumber.isEmpty())
	{
		// ask the user to enter an ItemID
		out << "<H1>Please Enter an ItemID!</H1>\n";

		// close the document
		out << footer;

		return 0;
	}

	// convert the passed in item number to a short
	uint16_t currentItemNr = itemNumber.toShort();

	EQItemDB* itemDB = new EQItemDB;
	QString nameString;
	QString loreString;
	bool hasEntry = false;
	EQItemDBEntry* entry = NULL;

	hasEntry = itemDB->GetItemData(currentItemNr, &entry);

	out << "<H1>Information on ItemID: " << currentItemNr << "</H1>\n";

	if (hasEntry)
	{
		loreString = entry->GetLoreName();
		nameString = entry->GetName();

		if (displayIcon)
			out << "<P><IMG src=\"" << ICON_DIR << entry->GetIconNr()
			<< ".png\" alt=\"Icon: " << entry->GetIconNr() << "\"/></P>";

		if (!nameString.isEmpty())
		{
			out << "<H2>" << nameString << "</H2>\n";
			out << "<P><B>Lore:</B> " << loreString << "<BR></P>\n";
		}
		else
		{
			out << "<H2>Lore: " << loreString << "</H2>\n";
		}

		out << "<P>\n";
		time_t updated = entry->GetUpdated();
		out << "<B>Last Updated:</B> " << ctime(&updated) << "<BR>\n";
		out << "<B>Icon Number:</B> " << entry->GetIconNr() << "<BR>\n";
		out << "<B>Model:</B> " << entry->GetIdFile() << "<BR>\n";
		out << "<B>ItemType:</B> " << QString::number(entry->GetItemType())
			<< "<BR>\n";
		out << "<B>Weight:</B> " << (int)entry->GetWeight() << "<BR>\n";
		out << "<B>Flags:</B> ";
		if (entry->IsBook())
			out << " BOOK";
		if (entry->IsContainer())
			out << " CONTAINER";
		if (entry->GetNoDrop() == 0)
			out << " NO-DROP";
		if (entry->GetNoRent() == 0)
			out << " NO-RENT";
		if (entry->GetMagic() == 1)
			out << " MAGIC";
		if (entry->GetLoreFlag())
			out << " LORE";
		else if (entry->GetSummonedFlag())
			out << " SUMMONED";
		else if (entry->GetArtifactFlag())
			out << " ARTIFACT";
		else if (entry->GetPendingLoreFlag())
			out << " PENDING-LORE";

		out << "<BR>\n";
		out << "<B>Size:</B> " << size_name(entry->GetSize()) << "<BR>\n";
		out << "<B>Slots:</B> " << print_slot(entry->GetSlots()) << "<BR>\n";
		out << "<B>Base Price:</B> " << reformatMoney(entry->GetCost())
			<< "<BR>\n";
		if (entry->GetSTR())
			out << "<B>Str:</B> " << (int)entry->GetSTR() << "<BR>\n";
		if (entry->GetSTA())
			out << "<B>Sta:</B> " << (int)entry->GetSTA() << "<BR>\n";
		if (entry->GetCHA())
			out << "<B>Cha:</B> " << (int)entry->GetCHA() << "<BR>\n";
		if (entry->GetDEX())
			out << "<B>Dex:</B> " << (int)entry->GetDEX() << "<BR>\n";
		if (entry->GetINT())
			out << "<B>Int:</B> " << (int)entry->GetINT() << "<BR>\n";
		if (entry->GetAGI())
			out << "<B>Agi:</B> " << (int)entry->GetAGI() << "<BR>\n";
		if (entry->GetWIS())
			out << "<B>Wis:</B> " << (int)entry->GetWIS() << "<BR>\n";
		if (entry->GetMR())
			out << "<B>Magic:</B> " << (int)entry->GetMR() << "<BR>\n";
		if (entry->GetFR())
			out << "<B>Fire:</B> " << (int)entry->GetFR() << "<BR>\n";
		if (entry->GetCR())
			out << "<B>Cold:</B> " << (int)entry->GetCR() << "<BR>\n";
		if (entry->GetDR())
			out << "<B>Disease:</B> " << (int)entry->GetDR() << "<BR>\n";
		if (entry->GetPR())
			out << "<B>Poison:</B> " << (int)entry->GetPR() << "<BR>\n";
		if (entry->GetHP())
			out << "<B>HP:</B> " << (int)entry->GetHP() << "<BR>\n";
		if (entry->GetMana())
			out << "<B>Mana:</B> " << (int)entry->GetMana() << "<BR>\n";
		if (entry->GetAC())
			out << "<B>AC:</B> " << (int)entry->GetAC() << "<BR>\n";
		if (entry->GetLight())
			out << "<B>Light:</B> " << (int)entry->GetLight() << "<BR>\n";
		if (entry->GetDelay())
			out << "<B>Delay:</B> " << (int)entry->GetDelay() << "<BR>\n";

		if (entry->GetDamage())
		{
			out << "<B>Damage:</B> " << (int)entry->GetDamage() << "<BR>\n";
			QString qsTemp = print_skill (entry->GetSkill());
			out << "<B>Skill:</B> ";

			if (qsTemp.find("U0x") == -1)
				out << qsTemp << "<BR>\n";
			else
				out << "Unknown (ID: " << qsTemp << ")<BR>\n";
		}

		if (entry->GetRange())
			out << "<B>Range:</B> " << (int)entry->GetRange() << "<BR>\n";

		if (entry->GetMaterial())
		{
			out << "<B>Material:</B> " << QString::number(entry->GetMaterial(), 16)
				<< " (" << print_material (entry->GetMaterial()) << ")<BR>\n";

			out << "<B>Color:</B> " << QString::number(entry->GetColor(), 16) << "<BR>\n";

			out << ((entry->GetColor())  ?
				(QString("<TABLE><TR><TD bgcolor=\"#%1\">").arg(entry->GetColor(), 6, 16)) :
			("<TABLE><TR><TD bgcolor=\"#ffffff\">"))
				<< "&nbsp;&nbsp;###&nbsp;SAMPLE&nbsp;###&nbsp;&nbsp</TD></TR></TABLE>\n";
		}
		else
			out << "<B>Material:</B> 0 (None)<BR>\n";

		if (entry->GetStackable() != -1)
			out << "<B>Stackable:</B> "
			<< ((entry->GetStackable() == 1) ? "yes" : "no?") << "<BR>\n";

		if (entry->GetEffectType() != -1)
			out << "<B>Effect Type:</B> "
			<< entry->GetEffectTypeString() << "<BR>\n";
		if (entry->GetSpellId() != ITEM_SPELLID_NOSPELL)
		{
			out << "<B>Spell Effect:</B> " << spell_name (entry->GetSpellId())
				<< "<BR>\n";
			if (entry->GetLevel())
				out << "<B>Casting Level:</B> " << (int)entry->GetLevel() << "<BR>\n";
			if (entry->GetCharges())
			{
				out << "<B>Charges:</B> ";

				if (entry->GetCharges() == -1)
					out << "Unlimited<BR>\n";
				else
					out << (int)entry->GetCharges() << "<BR>\n";
			}
			if (entry->GetCastTime())
				out << "<B>Casting Time:</B> " << (int)entry->GetCastTime()
				<< "<BR>\n";
		}
		out << "<B>Class:</B> " << print_classes (entry->GetClasses()) << "<BR>\n";
		out << "<B>Race:</B> " << print_races (entry->GetRaces()) << "<BR>\n";
		if (entry->GetSkillModId())
			out << "<B>Skill Modifier:</B> " << skill_name(entry->GetSkillModId())
			<< " " << (int)entry->GetSkillModPercent() << "% <BR>\n";
		if (entry->IsContainer())
		{
			if (entry->GetNumSlots())
				out << "<B>Container Slots:</B> " << (int)entry->GetNumSlots()
				<< "<BR>\n";
			if (entry->GetSizeCapacity())
				out << "<B>Size Capacity:</B> " << size_name(entry->GetSizeCapacity())
				<< "<BR>\n";
			if (entry->GetWeightReduction())
				out << "<B>% Weight Reduction:</B> " << (int)entry->GetWeightReduction()
				<< "<BR>\n";
		}
		out << "</P>\n";
	}

	int size = 0;

	if (displayBinaryData)
	{
		time_t updated;
		char* rawData = NULL;
		size = itemDB->GetItemRawData(currentItemNr, updated, &rawData);

		if ((size > 0) && (rawData != NULL))
		{
			out << "<P><B>Raw data: (" << size << " octets) last updated: "
				<< ctime(&updated) << "</B></P>\n";
			out << "</P>";
			out << "<PRE>\n";
			printdata (out, size, rawData);
			out << "</PRE>\n";
			delete [] rawData;
		}
	}

	if (!hasEntry && nameString.isEmpty() && loreString.isEmpty() &&
		(size == 0))
		out << "<P>Item " << currentItemNr << " not found</P>\n";

	// close the document with the footer
	out << footer;

	// delete DB entry
	delete entry;

	// shutdown the ItemDB instance
	itemDB->Shutdown();

	// delete the ItemDB instance
	delete itemDB;

	return 0;
}
Exemple #5
0
int displayRecord(EQItemDB* itemDB, 
		  uint16_t itemNr)
{
  QString nameString;
  QString loreString;
  bool hasEntry = false;
  EQItemDBEntry* entry = NULL;

  loreString = itemDB->GetItemLoreName(itemNr);
  nameString = itemDB->GetItemName(itemNr);
  hasEntry = itemDB->GetItemData(itemNr, &entry);

  printf ("Item ID: %d\n", itemNr);
 
  if (hasEntry)
    printf ("IconNr: %d\n", entry->GetIconNr());

  if (!nameString.isEmpty())
  {
    printf ("Name: %s\n", (const char*)nameString);
    printf ("Lore: %s\n", (const char*)loreString);
  }
  else
  {
    printf ("Lore: %s\n", (const char*)loreString);
  } 

  if (hasEntry)
  {
    printf ("Model: %s\n", (const char*)entry->GetIdFile());
    printf ("flag: 0x%4.4x\n", entry->GetFlag());
    printf ("MagicFlag: 0x%2.2x\n", entry->GetMagic());
    printf ("Weight: %d\n", entry->GetWeight());
    printf ("Flags: ");
    if (entry->IsBook())
      printf (" BOOK");
    if (entry->IsContainer())
      printf (" CONTAINER");
    if (entry->GetNoDrop() == 0)
      printf (" NO-DROP");
    if (entry->GetNoSave() == 0)
      printf (" NO-SAVE");
    if (entry->GetMagic() == 1)
      printf (" MAGIC");
    if (loreString[0] == '*')
      printf (" LORE");
    printf ("\n");
    printf ("Size: %s\n", (const char*)size_name(entry->GetSize()));
    printf ("Icon#: %d\n", entry->GetIconNr());
    printf ("Slots: %s\n", (const char*)print_slot (entry->GetSlots()));
    if (entry->GetNumSlots())
      printf ("Container Slots: %d\n", entry->GetNumSlots());
    printf ("Cost: %dcp\n", entry->GetCost());
    if (entry->GetSTR())
      printf ("Str: %d\n", entry->GetSTR());
    if (entry->GetSTA())
      printf ("Sta: %d\n", entry->GetSTA());
    if (entry->GetCHA())
      printf ("Cha: %d\n", entry->GetCHA());
    if (entry->GetDEX())
      printf ("Dex: %d\n", entry->GetDEX());
    if (entry->GetINT())
      printf ("Int: %d\n", entry->GetINT());
    if (entry->GetAGI())
      printf ("Agi: %d\n", entry->GetAGI());
    if (entry->GetWIS())
      printf ("Wis: %d\n", entry->GetWIS());
    if (entry->GetMR())
      printf ("Magic: %d\n", entry->GetMR());
    if (entry->GetFR())
      printf ("Fire: %d\n", entry->GetFR());
    if (entry->GetCR())
      printf ("Cold: %d\n", entry->GetCR());
    if (entry->GetDR())
      printf ("Disease: %d\n", entry->GetDR());
    if (entry->GetPR())
      printf ("Poison: %d\n", entry->GetPR());
    if (entry->GetHP())
      printf ("HP: %d\n", entry->GetHP());
    if (entry->GetMana())
      printf ("Mana: %d\n", entry->GetMana());
    if (entry->GetAC())
      printf ("AC: %d\n", entry->GetAC());
    if (entry->GetLight())
      printf ("Light: %d\n", entry->GetLight());
    if (entry->GetDelay())
      printf ("Delay: %d\n", entry->GetDelay());
    if (entry->GetDamage())
    {
      printf ("Damage: %d\n", entry->GetDamage());
      printf ("Skill: %s\n", (const char*)print_skill (entry->GetSkill()));
    }
    if (entry->GetRange())
      printf ("Range: %d\n", entry->GetRange());
    printf ("Material: 0x%2.2x (%s)\n", entry->GetMaterial(),
            (const char*)print_material (entry->GetMaterial()));
    printf("Color: 0x%8.8x\n",
           entry->GetColor());
    if (entry->GetSpellId0() != ITEM_SPELLID_NOSPELL)
      printf ("Effect1: %s\n", 
              (const char*)spell_name (entry->GetSpellId0()));
    if (entry->GetLevel())
      printf ("Casting Level: %d\n", entry->GetLevel());
    if (entry->GetCharges())
      printf ("Stack: %d\n", entry->GetCharges());
    if (entry->GetSpellId() != ITEM_SPELLID_NOSPELL)
      printf ("Effect2: %s\n", 
              (const char*)spell_name (entry->GetSpellId()));
    printf ("Class: %s\n", (const char*)print_classes (entry->GetClasses()));
    printf ("Race: %s\n", (const char*)print_races (entry->GetRaces()));
    if (entry->IsContainer())
    {
      if (entry->GetNumSlots())
        printf ("Container Slots: %d\n", entry->GetNumSlots());
      if (entry->GetSizeCapacity())
        printf ("Size Capacity: %s\n", (const char*)size_name(entry->GetSizeCapacity()));
      if (entry->GetWeightReduction())
        printf ("%% Weight Reduction: %d\n", entry->GetWeightReduction());
    }

    // don't need the entry anymore, delete it.
    delete entry;
  }

  unsigned char* rawData = NULL;
  int size = itemDB->GetItemRawData(itemNr, &rawData);

  if ((size > 0) && (rawData != NULL))
  {
    printf("Packet data: (%d octets)\n", size);
    if (size != sizeof(itemStruct))
      printf("Warning: (%d octets) != sizeof(itemStruct) (%d octets): "
	     "Data alignment is suspect!\n", 
	     size, sizeof(itemStruct));
    
    fprintData(stdout, size, rawData);

    delete [] rawData;
  }

  return 0;
}
 void print_on(outputStream* str) const {
   print_slot(str, name(), signature());
 }
void SB_SA_Util_Slot_Mgr::print(FILE *pp_f, Cb_Type pv_cb, int pv_print_type) {
    SB_SA_util_assert_ige(pv_print_type, PRINT_ALL); // sw fault
    SB_SA_util_assert_ile(pv_print_type, PRINT_FREE); // sw fault
    char la_line[200];
    const char *lp_slot_type;
    switch (pv_print_type) {
    case PRINT_ALL:
        lp_slot_type = "ALL";
        break;
    case PRINT_FREE:
        lp_slot_type = "FREE";
        break;
    case PRINT_USED:
        lp_slot_type = "USED";
        break;
    default:
        lp_slot_type = "<unknown>";
        break;
    }
    sprintf(la_line, "name=%s, type=%s, cap=%d, free=%d, used=%d, free-head=%d, free-tail=%d\n",
            ia_slotmgr_name, lp_slot_type, iv_cap, iv_free,
            iv_cap - iv_free, iv_head, iv_tail);
    pv_cb(pp_f, la_line);
    int *lp_slot;
    int lv_slot;
    switch (pv_print_type) {
    case PRINT_ALL:
        for (lv_slot = 0, lp_slot = ip_slots;
             lv_slot < iv_cap;
             lv_slot++, lp_slot++)
            print_slot(pp_f, pv_cb, lv_slot, lp_slot);
        break;
    case PRINT_FREE:
        switch (iv_alloc) {
        case ALLOC_FAST:
        case ALLOC_MIN:
            for (lv_slot = iv_head;;) {
                SB_SA_util_assert_ige(lv_slot, 0); // sw fault
                SB_SA_util_assert_ile(lv_slot, iv_cap); // sw fault
                lp_slot = &ip_slots[lv_slot];
                if (*lp_slot == SLOT_TAIL)
                    break;
                print_slot(pp_f, pv_cb, lv_slot, lp_slot);
                lv_slot = *lp_slot;
            }
            break;
        case ALLOC_FIFO:
            if (iv_head != SLOT_TAIL) {
                for (lv_slot = iv_head;;) {
                    SB_SA_util_assert_ige(lv_slot, 0); // sw fault
                    SB_SA_util_assert_ile(lv_slot, iv_cap); // sw fault
                    lp_slot = &ip_slots[lv_slot];
                    print_slot(pp_f, pv_cb, lv_slot, lp_slot);
                    lv_slot = *lp_slot;
                    if (lv_slot == SLOT_TAIL)
                        break;
                }
            }
            break;
        case ALLOC_SCAN:
            for (lv_slot = 0, lp_slot = ip_slots;
                 lv_slot < iv_cap;
                 lv_slot++, lp_slot++)
                if (*lp_slot == SLOT_FREE)
                    print_slot(pp_f, pv_cb, lv_slot, lp_slot);
            break;
        default:
            SB_SA_util_abort("invalid iv_alloc"); // sw fault
            break;
        }
        break;
    case PRINT_USED:
        for (lv_slot = 0, lp_slot = ip_slots;
             lv_slot < iv_cap;
             lv_slot++, lp_slot++)
            if (*lp_slot == SLOT_USED)
                print_slot(pp_f, pv_cb, lv_slot, lp_slot);
        break;
    }
}
Exemple #8
0
static int
print_struct(smbios_hdl_t *shp, const smbios_struct_t *sp, void *fp)
{
	smbios_info_t info;
	int hex = opt_x;
	const char *s;

	if (opt_t != -1 && opt_t != sp->smbstr_type)
		return (0); /* skip struct if type doesn't match -t */

	if (!opt_O && (sp->smbstr_type == SMB_TYPE_MEMCTL ||
	    sp->smbstr_type == SMB_TYPE_MEMMOD))
		return (0); /* skip struct if type is obsolete */

	if (g_hdr++ == 0 || !opt_s)
		oprintf(fp, "%-5s %-4s %s\n", "ID", "SIZE", "TYPE");

	oprintf(fp, "%-5u %-4lu",
	    (uint_t)sp->smbstr_id, (ulong_t)sp->smbstr_size);

	if ((s = smbios_type_name(sp->smbstr_type)) != NULL)
		oprintf(fp, " %s (type %u)", s, sp->smbstr_type);
	else if (sp->smbstr_type > SMB_TYPE_OEM_LO &&
	    sp->smbstr_type < SMB_TYPE_OEM_HI)
		oprintf(fp, " %s+%u (type %u)", "SMB_TYPE_OEM_LO",
		    sp->smbstr_type - SMB_TYPE_OEM_LO, sp->smbstr_type);
	else
		oprintf(fp, " %u", sp->smbstr_type);

	if ((s = smbios_type_desc(sp->smbstr_type)) != NULL)
		oprintf(fp, " (%s)\n", s);
	else
		oprintf(fp, "\n");

	if (opt_s)
		return (0); /* only print header line if -s specified */

	if (smbios_info_common(shp, sp->smbstr_id, &info) == 0) {
		oprintf(fp, "\n");
		print_common(&info, fp);
	}

	switch (sp->smbstr_type) {
	case SMB_TYPE_BIOS:
		oprintf(fp, "\n");
		print_bios(shp, fp);
		break;
	case SMB_TYPE_SYSTEM:
		oprintf(fp, "\n");
		print_system(shp, fp);
		break;
	case SMB_TYPE_BASEBOARD:
		oprintf(fp, "\n");
		print_bboard(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_CHASSIS:
		oprintf(fp, "\n");
		print_chassis(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_PROCESSOR:
		oprintf(fp, "\n");
		print_processor(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_CACHE:
		oprintf(fp, "\n");
		print_cache(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_PORT:
		oprintf(fp, "\n");
		print_port(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_SLOT:
		oprintf(fp, "\n");
		print_slot(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_OBDEVS:
		oprintf(fp, "\n");
		print_obdevs(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_OEMSTR:
	case SMB_TYPE_SYSCONFSTR:
		oprintf(fp, "\n");
		print_strtab(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_LANG:
		oprintf(fp, "\n");
		print_lang(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_EVENTLOG:
		oprintf(fp, "\n");
		print_evlog(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_MEMARRAY:
		oprintf(fp, "\n");
		print_memarray(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_MEMDEVICE:
		oprintf(fp, "\n");
		print_memdevice(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_MEMARRAYMAP:
		oprintf(fp, "\n");
		print_memarrmap(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_MEMDEVICEMAP:
		oprintf(fp, "\n");
		print_memdevmap(shp, sp->smbstr_id, fp);
		break;
	case SMB_TYPE_SECURITY:
		oprintf(fp, "\n");
		print_hwsec(shp, fp);
		break;
	case SMB_TYPE_BOOT:
		oprintf(fp, "\n");
		print_boot(shp, fp);
		break;
	case SMB_TYPE_IPMIDEV:
		oprintf(fp, "\n");
		print_ipmi(shp, fp);
		break;
	case SMB_TYPE_OBDEVEXT:
		oprintf(fp, "\n");
		print_obdevs_ext(shp, sp->smbstr_id, fp);
		break;
	case SUN_OEM_EXT_PROCESSOR:
		oprintf(fp, "\n");
		print_extprocessor(shp, sp->smbstr_id, fp);
		break;
	case SUN_OEM_EXT_PORT:
		oprintf(fp, "\n");
		print_extport(shp, sp->smbstr_id, fp);
		break;
	case SUN_OEM_PCIEXRC:
		oprintf(fp, "\n");
		print_pciexrc(shp, sp->smbstr_id, fp);
		break;
	case SUN_OEM_EXT_MEMARRAY:
		oprintf(fp, "\n");
		print_extmemarray(shp, sp->smbstr_id, fp);
		break;
	case SUN_OEM_EXT_MEMDEVICE:
		oprintf(fp, "\n");
		print_extmemdevice(shp, sp->smbstr_id, fp);
		break;
	default:
		hex++;
	}

	if (hex)
		print_bytes(sp->smbstr_data, sp->smbstr_size, fp);
	else
		oprintf(fp, "\n");

	return (0);
}