mirror of
https://github.com/SWG-Source/src.git
synced 2026-01-17 00:04:25 -05:00
WIP: Tools now generating 64 bit versions of IFF files
This commit is contained in:
@@ -113,7 +113,7 @@ Tag OutputFileHandler::convertStrToTag(
|
||||
|
||||
void OutputFileHandler::insertChunkData(
|
||||
void *data,
|
||||
int length
|
||||
int32 length
|
||||
)
|
||||
{
|
||||
outputIFF->insertChunkData(data, length);
|
||||
|
||||
@@ -33,7 +33,7 @@ public: // functions
|
||||
|
||||
void insertForm(const char *tagName);
|
||||
void insertChunk(const char *tagName);
|
||||
void insertChunkData(void *data, int length);
|
||||
void insertChunkData(void *data, int32 length);
|
||||
void exitForm(void);
|
||||
void exitChunk(void);
|
||||
|
||||
|
||||
@@ -205,32 +205,32 @@ public:
|
||||
Quaternion read_floatQuaternion(void);
|
||||
|
||||
// read arrays
|
||||
void read_int8 (int count, int8 *array);
|
||||
void read_int16 (int count, int16 *array);
|
||||
void read_int32 (int count, int32 *array);
|
||||
void read_uint8 (int count, uint8 *array);
|
||||
void read_uint16(int count, uint16 *array);
|
||||
void read_uint32(int count, uint32 *array);
|
||||
void read_char (int count, char *array);
|
||||
void read_int8 (int32 count, int8 *array);
|
||||
void read_int16 (int32 count, int16 *array);
|
||||
void read_int32 (int32 count, int32 *array);
|
||||
void read_uint8 (int32 count, uint8 *array);
|
||||
void read_uint16(int32 count, uint16 *array);
|
||||
void read_uint32(int32 count, uint32 *array);
|
||||
void read_char (int32 count, char *array);
|
||||
void read_floatVector(int count, Vector *array);
|
||||
void read_floatTransform(int count, Transform *array);
|
||||
void read_floatQuaternion(int count, Quaternion *array);
|
||||
|
||||
int8 *read_int8 (int count);
|
||||
int16 *read_int16 (int count);
|
||||
int32 *read_int32 (int count);
|
||||
uint8 *read_uint8 (int count);
|
||||
uint16 *read_uint16(int count);
|
||||
uint32 *read_uint32(int count);
|
||||
char *read_char (int count);
|
||||
int8 *read_int8 (int32 count);
|
||||
int16 *read_int16 (int32 count);
|
||||
int32 *read_int32 (int32 count);
|
||||
uint8 *read_uint8 (int32 count);
|
||||
uint16 *read_uint16(int32 count);
|
||||
uint32 *read_uint32(int32 count);
|
||||
char *read_char (int32 count);
|
||||
|
||||
void readRest_int8 (int8 *array, int numberOfElements);
|
||||
void readRest_int16 (int16 *array, int numberOfElements);
|
||||
void readRest_int32 (int32 *array, int numberOfElements);
|
||||
void readRest_uint8 (uint8 *array, int numberOfElements);
|
||||
void readRest_uint16(uint16 *array, int numberOfElements);
|
||||
void readRest_uint32(uint32 *array, int numberOfElements);
|
||||
void readRest_char (char *array, int numberOfElements);
|
||||
void readRest_int8 (int8 *array, int32 numberOfElements);
|
||||
void readRest_int16 (int16 *array, int32 numberOfElements);
|
||||
void readRest_int32 (int32 *array, int32 numberOfElements);
|
||||
void readRest_uint8 (uint8 *array, int32 numberOfElements);
|
||||
void readRest_uint16(uint16 *array, int32 numberOfElements);
|
||||
void readRest_uint32(uint32 *array, int32 numberOfElements);
|
||||
void readRest_char (char *array, int32 numberOfElements);
|
||||
|
||||
int8 *readRest_int8 (void);
|
||||
int16 *readRest_int16 (void);
|
||||
@@ -664,7 +664,7 @@ inline real Iff::read_float(void)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::read_int8(int count, int8 *array)
|
||||
inline void Iff::read_int8(int32 count, int8 *array)
|
||||
{
|
||||
read_misc(array, count * isizeof(*array));
|
||||
}
|
||||
@@ -682,7 +682,7 @@ inline void Iff::read_int8(int count, int8 *array)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::read_int16(int count, int16 *array)
|
||||
inline void Iff::read_int16(int32 count, int16 *array)
|
||||
{
|
||||
read_misc(array, count * isizeof(*array));
|
||||
}
|
||||
@@ -700,7 +700,7 @@ inline void Iff::read_int16(int count, int16 *array)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::read_int32(int count, int32 *array)
|
||||
inline void Iff::read_int32(int32 count, int32 *array)
|
||||
{
|
||||
read_misc(array, count * isizeof(*array));
|
||||
}
|
||||
@@ -718,7 +718,7 @@ inline void Iff::read_int32(int count, int32 *array)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::read_uint8(int count, uint8 *array)
|
||||
inline void Iff::read_uint8(int32 count, uint8 *array)
|
||||
{
|
||||
read_misc(array, count * isizeof(*array));
|
||||
}
|
||||
@@ -736,7 +736,7 @@ inline void Iff::read_uint8(int count, uint8 *array)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::read_uint16(int count, uint16 *array)
|
||||
inline void Iff::read_uint16(int32 count, uint16 *array)
|
||||
{
|
||||
read_misc(array, count * isizeof(*array));
|
||||
}
|
||||
@@ -754,7 +754,7 @@ inline void Iff::read_uint16(int count, uint16 *array)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::read_uint32(int count, uint32 *array)
|
||||
inline void Iff::read_uint32(int32 count, uint32 *array)
|
||||
{
|
||||
read_misc(array, count * isizeof(*array));
|
||||
}
|
||||
@@ -772,7 +772,7 @@ inline void Iff::read_uint32(int count, uint32 *array)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::read_char(int count, char *array)
|
||||
inline void Iff::read_char(int32 count, char *array)
|
||||
{
|
||||
read_misc(array, count * isizeof(*array));
|
||||
}
|
||||
@@ -792,7 +792,7 @@ inline void Iff::read_char(int count, char *array)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline int8 *Iff::read_int8(int count)
|
||||
inline int8 *Iff::read_int8(int32 count)
|
||||
{
|
||||
int8 *array = new int8[static_cast<size_t>(count)];
|
||||
read_int8(count, array);
|
||||
@@ -814,7 +814,7 @@ inline int8 *Iff::read_int8(int count)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline int16 *Iff::read_int16(int count)
|
||||
inline int16 *Iff::read_int16(int32 count)
|
||||
{
|
||||
int16 *array = new int16[static_cast<size_t>(count)];
|
||||
read_int16(count, array);
|
||||
@@ -836,7 +836,7 @@ inline int16 *Iff::read_int16(int count)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline int32 *Iff::read_int32(int count)
|
||||
inline int32 *Iff::read_int32(int32 count)
|
||||
{
|
||||
int32 *array = new int32[static_cast<size_t>(count)];
|
||||
read_int32(count, array);
|
||||
@@ -858,7 +858,7 @@ inline int32 *Iff::read_int32(int count)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline uint8 *Iff::read_uint8(int count)
|
||||
inline uint8 *Iff::read_uint8(int32 count)
|
||||
{
|
||||
uint8 *array = new uint8[static_cast<size_t>(count)];
|
||||
read_uint8(count, array);
|
||||
@@ -880,7 +880,7 @@ inline uint8 *Iff::read_uint8(int count)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline uint16 *Iff::read_uint16(int count)
|
||||
inline uint16 *Iff::read_uint16(int32 count)
|
||||
{
|
||||
uint16 *array = new uint16[static_cast<size_t>(count)];
|
||||
read_uint16(count, array);
|
||||
@@ -902,7 +902,7 @@ inline uint16 *Iff::read_uint16(int count)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline uint32 *Iff::read_uint32(int count)
|
||||
inline uint32 *Iff::read_uint32(int32 count)
|
||||
{
|
||||
uint32 *array = new uint32[static_cast<size_t>(count)];
|
||||
read_uint32(count, array);
|
||||
@@ -924,7 +924,7 @@ inline uint32 *Iff::read_uint32(int count)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline char *Iff::read_char(int count)
|
||||
inline char *Iff::read_char(int32 count)
|
||||
{
|
||||
char *array = new char[static_cast<size_t>(count)];
|
||||
read_char(count, array);
|
||||
@@ -954,10 +954,10 @@ inline char *Iff::read_char(int count)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::readRest_int8(int8 *array, int numberOfElements)
|
||||
inline void Iff::readRest_int8(int8 *array, int32 numberOfElements)
|
||||
{
|
||||
UNREF(numberOfElements);
|
||||
const int count = getChunkLengthLeft(isizeof(*array));
|
||||
const int32 count = getChunkLengthLeft(isizeof(*array));
|
||||
DEBUG_FATAL(count > numberOfElements, ("Iff::ReadRest_int8 overflow array %d/%d", count, numberOfElements));
|
||||
read_int8(count, array);
|
||||
}
|
||||
@@ -985,10 +985,10 @@ inline void Iff::readRest_int8(int8 *array, int numberOfElements)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::readRest_int16(int16 *array, int numberOfElements)
|
||||
inline void Iff::readRest_int16(int16 *array, int32 numberOfElements)
|
||||
{
|
||||
UNREF(numberOfElements);
|
||||
const int count = getChunkLengthLeft(isizeof(*array));
|
||||
const int32 count = getChunkLengthLeft(isizeof(*array));
|
||||
DEBUG_FATAL(count > numberOfElements, ("Iff::ReadRest_int8 overflow array %d/%d", count, numberOfElements));
|
||||
read_int16(count, array);
|
||||
}
|
||||
@@ -1016,10 +1016,10 @@ inline void Iff::readRest_int16(int16 *array, int numberOfElements)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::readRest_int32(int32 *array, int numberOfElements)
|
||||
inline void Iff::readRest_int32(int32 *array, int32 numberOfElements)
|
||||
{
|
||||
UNREF(numberOfElements);
|
||||
const int count = getChunkLengthLeft(isizeof(*array));
|
||||
const int32 count = getChunkLengthLeft(isizeof(*array));
|
||||
DEBUG_FATAL(count > numberOfElements, ("Iff::ReadRest_int8 overflow array %d/%d", count, numberOfElements));
|
||||
read_int32(count, array);
|
||||
}
|
||||
@@ -1047,10 +1047,10 @@ inline void Iff::readRest_int32(int32 *array, int numberOfElements)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::readRest_uint8(uint8 *array, int numberOfElements)
|
||||
inline void Iff::readRest_uint8(uint8 *array, int32 numberOfElements)
|
||||
{
|
||||
UNREF(numberOfElements);
|
||||
const int count = getChunkLengthLeft(isizeof(*array));
|
||||
const int32 count = getChunkLengthLeft(isizeof(*array));
|
||||
DEBUG_FATAL(count > numberOfElements, ("Iff::ReadRest_int8 overflow array %d/%d", count, numberOfElements));
|
||||
read_uint8(count, array);
|
||||
}
|
||||
@@ -1078,10 +1078,10 @@ inline void Iff::readRest_uint8(uint8 *array, int numberOfElements)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::readRest_uint16(uint16 *array, int numberOfElements)
|
||||
inline void Iff::readRest_uint16(uint16 *array, int32 numberOfElements)
|
||||
{
|
||||
UNREF(numberOfElements);
|
||||
const int count = getChunkLengthLeft(isizeof(*array));
|
||||
const int32 count = getChunkLengthLeft(isizeof(*array));
|
||||
DEBUG_FATAL(count > numberOfElements, ("Iff::ReadRest_int8 overflow array %d/%d", count, numberOfElements));
|
||||
read_uint16(count, array);
|
||||
}
|
||||
@@ -1109,10 +1109,10 @@ inline void Iff::readRest_uint16(uint16 *array, int numberOfElements)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::readRest_uint32(uint32 *array, int numberOfElements)
|
||||
inline void Iff::readRest_uint32(uint32 *array, int32 numberOfElements)
|
||||
{
|
||||
UNREF(numberOfElements);
|
||||
const int count = getChunkLengthLeft(isizeof(*array));
|
||||
const int32 count = getChunkLengthLeft(isizeof(*array));
|
||||
DEBUG_FATAL(count > numberOfElements, ("Iff::ReadRest_int8 overflow array %d/%d", count, numberOfElements));
|
||||
read_uint32(count, array);
|
||||
}
|
||||
@@ -1140,10 +1140,10 @@ inline void Iff::readRest_uint32(uint32 *array, int numberOfElements)
|
||||
* @see Iff::read_*()
|
||||
*/
|
||||
|
||||
inline void Iff::readRest_char(char *array, int numberOfElements)
|
||||
inline void Iff::readRest_char(char *array, int32 numberOfElements)
|
||||
{
|
||||
UNREF(numberOfElements);
|
||||
const int count = getChunkLengthLeft(isizeof(*array));
|
||||
const int32 count = getChunkLengthLeft(isizeof(*array));
|
||||
DEBUG_FATAL(count > numberOfElements, ("Iff::ReadRest_int8 overflow array %d/%d", count, numberOfElements));
|
||||
read_char(count, array);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ inline char *DuplicateString(const char *source)
|
||||
if (!source)
|
||||
return nullptr;
|
||||
|
||||
const uint length = strlen(source)+1;
|
||||
const uint32 length = strlen(source)+1;
|
||||
char *result = NON_NULL (new char[length]);
|
||||
memcpy(result, source, length);
|
||||
return result;
|
||||
@@ -208,11 +208,11 @@ inline void imemset(void *data, int value, int length)
|
||||
* @param length Number of bytes to copy
|
||||
*/
|
||||
|
||||
inline void imemcpy(void *destination, const void *source, int length)
|
||||
inline void imemcpy(void *destination, const void *source, int32 length)
|
||||
{
|
||||
DEBUG_FATAL(!destination, ("nullptr destination arg"));
|
||||
DEBUG_FATAL(!source, ("nullptr source arg"));
|
||||
memcpy(destination, source, static_cast<uint>(length));
|
||||
memcpy(destination, source, static_cast<uint32>(length));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -115,7 +115,7 @@ inline Tag ConvertStringToTag(const char *value)
|
||||
{
|
||||
Tag result = 0;
|
||||
|
||||
const int length = strlen(value);
|
||||
const uint32 length = strlen(value);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
const uint32 ch = static_cast<uint32>((i >= length) ? ' ' : value[i]);
|
||||
@@ -134,7 +134,7 @@ inline Tag ConvertStringToTag(const char *value)
|
||||
* @param value value to convert to tag format
|
||||
*/
|
||||
|
||||
inline Tag ConvertIntToTag(int value)
|
||||
inline Tag ConvertIntToTag(int32 value)
|
||||
{
|
||||
Tag result = 0;
|
||||
|
||||
@@ -142,7 +142,7 @@ inline Tag ConvertIntToTag(int value)
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
const uint digit = static_cast<uint>(static_cast<int>(value % 10));
|
||||
const uint32 digit = static_cast<uint32>(static_cast<int32>(value % 10));
|
||||
value /= 10;
|
||||
result |= (digit + '0') << (i * 8);
|
||||
}
|
||||
@@ -169,13 +169,13 @@ inline Tag ConvertIntToTag(int value)
|
||||
|
||||
inline void ConvertTagToString(Tag tag, char *buffer)
|
||||
{
|
||||
int i, j, ch;
|
||||
uint32 i, j, ch;
|
||||
|
||||
DEBUG_FATAL(!buffer, ("buffer is nullptr"));
|
||||
|
||||
for (i = 0, j = 24; i < 4; ++i, j -= 8)
|
||||
{
|
||||
ch = (static_cast<int>(tag) >> j) & 0xff; //lint !e702 // shift right of a signed quantity
|
||||
ch = (static_cast<uint32>(tag) >> j) & 0xff; //lint !e702 // shift right of a signed quantity
|
||||
if (isprint(ch))
|
||||
buffer[i] = static_cast<char>(ch);
|
||||
else
|
||||
@@ -200,15 +200,15 @@ inline void ConvertTagToString(Tag tag, char *buffer)
|
||||
* @return Integer form of tag string.
|
||||
*/
|
||||
|
||||
inline int ConvertTagSuffixToInt(Tag tag)
|
||||
inline int32 ConvertTagSuffixToInt(Tag tag)
|
||||
{
|
||||
int returnValue=0;
|
||||
int32 returnValue=0;
|
||||
for (int i=24;i>=0;i-=8)
|
||||
{
|
||||
const int c = (tag>>i) & 0xff;
|
||||
const int32 c = (tag>>i) & 0xff;
|
||||
if (c>='0' && c<='9')
|
||||
{
|
||||
returnValue = returnValue*10 + int(c) -'0';
|
||||
returnValue = returnValue*10 + int32(c) -'0';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -234,15 +234,15 @@ inline int ConvertTagSuffixToInt(Tag tag)
|
||||
* @return Integer form of tag string.
|
||||
*/
|
||||
|
||||
inline int ConvertTagToInt(Tag tag)
|
||||
inline int32 ConvertTagToInt(Tag tag)
|
||||
{
|
||||
int returnValue=0;
|
||||
int32 returnValue=0;
|
||||
for (int i=24;i>=0;i-=8)
|
||||
{
|
||||
const int c = (tag>>i) & 0xff;
|
||||
const int32 c = (tag>>i) & 0xff;
|
||||
if (c>='0' && c<='9')
|
||||
{
|
||||
returnValue = returnValue*10 + int(c) -'0';
|
||||
returnValue = returnValue*10 + int32(c) -'0';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -339,9 +339,6 @@ bool DataTableColumnType::lookupEnum(std::string const &label, int &result) cons
|
||||
result = (*i).second;
|
||||
return true;
|
||||
}
|
||||
for(std::map<std::string, uint32>::const_iterator it = m_enumMap->begin(); it != m_enumMap->end(); ++it) {
|
||||
WARNING(true,("Map Value: %s; ", it->first.c_str()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -819,13 +819,13 @@ void DataTableWriter::_saveColumns(NamedDataTable * ndt, Iff& iff) const
|
||||
{
|
||||
iff.insertChunk(TAG(C,O,L,S));
|
||||
NamedDataTable::DataTableColumnTypeVector::iterator j;
|
||||
int numCols = 0;
|
||||
int32 numCols = 0;
|
||||
for (j = ndt->m_types.begin(); j!=ndt->m_types.end(); ++j)
|
||||
{
|
||||
if ((*j)->getType() != DataTableColumnType::DT_Comment)
|
||||
++numCols;
|
||||
}
|
||||
iff.insertChunkData(&numCols, sizeof(int));
|
||||
iff.insertChunkData(&numCols, sizeof(int32));
|
||||
std::vector<std::string>::iterator i = ndt->m_columns.begin();
|
||||
j = ndt->m_types.begin();
|
||||
for (; i!= ndt->m_columns.end(); ++i, ++j)
|
||||
@@ -858,8 +858,8 @@ void DataTableWriter::_saveRows(NamedDataTable * ndt, Iff& iff) const
|
||||
{
|
||||
iff.insertChunk(TAG(R,O,W,S));
|
||||
|
||||
int numRows = static_cast<int>(ndt->m_rows.size());
|
||||
iff.insertChunkData(&numRows, sizeof(int));
|
||||
int32 numRows = static_cast<int32>(ndt->m_rows.size());
|
||||
iff.insertChunkData(&numRows, sizeof(int32));
|
||||
std::vector<NamedDataTable::DataTableRow* >::iterator i = ndt->m_rows.begin();
|
||||
for (; i!= ndt->m_rows.end(); ++i)
|
||||
{
|
||||
@@ -873,8 +873,8 @@ void DataTableWriter::_saveRows(NamedDataTable * ndt, Iff& iff) const
|
||||
{
|
||||
const DataTableCell * cell = *j;
|
||||
NOT_NULL(cell);
|
||||
int tmp = cell->getIntValue();
|
||||
iff.insertChunkData(&tmp, sizeof(int));
|
||||
int32 tmp = cell->getIntValue();
|
||||
iff.insertChunkData(&tmp, sizeof(int32));
|
||||
break;
|
||||
}
|
||||
case DataTableColumnType::DT_Float:
|
||||
|
||||
@@ -8,38 +8,38 @@ NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
byte OAEP_P_DEFAULT[1];
|
||||
|
||||
void xorbuf(byte *buf, const byte *mask, unsigned int count)
|
||||
void xorbuf(byte *buf, const byte *mask, uint32_t count)
|
||||
{
|
||||
if (((long unsigned int)buf | (long unsigned int)mask | count) % WORD_SIZE == 0)
|
||||
if (((long uint32_t)buf | (long uint32_t)mask | count) % WORD_SIZE == 0)
|
||||
XorWords((word *)buf, (const word *)mask, count/WORD_SIZE);
|
||||
else
|
||||
{
|
||||
for (unsigned int i=0; i<count; i++)
|
||||
for (uint32_t i=0; i<count; i++)
|
||||
buf[i] ^= mask[i];
|
||||
}
|
||||
}
|
||||
|
||||
void xorbuf(byte *output, const byte *input, const byte *mask, unsigned int count)
|
||||
void xorbuf(byte *output, const byte *input, const byte *mask, uint32_t count)
|
||||
{
|
||||
if (((long unsigned int)output | (long unsigned int)input | (long unsigned int)mask | count) % WORD_SIZE == 0)
|
||||
if (((long uint32_t)output | (long uint32_t)input | (long uint32_t)mask | count) % WORD_SIZE == 0)
|
||||
XorWords((word *)output, (const word *)input, (const word *)mask, count/WORD_SIZE);
|
||||
else
|
||||
{
|
||||
for (unsigned int i=0; i<count; i++)
|
||||
for (uint32_t i=0; i<count; i++)
|
||||
output[i] = input[i] ^ mask[i];
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Parity(unsigned long value)
|
||||
uint32_t Parity(unsigned long value)
|
||||
{
|
||||
for (unsigned int i=8*sizeof(value)/2; i>0; i/=2)
|
||||
for (uint32_t i=8*sizeof(value)/2; i>0; i/=2)
|
||||
value ^= value >> i;
|
||||
return (unsigned int)value&1;
|
||||
return (uint32_t)value&1;
|
||||
}
|
||||
|
||||
unsigned int BytePrecision(unsigned long value)
|
||||
uint32_t BytePrecision(unsigned long value)
|
||||
{
|
||||
unsigned int i;
|
||||
uint32_t i;
|
||||
for (i=sizeof(value); i; --i)
|
||||
if (value >> (i-1)*8)
|
||||
break;
|
||||
@@ -47,16 +47,16 @@ unsigned int BytePrecision(unsigned long value)
|
||||
return i;
|
||||
}
|
||||
|
||||
unsigned int BitPrecision(unsigned long value)
|
||||
uint32_t BitPrecision(unsigned long value)
|
||||
{
|
||||
if (!value)
|
||||
return 0;
|
||||
|
||||
unsigned int l=0, h=8*sizeof(value);
|
||||
uint32_t l=0, h=8*sizeof(value);
|
||||
|
||||
while (h-l > 1)
|
||||
{
|
||||
unsigned int t = (l+h)/2;
|
||||
uint32_t t = (l+h)/2;
|
||||
if (value >> t)
|
||||
l = t;
|
||||
else
|
||||
@@ -66,7 +66,7 @@ unsigned int BitPrecision(unsigned long value)
|
||||
return h;
|
||||
}
|
||||
|
||||
unsigned long Crop(unsigned long value, unsigned int size)
|
||||
unsigned long Crop(unsigned long value, uint32_t size)
|
||||
{
|
||||
if (size < 8*sizeof(value))
|
||||
return (value & ((1L << size) - 1));
|
||||
|
||||
@@ -15,39 +15,39 @@ NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
// ************** misc functions ***************
|
||||
|
||||
#define GETBYTE(x, y) (unsigned int)(((x)>>(8*(y)))&255)
|
||||
#define GETBYTE(x, y) (uint32_t)(((x)>>(8*(y)))&255)
|
||||
// this one may be faster on a Pentium
|
||||
// #define GETBYTE(x, y) (((byte *)&(x))[y])
|
||||
|
||||
unsigned int Parity(unsigned long);
|
||||
unsigned int BytePrecision(unsigned long);
|
||||
unsigned int BitPrecision(unsigned long);
|
||||
unsigned long Crop(unsigned long, unsigned int size);
|
||||
unsigned long Crop(unsigned long, uint32_t size);
|
||||
|
||||
inline unsigned int bitsToBytes(unsigned int bitCount)
|
||||
inline uint32_t bitsToBytes(uint32_t bitCount)
|
||||
{
|
||||
return ((bitCount+7)/(8));
|
||||
}
|
||||
|
||||
inline unsigned int bytesToWords(unsigned int byteCount)
|
||||
inline uint32_t bytesToWords(uint32_t byteCount)
|
||||
{
|
||||
return ((byteCount+WORD_SIZE-1)/WORD_SIZE);
|
||||
}
|
||||
|
||||
inline unsigned int bitsToWords(unsigned int bitCount)
|
||||
inline uint32_t bitsToWords(uint32_t bitCount)
|
||||
{
|
||||
return ((bitCount+WORD_BITS-1)/(WORD_BITS));
|
||||
}
|
||||
|
||||
void xorbuf(byte *buf, const byte *mask, unsigned int count);
|
||||
void xorbuf(byte *output, const byte *input, const byte *mask, unsigned int count);
|
||||
void xorbuf(byte *buf, const byte *mask, uint32_t count);
|
||||
void xorbuf(byte *output, const byte *input, const byte *mask, uint32_t count);
|
||||
|
||||
inline unsigned int RoundDownToMultipleOf(unsigned int n, unsigned int m)
|
||||
inline uint32_t RoundDownToMultipleOf(uint32_t n, uint32_t m)
|
||||
{
|
||||
return n - n%m;
|
||||
}
|
||||
|
||||
inline unsigned int RoundUpToMultipleOf(unsigned int n, unsigned int m)
|
||||
inline uint32_t RoundUpToMultipleOf(uint32_t n, uint32_t m)
|
||||
{
|
||||
return RoundDownToMultipleOf(n+m-1, m);
|
||||
}
|
||||
@@ -91,37 +91,37 @@ std::string IntToString(T a)
|
||||
|
||||
// ************** rotate functions ***************
|
||||
|
||||
template <class T> inline T rotlFixed(T x, unsigned int y)
|
||||
template <class T> inline T rotlFixed(T x, uint32_t y)
|
||||
{
|
||||
assert(y < sizeof(T)*8);
|
||||
return (x<<y) | (x>>(sizeof(T)*8-y));
|
||||
}
|
||||
|
||||
template <class T> inline T rotrFixed(T x, unsigned int y)
|
||||
template <class T> inline T rotrFixed(T x, uint32_t y)
|
||||
{
|
||||
assert(y < sizeof(T)*8);
|
||||
return (x>>y) | (x<<(sizeof(T)*8-y));
|
||||
}
|
||||
|
||||
template <class T> inline T rotlVariable(T x, unsigned int y)
|
||||
template <class T> inline T rotlVariable(T x, uint32_t y)
|
||||
{
|
||||
assert(y < sizeof(T)*8);
|
||||
return (x<<y) | (x>>(sizeof(T)*8-y));
|
||||
}
|
||||
|
||||
template <class T> inline T rotrVariable(T x, unsigned int y)
|
||||
template <class T> inline T rotrVariable(T x, uint32_t y)
|
||||
{
|
||||
assert(y < sizeof(T)*8);
|
||||
return (x>>y) | (x<<(sizeof(T)*8-y));
|
||||
}
|
||||
|
||||
template <class T> inline T rotlMod(T x, unsigned int y)
|
||||
template <class T> inline T rotlMod(T x, uint32_t y)
|
||||
{
|
||||
y %= sizeof(T)*8;
|
||||
return (x<<y) | (x>>(sizeof(T)*8-y));
|
||||
}
|
||||
|
||||
template <class T> inline T rotrMod(T x, unsigned int y)
|
||||
template <class T> inline T rotrMod(T x, uint32_t y)
|
||||
{
|
||||
y %= sizeof(T)*8;
|
||||
return (x>>y) | (x<<(sizeof(T)*8-y));
|
||||
@@ -129,36 +129,36 @@ template <class T> inline T rotrMod(T x, unsigned int y)
|
||||
|
||||
#ifdef INTEL_INTRINSICS
|
||||
|
||||
template<> inline word32 rotlFixed<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotlFixed<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
assert(y < 32);
|
||||
return y ? _lrotl(x, y) : x;
|
||||
}
|
||||
|
||||
template<> inline word32 rotrFixed<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotrFixed<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
assert(y < 32);
|
||||
return y ? _lrotr(x, y) : x;
|
||||
}
|
||||
|
||||
template<> inline word32 rotlVariable<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotlVariable<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
assert(y < 32);
|
||||
return _lrotl(x, y);
|
||||
}
|
||||
|
||||
template<> inline word32 rotrVariable<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotrVariable<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
assert(y < 32);
|
||||
return _lrotr(x, y);
|
||||
}
|
||||
|
||||
template<> inline word32 rotlMod<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotlMod<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
return _lrotl(x, y);
|
||||
}
|
||||
|
||||
template<> inline word32 rotrMod<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotrMod<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
return _lrotr(x, y);
|
||||
}
|
||||
@@ -167,36 +167,36 @@ template<> inline word32 rotrMod<word32>(word32 x, unsigned int y)
|
||||
|
||||
#ifdef PPC_INTRINSICS
|
||||
|
||||
template<> inline word32 rotlFixed<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotlFixed<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
assert(y < 32);
|
||||
return y ? __rlwinm(x,y,0,31) : x;
|
||||
}
|
||||
|
||||
template<> inline word32 rotrFixed<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotrFixed<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
assert(y < 32);
|
||||
return y ? __rlwinm(x,32-y,0,31) : x;
|
||||
}
|
||||
|
||||
template<> inline word32 rotlVariable<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotlVariable<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
assert(y < 32);
|
||||
return (__rlwnm(x,y,0,31));
|
||||
}
|
||||
|
||||
template<> inline word32 rotrVariable<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotrVariable<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
assert(y < 32);
|
||||
return (__rlwnm(x,32-y,0,31));
|
||||
}
|
||||
|
||||
template<> inline word32 rotlMod<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotlMod<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
return (__rlwnm(x,y,0,31));
|
||||
}
|
||||
|
||||
template<> inline word32 rotrMod<word32>(word32 x, unsigned int y)
|
||||
template<> inline word32 rotrMod<word32>(word32 x, uint32_t y)
|
||||
{
|
||||
return (__rlwnm(x,32-y,0,31));
|
||||
}
|
||||
@@ -297,17 +297,17 @@ inline T bitReverse(T value)
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void byteReverse(T *out, const T *in, unsigned int byteCount)
|
||||
void byteReverse(T *out, const T *in, uint32_t byteCount)
|
||||
{
|
||||
unsigned int count = (byteCount+sizeof(T)-1)/sizeof(T);
|
||||
for (unsigned int i=0; i<count; i++)
|
||||
uint32_t count = (byteCount+sizeof(T)-1)/sizeof(T);
|
||||
for (uint32_t i=0; i<count; i++)
|
||||
out[i] = byteReverse(in[i]);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void GetUserKeyLittleEndian(T *out, unsigned int outlen, const byte *in, unsigned int inlen)
|
||||
inline void GetUserKeyLittleEndian(T *out, uint32_t outlen, const byte *in, uint32_t inlen)
|
||||
{
|
||||
const unsigned int U = sizeof(T);
|
||||
const uint32_t U = sizeof(T);
|
||||
assert(inlen <= outlen*U);
|
||||
memcpy(out, in, inlen);
|
||||
memset((byte *)out+inlen, 0, outlen*U-inlen);
|
||||
@@ -317,9 +317,9 @@ inline void GetUserKeyLittleEndian(T *out, unsigned int outlen, const byte *in,
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void GetUserKeyBigEndian(T *out, unsigned int outlen, const byte *in, unsigned int inlen)
|
||||
inline void GetUserKeyBigEndian(T *out, uint32_t outlen, const byte *in, uint32_t inlen)
|
||||
{
|
||||
const unsigned int U = sizeof(T);
|
||||
const uint32_t U = sizeof(T);
|
||||
assert(inlen <= outlen*U);
|
||||
memcpy(out, in, inlen);
|
||||
memset((byte *)out+inlen, 0, outlen*U-inlen);
|
||||
@@ -468,23 +468,23 @@ T StringToWord(const std::string &str, bool highFirst = true)
|
||||
// ************** key length query ***************
|
||||
|
||||
/// support query of fixed key length
|
||||
template <unsigned int N>
|
||||
template <uint32_t N>
|
||||
class FixedKeyLength
|
||||
{
|
||||
public:
|
||||
enum {KEYLENGTH=N, MIN_KEYLENGTH=N, MAX_KEYLENGTH=N, DEFAULT_KEYLENGTH=N};
|
||||
/// returns the key length
|
||||
static unsigned int KeyLength(unsigned int) {return KEYLENGTH;}
|
||||
static unsigned int KeyLength(uint32_t) {return KEYLENGTH;}
|
||||
};
|
||||
|
||||
/// support query of variable key length, template parameters are default, min, max, multiple (default multiple 1)
|
||||
template <unsigned int D, unsigned int N, unsigned int M, unsigned int Q=1>
|
||||
template <uint32_t D, uint32_t N, uint32_t M, uint32_t Q=1>
|
||||
class VariableKeyLength
|
||||
{
|
||||
public:
|
||||
enum {MIN_KEYLENGTH=N, MAX_KEYLENGTH=M, DEFAULT_KEYLENGTH=D, KEYLENGTH_MULTIPLE=Q};
|
||||
/// returns the smallest valid key length in bytes that is >= min(n, MAX_KEYLENGTH)
|
||||
static unsigned int KeyLength(unsigned int n)
|
||||
static uint32_t KeyLength(uint32_t n)
|
||||
{
|
||||
assert(KEYLENGTH_MULTIPLE > 0 && MIN_KEYLENGTH % KEYLENGTH_MULTIPLE == 0 && MAX_KEYLENGTH % KEYLENGTH_MULTIPLE == 0);
|
||||
if (n < MIN_KEYLENGTH)
|
||||
@@ -503,7 +503,7 @@ class SameKeyLengthAs
|
||||
public:
|
||||
enum {MIN_KEYLENGTH=T::MIN_KEYLENGTH, MAX_KEYLENGTH=T::MAX_KEYLENGTH, DEFAULT_KEYLENGTH=T::DEFAULT_KEYLENGTH};
|
||||
/// returns the smallest valid key length in bytes that is >= min(n, MAX_KEYLENGTH)
|
||||
static unsigned int KeyLength(unsigned int keylength)
|
||||
static uint32_t KeyLength(uint32_t keylength)
|
||||
{return T::KeyLength(keylength);}
|
||||
};
|
||||
|
||||
@@ -520,11 +520,11 @@ public:
|
||||
//! a block of memory allocated using SecAlloc
|
||||
template <class T> struct SecBlock
|
||||
{
|
||||
explicit SecBlock(unsigned int size=0)
|
||||
explicit SecBlock(uint32_t size=0)
|
||||
: size(size) {ptr = SecAlloc(T, size);}
|
||||
SecBlock(const SecBlock<T> &t)
|
||||
: size(t.size) {ptr = SecAlloc(T, size); memcpy(ptr, t.ptr, size*sizeof(T));}
|
||||
SecBlock(const T *t, unsigned int len)
|
||||
SecBlock(const T *t, uint32_t len)
|
||||
: size(len) {ptr = SecAlloc(T, len); memcpy(ptr, t, len*sizeof(T));}
|
||||
~SecBlock()
|
||||
{SecFree(ptr, size);}
|
||||
@@ -551,13 +551,13 @@ template <class T> struct SecBlock
|
||||
|
||||
// CodeWarrior defines _MSC_VER
|
||||
#if !defined(_MSC_VER) || defined(__MWERKS__)
|
||||
T *operator +(unsigned int offset)
|
||||
T *operator +(uint32_t offset)
|
||||
{return ptr+offset;}
|
||||
const T *operator +(unsigned int offset) const
|
||||
const T *operator +(uint32_t offset) const
|
||||
{return ptr+offset;}
|
||||
T& operator[](unsigned int index)
|
||||
T& operator[](uint32_t index)
|
||||
{assert(index<size); return ptr[index];}
|
||||
const T& operator[](unsigned int index) const
|
||||
const T& operator[](uint32_t index) const
|
||||
{assert(index<size); return ptr[index];}
|
||||
#endif
|
||||
|
||||
@@ -572,7 +572,7 @@ template <class T> struct SecBlock
|
||||
|
||||
unsigned int Size() const {return size;}
|
||||
|
||||
void Assign(const T *t, unsigned int len)
|
||||
void Assign(const T *t, uint32_t len)
|
||||
{
|
||||
New(len);
|
||||
memcpy(ptr, t, len*sizeof(T));
|
||||
@@ -600,7 +600,7 @@ template <class T> struct SecBlock
|
||||
return !operator==(t);
|
||||
}
|
||||
|
||||
void New(unsigned int newSize)
|
||||
void New(uint32_t newSize)
|
||||
{
|
||||
if (newSize != size)
|
||||
{
|
||||
@@ -611,7 +611,7 @@ template <class T> struct SecBlock
|
||||
}
|
||||
}
|
||||
|
||||
void CleanNew(unsigned int newSize)
|
||||
void CleanNew(uint32_t newSize)
|
||||
{
|
||||
if (newSize != size)
|
||||
{
|
||||
@@ -623,7 +623,7 @@ template <class T> struct SecBlock
|
||||
memset(ptr, 0, size*sizeof(T));
|
||||
}
|
||||
|
||||
void Grow(unsigned int newSize)
|
||||
void Grow(uint32_t newSize)
|
||||
{
|
||||
if (newSize > size)
|
||||
{
|
||||
@@ -635,7 +635,7 @@ template <class T> struct SecBlock
|
||||
}
|
||||
}
|
||||
|
||||
void CleanGrow(unsigned int newSize)
|
||||
void CleanGrow(uint32_t newSize)
|
||||
{
|
||||
if (newSize > size)
|
||||
{
|
||||
@@ -648,7 +648,7 @@ template <class T> struct SecBlock
|
||||
}
|
||||
}
|
||||
|
||||
void Resize(unsigned int newSize)
|
||||
void Resize(uint32_t newSize)
|
||||
{
|
||||
if (newSize != size)
|
||||
{
|
||||
@@ -662,7 +662,7 @@ template <class T> struct SecBlock
|
||||
|
||||
void swap(SecBlock<T> &b);
|
||||
|
||||
unsigned int size;
|
||||
uint32_t size;
|
||||
T *ptr;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user