1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*-
2 // vim:ts=8:sw=8:noet:ai:
4 Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include "ass_utils.h"
29 int mystrtoi(char** p
, int base
, int* res
)
32 *res
= strtol(*p
, p
, base
);
33 if (*p
!= start
) return 1;
37 int mystrtou32(char** p
, int base
, uint32_t* res
)
40 *res
= strtoll(*p
, p
, base
);
41 if (*p
!= start
) return 1;
45 int mystrtod(char** p
, double* res
)
49 if (*p
!= start
) return 1;
53 int strtocolor(char** q
, uint32_t* res
)
60 else mp_msg(MSGT_ASS
, MSGL_DBG2
, "suspicious color format: \"%s\"\n", p
);
62 if (*p
== 'H' || *p
== 'h') {
64 result
= mystrtou32(&p
, 16, &color
);
66 result
= mystrtou32(&p
, 0, &color
);
70 unsigned char* tmp
= (unsigned char*)(&color
);
72 b
= tmp
[0]; tmp
[0] = tmp
[3]; tmp
[3] = b
;
73 b
= tmp
[1]; tmp
[1] = tmp
[2]; tmp
[2] = b
;