eal/windows: add headers for compatibility
[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 /* defining regex_t for Windows */
21 typedef void *regex_t;
22 /* defining regmatch_t for Windows */
23 typedef void *regmatch_t;
24
25 /**
26  * The regcomp() function will compile the regular expression
27  * contained in the string pointed to by the pattern argument
28  * and place the results in the structure pointed to by preg.
29  * The cflags argument is the bitwise inclusive OR of zero or
30  * more of the flags
31  */
32 static inline int regcomp(__rte_unused regex_t *preg,
33                 __rte_unused const char *regex, __rte_unused int cflags)
34 {
35         /* TODO */
36         /* This is a stub, not the expected result */
37         return REG_ESPACE;
38 }
39
40 /**
41  * The regexec() function compares the null-terminated string
42  * specified by string with the compiled regular expression
43  * preg initialised by a previous call to regcomp(). If it finds
44  * a match, regexec() returns 0; otherwise it returns non-zero
45  * indicating either no match or an error. The eflags argument
46  * is the bitwise inclusive OR of zero or more of the flags.
47  */
48 static inline int regexec(__rte_unused const regex_t *preg,
49                 __rte_unused const char *string, __rte_unused size_t nmatch,
50                 __rte_unused regmatch_t pmatch[], __rte_unused int eflags)
51 {
52         /* TODO */
53         /* This is a stub, not the expected result */
54         return REG_NOMATCH;
55 }
56
57 /**
58  * The regerror() function provides a mapping from error codes
59  * returned by regcomp() and regexec() to unspecified printable strings.
60  */
61 static inline size_t regerror(__rte_unused int errcode,
62                 __rte_unused const regex_t *preg, char *errbuf,
63                 __rte_unused size_t errbuf_size)
64 {
65         /* TODO */
66         /* This is a stub, not the expected result */
67         if (errbuf) {
68                 *errbuf = '\0';
69                 return 1;
70         }
71         return 0;
72 }
73
74 /**
75  * The regfree() function frees any memory allocated by regcomp()
76  * associated with preg.
77  */
78 static inline void regfree(__rte_unused regex_t *preg)
79 {
80         /* TODO */
81         /* This is a stub, not the expected result */
82 }
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif /* _REGEX_H_ */