fixed spelling issue and changed casting from C-style to new C++ style
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1572 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// File: TranslatorRoster.cpp
|
// File: TranslatorRoster.cpp
|
||||||
// Class: BTranslatorRoster
|
// Class: BTranslatorRoster
|
||||||
// Reimplimented by: Michael Wilber, Translation Kit Team
|
// Reimplemented by: Michael Wilber, Translation Kit Team
|
||||||
// Reimplimentation: 2002-06-11
|
// Reimplementation: 2002-06-11
|
||||||
//
|
//
|
||||||
// Description: This class is the guts of the translation kit, it makes the
|
// Description: This class is the guts of the translation kit, it makes the
|
||||||
// whole thing happen. It bridges the applications using this
|
// whole thing happen. It bridges the applications using this
|
||||||
@@ -652,9 +652,13 @@ BTranslatorRoster::Identify(BPositionIO *inSource,
|
|||||||
static int
|
static int
|
||||||
compare_data(const void *a, const void *b)
|
compare_data(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
register translator_info *ai = (translator_info *)a;
|
register const translator_info *ai =
|
||||||
register translator_info *bi = (translator_info *)b;
|
reinterpret_cast<const translator_info *> (a);
|
||||||
return (int) (- ai->quality * ai->capability +
|
|
||||||
|
register const translator_info *bi =
|
||||||
|
reinterpret_cast<const translator_info *> (b);
|
||||||
|
|
||||||
|
return static_cast<int> (- ai->quality * ai->capability +
|
||||||
bi->quality * bi->capability);
|
bi->quality * bi->capability);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1316,7 +1320,7 @@ BTranslatorRoster::LoadTranslator(const char *path)
|
|||||||
name++;
|
name++;
|
||||||
else
|
else
|
||||||
name = path;
|
name = path;
|
||||||
for (translator_node *i = fpTranslators; i; i=i->next)
|
for (translator_node *i = fpTranslators; i; i = i->next)
|
||||||
if (!strcmp(name, i->translator->TranslatorName()))
|
if (!strcmp(name, i->translator->TranslatorName()))
|
||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
// we use name for determining whether it's loaded
|
// we use name for determining whether it's loaded
|
||||||
@@ -1329,10 +1333,10 @@ BTranslatorRoster::LoadTranslator(const char *path)
|
|||||||
return image;
|
return image;
|
||||||
|
|
||||||
// Function pointer used to create post R4.5 style translators
|
// Function pointer used to create post R4.5 style translators
|
||||||
BTranslator *(*pMakeNthTranslator)(int32 n,image_id you,uint32 flags,...);
|
BTranslator *(*pMakeNthTranslator)(int32 n, image_id you, uint32 flags, ...);
|
||||||
|
|
||||||
status_t err = get_image_symbol(image, "make_nth_translator",
|
status_t err = get_image_symbol(image, "make_nth_translator",
|
||||||
B_SYMBOL_TYPE_TEXT, (void **)&pMakeNthTranslator);
|
B_SYMBOL_TYPE_TEXT, reinterpret_cast<void **> (&pMakeNthTranslator));
|
||||||
if (!err) {
|
if (!err) {
|
||||||
// If the translator add-on supports the post R4.5
|
// If the translator add-on supports the post R4.5
|
||||||
// translator creation mechanism
|
// translator creation mechanism
|
||||||
@@ -1349,54 +1353,78 @@ BTranslatorRoster::LoadTranslator(const char *path)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// If the translator add-on is in the R4.0 / R4.5 format
|
// If the translator add-on is in the R4.0 / R4.5 format
|
||||||
translator_data trandata;
|
translator_data trand;
|
||||||
trandata.translatorName = NULL;
|
trand.translatorName = NULL;
|
||||||
trandata.translatorInfo = NULL;
|
trand.translatorInfo = NULL;
|
||||||
trandata.translatorVersion = 0;
|
trand.translatorVersion = 0;
|
||||||
trandata.inputFormats = NULL;
|
trand.inputFormats = NULL;
|
||||||
trandata.outputFormats = NULL;
|
trand.outputFormats = NULL;
|
||||||
trandata.Identify = NULL;
|
trand.Identify = NULL;
|
||||||
trandata.Translate = NULL;
|
trand.Translate = NULL;
|
||||||
trandata.MakeConfig = NULL;
|
trand.MakeConfig = NULL;
|
||||||
trandata.GetConfigMessage = NULL;
|
trand.GetConfigMessage = NULL;
|
||||||
|
|
||||||
|
char *name = NULL, *info = NULL;
|
||||||
|
translation_format *ins = NULL, *outs = NULL;
|
||||||
|
|
||||||
// find all the symbols
|
// find all the symbols
|
||||||
err = get_image_symbol(image, "translatorName", B_SYMBOL_TYPE_DATA,
|
err = get_image_symbol(image, "translatorName", B_SYMBOL_TYPE_DATA,
|
||||||
(void **)&trandata.translatorName);
|
reinterpret_cast<void **> (&name));
|
||||||
if (!err && get_image_symbol(image, "translatorInfo",
|
if (err)
|
||||||
B_SYMBOL_TYPE_DATA, (void **)&trandata.translatorInfo))
|
name = NULL;
|
||||||
trandata.translatorInfo = NULL;
|
else if (!err && get_image_symbol(image, "translatorInfo",
|
||||||
long * vptr = NULL;
|
B_SYMBOL_TYPE_DATA, reinterpret_cast<void **> (&info)))
|
||||||
if (!err)
|
info = NULL;
|
||||||
|
|
||||||
|
int32 *pn = NULL;
|
||||||
|
if (!err) {
|
||||||
err = get_image_symbol(image, "translatorVersion",
|
err = get_image_symbol(image, "translatorVersion",
|
||||||
B_SYMBOL_TYPE_DATA, (void **)&vptr);
|
B_SYMBOL_TYPE_DATA, reinterpret_cast<void **> (&pn));
|
||||||
if (!err && (vptr != NULL))
|
if (!err && (pn != NULL))
|
||||||
trandata.translatorVersion = *vptr;
|
trand.translatorVersion = *pn;
|
||||||
|
}
|
||||||
|
|
||||||
if (!err && get_image_symbol(image, "inputFormats",
|
if (!err && get_image_symbol(image, "inputFormats",
|
||||||
B_SYMBOL_TYPE_DATA, (void **)&trandata.inputFormats))
|
B_SYMBOL_TYPE_DATA,
|
||||||
trandata.inputFormats = NULL;
|
reinterpret_cast<void **> (&ins)))
|
||||||
|
ins = NULL;
|
||||||
|
|
||||||
if (!err && get_image_symbol(image, "outputFormats",
|
if (!err && get_image_symbol(image, "outputFormats",
|
||||||
B_SYMBOL_TYPE_DATA, (void **)&trandata.outputFormats))
|
B_SYMBOL_TYPE_DATA,
|
||||||
trandata.outputFormats = NULL;
|
reinterpret_cast<void **> (&outs)))
|
||||||
|
outs = NULL;
|
||||||
|
|
||||||
if (!err)
|
if (!err)
|
||||||
err = get_image_symbol(image, "Identify", B_SYMBOL_TYPE_TEXT,
|
err = get_image_symbol(image, "Identify",
|
||||||
(void **)&trandata.Identify);
|
B_SYMBOL_TYPE_TEXT,
|
||||||
|
reinterpret_cast<void **> (&trand.Identify));
|
||||||
|
|
||||||
if (!err)
|
if (!err)
|
||||||
err = get_image_symbol(image, "Translate",
|
err = get_image_symbol(image, "Translate",
|
||||||
B_SYMBOL_TYPE_TEXT, (void **)&trandata.Translate);
|
B_SYMBOL_TYPE_TEXT,
|
||||||
|
reinterpret_cast<void **> (&trand.Translate));
|
||||||
|
|
||||||
if (!err && get_image_symbol(image, "MakeConfig",
|
if (!err && get_image_symbol(image, "MakeConfig",
|
||||||
B_SYMBOL_TYPE_TEXT, (void **)&trandata.MakeConfig))
|
B_SYMBOL_TYPE_TEXT,
|
||||||
trandata.MakeConfig = NULL;
|
reinterpret_cast<void **> (&trand.MakeConfig)))
|
||||||
|
trand.MakeConfig = NULL;
|
||||||
|
|
||||||
if (!err && get_image_symbol(image, "GetConfigMessage",
|
if (!err && get_image_symbol(image, "GetConfigMessage",
|
||||||
B_SYMBOL_TYPE_TEXT, (void **)&trandata.GetConfigMessage))
|
B_SYMBOL_TYPE_TEXT,
|
||||||
trandata.GetConfigMessage = NULL;
|
reinterpret_cast<void **> (&trand.GetConfigMessage)))
|
||||||
|
trand.GetConfigMessage = NULL;
|
||||||
|
|
||||||
|
trand.translatorName = name;
|
||||||
|
trand.translatorInfo = info;
|
||||||
|
trand.inputFormats = ins;
|
||||||
|
trand.outputFormats = outs;
|
||||||
|
|
||||||
// if add-on is not in the correct format, return with error
|
// if add-on is not in the correct format, return with error
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
// add this translator to the list
|
// add this translator to the list
|
||||||
BR4xTranslator *pR4xTran = new BR4xTranslator(&trandata);
|
BR4xTranslator *pR4xTran = new BR4xTranslator(&trand);
|
||||||
AddTranslatorToList(pR4xTran, path, image, false);
|
AddTranslatorToList(pR4xTran, path, image, false);
|
||||||
// do not call Acquire() on ptran because I want it to be
|
// do not call Acquire() on ptran because I want it to be
|
||||||
// deleted the first time Release() is called on it.
|
// deleted the first time Release() is called on it.
|
||||||
|
|||||||
Reference in New Issue
Block a user