Cryptography Reference
In-Depth Information
if (!s)
{
return -1;
}
else
{
return 0;
}
}
1 ,
while it returns 0 if the operation is successful. It is implemented as a template ,so
that it can be used with both ofstream objects and fstream objects. The function
read_ind_ushort() is created as its counterpart:
The function write_ind_ushort() returns in the case of error the value
template <class T>
int read_ind_ushort (T& s, clint *dest)
{
UCHAR buff[sizeof(clint)];
unsigned i;
s.read (buff, sizeof(clint));
if (!s)
{
return -1;
}
else
{
*dest = 0;
for (i = 0; i < sizeof(clint); i++)
{
*dest |= ((clint)buff[i]) << (i << 3);
}
return 0;
}
}
The output operators now use this neutral format to write from a LINT object
to a file. To elucidate the situation we shall present the implementation of the
operator for the class ofstream .
ofstream& operator<< (ofstream& s, const LINT& ln)
{
if (ln.status == E_LINT_INV)
LINT::panic (E_LINT_VAL, "ofstream operator<<", 0, __LINE__);
Search WWH ::




Custom Search