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 
84 size_t av_strlcpy(char *dst, const char *src, size_t size);
85 
102 size_t av_strlcat(char *dst, const char *src, size_t size);
103 
116 size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4);
117 
121 char *av_d2str(double d);
122 
137 char *av_get_token(const char **buf, const char *term);
138 
142 static inline int av_toupper(int c)
143 {
144  if (c >= 'a' && c <= 'z')
145  c ^= 0x20;
146  return c;
147 }
148 
152 static inline int av_tolower(int c)
153 {
154  if (c >= 'A' && c <= 'Z')
155  c ^= 0x20;
156  return c;
157 }
158 
159 /*
160  * Locale-independent case-insensitive compare.
161  * @note This means only ASCII-range characters are case-insensitive
162  */
163 int av_strcasecmp(const char *a, const char *b);
164 
169 int av_strncasecmp(const char *a, const char *b, size_t n);
170 
175 #endif /* AVUTIL_AVSTRING_H */
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:51
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
Definition: avstring.c:147
#define b
Definition: swscale.c:1335
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:40
static int av_tolower(int c)
Locale-independent conversion of ASCII characters to lowercase.
Definition: avstring.h:152
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:64
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:103
#define av_printf_format(fmtpos, attrpos)
Definition: attributes.h:133
int av_strcasecmp(const char *a, const char *b)
Definition: avstring.c:137
size_t char * av_d2str(double d)
Convert a number to a av_malloced string.
Definition: avstring.c:94
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:74
static int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
Definition: avstring.h:142
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:29
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.