Libav
avstring.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 Mans Rullgard
3  *
4  * This file is part of Libav.
5  *
6  * Libav 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  * Libav 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 Libav; 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 #include "attributes.h"
26 
41 int av_strstart(const char *str, const char *pfx, const char **ptr);
42 
53 int av_stristart(const char *str, const char *pfx, const char **ptr);
54 
67 char *av_stristr(const char *haystack, const char *needle);
68 
82 char *av_strnstr(const char *haystack, const char *needle, size_t hay_length);
83 
99 size_t av_strlcpy(char *dst, const char *src, size_t size);
100 
117 size_t av_strlcat(char *dst, const char *src, size_t size);
118 
131 size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4);
132 
136 char *av_d2str(double d);
137 
152 char *av_get_token(const char **buf, const char *term);
153 
157 static inline av_const int av_isdigit(int c)
158 {
159  return c >= '0' && c <= '9';
160 }
161 
165 static inline av_const int av_isgraph(int c)
166 {
167  return c > 32 && c < 127;
168 }
169 
173 static inline av_const int av_isspace(int c)
174 {
175  return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' ||
176  c == '\v';
177 }
178 
182 static inline av_const int av_toupper(int c)
183 {
184  if (c >= 'a' && c <= 'z')
185  c ^= 0x20;
186  return c;
187 }
188 
192 static inline av_const int av_tolower(int c)
193 {
194  if (c >= 'A' && c <= 'Z')
195  c ^= 0x20;
196  return c;
197 }
198 
202 static inline av_const int av_isxdigit(int c)
203 {
204  c = av_tolower(c);
205  return av_isdigit(c) || (c >= 'a' && c <= 'f');
206 }
207 
208 /*
209  * Locale-independent case-insensitive compare.
210  * @note This means only ASCII-range characters are case-insensitive
211  */
212 int av_strcasecmp(const char *a, const char *b);
213 
218 int av_strncasecmp(const char *a, const char *b, size_t n);
219 
220 
226 const char *av_basename(const char *path);
227 
234 const char *av_dirname(char *path);
235 
236 
243 int av_match_name(const char *name, const char *names);
244 
249 #endif /* AVUTIL_AVSTRING_H */
#define av_const
Definition: attributes.h:60
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
Definition: avstring.h:157
int size
char * av_stristr(const char *haystack, const char *needle)
Locate the first case-independent occurrence in the string haystack of the string needle...
Definition: avstring.c:54
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
Definition: avstring.h:173
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
Definition: avstring.c:166
Macro definitions for various function/variable attributes.
int av_stristart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str independent of case.
Definition: avstring.c:43
const char * av_basename(const char *path)
Thread safe basename.
Definition: avstring.c:177
#define b
Definition: input.c:52
#define src
Definition: vp8dsp.c:254
static av_const int av_tolower(int c)
Locale-independent conversion of ASCII characters to lowercase.
Definition: avstring.h:192
int av_match_name(const char *name, const char *names)
Match instances of a name in a comma-separated list of names.
Definition: avstring.c:215
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:81
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
Definition: avstring.c:121
#define av_printf_format(fmtpos, attrpos)
Definition: attributes.h:117
const char * name
Definition: qsvenc.c:44
int av_strcasecmp(const char *a, const char *b)
Definition: avstring.c:156
AVFifoBuffer ** buf
single buffer for interleaved, per-channel buffers for planar
Definition: audio_fifo.c:35
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
Definition: avstring.h:182
size_t char * av_d2str(double d)
Convert a number to a av_malloced string.
Definition: avstring.c:111
static av_const int av_isxdigit(int c)
Locale-independent conversion of ASCII isxdigit.
Definition: avstring.h:202
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
Definition: avstring.c:91
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
Definition: avstring.c:32
static av_const int av_isgraph(int c)
Locale-independent conversion of ASCII isgraph.
Definition: avstring.h:165
char * av_strnstr(const char *haystack, const char *needle, size_t hay_length)
Locate the first occurrence of the string needle in the string haystack where not more than hay_lengt...
Definition: avstring.c:67
const char * av_dirname(char *path)
Thread safe dirname.
Definition: avstring.c:194
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...) av_printf_format(3
Append output to a string, according to a format.