2001-02-23 21:21:06 +03:00
|
|
|
/*
|
|
|
|
* Header for int64.c.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PUTTY_INT64_H
|
|
|
|
#define PUTTY_INT64_H
|
|
|
|
|
2018-05-24 11:17:13 +03:00
|
|
|
#include "defs.h"
|
|
|
|
|
2001-02-23 21:21:06 +03:00
|
|
|
typedef struct {
|
|
|
|
unsigned long hi, lo;
|
2005-09-13 23:24:35 +04:00
|
|
|
} uint64;
|
2001-02-23 21:21:06 +03:00
|
|
|
|
|
|
|
uint64 uint64_div10(uint64 x, int *remainder);
|
|
|
|
void uint64_decimal(uint64 x, char *buffer);
|
|
|
|
uint64 uint64_make(unsigned long hi, unsigned long lo);
|
|
|
|
uint64 uint64_add(uint64 x, uint64 y);
|
|
|
|
uint64 uint64_add32(uint64 x, unsigned long y);
|
2001-08-26 15:35:11 +04:00
|
|
|
int uint64_compare(uint64 x, uint64 y);
|
2006-08-05 17:48:53 +04:00
|
|
|
uint64 uint64_subtract(uint64 x, uint64 y);
|
|
|
|
double uint64_to_double(uint64 x);
|
|
|
|
uint64 uint64_shift_right(uint64 x, int shift);
|
|
|
|
uint64 uint64_shift_left(uint64 x, int shift);
|
|
|
|
uint64 uint64_from_decimal(char *str);
|
2001-02-23 21:21:06 +03:00
|
|
|
|
2018-05-24 11:17:13 +03:00
|
|
|
void BinarySink_put_uint64(BinarySink *, uint64);
|
Introduce a centralised unmarshaller, 'BinarySource'.
This is the companion to the BinarySink system I introduced a couple
of weeks ago, and provides the same type-genericity which will let me
use the same get_* routines on an SSH packet, an SFTP packet or
anything else that chooses to include an implementing substructure.
However, unlike BinarySink which contained a (one-function) vtable,
BinarySource contains only mutable data fields - so another thing you
might very well want to do is to simply instantiate a bare one without
any containing object at all. I couldn't quite coerce C into letting
me use the same setup macro in both cases, so I've arranged a
BinarySource_INIT you can use on larger implementing objects and a
BinarySource_BARE_INIT you can use on a BinarySource not contained in
anything.
The API follows the general principle that even if decoding fails, the
decode functions will always return _some_ kind of value, with the
same dynamically-allocated-ness they would have used for a completely
successful value. But they also set an error flag in the BinarySource
which can be tested later. So instead of having to decode a 10-field
packet by means of 10 separate 'if (!get_foo(src)) throw error'
clauses, you can just write 10 'variable = get_foo(src)' statements
followed by a single check of get_err(src), and if the error check
fails, you have to do exactly the same set of frees you would have
after a successful decode.
2018-06-02 10:25:19 +03:00
|
|
|
uint64 BinarySource_get_uint64(BinarySource *);
|
2018-05-24 11:17:13 +03:00
|
|
|
|
2001-02-23 21:21:06 +03:00
|
|
|
#endif
|