change all length agruments and return types to size_t or ssize_t
This commit is contained in:
@ -27,7 +27,7 @@ class BCDConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse (const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
bool printLong(const StreamFormat&, StreamBuffer&, long);
|
||||
long scanLong(const StreamFormat&, const char*, long&);
|
||||
ssize_t scanLong(const StreamFormat&, const char*, long&);
|
||||
};
|
||||
|
||||
int BCDConverter::
|
||||
@ -41,7 +41,7 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
unsigned char bcd;
|
||||
bool neg = false;
|
||||
long i;
|
||||
ssize_t i;
|
||||
unsigned long prec = fmt.prec < 0 ? 2 * sizeof(value) : fmt.prec; // number of nibbles
|
||||
unsigned long width = (prec + (fmt.flags & sign_flag ? 2 : 1)) / 2;
|
||||
if (fmt.width > width) width = fmt.width;
|
||||
@ -73,7 +73,7 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
{
|
||||
// most significant byte first (big endian)
|
||||
output.append('\0', width);
|
||||
if (neg) output[-width] |= 0xf0;
|
||||
if (neg) output[-(long)width] |= 0xf0;
|
||||
i = 0;
|
||||
while (width-- && prec)
|
||||
{
|
||||
@ -91,10 +91,10 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
return true;
|
||||
}
|
||||
|
||||
long BCDConverter::
|
||||
ssize_t BCDConverter::
|
||||
scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
{
|
||||
long length = 0;
|
||||
ssize_t consumed = 0;
|
||||
long val = 0;
|
||||
unsigned char bcd1, bcd10;
|
||||
long width = fmt.width;
|
||||
@ -105,7 +105,7 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
int shift = 1;
|
||||
while (width--)
|
||||
{
|
||||
bcd1 = bcd10 = (unsigned char) input[length++];
|
||||
bcd1 = bcd10 = input[consumed++];
|
||||
bcd1 &= 0x0F;
|
||||
bcd10 >>= 4;
|
||||
if (bcd1 > 9 || shift * bcd1 < bcd1) break;
|
||||
@ -128,10 +128,10 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
while (width--)
|
||||
{
|
||||
long temp;
|
||||
bcd1 = bcd10 = (unsigned char) input[length];
|
||||
bcd1 = bcd10 = input[consumed];
|
||||
bcd1 &= 0x0F;
|
||||
bcd10 >>= 4;
|
||||
if (length == 0 && fmt.flags & sign_flag && bcd10)
|
||||
if (consumed == 0 && fmt.flags & sign_flag && bcd10)
|
||||
{
|
||||
sign = -1;
|
||||
bcd10 = 0;
|
||||
@ -140,17 +140,17 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
temp = val * 100 + (bcd1 + 10 * bcd10);
|
||||
if (temp < val)
|
||||
{
|
||||
length = 0;
|
||||
consumed = 0;
|
||||
break;
|
||||
}
|
||||
val = temp;
|
||||
length++;
|
||||
consumed++;
|
||||
}
|
||||
val *= sign;
|
||||
}
|
||||
if (length == 0) return -1;
|
||||
if (consumed == 0) return -1;
|
||||
value = val;
|
||||
return length;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
RegisterConverter (BCDConverter, "D");
|
||||
|
@ -29,7 +29,7 @@ class BinaryConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
bool printLong(const StreamFormat&, StreamBuffer&, long);
|
||||
long scanLong(const StreamFormat&, const char*, long&);
|
||||
ssize_t scanLong(const StreamFormat&, const char*, long&);
|
||||
};
|
||||
|
||||
int BinaryConverter::
|
||||
@ -42,7 +42,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
info.append("01");
|
||||
return unsigned_format;
|
||||
}
|
||||
|
||||
|
||||
// user defined characters for %B (next 2 in source)
|
||||
if (*source)
|
||||
{
|
||||
@ -70,7 +70,7 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
prec = 32;
|
||||
#if (LONG_BIT > 32)
|
||||
if (x > 0xFFFFFFFF) { prec = 64; x >>=32; }
|
||||
#endif
|
||||
#endif
|
||||
if (x <= 0x0000FFFF) { prec -= 16; x <<=16; }
|
||||
if (x <= 0x00FFFFFF) { prec -= 8; x <<=8; }
|
||||
if (x <= 0x0FFFFFFF) { prec -= 4; x <<=4; }
|
||||
@ -132,39 +132,39 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
return true;
|
||||
}
|
||||
|
||||
long BinaryConverter::
|
||||
ssize_t BinaryConverter::
|
||||
scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
{
|
||||
long val = 0;
|
||||
long width = fmt.width;
|
||||
if (width == 0) width = -1;
|
||||
long length = 0;
|
||||
size_t consumed = 0;
|
||||
char zero = fmt.info[0];
|
||||
char one = fmt.info[1];
|
||||
if (!isspace(zero) && !isspace(one))
|
||||
while (isspace(input[length])) length++; // skip whitespaces
|
||||
if (input[length] != zero && input[length] != one) return -1;
|
||||
while (isspace(input[consumed])) consumed++; // skip whitespaces
|
||||
if (input[consumed] != zero && input[consumed] != one) return -1;
|
||||
if (fmt.flags & alt_flag)
|
||||
{
|
||||
// little endian (least significan bit first)
|
||||
long mask = 1;
|
||||
while (width-- && (input[length] == zero || input[length] == one))
|
||||
while (width-- && (input[consumed] == zero || input[consumed] == one))
|
||||
{
|
||||
if (input[length++] == one) val |= mask;
|
||||
if (input[consumed++] == one) val |= mask;
|
||||
mask <<= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// big endian (most significan bit first)
|
||||
while (width-- && (input[length] == zero || input[length] == one))
|
||||
while (width-- && (input[consumed] == zero || input[consumed] == one))
|
||||
{
|
||||
val <<= 1;
|
||||
if (input[length++] == one) val |= 1;
|
||||
if (input[consumed++] == one) val |= 1;
|
||||
}
|
||||
}
|
||||
value = val;
|
||||
return length;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
RegisterConverter (BinaryConverter, "bB");
|
||||
|
@ -39,9 +39,9 @@ static int strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef unsigned int (*checksumFunc)(const unsigned char* data, unsigned int len, unsigned int init);
|
||||
typedef unsigned int (*checksumFunc)(const unsigned char* data, size_t len, unsigned int init);
|
||||
|
||||
static unsigned int sum(const unsigned char* data, unsigned int len, unsigned int sum)
|
||||
static unsigned int sum(const unsigned char* data, size_t len, unsigned int sum)
|
||||
{
|
||||
while (len--)
|
||||
{
|
||||
@ -50,7 +50,7 @@ static unsigned int sum(const unsigned char* data, unsigned int len, unsigned in
|
||||
return sum;
|
||||
}
|
||||
|
||||
static unsigned int xor8(const unsigned char* data, unsigned int len, unsigned int sum)
|
||||
static unsigned int xor8(const unsigned char* data, size_t len, unsigned int sum)
|
||||
{
|
||||
while (len--)
|
||||
{
|
||||
@ -59,12 +59,12 @@ static unsigned int xor8(const unsigned char* data, unsigned int len, unsigned i
|
||||
return sum;
|
||||
}
|
||||
|
||||
static unsigned int xor7(const unsigned char* data, unsigned int len, unsigned int sum)
|
||||
static unsigned int xor7(const unsigned char* data, size_t len, unsigned int sum)
|
||||
{
|
||||
return xor8(data, len, sum) & 0x7F;
|
||||
}
|
||||
|
||||
static unsigned int crc_0x07(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
static unsigned int crc_0x07(const unsigned char* data, size_t len, unsigned int crc)
|
||||
{
|
||||
// x^8 + x^2 + x^1 + x^0 (0x07)
|
||||
const static unsigned char table[256] = {
|
||||
@ -105,7 +105,7 @@ static unsigned int crc_0x07(const unsigned char* data, unsigned int len, unsign
|
||||
return crc;
|
||||
}
|
||||
|
||||
static unsigned int crc_0x31(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
static unsigned int crc_0x31(const unsigned char* data, size_t len, unsigned int crc)
|
||||
{
|
||||
// x^8 + x^5 + x^4 + x^0 (0x31)
|
||||
const static unsigned char table[256] = {
|
||||
@ -146,7 +146,7 @@ static unsigned int crc_0x31(const unsigned char* data, unsigned int len, unsign
|
||||
return crc;
|
||||
}
|
||||
|
||||
static unsigned int crc_0x8005(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
static unsigned int crc_0x8005(const unsigned char* data, size_t len, unsigned int crc)
|
||||
{
|
||||
// x^16 + x^15 + x^2 + x^0 (0x8005)
|
||||
const static unsigned short table[256] = {
|
||||
@ -187,7 +187,7 @@ static unsigned int crc_0x8005(const unsigned char* data, unsigned int len, unsi
|
||||
return crc;
|
||||
}
|
||||
|
||||
static unsigned int crc_0x8005_r(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
static unsigned int crc_0x8005_r(const unsigned char* data, size_t len, unsigned int crc)
|
||||
{
|
||||
// x^16 + x^15 + x^2 + x^0 (0x8005)
|
||||
// reflected
|
||||
@ -229,7 +229,7 @@ static unsigned int crc_0x8005_r(const unsigned char* data, unsigned int len, un
|
||||
return crc;
|
||||
}
|
||||
|
||||
static unsigned int crc_0x1021(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
static unsigned int crc_0x1021(const unsigned char* data, size_t len, unsigned int crc)
|
||||
{
|
||||
// x^16 + x^12 + x^5 + x^0 (0x1021)
|
||||
const static unsigned short table[256] = {
|
||||
@ -270,7 +270,7 @@ static unsigned int crc_0x1021(const unsigned char* data, unsigned int len, unsi
|
||||
return crc;
|
||||
}
|
||||
|
||||
static unsigned int crc_0x04C11DB7(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
static unsigned int crc_0x04C11DB7(const unsigned char* data, size_t len, unsigned int crc)
|
||||
{
|
||||
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 +
|
||||
// x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 (0x04C11DB7)
|
||||
@ -344,7 +344,7 @@ static unsigned int crc_0x04C11DB7(const unsigned char* data, unsigned int len,
|
||||
return crc;
|
||||
}
|
||||
|
||||
static unsigned int crc_0x04C11DB7_r(const unsigned char* data, unsigned int len, unsigned int crc)
|
||||
static unsigned int crc_0x04C11DB7_r(const unsigned char* data, size_t len, unsigned int crc)
|
||||
{
|
||||
// x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 +
|
||||
// x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0 (0x04C11DB7)
|
||||
@ -419,13 +419,13 @@ static unsigned int crc_0x04C11DB7_r(const unsigned char* data, unsigned int len
|
||||
return crc;
|
||||
}
|
||||
|
||||
static unsigned int adler32(const unsigned char* data, unsigned int len, unsigned int init)
|
||||
static unsigned int adler32(const unsigned char* data, size_t len, unsigned int init)
|
||||
{
|
||||
unsigned int a = init & 0xFFFF;
|
||||
unsigned int b = (init >> 16) & 0xFFFF;
|
||||
|
||||
while (len) {
|
||||
unsigned int tlen = len > 5550 ? 5550 : len;
|
||||
size_t tlen = len > 5550 ? 5550 : len;
|
||||
len -= tlen;
|
||||
do {
|
||||
a += *data++;
|
||||
@ -440,10 +440,10 @@ static unsigned int adler32(const unsigned char* data, unsigned int len, unsigne
|
||||
return b << 16 | a;
|
||||
}
|
||||
|
||||
static unsigned int hexsum(const unsigned char* data, unsigned int len, unsigned int sum)
|
||||
static unsigned int hexsum(const unsigned char* data, size_t len, unsigned int sum)
|
||||
{
|
||||
// Add all hex digits, ignore all other bytes.
|
||||
unsigned int d;
|
||||
unsigned int d;
|
||||
while (len--)
|
||||
{
|
||||
d = toupper(*data++);
|
||||
@ -500,7 +500,7 @@ class ChecksumConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse (const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
bool printPseudo(const StreamFormat&, StreamBuffer&);
|
||||
long scanPseudo(const StreamFormat&, StreamBuffer&, long& cursor);
|
||||
ssize_t scanPseudo(const StreamFormat&, StreamBuffer&, size_t& cursor);
|
||||
};
|
||||
|
||||
int ChecksumConverter::
|
||||
@ -536,7 +536,7 @@ parse(const StreamFormat&, StreamBuffer& info, const char*& source, bool)
|
||||
notflag = true;
|
||||
}
|
||||
unsigned char fnum;
|
||||
int len = p-source;
|
||||
size_t len = p-source;
|
||||
unsigned int init, xorout;
|
||||
for (fnum = 0; fnum < sizeof(checksumMap)/sizeof(checksum); fnum++)
|
||||
{
|
||||
@ -575,13 +575,13 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
unsigned int xorout = extract<unsigned int>(info);
|
||||
unsigned char fnum = extract<unsigned char>(info);
|
||||
|
||||
int start = format.width;
|
||||
int length = output.length()-format.width;
|
||||
size_t start = format.width;
|
||||
size_t length = output.length()-format.width;
|
||||
if (format.prec > 0) length -= format.prec;
|
||||
|
||||
debug("ChecksumConverter %s: output to check: \"%s\"\n",
|
||||
checksumMap[fnum].name, output.expand(start,length)());
|
||||
|
||||
|
||||
sum = (xorout ^ checksumMap[fnum].func(
|
||||
reinterpret_cast<unsigned char*>(output(start)), length, init))
|
||||
& mask[checksumMap[fnum].bytes];
|
||||
@ -591,7 +591,7 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
|
||||
int i;
|
||||
unsigned outchar;
|
||||
|
||||
|
||||
if (format.flags & sign_flag) // decimal
|
||||
{
|
||||
// get number of decimal digits from number of bytes: ceil(xbytes*2.5)
|
||||
@ -599,7 +599,7 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
output.print("%0*d", i, sum);
|
||||
debug("ChecksumConverter %s: decimal appending %0*d\n",
|
||||
checksumMap[fnum].name, i, sum);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (format.flags & alt_flag) // lsb first (little endian)
|
||||
{
|
||||
@ -641,28 +641,28 @@ printPseudo(const StreamFormat& format, StreamBuffer& output)
|
||||
return true;
|
||||
}
|
||||
|
||||
long ChecksumConverter::
|
||||
scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
ssize_t ChecksumConverter::
|
||||
scanPseudo(const StreamFormat& format, StreamBuffer& input, size_t& cursor)
|
||||
{
|
||||
unsigned int sum;
|
||||
const char* info = format.info;
|
||||
unsigned int init = extract<unsigned int>(info);
|
||||
unsigned int xorout = extract<unsigned int>(info);
|
||||
int start = format.width;
|
||||
size_t start = format.width;
|
||||
unsigned char fnum = extract<unsigned char>(info);
|
||||
long length = cursor-format.width;
|
||||
size_t length = cursor-format.width;
|
||||
|
||||
if (format.prec > 0) length -= format.prec;
|
||||
|
||||
|
||||
debug("ChecksumConverter %s: input to check: \"%s\n",
|
||||
checksumMap[fnum].name, input.expand(start,length)());
|
||||
|
||||
int expectedLength =
|
||||
size_t expectedLength =
|
||||
// get number of decimal digits from number of bytes: ceil(bytes*2.5)
|
||||
format.flags & sign_flag ? (checksumMap[fnum].bytes + 1) * 25 / 10 - 2 :
|
||||
format.flags & (zero_flag|left_flag) ? 2 * checksumMap[fnum].bytes :
|
||||
checksumMap[fnum].bytes;
|
||||
|
||||
|
||||
if (input.length() - cursor < expectedLength)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input '%s' too short for checksum\n",
|
||||
@ -671,15 +671,15 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
}
|
||||
|
||||
sum = (xorout ^ checksumMap[fnum].func(
|
||||
reinterpret_cast<unsigned char*>(input(start)), length, init))
|
||||
(unsigned char*)input(start), length, init))
|
||||
& mask[checksumMap[fnum].bytes];
|
||||
|
||||
debug("ChecksumConverter %s: input checksum is 0x%0*X\n",
|
||||
checksumMap[fnum].name, 2*checksumMap[fnum].bytes, sum);
|
||||
|
||||
int i, j;
|
||||
unsigned inchar;
|
||||
|
||||
unsigned int inchar;
|
||||
|
||||
if (format.flags & sign_flag) // decimal
|
||||
{
|
||||
unsigned int sumin = 0;
|
||||
@ -691,12 +691,12 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
}
|
||||
if (sumin != sum)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input %0*u does not match checksum %0*u\n",
|
||||
debug("ChecksumConverter %s: Input %0*u does not match checksum %0*u\n",
|
||||
checksumMap[fnum].name, i, sumin, expectedLength, sum);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
if (format.flags & alt_flag) // lsb first (little endian)
|
||||
{
|
||||
for (i = 0; i < checksumMap[fnum].bytes; i++)
|
||||
@ -705,7 +705,7 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
{
|
||||
if (sscanf(input(cursor+2*i), "%2X", &inchar) != 1)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte '%s' is not a hex byte\n",
|
||||
debug("ChecksumConverter %s: Input byte '%s' is not a hex byte\n",
|
||||
checksumMap[fnum].name, input.expand(cursor+2*i,2)());
|
||||
return -1;
|
||||
}
|
||||
@ -715,13 +715,13 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
{
|
||||
if ((input[cursor+2*i] & 0xf0) != 0x30)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
checksumMap[fnum].name, input[cursor+2*i]);
|
||||
return -1;
|
||||
}
|
||||
if ((input[cursor+2*i+1] & 0xf0) != 0x30)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
checksumMap[fnum].name, input[cursor+2*i+1]);
|
||||
return -1;
|
||||
}
|
||||
@ -733,7 +733,7 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
}
|
||||
if (inchar != ((sum >> 8*i) & 0xff))
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X does not match checksum 0x%0*X\n",
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X does not match checksum 0x%0*X\n",
|
||||
checksumMap[fnum].name, inchar, 2*checksumMap[fnum].bytes, sum);
|
||||
return -1;
|
||||
}
|
||||
@ -752,13 +752,13 @@ scanPseudo(const StreamFormat& format, StreamBuffer& input, long& cursor)
|
||||
{
|
||||
if ((input[cursor+2*i] & 0xf0) != 0x30)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
checksumMap[fnum].name, input[cursor+2*i]);
|
||||
return -1;
|
||||
}
|
||||
if ((input[cursor+2*i+1] & 0xf0) != 0x30)
|
||||
{
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
debug("ChecksumConverter %s: Input byte 0x%02X is not in range 0x30 - 0x3F\n",
|
||||
checksumMap[fnum].name, input[cursor+2*i+1]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class EnumConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
bool printLong(const StreamFormat&, StreamBuffer&, long);
|
||||
long scanLong(const StreamFormat&, const char*, long&);
|
||||
ssize_t scanLong(const StreamFormat&, const char*, long&);
|
||||
};
|
||||
|
||||
// info format: <numEnums><index><string>0<index><string>0...
|
||||
@ -45,10 +45,10 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
return false;
|
||||
}
|
||||
long numEnums = 0;
|
||||
int n = info.length(); // put numEnums here later
|
||||
size_t n = info.length(); // put numEnums here later
|
||||
info.append(&numEnums, sizeof(numEnums));
|
||||
long index = 0;
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
i = info.length(); // put index here later
|
||||
info.append(&index, sizeof(index));
|
||||
while (*source)
|
||||
@ -56,7 +56,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
if (*source == '=' && (fmt.flags & alt_flag))
|
||||
{
|
||||
char* p;
|
||||
|
||||
|
||||
if (*++source == '?')
|
||||
{
|
||||
// default choice
|
||||
@ -78,7 +78,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
-numEnums, info.expand()());
|
||||
return enum_format;
|
||||
}
|
||||
|
||||
|
||||
index = strtol(source, &p, 0);
|
||||
if (p == source || (*p != '|' && *p != '}'))
|
||||
{
|
||||
@ -93,7 +93,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
{
|
||||
numEnums++;
|
||||
info.append('\0');
|
||||
|
||||
|
||||
if (*source++ == '}')
|
||||
{
|
||||
memcpy(info(n), &numEnums, sizeof(numEnums));
|
||||
@ -101,7 +101,7 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
numEnums, info.expand()());
|
||||
return enum_format;
|
||||
}
|
||||
index ++;
|
||||
index++;
|
||||
i = info.length();
|
||||
info.append(&index, sizeof(index));
|
||||
}
|
||||
@ -123,8 +123,8 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
long numEnums = extract<long>(s);
|
||||
long index = extract<long>(s);
|
||||
bool noDefault = numEnums >= 0;
|
||||
|
||||
if (numEnums < 0) numEnums=-numEnums-1;
|
||||
|
||||
if (numEnums < 0) numEnums=-numEnums-1;
|
||||
while (numEnums-- && (value != index))
|
||||
{
|
||||
while(*s)
|
||||
@ -148,7 +148,7 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
return true;
|
||||
}
|
||||
|
||||
long EnumConverter::
|
||||
ssize_t EnumConverter::
|
||||
scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
{
|
||||
debug("EnumConverter::scanLong(%%%c, \"%s\")\n",
|
||||
@ -156,31 +156,31 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
const char* s = fmt.info;
|
||||
long numEnums = extract<long>(s);
|
||||
long index;
|
||||
long length;
|
||||
|
||||
ssize_t consumed;
|
||||
bool match;
|
||||
|
||||
while (numEnums--)
|
||||
{
|
||||
index = extract<long>(s);
|
||||
debug("EnumConverter::scanLong: check #%ld \"%s\"\n", index, s);
|
||||
length = 0;
|
||||
consumed = 0;
|
||||
match = true;
|
||||
while(*s)
|
||||
{
|
||||
if (*s == StreamProtocolParser::skip)
|
||||
{
|
||||
s++;
|
||||
length++;
|
||||
consumed++;
|
||||
continue;
|
||||
}
|
||||
if (*s == esc) s++;
|
||||
if (*s++ != input[length++]) match = false;
|
||||
if (*s++ != input[consumed++]) match = false;
|
||||
}
|
||||
if (match)
|
||||
{
|
||||
debug("EnumConverter::scanLong: value %ld matches\n", index);
|
||||
value = index;
|
||||
return length;
|
||||
return consumed;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* (C) 2008 Dirk Zimoch (dirk.zimoch@psi.ch) *
|
||||
* *
|
||||
* This is a custom exponential format converter for *
|
||||
* This is a custom exponential format converter for *
|
||||
* StreamDevice. *
|
||||
* The number is represented as two signed integers, mantissa *
|
||||
* and exponent, like in +00011-01 *
|
||||
@ -39,7 +39,7 @@
|
||||
class MantissaExponentConverter : public StreamFormatConverter
|
||||
{
|
||||
virtual int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
virtual long scanDouble(const StreamFormat&, const char*, double&);
|
||||
virtual ssize_t scanDouble(const StreamFormat&, const char*, double&);
|
||||
virtual bool printDouble(const StreamFormat&, StreamBuffer&, double);
|
||||
};
|
||||
|
||||
@ -50,13 +50,13 @@ parse(const StreamFormat&, StreamBuffer&,
|
||||
return double_format;
|
||||
}
|
||||
|
||||
long MantissaExponentConverter::
|
||||
ssize_t MantissaExponentConverter::
|
||||
scanDouble(const StreamFormat& fmt, const char* input, double& value)
|
||||
{
|
||||
int mantissa;
|
||||
int exponent;
|
||||
int length = -1;
|
||||
|
||||
|
||||
sscanf(input, "%d%d%n", &mantissa, &exponent, &length);
|
||||
if (fmt.flags & skip_flag) return length;
|
||||
if (length == -1) return -1;
|
||||
@ -70,15 +70,15 @@ printDouble(const StreamFormat& fmt, StreamBuffer& output, double value)
|
||||
// Have to divide value into mantissa and exponent
|
||||
// precision field is number of characters in mantissa
|
||||
// number of characters in exponent is at least 2
|
||||
int spaces;
|
||||
size_t spaces;
|
||||
StreamBuffer buf;
|
||||
int prec = fmt.prec;
|
||||
|
||||
|
||||
if (prec < 1) prec = 6;
|
||||
buf.print("%.*e", prec-1, fabs(value)/pow(10.0, prec-1));
|
||||
buf.remove(1,1);
|
||||
buf.remove(buf.find('e'),1);
|
||||
|
||||
|
||||
spaces = fmt.width-buf.length();
|
||||
if (fmt.flags & (space_flag|sign_flag) || value < 0.0) spaces--;
|
||||
if (spaces < 0) spaces = 0;
|
||||
|
@ -27,7 +27,7 @@ class RawConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
bool printLong(const StreamFormat&, StreamBuffer&, long);
|
||||
long scanLong(const StreamFormat&, const char*, long&);
|
||||
ssize_t scanLong(const StreamFormat&, const char*, long&);
|
||||
};
|
||||
|
||||
int RawConverter::
|
||||
@ -44,7 +44,7 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
unsigned long width = prec; // number of bytes in output
|
||||
if (prec > sizeof(long)) prec=sizeof(long);
|
||||
if (fmt.width > width) width = fmt.width;
|
||||
|
||||
|
||||
char byte = 0;
|
||||
if (fmt.flags & alt_flag) // little endian (lsb first)
|
||||
{
|
||||
@ -95,10 +95,10 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
return true;
|
||||
}
|
||||
|
||||
long RawConverter::
|
||||
ssize_t RawConverter::
|
||||
scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
{
|
||||
long length = 0;
|
||||
ssize_t consumed = 0;
|
||||
long val = 0;
|
||||
unsigned long width = fmt.width;
|
||||
if (width == 0) width = 1; // default: 1 byte
|
||||
@ -112,7 +112,7 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
unsigned int shift = 0;
|
||||
while (--width && shift < sizeof(long)*8)
|
||||
{
|
||||
val |= ((unsigned char) input[length++]) << shift;
|
||||
val |= ((unsigned char)input[consumed++]) << shift;
|
||||
shift += 8;
|
||||
}
|
||||
if (width == 0)
|
||||
@ -120,15 +120,15 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
if (fmt.flags & zero_flag)
|
||||
{
|
||||
// fill with zero
|
||||
val |= ((unsigned char) input[length++]) << shift;
|
||||
val |= ((unsigned char)input[consumed++]) << shift;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fill with sign
|
||||
val |= ((signed char) input[length++]) << shift;
|
||||
val |= ((signed char)input[consumed++]) << shift;
|
||||
}
|
||||
}
|
||||
length += width; // ignore upper bytes not fitting in long
|
||||
consumed += width; // ignore upper bytes not fitting in long
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -136,21 +136,21 @@ scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
if (fmt.flags & zero_flag)
|
||||
{
|
||||
// fill with zero
|
||||
val = (unsigned char) input[length++];
|
||||
val = (unsigned char)input[consumed++];
|
||||
}
|
||||
else
|
||||
{
|
||||
// fill with sign
|
||||
val = (signed char) input[length++];
|
||||
val = (signed char)input[consumed++];
|
||||
}
|
||||
while (--width)
|
||||
{
|
||||
val <<= 8;
|
||||
val |= (unsigned char) input[length++];
|
||||
val |= (unsigned char)input[consumed++];
|
||||
}
|
||||
}
|
||||
value = val;
|
||||
return length;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
RegisterConverter (RawConverter, "r");
|
||||
|
@ -29,7 +29,7 @@ class RawFloatConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
bool printDouble(const StreamFormat&, StreamBuffer&, double);
|
||||
long scanDouble(const StreamFormat&, const char*, double&);
|
||||
ssize_t scanDouble(const StreamFormat&, const char*, double&);
|
||||
};
|
||||
|
||||
int RawFloatConverter::
|
||||
@ -90,7 +90,7 @@ printDouble(const StreamFormat& format, StreamBuffer& output, double value)
|
||||
return true;
|
||||
}
|
||||
|
||||
long RawFloatConverter::
|
||||
ssize_t RawFloatConverter::
|
||||
scanDouble(const StreamFormat& format, const char* input, double& value)
|
||||
{
|
||||
int nbOfBytes;
|
||||
|
@ -136,8 +136,12 @@ append(const void* s, ssize_t size)
|
||||
}
|
||||
|
||||
ssize_t StreamBuffer::
|
||||
find(const void* m, size_t size, ssize_t start) const
|
||||
find(const char* m, size_t size, ssize_t start) const
|
||||
{
|
||||
if (m && size == 0)
|
||||
{
|
||||
size = strlen(m);
|
||||
}
|
||||
if (start < 0)
|
||||
{
|
||||
start += len;
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(ssize_t)
|
||||
#define ssize_t ptrdiff_t
|
||||
#endif
|
||||
|
||||
@ -94,11 +94,11 @@ public:
|
||||
{return len>0;}
|
||||
|
||||
// length: get current data length
|
||||
ssize_t length() const
|
||||
size_t length() const
|
||||
{return len;}
|
||||
|
||||
// capacity: get current max data length (spare one byte for end)
|
||||
ssize_t capacity() const
|
||||
size_t capacity() const
|
||||
{return cap-1;}
|
||||
|
||||
// end: get pointer to byte after last data byte
|
||||
@ -205,10 +205,7 @@ public:
|
||||
c, start<0?-start:len-start)))?
|
||||
p-(buffer+offs) : -1;}
|
||||
|
||||
ssize_t find(const void* s, size_t size, ssize_t start=0) const;
|
||||
|
||||
ssize_t find(const char* s, ssize_t start=0) const
|
||||
{return find(s, s?strlen(s):0, start);}
|
||||
ssize_t find(const char* s, size_t size=0, ssize_t start=0) const;
|
||||
|
||||
ssize_t find(const StreamBuffer& s, ssize_t start=0) const
|
||||
{return find(s.buffer+s.offs, s.len, start);}
|
||||
|
@ -196,7 +196,7 @@ parse(const char* filename, const char* _protocolname)
|
||||
{
|
||||
protocolname = _protocolname;
|
||||
// extract substitutions from protocolname "name(sub1,sub2)"
|
||||
int i = protocolname.find('(');
|
||||
ssize_t i = protocolname.find('(');
|
||||
if (i >= 0)
|
||||
{
|
||||
while (i >= 0)
|
||||
@ -635,7 +635,7 @@ formatOutput()
|
||||
char command;
|
||||
const char* fieldName = NULL;
|
||||
const char* formatstring;
|
||||
int formatstringlen;
|
||||
size_t formatstringlen;
|
||||
|
||||
outputLine.clear();
|
||||
while ((command = *commandIndex++) != StreamProtocolParser::eos)
|
||||
@ -1019,8 +1019,8 @@ readCallback(StreamIoStatus status,
|
||||
|
||||
// prepare to parse the input
|
||||
const char *commandStart = commandIndex;
|
||||
long end = -1;
|
||||
long termlen = 0;
|
||||
ssize_t end = -1;
|
||||
size_t termlen = 0;
|
||||
|
||||
if (inTerminator)
|
||||
{
|
||||
@ -1029,7 +1029,7 @@ readCallback(StreamIoStatus status,
|
||||
// do not parse old chunks again or performance decreases to O(n^2)
|
||||
// but make sure to get all terminators in multi-line input
|
||||
|
||||
long start;
|
||||
ssize_t start;
|
||||
if (unparsedInput)
|
||||
{
|
||||
// multi-line input sets 'unparsedInput' and removes the line
|
||||
@ -1092,7 +1092,7 @@ readCallback(StreamIoStatus status,
|
||||
name());
|
||||
flags |= AcceptInput;
|
||||
if (maxInput)
|
||||
return maxInput - inputBuffer.length();
|
||||
return (long)(maxInput - inputBuffer.length());
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
@ -1197,7 +1197,7 @@ matchInput()
|
||||
{
|
||||
fieldAddress.clear();
|
||||
normal_format:
|
||||
int consumed;
|
||||
ssize_t consumed;
|
||||
// code layout:
|
||||
// formatstring <eos> StreamFormat [info]
|
||||
formatstring.clear();
|
||||
@ -1215,7 +1215,7 @@ normal_format:
|
||||
{
|
||||
long ldummy;
|
||||
double ddummy;
|
||||
long unsigned size=0;
|
||||
size_t size=0;
|
||||
switch (fmt.type)
|
||||
{
|
||||
case unsigned_format:
|
||||
@ -1388,7 +1388,7 @@ normal_format:
|
||||
consumedInput++;
|
||||
}
|
||||
}
|
||||
long surplus = inputLine.length()-consumedInput;
|
||||
size_t surplus = inputLine.length()-consumedInput;
|
||||
if (surplus > 0 && !(flags & IgnoreExtraInput))
|
||||
{
|
||||
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
|
||||
@ -1430,8 +1430,8 @@ matchSeparator()
|
||||
flags |= Separator;
|
||||
return true;
|
||||
}
|
||||
long i;
|
||||
long j = consumedInput;
|
||||
size_t i;
|
||||
size_t j = consumedInput;
|
||||
for (i = 0; i < separator.length(); i++)
|
||||
{
|
||||
switch (separator[i])
|
||||
@ -1459,7 +1459,7 @@ matchSeparator()
|
||||
return true;
|
||||
}
|
||||
|
||||
long StreamCore::
|
||||
ssize_t StreamCore::
|
||||
scanValue(const StreamFormat& fmt, long& value)
|
||||
{
|
||||
if (fmt.type != unsigned_format && fmt.type != signed_format && fmt.type != enum_format)
|
||||
@ -1470,7 +1470,7 @@ scanValue(const StreamFormat& fmt, long& value)
|
||||
}
|
||||
flags |= ScanTried;
|
||||
if (!matchSeparator()) return -1;
|
||||
long consumed = StreamFormatConverter::find(fmt.conv)->
|
||||
ssize_t consumed = StreamFormatConverter::find(fmt.conv)->
|
||||
scanLong(fmt, inputLine(consumedInput), value);
|
||||
debug("StreamCore::scanValue(%s, format=%%%c, long) input=\"%s\"\n",
|
||||
name(), fmt.conv, inputLine.expand(consumedInput)());
|
||||
@ -1484,14 +1484,14 @@ scanValue(const StreamFormat& fmt, long& value)
|
||||
else return -1;
|
||||
}
|
||||
if (fmt.flags & fix_width_flag && (unsigned long)consumed != fmt.width) return -1;
|
||||
if (consumed > inputLine.length()-consumedInput) return -1;
|
||||
if ((size_t)consumed > inputLine.length()-consumedInput) return -1;
|
||||
debug("StreamCore::scanValue(%s) scanned %li\n",
|
||||
name(), value);
|
||||
flags |= GotValue;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
long StreamCore::
|
||||
ssize_t StreamCore::
|
||||
scanValue(const StreamFormat& fmt, double& value)
|
||||
{
|
||||
if (fmt.type != double_format)
|
||||
@ -1502,7 +1502,7 @@ scanValue(const StreamFormat& fmt, double& value)
|
||||
}
|
||||
flags |= ScanTried;
|
||||
if (!matchSeparator()) return -1;
|
||||
long consumed = StreamFormatConverter::find(fmt.conv)->
|
||||
ssize_t consumed = StreamFormatConverter::find(fmt.conv)->
|
||||
scanDouble(fmt, inputLine(consumedInput), value);
|
||||
debug("StreamCore::scanValue(%s, format=%%%c, double) input=\"%s\"\n",
|
||||
name(), fmt.conv, inputLine.expand(consumedInput, 20)());
|
||||
@ -1515,16 +1515,16 @@ scanValue(const StreamFormat& fmt, double& value)
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
if (fmt.flags & fix_width_flag && ((unsigned long)consumed != (fmt.width + fmt.prec + 1))) return -1;
|
||||
if (consumed > inputLine.length()-consumedInput) return -1;
|
||||
if (fmt.flags & fix_width_flag && (consumed != (fmt.width + fmt.prec + 1))) return -1;
|
||||
if ((size_t)consumed > inputLine.length()-consumedInput) return -1;
|
||||
debug("StreamCore::scanValue(%s) scanned %#g\n",
|
||||
name(), value);
|
||||
flags |= GotValue;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
long StreamCore::
|
||||
scanValue(const StreamFormat& fmt, char* value, unsigned long& size)
|
||||
ssize_t StreamCore::
|
||||
scanValue(const StreamFormat& fmt, char* value, size_t& size)
|
||||
{
|
||||
if (fmt.type != string_format)
|
||||
{
|
||||
@ -1534,7 +1534,7 @@ scanValue(const StreamFormat& fmt, char* value, unsigned long& size)
|
||||
}
|
||||
flags |= ScanTried;
|
||||
if (!matchSeparator()) return -1;
|
||||
long consumed = StreamFormatConverter::find(fmt.conv)->
|
||||
ssize_t consumed = StreamFormatConverter::find(fmt.conv)->
|
||||
scanString(fmt, inputLine(consumedInput), value, size);
|
||||
debug("StreamCore::scanValue(%s, format=%%%c, char*, size=%ld) input=\"%s\"\n",
|
||||
name(), fmt.conv, size, inputLine.expand(consumedInput)());
|
||||
|
@ -135,10 +135,10 @@ protected:
|
||||
bool printValue(const StreamFormat& format, long value);
|
||||
bool printValue(const StreamFormat& format, double value);
|
||||
bool printValue(const StreamFormat& format, char* value);
|
||||
long scanValue(const StreamFormat& format, long& value);
|
||||
long scanValue(const StreamFormat& format, double& value);
|
||||
long scanValue(const StreamFormat& format, char* value, unsigned long& size);
|
||||
long scanValue(const StreamFormat& format);
|
||||
ssize_t scanValue(const StreamFormat& format, long& value);
|
||||
ssize_t scanValue(const StreamFormat& format, double& value);
|
||||
ssize_t scanValue(const StreamFormat& format, char* value, size_t& size);
|
||||
ssize_t scanValue(const StreamFormat& format);
|
||||
|
||||
StreamBuffer protocolname;
|
||||
unsigned long lockTimeout;
|
||||
@ -163,7 +163,7 @@ protected:
|
||||
StreamBuffer outputLine;
|
||||
StreamBuffer inputBuffer;
|
||||
StreamBuffer inputLine;
|
||||
long consumedInput;
|
||||
size_t consumedInput;
|
||||
ProtocolResult runningHandler;
|
||||
StreamBuffer fieldAddress;
|
||||
|
||||
|
@ -116,7 +116,7 @@ class Stream : protected StreamCore
|
||||
#endif
|
||||
int status;
|
||||
int convert;
|
||||
long currentValueLength;
|
||||
ssize_t currentValueLength;
|
||||
IOSCANPVT ioscanpvt;
|
||||
CALLBACK commandCallback;
|
||||
CALLBACK processCallback;
|
||||
@ -155,7 +155,7 @@ class Stream : protected StreamCore
|
||||
long initRecord(const char* filename, const char* protocol,
|
||||
const char* busname, int addr, const char* busparam);
|
||||
bool print(format_t *format, va_list ap);
|
||||
long scan(format_t *format, void* pvalue, size_t maxStringSize);
|
||||
ssize_t scan(format_t *format, void* pvalue, size_t maxStringSize);
|
||||
bool process();
|
||||
|
||||
// device support functions
|
||||
@ -165,7 +165,7 @@ class Stream : protected StreamCore
|
||||
friend long streamGetIointInfo(int cmd, dbCommon *record,
|
||||
IOSCANPVT *ppvt);
|
||||
friend long streamPrintf(dbCommon *record, format_t *format, ...);
|
||||
friend long streamScanfN(dbCommon *record, format_t *format,
|
||||
friend ssize_t streamScanfN(dbCommon *record, format_t *format,
|
||||
void*, size_t maxStringSize);
|
||||
friend long streamReload(const char* recordname);
|
||||
|
||||
@ -282,9 +282,9 @@ struct drvet stream = {
|
||||
epicsExportAddress(drvet, stream);
|
||||
|
||||
#ifdef EPICS_3_13
|
||||
void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
void streamEpicsPrintTimestamp(char* buffer, size_t size)
|
||||
{
|
||||
int tlen;
|
||||
size_t tlen;
|
||||
char* c;
|
||||
TS_STAMP tm;
|
||||
tsLocalTime (&tm);
|
||||
@ -297,12 +297,12 @@ void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
sprintf(buffer+tlen, " %.*s", size-tlen-2, taskName(0));
|
||||
}
|
||||
#else // !EPICS_3_13
|
||||
void streamEpicsPrintTimestamp(char* buffer, int size)
|
||||
void streamEpicsPrintTimestamp(char* buffer, size_t size)
|
||||
{
|
||||
int tlen;
|
||||
size_t tlen;
|
||||
epicsTime tm = epicsTime::getCurrent();
|
||||
tlen = tm.strftime(buffer, size, "%Y/%m/%d %H:%M:%S.%06f");
|
||||
sprintf(buffer+tlen, " %.*s", size-tlen-2, epicsThreadGetNameSelf());
|
||||
sprintf(buffer+tlen, " %.*s", (int)(size-tlen-2), epicsThreadGetNameSelf());
|
||||
}
|
||||
#endif // !EPICS_3_13
|
||||
|
||||
@ -540,10 +540,10 @@ long streamPrintf(dbCommon *record, format_t *format, ...)
|
||||
return success ? OK : ERROR;
|
||||
}
|
||||
|
||||
long streamScanfN(dbCommon* record, format_t *format,
|
||||
ssize_t streamScanfN(dbCommon* record, format_t *format,
|
||||
void* value, size_t maxStringSize)
|
||||
{
|
||||
long size;
|
||||
ssize_t size;
|
||||
debug("streamScanfN(%s,format=%%%c,maxStringSize=%ld)\n",
|
||||
record->name, format->priv->conv, (long)maxStringSize);
|
||||
Stream* pstream = (Stream*)record->dpvt;
|
||||
@ -791,12 +791,12 @@ print(format_t *format, va_list ap)
|
||||
return false;
|
||||
}
|
||||
|
||||
long Stream::
|
||||
ssize_t Stream::
|
||||
scan(format_t *format, void* value, size_t maxStringSize)
|
||||
{
|
||||
// called by streamScanfN
|
||||
|
||||
unsigned long size = maxStringSize;
|
||||
size_t size = maxStringSize;
|
||||
// first remove old value from inputLine (if we are scanning arrays)
|
||||
consumedInput += currentValueLength;
|
||||
currentValueLength = 0;
|
||||
@ -1145,14 +1145,14 @@ bool Stream::
|
||||
matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
{
|
||||
// this function must increase consumedInput
|
||||
long consumed = 0;
|
||||
ssize_t consumed = 0;
|
||||
long lval;
|
||||
double dval;
|
||||
char* buffer;
|
||||
int status;
|
||||
const char* putfunc;
|
||||
format_s fmt;
|
||||
unsigned long stringsize = MAX_STRING_SIZE;
|
||||
size_t stringsize = MAX_STRING_SIZE;
|
||||
|
||||
fmt.type = dbfMapping[format.type];
|
||||
fmt.priv = &format;
|
||||
@ -1163,8 +1163,8 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
StreamBuffer fieldBuffer;
|
||||
DBADDR* pdbaddr = (DBADDR*)fieldaddress;
|
||||
size_t size;
|
||||
unsigned long nord;
|
||||
unsigned long nelem = pdbaddr->no_elements;
|
||||
size_t nord;
|
||||
size_t nelem = pdbaddr->no_elements;
|
||||
if (format.type == string_format &&
|
||||
(pdbaddr->field_type == DBF_CHAR || pdbaddr->field_type == DBF_UCHAR))
|
||||
{
|
||||
@ -1320,7 +1320,7 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
// write into own record, thus don't process it
|
||||
// in @init we must not process other record
|
||||
putfunc = "dbPut";
|
||||
status = dbPut(pdbaddr, fmt.type, buffer, nord);
|
||||
status = dbPut(pdbaddr, fmt.type, buffer, (long)nord);
|
||||
if (INIT_RUN && pdbaddr->precord != record)
|
||||
{
|
||||
// clean error status of other record in @init
|
||||
@ -1334,7 +1334,7 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
|
||||
// write into other record, thus process it
|
||||
putfunc = "dbPutField";
|
||||
status = dbPutField(pdbaddr, fmt.type,
|
||||
buffer, nord);
|
||||
buffer, (long)nord);
|
||||
}
|
||||
debug("Stream::matchValue(%s): %s(%s.%s, %s, %s) status=0x%x\n",
|
||||
name(), putfunc,
|
||||
|
@ -41,20 +41,20 @@ FILE *StreamDebugFile = NULL;
|
||||
by setting the StreamPrintTimestampFunction variable
|
||||
to your own function.
|
||||
*/
|
||||
static void printTimestamp(char* buffer, int size)
|
||||
static void printTimestamp(char* buffer, size_t size)
|
||||
{
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
time(&t);
|
||||
#ifdef _WIN32
|
||||
tm = *localtime(&t);
|
||||
#else
|
||||
#else
|
||||
localtime_r(&t, &tm);
|
||||
#endif
|
||||
strftime(buffer, size, "%Y/%m/%d %H:%M:%S", &tm);
|
||||
}
|
||||
|
||||
void (*StreamPrintTimestampFunction)(char* buffer, int size) = printTimestamp;
|
||||
void (*StreamPrintTimestampFunction)(char* buffer, size_t size) = printTimestamp;
|
||||
|
||||
void StreamError(const char* fmt, ...)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
extern int streamDebug;
|
||||
extern int streamError;
|
||||
extern void (*StreamPrintTimestampFunction)(char* buffer, int size);
|
||||
extern void (*StreamPrintTimestampFunction)(char* buffer, size_t size);
|
||||
|
||||
void StreamError(int line, const char* file, const char* fmt, ...)
|
||||
__attribute__((__format__(__printf__,3,4)));
|
||||
|
@ -205,7 +205,7 @@ printPseudo(const StreamFormat& fmt, StreamBuffer&)
|
||||
return false;
|
||||
}
|
||||
|
||||
long StreamFormatConverter::
|
||||
ssize_t StreamFormatConverter::
|
||||
scanLong(const StreamFormat& fmt, const char*, long&)
|
||||
{
|
||||
error("Unimplemented scanLong method for %%%c format\n",
|
||||
@ -213,7 +213,7 @@ scanLong(const StreamFormat& fmt, const char*, long&)
|
||||
return -1;
|
||||
}
|
||||
|
||||
long StreamFormatConverter::
|
||||
ssize_t StreamFormatConverter::
|
||||
scanDouble(const StreamFormat& fmt, const char*, double&)
|
||||
{
|
||||
error("Unimplemented scanDouble method for %%%c format\n",
|
||||
@ -221,16 +221,16 @@ scanDouble(const StreamFormat& fmt, const char*, double&)
|
||||
return -1;
|
||||
}
|
||||
|
||||
long StreamFormatConverter::
|
||||
scanString(const StreamFormat& fmt, const char*, char*, unsigned long&)
|
||||
ssize_t StreamFormatConverter::
|
||||
scanString(const StreamFormat& fmt, const char*, char*, size_t&)
|
||||
{
|
||||
error("Unimplemented scanString method for %%%c format\n",
|
||||
fmt.conv);
|
||||
return -1;
|
||||
}
|
||||
|
||||
long StreamFormatConverter::
|
||||
scanPseudo(const StreamFormat& fmt, StreamBuffer&, long&)
|
||||
ssize_t StreamFormatConverter::
|
||||
scanPseudo(const StreamFormat& fmt, StreamBuffer&, size_t&)
|
||||
{
|
||||
error("Unimplemented scanPseudo method for %%%c format\n",
|
||||
fmt.conv);
|
||||
@ -255,15 +255,15 @@ static void copyFormatString(StreamBuffer& info, const char* source)
|
||||
|
||||
// Standard Long Converter for 'diouxX'
|
||||
|
||||
static long prepareval(const StreamFormat& fmt, const char*& input, bool& neg)
|
||||
static size_t prepareval(const StreamFormat& fmt, const char*& input, bool& neg)
|
||||
{
|
||||
long consumed = 0;
|
||||
size_t consumed = 0;
|
||||
neg = false;
|
||||
while (isspace(*input)) { input++; consumed++; }
|
||||
if (fmt.width)
|
||||
{
|
||||
// take local copy because strto* don't have width parameter
|
||||
int width = fmt.width;
|
||||
size_t width = fmt.width;
|
||||
if (fmt.flags & space_flag)
|
||||
{
|
||||
// normally whitespace does not count to width
|
||||
@ -297,7 +297,7 @@ class StdLongConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse(const StreamFormat& fmt, StreamBuffer& output, const char*& value, bool scanFormat);
|
||||
bool printLong(const StreamFormat& fmt, StreamBuffer& output, long value);
|
||||
long scanLong(const StreamFormat& fmt, const char* input, long& value);
|
||||
ssize_t scanLong(const StreamFormat& fmt, const char* input, long& value);
|
||||
};
|
||||
|
||||
int StdLongConverter::
|
||||
@ -334,11 +334,11 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
return true;
|
||||
}
|
||||
|
||||
long StdLongConverter::
|
||||
ssize_t StdLongConverter::
|
||||
scanLong(const StreamFormat& fmt, const char* input, long& value)
|
||||
{
|
||||
char* end;
|
||||
long consumed;
|
||||
ssize_t consumed;
|
||||
bool neg;
|
||||
int base;
|
||||
long v;
|
||||
@ -379,7 +379,7 @@ class StdDoubleConverter : public StreamFormatConverter
|
||||
{
|
||||
virtual int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
virtual bool printDouble(const StreamFormat&, StreamBuffer&, double);
|
||||
virtual long scanDouble(const StreamFormat&, const char*, double&);
|
||||
virtual ssize_t scanDouble(const StreamFormat&, const char*, double&);
|
||||
};
|
||||
|
||||
int StdDoubleConverter::
|
||||
@ -411,11 +411,11 @@ printDouble(const StreamFormat& fmt, StreamBuffer& output, double value)
|
||||
return true;
|
||||
}
|
||||
|
||||
long StdDoubleConverter::
|
||||
ssize_t StdDoubleConverter::
|
||||
scanDouble(const StreamFormat& fmt, const char* input, double& value)
|
||||
{
|
||||
char* end;
|
||||
long consumed;
|
||||
ssize_t consumed;
|
||||
bool neg;
|
||||
|
||||
consumed = prepareval(fmt, input, neg);
|
||||
@ -435,7 +435,7 @@ class StdStringConverter : public StreamFormatConverter
|
||||
{
|
||||
virtual int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
virtual bool printString(const StreamFormat&, StreamBuffer&, const char*);
|
||||
virtual long scanString(const StreamFormat&, const char*, char*, unsigned long&);
|
||||
virtual ssize_t scanString(const StreamFormat&, const char*, char*, size_t&);
|
||||
};
|
||||
|
||||
int StdStringConverter::
|
||||
@ -483,13 +483,13 @@ printString(const StreamFormat& fmt, StreamBuffer& output, const char* value)
|
||||
return true;
|
||||
}
|
||||
|
||||
long StdStringConverter::
|
||||
ssize_t StdStringConverter::
|
||||
scanString(const StreamFormat& fmt, const char* input,
|
||||
char* value, unsigned long &size)
|
||||
char* value, size_t& size)
|
||||
{
|
||||
long consumed = 0;
|
||||
long space_left = size;
|
||||
int width = fmt.width;
|
||||
ssize_t consumed = 0;
|
||||
size_t space_left = size;
|
||||
ssize_t width = fmt.width;
|
||||
|
||||
if ((fmt.flags & skip_flag) || value == NULL) space_left = 0;
|
||||
|
||||
@ -547,7 +547,7 @@ class StdCharsConverter : public StreamFormatConverter
|
||||
{
|
||||
virtual int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
virtual bool printLong(const StreamFormat&, StreamBuffer&, long);
|
||||
virtual long scanString(const StreamFormat&, const char*, char*, unsigned long&);
|
||||
virtual ssize_t scanString(const StreamFormat&, const char*, char*, size_t&);
|
||||
};
|
||||
|
||||
int StdCharsConverter::
|
||||
@ -583,13 +583,13 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value)
|
||||
return true;
|
||||
}
|
||||
|
||||
long StdCharsConverter::
|
||||
ssize_t StdCharsConverter::
|
||||
scanString(const StreamFormat& fmt, const char* input,
|
||||
char* value, unsigned long& size)
|
||||
char* value, size_t& size)
|
||||
{
|
||||
long consumed = 0;
|
||||
long width = fmt.width;
|
||||
long space_left = size;
|
||||
size_t consumed = 0;
|
||||
size_t width = fmt.width;
|
||||
size_t space_left = size;
|
||||
|
||||
if ((fmt.flags & skip_flag) || value == NULL) space_left = 0;
|
||||
|
||||
@ -623,7 +623,7 @@ RegisterConverter (StdCharsConverter, "c");
|
||||
class StdCharsetConverter : public StreamFormatConverter
|
||||
{
|
||||
virtual int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
virtual long scanString(const StreamFormat&, const char*, char*, unsigned long&);
|
||||
virtual ssize_t scanString(const StreamFormat&, const char*, char*, size_t&);
|
||||
// no print method, %[ is readonly
|
||||
};
|
||||
|
||||
@ -702,13 +702,13 @@ parse(const StreamFormat& fmt, StreamBuffer& info,
|
||||
return string_format;
|
||||
}
|
||||
|
||||
long StdCharsetConverter::
|
||||
ssize_t StdCharsetConverter::
|
||||
scanString(const StreamFormat& fmt, const char* input,
|
||||
char* value, unsigned long& size)
|
||||
char* value, size_t& size)
|
||||
{
|
||||
long consumed = 0;
|
||||
long width = fmt.width;
|
||||
long space_left = size;
|
||||
ssize_t consumed = 0;
|
||||
ssize_t width = fmt.width;
|
||||
size_t space_left = size;
|
||||
|
||||
if ((fmt.flags & skip_flag) || value == NULL) space_left = 0;
|
||||
|
||||
|
@ -56,14 +56,14 @@ public:
|
||||
StreamBuffer& output, const char* value);
|
||||
virtual bool printPseudo(const StreamFormat& fmt,
|
||||
StreamBuffer& output);
|
||||
virtual long scanLong(const StreamFormat& fmt,
|
||||
virtual ssize_t scanLong(const StreamFormat& fmt,
|
||||
const char* input, long& value);
|
||||
virtual long scanDouble(const StreamFormat& fmt,
|
||||
virtual ssize_t scanDouble(const StreamFormat& fmt,
|
||||
const char* input, double& value);
|
||||
virtual long scanString(const StreamFormat& fmt,
|
||||
const char* input, char* value, unsigned long& size);
|
||||
virtual long scanPseudo(const StreamFormat& fmt,
|
||||
StreamBuffer& inputLine, long& cursor);
|
||||
virtual ssize_t scanString(const StreamFormat& fmt,
|
||||
const char* input, char* value, size_t& size);
|
||||
virtual ssize_t scanPseudo(const StreamFormat& fmt,
|
||||
StreamBuffer& inputLine, size_t& cursor);
|
||||
};
|
||||
|
||||
inline StreamFormatConverter* StreamFormatConverter::
|
||||
|
@ -446,7 +446,7 @@ terminated and the line number is stored for later use.
|
||||
Each time newline is read, line is incremented.
|
||||
*/
|
||||
if (!specialchars) specialchars = specialChars;
|
||||
long token = buffer.length();
|
||||
size_t token = buffer.length();
|
||||
int l = line;
|
||||
|
||||
int c = readChar();
|
||||
@ -580,7 +580,7 @@ parseAssignment(const char* name, Protocol& protocol)
|
||||
bool StreamProtocolParser::
|
||||
parseValue(StreamBuffer& buffer, bool lazy)
|
||||
{
|
||||
long token;
|
||||
size_t token;
|
||||
int c;
|
||||
|
||||
do c = readChar(); while (c == ' '); // skip leading spaces
|
||||
@ -594,7 +594,7 @@ parseValue(StreamBuffer& buffer, bool lazy)
|
||||
c = buffer[token];
|
||||
if (c == '$') // a variable
|
||||
{
|
||||
long varname = token+1;
|
||||
size_t varname = token+1;
|
||||
if (buffer[varname] == '"') varname++; // quoted variable
|
||||
if (lazy || (buffer[varname] >= '0' && buffer[varname] <= '9'))
|
||||
{
|
||||
@ -1066,7 +1066,7 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
bool escaped = false;
|
||||
int newline = 0;
|
||||
StreamBuffer formatbuffer;
|
||||
int formatpos = buffer.length();
|
||||
size_t formatpos = buffer.length();
|
||||
line = getLineNumber(source);
|
||||
|
||||
debug("StreamProtocolParser::Protocol::compileString "
|
||||
@ -1116,7 +1116,7 @@ compileString(StreamBuffer& buffer, const char*& source,
|
||||
formatbuffer());
|
||||
return false;
|
||||
}
|
||||
int formatlen = p - buffer(formatpos);
|
||||
size_t formatlen = p - buffer(formatpos);
|
||||
buffer.replace(formatpos, formatlen, formatbuffer);
|
||||
debug("StreamProtocolParser::Protocol::compileString "
|
||||
"replaced by: \"%s\"\n", buffer.expand(formatpos)());
|
||||
@ -1392,7 +1392,7 @@ compileFormat(StreamBuffer& buffer, const char*& formatstr,
|
||||
*/
|
||||
const char* source = formatstr;
|
||||
StreamFormat streamFormat;
|
||||
int fieldname = 0;
|
||||
size_t fieldname = 0;
|
||||
// look for fieldname
|
||||
if (source[1] == '(')
|
||||
{
|
||||
@ -1432,12 +1432,12 @@ compileFormat(StreamBuffer& buffer, const char*& formatstr,
|
||||
buffer.append(format);
|
||||
}
|
||||
const char* formatstart = source + 1;
|
||||
|
||||
|
||||
// parse format and get info string
|
||||
StreamBuffer infoString;
|
||||
int type = StreamFormatConverter::parseFormat(source,
|
||||
formatType, streamFormat, infoString);
|
||||
|
||||
|
||||
if (!type)
|
||||
{
|
||||
// parsing failed
|
||||
|
@ -29,10 +29,10 @@
|
||||
/* timezone in UNIX contains the seconds between UTC and local time,
|
||||
but not in Free-BSD! Here timezone() is a function delivering
|
||||
the time zone abbreviation (e.g. CET). Alternatively, the timezone
|
||||
value can also be gained from tm_gmtoff of the tm-structure.
|
||||
value can also be gained from tm_gmtoff of the tm-structure.
|
||||
HJK, 4.4.14 */
|
||||
/* The same seems to be true for other BSDs. DZ. */
|
||||
|
||||
|
||||
#if defined(__FreeBSD__) || \
|
||||
defined(__NetBSD__) || \
|
||||
defined(__OpenBSD__) || \
|
||||
@ -75,7 +75,7 @@ class TimestampConverter : public StreamFormatConverter
|
||||
{
|
||||
int parse(const StreamFormat&, StreamBuffer&, const char*&, bool);
|
||||
bool printDouble(const StreamFormat&, StreamBuffer&, double);
|
||||
long scanDouble(const StreamFormat&, const char*, double&);
|
||||
ssize_t scanDouble(const StreamFormat&, const char*, double&);
|
||||
};
|
||||
|
||||
int TimestampConverter::
|
||||
@ -151,10 +151,10 @@ printDouble(const StreamFormat& format, StreamBuffer& output, double value)
|
||||
struct tm brokenDownTime;
|
||||
char buffer [40];
|
||||
char fracbuffer [15];
|
||||
int length;
|
||||
size_t length;
|
||||
time_t sec;
|
||||
double frac;
|
||||
int i, n;
|
||||
size_t i, n;
|
||||
char* c;
|
||||
char* p;
|
||||
|
||||
@ -172,7 +172,7 @@ printDouble(const StreamFormat& format, StreamBuffer& output, double value)
|
||||
n = strtol(output(i+1), &c, 10);
|
||||
if (*c++ != 'f') return false;
|
||||
/* print fractional part */
|
||||
sprintf(fracbuffer, "%.*f", n, frac);
|
||||
sprintf(fracbuffer, "%.*f", (int)n, frac);
|
||||
p = strchr(fracbuffer, '.')+1;
|
||||
output.replace(i, c-output(i), p);
|
||||
}
|
||||
@ -516,7 +516,7 @@ startover:
|
||||
return input;
|
||||
}
|
||||
|
||||
long TimestampConverter::
|
||||
ssize_t TimestampConverter::
|
||||
scanDouble(const StreamFormat& format, const char* input, double& value)
|
||||
{
|
||||
struct tm brokenDownTime;
|
||||
|
@ -55,6 +55,10 @@ extern "C" {
|
||||
#include "dbAccess.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(ssize_t)
|
||||
#define ssize_t ptrdiff_t
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && defined(EPICS_3_13)
|
||||
}
|
||||
#endif
|
||||
@ -74,16 +78,16 @@ extern const char StreamVersion [];
|
||||
|
||||
typedef long (*streamIoFunction) (dbCommon*, format_t*);
|
||||
|
||||
epicsShareFunc long streamInit(int after);
|
||||
epicsShareFunc long streamInitRecord(dbCommon *record,
|
||||
long streamInit(int after);
|
||||
long streamInitRecord(dbCommon *record,
|
||||
const struct link *ioLink,
|
||||
streamIoFunction readData, streamIoFunction writeData);
|
||||
epicsShareFunc long streamReport(int interest);
|
||||
epicsShareFunc long streamReadWrite(dbCommon *record);
|
||||
epicsShareFunc long streamGetIointInfo(int cmd,
|
||||
long streamReport(int interest);
|
||||
long streamReadWrite(dbCommon *record);
|
||||
long streamGetIointInfo(int cmd,
|
||||
dbCommon *record, IOSCANPVT *ppvt);
|
||||
epicsShareFunc long streamPrintf(dbCommon *record, format_t *format, ...);
|
||||
epicsShareFunc long streamScanfN(dbCommon *record, format_t *format,
|
||||
long streamPrintf(dbCommon *record, format_t *format, ...);
|
||||
ssize_t streamScanfN(dbCommon *record, format_t *format,
|
||||
void*, size_t maxStringSize);
|
||||
|
||||
/* backward compatibility stuff */
|
||||
|
@ -39,7 +39,7 @@ static long readData(dbCommon *record, format_t *format)
|
||||
else
|
||||
{
|
||||
/* No MASK, (NOBT = 0): use VAL field */
|
||||
mbbiD->val = val;
|
||||
mbbiD->val = val; /* no cast because we cannot be sure about type of VAL */
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
}
|
||||
|
@ -41,17 +41,17 @@ static long readData(dbCommon *record, format_t *format)
|
||||
if ((&mbbi->zrvl)[i])
|
||||
{
|
||||
if (mbbi->mask) val &= mbbi->mask;
|
||||
mbbi->rval = val;
|
||||
mbbi->rval = (epicsEnum16)val;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
mbbi->val = val;
|
||||
mbbi->val = (epicsEnum16)val;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
case DBF_ENUM:
|
||||
{
|
||||
if (streamScanf(record, format, &val) == ERROR) return ERROR;
|
||||
mbbi->val = val;
|
||||
mbbi->val = (epicsEnum16)val;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
case DBF_STRING:
|
||||
@ -63,7 +63,7 @@ static long readData(dbCommon *record, format_t *format)
|
||||
{
|
||||
if (strcmp ((&mbbi->zrst)[val], buffer) == 0)
|
||||
{
|
||||
mbbi->val = val;
|
||||
mbbi->val = (epicsEnum16)val;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ static long readData(dbCommon *record, format_t *format)
|
||||
else
|
||||
{
|
||||
/* No MASK, (NOBT = 0): use VAL field */
|
||||
mbboD->val = val;
|
||||
mbboD->val = val; /* no cast because we cannot be sure about type of VAL */
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
}
|
||||
|
@ -46,13 +46,13 @@ static long readData(dbCommon *record, format_t *format)
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
mbbo->val = val;
|
||||
mbbo->val = (epicsEnum16)val;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
case DBF_ENUM:
|
||||
{
|
||||
if (streamScanf(record, format, &val) == ERROR) return ERROR;
|
||||
mbbo->val = val;
|
||||
mbbo->val = (epicsEnum16)val;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
case DBF_STRING:
|
||||
@ -64,7 +64,7 @@ static long readData(dbCommon *record, format_t *format)
|
||||
{
|
||||
if (strcmp ((&mbbo->zrst)[val], buffer) == 0)
|
||||
{
|
||||
mbbo->val = val;
|
||||
mbbo->val = (epicsEnum16)val;
|
||||
return DO_NOT_CONVERT;
|
||||
}
|
||||
}
|
||||
|
@ -114,13 +114,14 @@ static long readData(dbCommon *record, format_t *format)
|
||||
case DBF_CHAR:
|
||||
case DBF_UCHAR:
|
||||
wf->nord = 0;
|
||||
if ((lval = streamScanfN(record, format,
|
||||
ssize_t length;
|
||||
if ((length = streamScanfN(record, format,
|
||||
(char *)wf->bptr, wf->nelm)) == ERROR)
|
||||
{
|
||||
memset(wf->bptr, 0, wf->nelm);
|
||||
return ERROR;
|
||||
}
|
||||
if ((size_t)lval < wf->nelm)
|
||||
if (length < wf->nelm)
|
||||
{
|
||||
memset(((char*)wf->bptr)+lval , 0, wf->nelm-lval);
|
||||
lval++;
|
||||
|
Reference in New Issue
Block a user