void dump_translation_formats(BString &bstr, const translation_format *pfmts, int32 nfmts) { BString *str1 = NULL; for (int i = 0; i < nfmts; i++) { BString string = B_TRANSLATE("\nType: '%1' (%2)\n" "Group: '%3' (%4)\n" "Quality: %5\n" "Capability: %6\n" "MIME Type: %7\n" "Name: %8\n"); string.ReplaceFirst("%1", char_format(pfmts[i].type)); string.ReplaceFirst("%2", hex_format(pfmts[i].type)); string.ReplaceFirst("%3", char_format(pfmts[i].group)); string.ReplaceFirst("%4", hex_format(pfmts[i].group)); char str2[127] = { 0 }; sprintf(str2, "%f", pfmts[i].quality); string.ReplaceFirst("%5", str2 ); str2[0] = '\0'; sprintf(str2, "%f", pfmts[i].capability); string.ReplaceFirst("%6", str2 ); string.ReplaceFirst("%7", pfmts[i].MIME); string.ReplaceFirst("%8", pfmts[i].name); if (i == 0) str1 = new BString(string); else str1->Append(string); } bstr = str1->String(); }
void dump_translation_formats(BString &bstr, const translation_format *pfmts, int32 nfmts) { for (int i = 0; i < nfmts; i++) { bstr << "\nType: '" << char_format(pfmts[i].type) << "' (" << hex_format(pfmts[i].type) << ")\n"; bstr << "Group: '" << char_format(pfmts[i].group) << "' (" << hex_format(pfmts[i].group) << ")\n"; bstr << "Quality: " << pfmts[i].quality << "\n"; bstr << "Capability: " << pfmts[i].capability << "\n"; bstr << "MIME Type: " << pfmts[i].MIME << "\n"; bstr << "Name: " << pfmts[i].name << "\n"; } }
char * scanner_format(struct t_scanner *scanner) { char buf[SCRATCH_BUF_SIZE + 1]; int len; char *toobig = "<#scanner: TOO_BIG>"; int allocsize; char *source; struct t_char *current; struct t_char blank; if (scanner->current) { current = scanner->current; } else { memset(&blank, 0, sizeof(struct t_char)); current = ␣ } len = snprintf(buf, SCRATCH_BUF_SIZE, "<#scanner: {c: %s, token: %s, debug: %d, token_count: %d, pushback_size: %d, error: %d}>", char_format(scanner->current), token_format(scanner->token), scanner->debug, list_size(&scanner->t_list), list_size(&scanner->t_pushback), scanner->error); if (len > SCRATCH_BUF_SIZE) { allocsize = strlen(toobig) + 1; source = toobig; } else { allocsize = len + 1; source = buf; } if (scanner->formatbuf) free(scanner->formatbuf); scanner->formatbuf = malloc(sizeof(char) * allocsize); strcpy(scanner->formatbuf, buf); return scanner->formatbuf; }
// Send information about the currently open image to the // BApplication object so it can send it to the InfoWindow void ImageView::UpdateInfoWindow(const BPath &path, BMessage &ioExtension, const translator_info &tinfo, BTranslatorRoster *proster) { BMessage msg(M_INFO_WINDOW_TEXT); BString bstr; bstr = B_TRANSLATE("Image: %1\n" "Color Space: %2 (%3)\n" "Dimensions: %4 x %5\n" "Bytes per Row: %6\n" "Total Bytes: %7\n" "\nIdentify Info:\n" "ID String: %8\n" "MIME Type: %9\n" "Type: '%10' (%11)\n" "Translator ID: %12\n" "Group: '%13' (%14)\n" "Quality: %15\n" "Capability: %16\n" "\nExtension Info:\n"); bstr.ReplaceFirst("%1", path.Path()); color_space cs = fpbitmap->ColorSpace(); bstr.ReplaceFirst("%2", get_color_space_name(cs)); bstr.ReplaceFirst("%3", hex_format(static_cast<uint32>(cs))); char str2[127] = { 0 }; sprintf(str2, "%ld", fpbitmap->Bounds().IntegerWidth() + 1); bstr.ReplaceFirst("%4", str2); str2[0] = '\0'; sprintf(str2, "%ld", fpbitmap->Bounds().IntegerHeight() + 1); bstr.ReplaceFirst("%5", str2); str2[0] = '\0'; sprintf(str2, "%ld", fpbitmap->BytesPerRow()); bstr.ReplaceFirst("%6", str2); str2[0] = '\0'; sprintf(str2, "%ld", fpbitmap->BitsLength()); bstr.ReplaceFirst("%7", str2); bstr.ReplaceFirst("%8", tinfo.name); bstr.ReplaceFirst("%9", tinfo.MIME); bstr.ReplaceFirst("%10", char_format(tinfo.type)); bstr.ReplaceFirst("%11", hex_format(tinfo.type)); str2[0] = '\0'; sprintf(str2, "%ld", tinfo.translator); bstr.ReplaceFirst("%12", str2); bstr.ReplaceFirst("%13", char_format(tinfo.group)); bstr.ReplaceFirst("%14", hex_format(tinfo.group)); str2[0] = '\0'; sprintf(str2, "%f", tinfo.quality); bstr.ReplaceFirst("%15", str2); str2[0] = '\0'; sprintf(str2, "%f", tinfo.capability); bstr.ReplaceFirst("%16", str2); int32 document_count = 0, document_index = 0; // Translator Info const char *tranname = NULL, *traninfo = NULL; int32 tranversion = 0; if (ioExtension.FindInt32("/documentCount", &document_count) == B_OK) { BString str = B_TRANSLATE("Number of Documents: %1\n" "\nTranslator Used:\n" "Name: %2\n" "Info: %3\n" "Version: %4\n"); char str2[127] = { 0 }; sprintf(str2, "%ld", document_count); str.ReplaceFirst("%1", str2); str.ReplaceFirst("%2", tranname); str.ReplaceFirst("%3", traninfo); str2[0] = '\0'; sprintf(str2, "%d", (int)tranversion); str.ReplaceFirst("%4", str2); bstr.Append(str.String()); } else if (ioExtension.FindInt32("/documentIndex", &document_index) == B_OK) { BString str = B_TRANSLATE("Selected Document: %1\n" "\nTranslator Used:\n" "Name: %2\n" "Info: %3\n" "Version: %4\n"); char str2[127] = { 0 }; sprintf(str2, "%ld", document_index); str.ReplaceFirst("%1", str2); str.ReplaceFirst("%2", tranname); str.ReplaceFirst("%3", traninfo); str2[0] = '\0'; sprintf(str2, "%d", (int)tranversion); str.ReplaceFirst("%4", str2); bstr.Append(str.String()); } else if (proster->GetTranslatorInfo(tinfo.translator, &tranname, &traninfo, &tranversion) == B_OK) { BString str = B_TRANSLATE("\nTranslator Used:\n" "Name: %1\n" "Info: %2\n" "Version: %3\n"); str.ReplaceFirst("%1", tranname); str.ReplaceFirst("%2", traninfo); char str2[127] = { 0 }; sprintf(str2, "%d", (int)tranversion); str.ReplaceFirst("%3", str2); bstr.Append(str.String()); } // Translator Input / Output Formats int32 nins = 0, nouts = 0; const translation_format *pins = NULL, *pouts = NULL; if (proster->GetInputFormats(tinfo.translator, &pins, &nins) == B_OK) { bstr << B_TRANSLATE("\nInput Formats:"); dump_translation_formats(bstr, pins, nins); pins = NULL; } if (proster->GetOutputFormats(tinfo.translator, &pouts, &nouts) == B_OK) { bstr << B_TRANSLATE("\nOutput Formats:"); dump_translation_formats(bstr, pouts, nouts); pouts = NULL; } msg.AddString("text", bstr); be_app->PostMessage(&msg); }
// Send information about the currently open image to the // BApplication object so it can send it to the InfoWindow void ImageView::UpdateInfoWindow(const BPath &path, BMessage &ioExtension, const translator_info &tinfo, BTranslatorRoster *proster) { BMessage msg(M_INFO_WINDOW_TEXT); BString bstr; // Bitmap Info bstr << "Image: " << path.Path() << "\n"; color_space cs = fpbitmap->ColorSpace(); bstr << "Color Space: " << get_color_space_name(cs) << " (" << hex_format(static_cast<uint32>(cs)) << ")\n"; bstr << "Dimensions: " << fpbitmap->Bounds().IntegerWidth() + 1 << " x " << fpbitmap->Bounds().IntegerHeight() + 1 << "\n"; bstr << "Bytes per Row: " << fpbitmap->BytesPerRow() << "\n"; bstr << "Total Bytes: " << fpbitmap->BitsLength() << "\n"; // Identify Info bstr << "\nIdentify Info:\n"; bstr << "ID String: " << tinfo.name << "\n"; bstr << "MIME Type: " << tinfo.MIME << "\n"; bstr << "Type: '" << char_format(tinfo.type) << "' (" << hex_format(tinfo.type) << ")\n"; bstr << "Translator ID: " << tinfo.translator << "\n"; bstr << "Group: '" << char_format(tinfo.group) << "' (" << hex_format(tinfo.group) << ")\n"; bstr << "Quality: " << tinfo.quality << "\n"; bstr << "Capability: " << tinfo.capability << "\n"; // Extension Info bstr << "\nExtension Info:\n"; int32 document_count = 0, document_index = 0; if (ioExtension.FindInt32("/documentCount", &document_count) == B_OK) bstr << "Number of Documents: " << document_count << "\n"; if (ioExtension.FindInt32("/documentIndex", &document_index) == B_OK) bstr << "Selected Document: " << document_index << "\n"; // Translator Info const char *tranname = NULL, *traninfo = NULL; int32 tranversion = 0; if (proster->GetTranslatorInfo(tinfo.translator, &tranname, &traninfo, &tranversion) == B_OK) { bstr << "\nTranslator Used:\n"; bstr << "Name: " << tranname << "\n"; bstr << "Info: " << traninfo << "\n"; bstr << "Version: " << tranversion << "\n"; } // Translator Input / Output Formats int32 nins = 0, nouts = 0; const translation_format *pins = NULL, *pouts = NULL; if (proster->GetInputFormats(tinfo.translator, &pins, &nins) == B_OK) { bstr << "\nInput Formats:"; dump_translation_formats(bstr, pins, nins); pins = NULL; } if (proster->GetOutputFormats(tinfo.translator, &pouts, &nouts) == B_OK) { bstr << "\nOutput Formats:"; dump_translation_formats(bstr, pouts, nouts); pouts = NULL; } msg.AddString("text", bstr); be_app->PostMessage(&msg); }