2 * Various simple utilities for ffmpeg system
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #if !defined(CONFIG_NOCUTILS)
24 * Return TRUE if val is a prefix of str. If it returns TRUE, ptr is
25 * set to the next character in 'str' after the prefix.
27 * @param str input string
28 * @param val prefix to test
29 * @param ptr updated after the prefix in str in there is a match
30 * @return TRUE if there is a match
32 int strstart(const char *str, const char *val, const char **ptr)
49 * Return TRUE if val is a prefix of str (case independent). If it
50 * returns TRUE, ptr is set to the next character in 'str' after the
53 * @param str input string
54 * @param val prefix to test
55 * @param ptr updated after the prefix in str in there is a match
56 * @return TRUE if there is a match */
57 int stristart(const char *str, const char *val, const char **ptr)
63 if (toupper(*(const unsigned char *)p) != toupper(*(const unsigned char *)q))
74 * Copy the string str to buf. If str length is bigger than buf_size -
75 * 1 then it is clamped to buf_size - 1.
76 * NOTE: this function does what strncpy should have done to be
77 * useful. NEVER use strncpy.
79 * @param buf destination buffer
80 * @param buf_size size of destination buffer
81 * @param str source string
83 void pstrcpy(char *buf, int buf_size, const char *str)
93 if (c == 0 || q >= buf + buf_size - 1)
100 /* strcat and truncate. */
101 char *pstrcat(char *buf, int buf_size, const char *s)
106 pstrcpy(buf + len, buf_size - len, s);
112 /* add one element to a dynamic array */
113 void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem)
120 if ((nb & (nb - 1)) == 0) {
125 tab = av_realloc(tab, nb_alloc * sizeof(unsigned long));