summaryrefslogtreecommitdiff
path: root/indra/llinventory/llsaleinfo.cpp
diff options
context:
space:
mode:
authorprep <prep@lindenlab.com>2013-03-11 18:02:16 -0400
committerprep <prep@lindenlab.com>2013-03-11 18:02:16 -0400
commit46ab23c94be164cb174a97bde11cc38067f9edd0 (patch)
treee671f5a9c9800a871500532eaba55ce26df5e6ad /indra/llinventory/llsaleinfo.cpp
parent9ea6a96be9a5fda489d5e5ce28fc2df7c6f4c309 (diff)
llinventory merge fixes
Diffstat (limited to 'indra/llinventory/llsaleinfo.cpp')
-rw-r--r--indra/llinventory/llsaleinfo.cpp95
1 files changed, 69 insertions, 26 deletions
diff --git a/indra/llinventory/llsaleinfo.cpp b/indra/llinventory/llsaleinfo.cpp
index a829667933..dd408a8efe 100644
--- a/indra/llinventory/llsaleinfo.cpp
+++ b/indra/llinventory/llsaleinfo.cpp
@@ -81,13 +81,15 @@ U32 LLSaleInfo::getCRC32() const
BOOL LLSaleInfo::exportFile(LLFILE* fp) const
{
- llofstream ofs(fp);
- return exportStream(ofs);
+ 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;
}
-BOOL LLSaleInfo::exportStream(std::ostream& output_stream) const
+BOOL LLSaleInfo::exportLegacyStream(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";
@@ -132,39 +134,80 @@ 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)
{
- llifstream ifs(fp);
- return importStream(ifs, has_perm_mask, 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[BUFSIZE]; /* Flawfinder: ignore */
- char keyword[255]; /* Flawfinder: ignore */
- char valuestr[255]; /* Flawfinder: ignore */
+ 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(input_stream.good())
+ while(success && (!feof(fp)))
{
- input_stream.getline(buffer, MAX_STRING);
- if (input_stream.eof())
+ if (fgets(buffer, MAX_STRING, fp) == NULL)
+ {
+ buffer[0] = '\0';
+ }
+
+ sscanf( /* Flawfinder: ignore */
+ buffer,
+ " %254s %254s",
+ keyword, valuestr);
+ if(!keyword[0])
{
- llwarns << "Bad sale info: early end of input stream"
- << llendl;
- return FALSE;
+ continue;
+ }
+ if(0 == strcmp("{",keyword))
+ {
+ continue;
+ }
+ if(0 == strcmp("}", keyword))
+ {
+ break;
}
- if (input_stream.fail())
+ else if(0 == strcmp("sale_type", keyword))
{
- llwarns << "Bad sale info: failed to read from input stream"
- << llendl;
- return FALSE;
+ 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;
+}
+
+BOOL LLSaleInfo::importLegacyStream(std::istream& input_stream, 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 && input_stream.good())
+ {
+ input_stream.getline(buffer, MAX_STRING);
sscanf( /* Flawfinder: ignore */
buffer,
" %254s %254s",
@@ -202,7 +245,7 @@ BOOL LLSaleInfo::importStream(std::istream& input_stream, BOOL& has_perm_mask, U
<< "' in sale info import" << llendl;
}
}
- return TRUE;
+ return success;
}
void LLSaleInfo::setSalePrice(S32 price)