]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/frrstr.h
Merge pull request #12818 from imzyxwvu/fix/other-table-inactive
[mirror_frr.git] / lib / frrstr.h
index 3a935c90cb26062c0d9cf5d97888634aac2e10de..19ba09e213190e874122327c63c0d6b1719d11a2 100644 (file)
@@ -1,28 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * FRR string processing utilities.
  * Copyright (C) 2018  Cumulus Networks, Inc.
  *                     Quentin Young
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program 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 General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #ifndef _FRRSTR_H_
 #define _FRRSTR_H_
 
 #include <sys/types.h>
+#include <sys/types.h>
+#ifdef HAVE_LIBPCRE2_POSIX
+#ifndef _FRR_PCRE2_POSIX
+#define _FRR_PCRE2_POSIX
+#include <pcre2posix.h>
+#endif /* _FRR_PCRE2_POSIX */
+#elif defined(HAVE_LIBPCREPOSIX)
+#include <pcreposix.h>
+#else
 #include <regex.h>
+#endif /* HAVE_LIBPCRE2_POSIX */
 #include <stdbool.h>
 
 #include "vector.h"
@@ -149,6 +146,26 @@ bool frrstr_endswith(const char *str, const char *suffix);
  */
 int all_digit(const char *str);
 
+/*
+ * Copy the hexadecimal representation of the string to a buffer.
+ *
+ * buff
+ *    Buffer to copy result into with size of at least (2 * num) + 1.
+ *
+ * bufsiz
+ *    Size of destination buffer.
+ *
+ * str
+ *    String to represent as hexadecimal.
+ *
+ * num
+ *    Number of characters to copy.
+ *
+ * Returns:
+ *    Pointer to buffer containing resulting hexadecimal representation.
+ */
+char *frrstr_hex(char *buff, size_t bufsiz, const uint8_t *str, size_t num);
+
 #ifdef __cplusplus
 }
 #endif