Mercurial > mplayer.hg
comparison libass/ass_utils.c @ 18937:9e95ac641e77
Initial libass release (without mencoder support).
author | eugeni |
---|---|
date | Fri, 07 Jul 2006 18:26:51 +0000 |
parents | |
children | 9dc06456af0f |
comparison
equal
deleted
inserted
replaced
18936:b80b0c115a24 | 18937:9e95ac641e77 |
---|---|
1 #include "config.h" | |
2 | |
3 #include <stdlib.h> | |
4 #include <stdint.h> | |
5 #include <sys/time.h> | |
6 #include <time.h> | |
7 | |
8 #include "mp_msg.h" | |
9 #include "ass_utils.h" | |
10 | |
11 int mystrtoi(char** p, int base, int* res) | |
12 { | |
13 char* start = *p; | |
14 *res = strtol(*p, p, base); | |
15 if (*p != start) return 1; | |
16 else return 0; | |
17 } | |
18 | |
19 int mystrtou32(char** p, int base, uint32_t* res) | |
20 { | |
21 char* start = *p; | |
22 *res = strtoll(*p, p, base); | |
23 if (*p != start) return 1; | |
24 else return 0; | |
25 } | |
26 | |
27 int mystrtod(char** p, double* res) | |
28 { | |
29 char* start = *p; | |
30 *res = strtod(*p, p); | |
31 if (*p != start) return 1; | |
32 else return 0; | |
33 } | |
34 | |
35 int strtocolor(char** q, uint32_t* res) | |
36 { | |
37 uint32_t color = 0; | |
38 int result; | |
39 char* p = *q; | |
40 | |
41 if (*p == '&') ++p; | |
42 else mp_msg(MSGT_GLOBAL, MSGL_V, "bad color: \"%s\"\n", p); | |
43 | |
44 if (*p == 'H') { | |
45 ++p; | |
46 result = mystrtou32(&p, 16, &color); | |
47 } else { | |
48 result = mystrtou32(&p, 10, &color); | |
49 } | |
50 | |
51 { | |
52 unsigned char* tmp = (unsigned char*)(&color); | |
53 unsigned char b; | |
54 b = tmp[0]; tmp[0] = tmp[3]; tmp[3] = b; | |
55 b = tmp[1]; tmp[1] = tmp[2]; tmp[2] = b; | |
56 } | |
57 if (*p == '&') ++p; | |
58 *q = p; | |
59 | |
60 *res = color; | |
61 return result; | |
62 } | |
63 |