A new bif unique_id(prefix) that returns a string that's unique across

Bro instaces with high probablity.

"prefix" is a string that will be prepended to the returned ID.
This commit is contained in:
Robin Sommer 2011-06-07 17:28:20 -07:00
parent 4bdb94955d
commit 8266709e20
10 changed files with 96 additions and 59 deletions

View file

@ -111,7 +111,7 @@ extern char* strcasestr(const char* s, const char* find);
#endif
extern const char* strpbrk_n(size_t len, const char* s, const char* charset);
template<class T> int atoi_n(int len, const char* s, const char** end, int base, T& result);
extern char* uitoa_n(uint64 value, char* str, int n, int base);
extern char* uitoa_n(uint64 value, char* str, int n, int base, const char* prefix=0);
int strstr_n(const int big_len, const unsigned char* big,
const int little_len, const unsigned char* little);
extern int fputs(int len, const char* s, FILE* fp);
@ -233,6 +233,10 @@ extern struct timeval double_to_timeval(double t);
// Return > 0 if tv_a > tv_b, 0 if equal, < 0 if tv_a < tv_b.
extern int time_compare(struct timeval* tv_a, struct timeval* tv_b);
// Returns an integer that's very likely to be unique, even across Bro
// instances.
extern uint64 calculate_unique_id();
// For now, don't use hash_maps - they're not fully portable.
#if 0
// Use for hash_map's string keys.