Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/iFabio/Chameleon/i386/modules/klibc/strtotimex.c

Source at commit 307 created 13 years 12 days ago.
By ifabio, merge changes from trunk (929). Also merge the module changes from Azimutz branche (fix compile error) Also edited the info.plist into AHCIPortInjector.kext: http://forum.voodooprojects.org/index.php/topic,1170.0.html
1/*
2 * strtotimex.c
3 *
4 * Nonstandard function which takes a string and converts it to a
5 * struct timespec/timeval. Returns a pointer to the first non-numeric
6 * character in the string.
7 *
8 */
9
10#include <ctype.h>
11#include <inttypes.h>
12#include <stdlib.h>
13#include <time.h>
14#include <sys/time.h>
15
16uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n);
17
18char *NAME(const char *str, TIMEX * ts)
19{
20int n;
21char *s, *s0;
22__typeof__(ts->FSEC) fs;/* Fractional seconds */
23
24ts->tv_sec = strntoumax(str, &s, 10, ~(size_t) 0);
25fs = 0;
26
27if (*s == '.') {
28s0 = s + 1;
29
30fs = strntoumax(s0, &s, 10, DECIMALS);
31n = s - s0;
32
33while (isdigit(*s))
34s++;
35
36for (; n < DECIMALS; n++)
37fs *= 10;
38}
39
40ts->FSEC = fs;
41return s;
42}
43

Archive Download this file

Revision: 307