/* * utils.c * * Utility stuff * * (c) 2008 Thomas White * * thrust3d - a silly game * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "utils.h" int this_point_not_reached = 0; void chomp(char *a) { unsigned int i; for ( i=0; i 0 ) { /* This is a deliminator after a sequence of non-deliminator chars */ n = assplode_extract(&bits, n, n_captured, start, a); } n_captured = 0; if ( (flags & ASSPLODE_DUPS) && last_was_delim ) { n = assplode_extract(&bits, n, 0, start, a); } last_was_delim = 1; } else { if ( n_captured == 0 ) { /* No characters currently found, so this is the start */ start = i; } n_captured++; last_was_delim = 0; } i++; } /* Left over characters at the end? */ if ( n_captured > 0 ) { n = assplode_extract(&bits, n, n_captured, start, a); } *pbits = bits; return n; } double utils_highresms() { struct timeval tv; suseconds_t us; time_t sec; gettimeofday(&tv, NULL); us = tv.tv_usec; sec = tv.tv_sec; return ((double)us+1000000.0*sec)/1000.0; }