blob: 4a650a44b73b321ee858602cb6eb911638cfb2eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
int wait(int 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;
}
int slen(char *str) {
return (int) strlen(str);
}
char charAt(char *str, int x) {
return str[x];
}
int parse_int(char *str) {
return (int) atoi(str);
}
int as_int(float x) {
return (int) x;
}
char* istr(int x) {
char* snum = malloc(12);
sprintf(snum, "%d", x);
//char* result = snum;
return snum;
}
|