/* * Function: parse_size_directive * Purpose: Parse the size directive passed on the commandline. The size * directive is an integer followed by a size indicator: * * K, k - Kilobyte * M, m - Megabyte * * Return: The size as a size_t because this is related to buffer size. * If an unknown size indicator is used, then the program will * exit with EXIT_FAILURE as the return value. * Programmer: Bill Wendling, 05. June 2002 * Modifications: */ static unsigned long parse_size_directive(const char *size) { unsigned long s; char *endptr; s = HDstrtoul(size, &endptr, 10); if (endptr && *endptr) { while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t')) ++endptr; switch (*endptr) { case 'K': case 'k': s *= ONE_KB; break; case 'M': case 'm': s *= ONE_MB; break; case 'G': case 'g': s *= ONE_GB; break; default: error("illegal size specifier '%c'", *endptr); break; } } return s; }
/* * Enable alarm on test execution, configurable by environment variable */ void TestAlarmOn(void) { char * env_val = HDgetenv("HDF5_ALARM_SECONDS"); /* Alarm environment */ unsigned long alarm_sec = H5_ALARM_SEC; /* Number of seconds before alarm goes off */ /* Get the alarm value from the environment variable, if set */ if(env_val != NULL) alarm_sec = (unsigned)HDstrtoul(env_val, (char **)NULL, 10); /* Set the number of seconds before alarm goes off */ HDalarm((unsigned)alarm_sec); }