diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -16,11 +16,36 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#define _GNU_SOURCE + #include <ctype.h> +#include <errno.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <util.h> +int +msleep(long msec) +{ + struct timespec ts; + int res; + + if (msec < 0) { + errno = EINVAL; + return -1; + } + + ts.tv_sec = msec / 1000; + ts.tv_nsec = (msec % 1000) * 1000000; + + do { + res = nanosleep(&ts, &ts); + } while (res && errno == EINTR); + + return res; +} + char * ltrim(char *s) { |