shell: split read builtin from ash
[oweals/busybox.git] / shell / match.h
1 /* match.h - interface to shell ##/%% matching code */
2
3 #ifndef SHELL_MATCH_H
4 #define SHELL_MATCH_H 1
5
6 PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
7
8 typedef char *(*scan_t)(char *string, char *match, bool match_at_left);
9
10 char *scanleft(char *string, char *match, bool match_at_left);
11 char *scanright(char *string, char *match, bool match_at_left);
12
13 static inline scan_t pick_scan(char op1, char op2, bool *match_at_left)
14 {
15         /* #  - scanleft
16          * ## - scanright
17          * %  - scanright
18          * %% - scanleft
19          */
20         if (op1 == '#') {
21                 *match_at_left = true;
22                 return op1 == op2 ? scanright : scanleft;
23         } else {
24                 *match_at_left = false;
25                 return op1 == op2 ? scanleft : scanright;
26         }
27 }
28
29 POP_SAVED_FUNCTION_VISIBILITY
30
31 #endif