Mercurial > libavutil.hg
annotate avstring.h @ 799:cb32a271f4cd libavutil
Add a function to convert a number to a av_malloced string.
author | michael |
---|---|
date | Sun, 13 Dec 2009 17:09:41 +0000 |
parents | 81aecbb6bbb2 |
children | 197e6e41f46f |
rev | line source |
---|---|
347 | 1 /* |
2 * Copyright (c) 2007 Mans Rullgard | |
3 * | |
4 * This file is part of FFmpeg. | |
5 * | |
6 * FFmpeg is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 2.1 of the License, or (at your option) any later version. | |
10 * | |
11 * FFmpeg 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 GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with FFmpeg; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
19 */ | |
20 | |
567 | 21 #ifndef AVUTIL_AVSTRING_H |
22 #define AVUTIL_AVSTRING_H | |
347 | 23 |
24 #include <stddef.h> | |
799
cb32a271f4cd
Add a function to convert a number to a av_malloced string.
michael
parents:
778
diff
changeset
|
25 #include "mem.h" |
347 | 26 |
27 /** | |
28 * Return non-zero if pfx is a prefix of str. If it is, *ptr is set to | |
29 * the address of the first character in str after the prefix. | |
30 * | |
31 * @param str input string | |
32 * @param pfx prefix to test | |
637 | 33 * @param ptr updated if the prefix is matched inside str |
347 | 34 * @return non-zero if the prefix matches, zero otherwise |
35 */ | |
36 int av_strstart(const char *str, const char *pfx, const char **ptr); | |
37 | |
38 /** | |
39 * Return non-zero if pfx is a prefix of str independent of case. If | |
40 * it is, *ptr is set to the address of the first character in str | |
41 * after the prefix. | |
42 * | |
43 * @param str input string | |
44 * @param pfx prefix to test | |
637 | 45 * @param ptr updated if the prefix is matched inside str |
347 | 46 * @return non-zero if the prefix matches, zero otherwise |
47 */ | |
48 int av_stristart(const char *str, const char *pfx, const char **ptr); | |
49 | |
50 /** | |
51 * Copy the string src to dst, but no more than size - 1 bytes, and | |
633 | 52 * null-terminate dst. |
347 | 53 * |
54 * This function is the same as BSD strlcpy(). | |
55 * | |
56 * @param dst destination buffer | |
57 * @param src source string | |
58 * @param size size of destination buffer | |
59 * @return the length of src | |
778
81aecbb6bbb2
Add warnings to av_strlcat and av_strlcpy doxygen that the input strings
reimar
parents:
637
diff
changeset
|
60 * |
81aecbb6bbb2
Add warnings to av_strlcat and av_strlcpy doxygen that the input strings
reimar
parents:
637
diff
changeset
|
61 * WARNING: since the return value is the length of src, src absolutely |
81aecbb6bbb2
Add warnings to av_strlcat and av_strlcpy doxygen that the input strings
reimar
parents:
637
diff
changeset
|
62 * _must_ be a properly 0-terminated string, otherwise this will read beyond |
81aecbb6bbb2
Add warnings to av_strlcat and av_strlcpy doxygen that the input strings
reimar
parents:
637
diff
changeset
|
63 * the end of the buffer and possibly crash. |
347 | 64 */ |
65 size_t av_strlcpy(char *dst, const char *src, size_t size); | |
66 | |
67 /** | |
68 * Append the string src to the string dst, but to a total length of | |
633 | 69 * no more than size - 1 bytes, and null-terminate dst. |
347 | 70 * |
71 * This function is similar to BSD strlcat(), but differs when | |
72 * size <= strlen(dst). | |
73 * | |
74 * @param dst destination buffer | |
75 * @param src source string | |
76 * @param size size of destination buffer | |
77 * @return the total length of src and dst | |
778
81aecbb6bbb2
Add warnings to av_strlcat and av_strlcpy doxygen that the input strings
reimar
parents:
637
diff
changeset
|
78 * |
81aecbb6bbb2
Add warnings to av_strlcat and av_strlcpy doxygen that the input strings
reimar
parents:
637
diff
changeset
|
79 * WARNING: since the return value use the length of src and dst, these absolutely |
81aecbb6bbb2
Add warnings to av_strlcat and av_strlcpy doxygen that the input strings
reimar
parents:
637
diff
changeset
|
80 * _must_ be a properly 0-terminated strings, otherwise this will read beyond |
81aecbb6bbb2
Add warnings to av_strlcat and av_strlcpy doxygen that the input strings
reimar
parents:
637
diff
changeset
|
81 * the end of the buffer and possibly crash. |
347 | 82 */ |
83 size_t av_strlcat(char *dst, const char *src, size_t size); | |
84 | |
369
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
85 /** |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
86 * Append output to a string, according to a format. Never write out of |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
87 * the destination buffer, and and always put a terminating 0 within |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
88 * the buffer. |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
89 * @param dst destination buffer (string to which the output is |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
90 * appended) |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
91 * @param size total size of the destination buffer |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
92 * @param fmt printf-compatible format string, specifying how the |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
93 * following parameters are used |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
94 * @return the length of the string that would have been generated |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
95 * if enough space had been available |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
96 */ |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
97 size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...); |
2cd0add8ac0c
Implement av_strlcatf(): a strlcat which adds a printf style formatted string
lucabe
parents:
347
diff
changeset
|
98 |
799
cb32a271f4cd
Add a function to convert a number to a av_malloced string.
michael
parents:
778
diff
changeset
|
99 /** |
cb32a271f4cd
Add a function to convert a number to a av_malloced string.
michael
parents:
778
diff
changeset
|
100 * Convert a number to a av_malloced string. |
cb32a271f4cd
Add a function to convert a number to a av_malloced string.
michael
parents:
778
diff
changeset
|
101 */ |
cb32a271f4cd
Add a function to convert a number to a av_malloced string.
michael
parents:
778
diff
changeset
|
102 char *av_d2str(double d); |
cb32a271f4cd
Add a function to convert a number to a av_malloced string.
michael
parents:
778
diff
changeset
|
103 |
567 | 104 #endif /* AVUTIL_AVSTRING_H */ |