Completed code migration from LLViewerWearable to LLWearable.

This commit is contained in:
Shyotl
2013-01-05 00:33:55 -06:00
parent bea4bc6a1a
commit 5cf091b8b2
16 changed files with 1252 additions and 1242 deletions

View File

@@ -87,15 +87,13 @@ U32 LLSaleInfo::getCRC32() const
BOOL LLSaleInfo::exportFile(LLFILE* fp) const
{
fprintf(fp, "\tsale_info\t0\n\t{\n");
fprintf(fp, "\t\tsale_type\t%s\n", lookup(mSaleType));
fprintf(fp, "\t\tsale_price\t%d\n", mSalePrice);
fprintf(fp,"\t}\n");
return TRUE;
llofstream ofs(fp);
return exportStream(ofs);
}
BOOL LLSaleInfo::exportLegacyStream(std::ostream& output_stream) const
BOOL LLSaleInfo::exportStream(std::ostream& output_stream) const
{
if (!output_stream.good()) return FALSE;
output_stream << "\tsale_info\t0\n\t{\n";
output_stream << "\t\tsale_type\t" << lookup(mSaleType) << "\n";
output_stream << "\t\tsale_price\t" << mSalePrice << "\n";
@@ -140,80 +138,39 @@ bool LLSaleInfo::fromLLSD(const LLSD& sd, BOOL& has_perm_mask, U32& perm_mask)
BOOL LLSaleInfo::importFile(LLFILE* fp, BOOL& has_perm_mask, U32& perm_mask)
{
has_perm_mask = FALSE;
// *NOTE: Changing the buffer size will require changing the scanf
// calls below.
char buffer[MAX_STRING]; /* Flawfinder: ignore */
char keyword[MAX_STRING]; /* Flawfinder: ignore */
char valuestr[MAX_STRING]; /* Flawfinder: ignore */
BOOL success = TRUE;
keyword[0] = '\0';
valuestr[0] = '\0';
while(success && (!feof(fp)))
{
if (fgets(buffer, MAX_STRING, fp) == NULL)
{
buffer[0] = '\0';
}
sscanf( /* Flawfinder: ignore */
buffer,
" %254s %254s",
keyword, valuestr);
if(!keyword[0])
{
continue;
}
if(0 == strcmp("{",keyword))
{
continue;
}
if(0 == strcmp("}", keyword))
{
break;
}
else if(0 == strcmp("sale_type", keyword))
{
mSaleType = lookup(valuestr);
}
else if(0 == strcmp("sale_price", keyword))
{
sscanf(valuestr, "%d", &mSalePrice);
mSalePrice = llclamp(mSalePrice, 0, S32_MAX);
}
else if (!strcmp("perm_mask", keyword))
{
//llinfos << "found deprecated keyword perm_mask" << llendl;
has_perm_mask = TRUE;
sscanf(valuestr, "%x", &perm_mask);
}
else
{
llwarns << "unknown keyword '" << keyword
<< "' in sale info import" << llendl;
}
}
return success;
llifstream ifs(fp);
return importStream(ifs, has_perm_mask, perm_mask);
}
BOOL LLSaleInfo::importLegacyStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask)
BOOL LLSaleInfo::importStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask)
{
has_perm_mask = FALSE;
const S32 BUFSIZE = 16384;
// *NOTE: Changing the buffer size will require changing the scanf
// calls below.
char buffer[MAX_STRING]; /* Flawfinder: ignore */
char keyword[MAX_STRING]; /* Flawfinder: ignore */
char valuestr[MAX_STRING]; /* Flawfinder: ignore */
BOOL success = TRUE;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
char keyword[255]; /* Flawfinder: ignore */
char valuestr[255]; /* Flawfinder: ignore */
keyword[0] = '\0';
valuestr[0] = '\0';
while(success && input_stream.good())
while(input_stream.good())
{
input_stream.getline(buffer, MAX_STRING);
if (input_stream.eof())
{
llwarns << "Bad sale info: early end of input stream"
<< llendl;
return FALSE;
}
if (input_stream.fail())
{
llwarns << "Bad sale info: failed to read from input stream"
<< llendl;
return FALSE;
}
sscanf( /* Flawfinder: ignore */
buffer,
" %254s %254s",
@@ -251,7 +208,7 @@ BOOL LLSaleInfo::importLegacyStream(std::istream& input_stream, BOOL& has_perm_m
<< "' in sale info import" << llendl;
}
}
return success;
return TRUE;
}
void LLSaleInfo::setSalePrice(S32 price)