mirror of
https://github.com/tio/tio.git
synced 2026-05-01 23:07:58 +02:00
Move string_to_long() to misc.c
This commit is contained in:
parent
d7b038d4ef
commit
e9d5a23129
4 changed files with 19 additions and 17 deletions
17
src/misc.c
17
src/misc.c
|
|
@ -25,6 +25,7 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include "error.h"
|
||||
#include "print.h"
|
||||
#include "options.h"
|
||||
|
|
@ -91,3 +92,19 @@ void delay(long ms)
|
|||
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
long string_to_long(char *string)
|
||||
{
|
||||
long result;
|
||||
char *end_token;
|
||||
|
||||
errno = 0;
|
||||
result = strtol(string, &end_token, 10);
|
||||
if ((errno != 0) || (*end_token != 0))
|
||||
{
|
||||
printf("Error: Invalid digit\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue