827f938414469799ddc18ccf328056274ac5b4ff
[dpdk.git] / lib / librte_eal / windows / eal / include / regex.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019 Intel Corporation
3  */
4
5 #ifndef _REGEX_H_
6 #define _REGEX_H_
7
8 /**
9  * This file is required to support the common code in eal_common_log.c
10  * as Microsoft libc does not contain regex.h. This may be removed in
11  * future releases.
12  */
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #define REG_NOMATCH 1
18 #define REG_ESPACE 12
19
20 #include <rte_common.h>
21
22 /* defining regex_t for Windows */
23 typedef void *regex_t;
24 /* defining regmatch_t for Windows */
25 typedef void *regmatch_t;
26
27 /**
28  * The regcomp() function will compile the regular expression
29  * contained in the string pointed to by the pattern argument
30  * and place the results in the structure pointed to by preg.
31  * The cflags argument is the bitwise inclusive OR of zero or
32  * more of the flags
33  */
34 static inline int regcomp(__rte_unused regex_t *preg,
35                 __rte_unused const char *regex, __rte_unused int cflags)
36 {
37         /* TODO */
38         /* This is a stub, not the expected result */
39         return REG_ESPACE;
40 }
41
42 /**
43  * The regexec() function compares the null-terminated string
44  * specified by string with the compiled regular expression
45  * preg initialised by a previous call to regcomp(). If it finds
46  * a match, regexec() returns 0; otherwise it returns non-zero
47  * indicating either no match or an error. The eflags argument
48  * is the bitwise inclusive OR of zero or more of the flags.
49  */
50 static inline int regexec(__rte_unused const regex_t *preg,
51                 __rte_unused const char *string, __rte_unused size_t nmatch,
52                 __rte_unused regmatch_t pmatch[], __rte_unused int eflags)
53 {
54         /* TODO */
55         /* This is a stub, not the expected result */
56         return REG_NOMATCH;
57 }
58
59 /**
60  * The regerror() function provides a mapping from error codes
61  * returned by regcomp() and regexec() to unspecified printable strings.
62  */
63 static inline size_t regerror(__rte_unused int errcode,
64                 __rte_unused const regex_t *preg, char *errbuf,
65                 __rte_unused size_t errbuf_size)
66 {
67         /* TODO */
68         /* This is a stub, not the expected result */
69         if (errbuf) {
70                 *errbuf = '\0';
71                 return 1;
72         }
73         return 0;
74 }
75
76 /**
77  * The regfree() function frees any memory allocated by regcomp()
78  * associated with preg.
79  */
80 static inline void regfree(__rte_unused regex_t *preg)
81 {
82         /* TODO */
83         /* This is a stub, not the expected result */
84 }
85
86 #ifdef __cplusplus
87 }
88 #endif
89
90 #endif /* _REGEX_H_ */