2012-11-30 15:21:02 +00:00
|
|
|
/*
|
2014-05-01 02:11:09 +00:00
|
|
|
* Copyright (C) 2007-2014 Red Hat, Inc.
|
2012-11-30 15:21:02 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-18 16:13:02 +00:00
|
|
|
#pragma once
|
2012-11-30 15:21:02 +00:00
|
|
|
|
2019-06-18 16:13:02 +00:00
|
|
|
#include "internal.h"
|
2018-07-13 17:54:41 +00:00
|
|
|
|
2020-01-14 13:30:07 +00:00
|
|
|
#define VIR_INT64_STR_BUFLEN 21
|
|
|
|
|
2013-04-03 10:36:23 +00:00
|
|
|
int virStrToLong_i(char const *s,
|
|
|
|
char **end_ptr,
|
|
|
|
int base,
|
2014-07-21 08:17:02 +00:00
|
|
|
int *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2013-04-03 10:36:23 +00:00
|
|
|
|
|
|
|
int virStrToLong_ui(char const *s,
|
|
|
|
char **end_ptr,
|
|
|
|
int base,
|
2014-07-21 08:17:02 +00:00
|
|
|
unsigned int *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2014-05-01 02:11:09 +00:00
|
|
|
int virStrToLong_uip(char const *s,
|
|
|
|
char **end_ptr,
|
|
|
|
int base,
|
2014-07-21 08:17:02 +00:00
|
|
|
unsigned int *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2013-04-03 10:36:23 +00:00
|
|
|
int virStrToLong_l(char const *s,
|
|
|
|
char **end_ptr,
|
|
|
|
int base,
|
2014-07-21 08:17:02 +00:00
|
|
|
long *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2013-04-03 10:36:23 +00:00
|
|
|
int virStrToLong_ul(char const *s,
|
|
|
|
char **end_ptr,
|
|
|
|
int base,
|
2014-07-21 08:17:02 +00:00
|
|
|
unsigned long *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2014-05-01 02:11:09 +00:00
|
|
|
int virStrToLong_ulp(char const *s,
|
|
|
|
char **end_ptr,
|
|
|
|
int base,
|
2014-07-21 08:17:02 +00:00
|
|
|
unsigned long *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2013-04-03 10:36:23 +00:00
|
|
|
int virStrToLong_ll(char const *s,
|
|
|
|
char **end_ptr,
|
|
|
|
int base,
|
2014-07-21 08:17:02 +00:00
|
|
|
long long *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2013-04-03 10:36:23 +00:00
|
|
|
int virStrToLong_ull(char const *s,
|
|
|
|
char **end_ptr,
|
|
|
|
int base,
|
2014-07-21 08:17:02 +00:00
|
|
|
unsigned long long *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2014-05-01 02:11:09 +00:00
|
|
|
int virStrToLong_ullp(char const *s,
|
|
|
|
char **end_ptr,
|
|
|
|
int base,
|
2014-07-21 08:17:02 +00:00
|
|
|
unsigned long long *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2013-04-03 10:36:23 +00:00
|
|
|
int virStrToDouble(char const *s,
|
|
|
|
char **end_ptr,
|
2014-07-21 08:17:02 +00:00
|
|
|
double *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2013-04-03 10:36:23 +00:00
|
|
|
|
2017-06-21 17:08:28 +00:00
|
|
|
int virDoubleToStr(char **strp, double number)
|
2019-10-22 13:26:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(1);
|
2017-06-21 17:08:28 +00:00
|
|
|
|
2013-04-03 10:36:23 +00:00
|
|
|
void virSkipSpaces(const char **str) ATTRIBUTE_NONNULL(1);
|
|
|
|
void virSkipSpacesAndBackslash(const char **str) ATTRIBUTE_NONNULL(1);
|
2021-01-08 00:55:43 +00:00
|
|
|
void virSkipToDigit(const char **str) ATTRIBUTE_NONNULL(1);
|
2013-04-03 10:36:23 +00:00
|
|
|
void virTrimSpaces(char *str, char **endp) ATTRIBUTE_NONNULL(1);
|
|
|
|
void virSkipSpacesBackwards(const char *str, char **endp)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
|
|
2014-10-22 08:26:42 +00:00
|
|
|
bool virStringIsEmpty(const char *str);
|
|
|
|
|
2021-03-02 10:00:23 +00:00
|
|
|
int virStrcpy(char *dest, const char *src, size_t destbytes);
|
2019-06-18 16:13:02 +00:00
|
|
|
#define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
|
2013-04-03 12:51:20 +00:00
|
|
|
|
2013-11-28 11:14:59 +00:00
|
|
|
int virStringSortCompare(const void *a, const void *b);
|
|
|
|
int virStringSortRevCompare(const void *a, const void *b);
|
2015-06-15 16:53:58 +00:00
|
|
|
int virStringToUpper(char **dst, const char *src);
|
2013-11-28 11:14:59 +00:00
|
|
|
|
2014-01-23 09:28:29 +00:00
|
|
|
ssize_t virStringSearch(const char *str,
|
|
|
|
const char *regexp,
|
|
|
|
size_t max_results,
|
|
|
|
char ***matches)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
|
|
|
|
|
2017-05-11 15:16:13 +00:00
|
|
|
bool virStringMatch(const char *str,
|
|
|
|
const char *regexp);
|
|
|
|
|
2014-02-19 20:30:46 +00:00
|
|
|
char *virStringReplace(const char *haystack,
|
|
|
|
const char *oldneedle,
|
|
|
|
const char *newneedle)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
|
|
|
|
2019-03-06 16:05:03 +00:00
|
|
|
bool virStringHasSuffix(const char *str,
|
|
|
|
const char *suffix);
|
2019-03-07 09:17:19 +00:00
|
|
|
bool virStringHasCaseSuffix(const char *str,
|
|
|
|
const char *suffix);
|
2019-03-07 09:18:38 +00:00
|
|
|
bool virStringStripSuffix(char *str,
|
2019-10-14 12:25:14 +00:00
|
|
|
const char *suffix) G_GNUC_WARN_UNUSED_RESULT;
|
2019-03-07 09:18:58 +00:00
|
|
|
bool virStringMatchesNameSuffix(const char *file,
|
|
|
|
const char *name,
|
|
|
|
const char *suffix);
|
2019-03-06 14:07:26 +00:00
|
|
|
|
2014-10-07 15:27:40 +00:00
|
|
|
void virStringStripIPv6Brackets(char *str);
|
2017-04-26 14:26:53 +00:00
|
|
|
bool virStringHasChars(const char *str,
|
|
|
|
const char *chars);
|
2015-04-14 10:30:16 +00:00
|
|
|
bool virStringHasControlChars(const char *str);
|
|
|
|
void virStringStripControlChars(char *str);
|
2017-12-18 14:46:53 +00:00
|
|
|
void virStringFilterChars(char *str, const char *valid);
|
2014-10-07 15:27:40 +00:00
|
|
|
|
2016-04-11 11:35:25 +00:00
|
|
|
bool virStringIsPrintable(const char *str);
|
2016-05-12 15:43:39 +00:00
|
|
|
bool virStringBufferIsPrintable(const uint8_t *buf, size_t buflen);
|
2016-04-11 11:35:25 +00:00
|
|
|
|
2017-05-10 08:16:11 +00:00
|
|
|
void virStringTrimOptionalNewline(char *str);
|
2017-03-29 11:48:22 +00:00
|
|
|
|
2017-07-13 13:31:50 +00:00
|
|
|
int virStringParsePort(const char *str,
|
2017-07-20 10:42:53 +00:00
|
|
|
unsigned int *port)
|
2019-10-14 12:25:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
|
2017-07-13 13:31:50 +00:00
|
|
|
|
2019-03-13 06:30:10 +00:00
|
|
|
int virStringParseYesNo(const char *str,
|
|
|
|
bool *result)
|
2019-10-14 12:25:14 +00:00
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|