utility Namespace Reference

utility is a repository for assorted useful functions. More...


Functions

unsigned int bizarre_checksum (const byte *data, int length)
 A different type of checksum with somewhat unknown properties.
uint16 fletcher_checksum (const byte *data, int length)
 A positionally computed error detection value.
uint16 rolling_fletcher_checksum (uint16 previous, const byte *data, int len)
 Fletcher checksums applied to streaming data.
byte byte_checksum (const byte *data, int length)
 simple byte-sized checksum based on additive roll-over.
u_int short_checksum (const byte *data, int length)
 simple shorty checksum based on additive roll-over.
u_int hash_bytes (const void *key_data, int key_length)
 returns a value that can be used for indexing into a hash table.
istring timestamp (bool add_space=false, bool add_date=false)
 Returns a string with the current time in hours, min, sec and ms.


Detailed Description

utility is a repository for assorted useful functions.

Function Documentation

unsigned int utility::bizarre_checksum ( const byte data,
int  length 
)

A different type of checksum with somewhat unknown properties.

It attempts to be incorporate positioning of the bytes.

Definition at line 29 of file utility.cpp.

References HIGHEST_MOD_VALUE.

Referenced by do_checksum().

byte utility::byte_checksum ( const byte data,
int  length 
)

simple byte-sized checksum based on additive roll-over.

Definition at line 64 of file utility.cpp.

uint16 utility::fletcher_checksum ( const byte data,
int  length 
)

A positionally computed error detection value.

Definition at line 39 of file utility.cpp.

Referenced by internet_machine_uid::internet_machine_uid(), and rolling_fletcher_checksum().

u_int utility::hash_bytes ( const void *  key_data,
int  key_length 
)

returns a value that can be used for indexing into a hash table.

the returned value is loosely based on the "key_data" and the "key_length" we are provided with.

Definition at line 97 of file utility.cpp.

Referenced by rotating_byte_hasher::hash().

uint16 utility::rolling_fletcher_checksum ( uint16  previous,
const byte data,
int  len 
)

Fletcher checksums applied to streaming data.

this is not strictly a fletcher checksum, but it uses the normal fletcher checksum on the specified data and XORs it with the "previous" value of the checksum. this leads to a regenerable number that should always be the same if done on the same data using the same chunking factor (the "len"), although of course the last piece of data does not have to be "len" bytes.

Definition at line 60 of file utility.cpp.

References fletcher_checksum().

Referenced by file_info::calculate(), and do_fletcher_checksum().

u_int utility::short_checksum ( const byte data,
int  length 
)

simple shorty checksum based on additive roll-over.

Definition at line 71 of file utility.cpp.

istring utility::timestamp ( bool  add_space = false,
bool  add_date = false 
)

Returns a string with the current time in hours, min, sec and ms.

"add_space" causes the stamp to have a space character after the outer bracket. "add_date" causes the stamp to include the current date as part of the stamp.

Definition at line 81 of file utility.cpp.

References earth_time::now().

Referenced by application_shell::log(), guards::make_error_message(), program_wide_logger(), post_office::show_mail(), hoople_api::low_level_methods::timestamp(), timestamp(), and critical_events::write_to_critical_events().


Generated on Sat Aug 30 04:33:38 2008 for HOOPLE Libraries by  doxygen 1.5.1