199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2019 Intel Corporation 399a2dd95SBruce Richardson */ 499a2dd95SBruce Richardson 599a2dd95SBruce Richardson #ifndef _REGEX_H_ 699a2dd95SBruce Richardson #define _REGEX_H_ 799a2dd95SBruce Richardson 899a2dd95SBruce Richardson /** 999a2dd95SBruce Richardson * This file is required to support the common code in eal_common_log.c 1099a2dd95SBruce Richardson * as Microsoft libc does not contain regex.h. This may be removed in 1199a2dd95SBruce Richardson * future releases. 1299a2dd95SBruce Richardson */ 1399a2dd95SBruce Richardson #define REG_NOMATCH 1 1499a2dd95SBruce Richardson #define REG_ESPACE 12 1599a2dd95SBruce Richardson 1699a2dd95SBruce Richardson #include <rte_common.h> 1799a2dd95SBruce Richardson 18*719834a6SMattias Rönnblom #ifdef __cplusplus 19*719834a6SMattias Rönnblom extern "C" { 20*719834a6SMattias Rönnblom #endif 21*719834a6SMattias Rönnblom 2299a2dd95SBruce Richardson /* defining regex_t for Windows */ 2399a2dd95SBruce Richardson typedef void *regex_t; 2499a2dd95SBruce Richardson /* defining regmatch_t for Windows */ 2599a2dd95SBruce Richardson typedef void *regmatch_t; 2699a2dd95SBruce Richardson 2799a2dd95SBruce Richardson /** 2899a2dd95SBruce Richardson * The regcomp() function will compile the regular expression 2999a2dd95SBruce Richardson * contained in the string pointed to by the pattern argument 3099a2dd95SBruce Richardson * and place the results in the structure pointed to by preg. 3199a2dd95SBruce Richardson * The cflags argument is the bitwise inclusive OR of zero or 3299a2dd95SBruce Richardson * more of the flags 3399a2dd95SBruce Richardson */ 3499a2dd95SBruce Richardson static inline int regcomp(__rte_unused regex_t *preg, 3599a2dd95SBruce Richardson __rte_unused const char *regex, __rte_unused int cflags) 3699a2dd95SBruce Richardson { 3799a2dd95SBruce Richardson /* TODO */ 3899a2dd95SBruce Richardson /* This is a stub, not the expected result */ 3999a2dd95SBruce Richardson return REG_ESPACE; 4099a2dd95SBruce Richardson } 4199a2dd95SBruce Richardson 4299a2dd95SBruce Richardson /** 4399a2dd95SBruce Richardson * The regexec() function compares the null-terminated string 4499a2dd95SBruce Richardson * specified by string with the compiled regular expression 4599a2dd95SBruce Richardson * preg initialised by a previous call to regcomp(). If it finds 4699a2dd95SBruce Richardson * a match, regexec() returns 0; otherwise it returns non-zero 4799a2dd95SBruce Richardson * indicating either no match or an error. The eflags argument 4899a2dd95SBruce Richardson * is the bitwise inclusive OR of zero or more of the flags. 4999a2dd95SBruce Richardson */ 5099a2dd95SBruce Richardson static inline int regexec(__rte_unused const regex_t *preg, 5199a2dd95SBruce Richardson __rte_unused const char *string, __rte_unused size_t nmatch, 5299a2dd95SBruce Richardson __rte_unused regmatch_t pmatch[], __rte_unused int eflags) 5399a2dd95SBruce Richardson { 5499a2dd95SBruce Richardson /* TODO */ 5599a2dd95SBruce Richardson /* This is a stub, not the expected result */ 5699a2dd95SBruce Richardson return REG_NOMATCH; 5799a2dd95SBruce Richardson } 5899a2dd95SBruce Richardson 5999a2dd95SBruce Richardson /** 6099a2dd95SBruce Richardson * The regerror() function provides a mapping from error codes 6199a2dd95SBruce Richardson * returned by regcomp() and regexec() to unspecified printable strings. 6299a2dd95SBruce Richardson */ 6399a2dd95SBruce Richardson static inline size_t regerror(__rte_unused int errcode, 6499a2dd95SBruce Richardson __rte_unused const regex_t *preg, char *errbuf, 6599a2dd95SBruce Richardson __rte_unused size_t errbuf_size) 6699a2dd95SBruce Richardson { 6799a2dd95SBruce Richardson /* TODO */ 6899a2dd95SBruce Richardson /* This is a stub, not the expected result */ 6999a2dd95SBruce Richardson if (errbuf) { 7099a2dd95SBruce Richardson *errbuf = '\0'; 7199a2dd95SBruce Richardson return 1; 7299a2dd95SBruce Richardson } 7399a2dd95SBruce Richardson return 0; 7499a2dd95SBruce Richardson } 7599a2dd95SBruce Richardson 7699a2dd95SBruce Richardson /** 7799a2dd95SBruce Richardson * The regfree() function frees any memory allocated by regcomp() 7899a2dd95SBruce Richardson * associated with preg. 7999a2dd95SBruce Richardson */ 8099a2dd95SBruce Richardson static inline void regfree(__rte_unused regex_t *preg) 8199a2dd95SBruce Richardson { 8299a2dd95SBruce Richardson /* TODO */ 8399a2dd95SBruce Richardson /* This is a stub, not the expected result */ 8499a2dd95SBruce Richardson } 8599a2dd95SBruce Richardson 8699a2dd95SBruce Richardson #ifdef __cplusplus 8799a2dd95SBruce Richardson } 8899a2dd95SBruce Richardson #endif 8999a2dd95SBruce Richardson 9099a2dd95SBruce Richardson #endif /* _REGEX_H_ */ 91