Statistics
| Branch: | Revision:

ffmpeg / libavutil / avstring.h @ ac6ef868

History | View | Annotate | Download (3.88 KB)

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

    
21
#ifndef AVUTIL_AVSTRING_H
22
#define AVUTIL_AVSTRING_H
23

    
24
#include <stddef.h>
25

    
26
/**
27
 * Return non-zero if pfx is a prefix of str. If it is, *ptr is set to
28
 * the address of the first character in str after the prefix.
29
 *
30
 * @param str input string
31
 * @param pfx prefix to test
32
 * @param ptr updated if the prefix is matched inside str
33
 * @return non-zero if the prefix matches, zero otherwise
34
 */
35
int av_strstart(const char *str, const char *pfx, const char **ptr);
36

    
37
/**
38
 * Return non-zero if pfx is a prefix of str independent of case. If
39
 * it is, *ptr is set to the address of the first character in str
40
 * after the prefix.
41
 *
42
 * @param str input string
43
 * @param pfx prefix to test
44
 * @param ptr updated if the prefix is matched inside str
45
 * @return non-zero if the prefix matches, zero otherwise
46
 */
47
int av_stristart(const char *str, const char *pfx, const char **ptr);
48

    
49
/**
50
 * Locate the first case-independent occurrence in the string s1 of
51
 * the string s2.  A zero-length string s2 is considered to match at
52
 * the start of s1.
53
 *
54
 * This function is a case-insensitive version of the standard strstr().
55
 *
56
 * @param s1 string to search in
57
 * @param s2 string to search for
58
 * @return pointer to the located match within s1 or a null pointer if no match
59
 */
60
char *av_stristr(const char *s1, const char *s2);
61

    
62
/**
63
 * Copy the string src to dst, but no more than size - 1 bytes, and
64
 * null-terminate dst.
65
 *
66
 * This function is the same as BSD strlcpy().
67
 *
68
 * @param dst destination buffer
69
 * @param src source string
70
 * @param size size of destination buffer
71
 * @return the length of src
72
 *
73
 * WARNING: since the return value is the length of src, src absolutely
74
 * _must_ be a properly 0-terminated string, otherwise this will read beyond
75
 * the end of the buffer and possibly crash.
76
 */
77
size_t av_strlcpy(char *dst, const char *src, size_t size);
78

    
79
/**
80
 * Append the string src to the string dst, but to a total length of
81
 * no more than size - 1 bytes, and null-terminate dst.
82
 *
83
 * This function is similar to BSD strlcat(), but differs when
84
 * size <= strlen(dst).
85
 *
86
 * @param dst destination buffer
87
 * @param src source string
88
 * @param size size of destination buffer
89
 * @return the total length of src and dst
90
 *
91
 * WARNING: since the return value use the length of src and dst, these absolutely
92
 * _must_ be a properly 0-terminated strings, otherwise this will read beyond
93
 * the end of the buffer and possibly crash.
94
 */
95
size_t av_strlcat(char *dst, const char *src, size_t size);
96

    
97
/**
98
 * Append output to a string, according to a format. Never write out of
99
 * the destination buffer, and always put a terminating 0 within
100
 * the buffer.
101
 * @param dst destination buffer (string to which the output is
102
 *  appended)
103
 * @param size total size of the destination buffer
104
 * @param fmt printf-compatible format string, specifying how the
105
 *  following parameters are used
106
 * @return the length of the string that would have been generated
107
 *  if enough space had been available
108
 */
109
size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...);
110

    
111
/**
112
 * Convert a number to a av_malloced string.
113
 */
114
char *av_d2str(double d);
115

    
116
#endif /* AVUTIL_AVSTRING_H */