summaryrefslogtreecommitdiff
path: root/dviware/quicspool/man/glob.l
blob: 667ab942ccd7eca106a1e37ecde41caef8ef9e6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
.\" $Header: glob.l,v 1.1 88/01/15 12:58:23 simpson Rel $
.\" $Log:	glob.l,v $
.\" Revision 1.1  88/01/15  12:58:23  simpson
.\" initial release
.\" 
.\" Revision 0.1  87/12/11  17:56:52  simpson
.\" beta test
.\" 
.TH GLOB 3 TRW
.UC
.SH NAME
glob \- shell style pattern matching
.SH SYNOPSIS
.nf
.B #include <local/glob.h>

.B int glob_compile(pattern, buffer)
.B char *pattern;
.B char *buffer;

.B int glob_execute(buffer, s)
.B char *buffer;
.B char *s;

.B int glob_match (pattern, s)
.B char *pattern;
.B char *s;
.fi

.B cc 
[ flags ] files
.B -lglob
[ libraries ]
.fi
.SH DESCRIPTION
.I Glob
is a pattern matching facility similar to that of
.IR sh (1)
and
.IR csh (1).
.PP
A pattern specifies a set of strings of characters.
A member of this set of strings is said to be matched by the pattern.
.TP
(1)
Any character except a special character matches itself.
The special characters are [ * and ?.
.TP
(2)
A ? matches any character.
.TP
(3)
A nonempty string
.I s
bracketed
.RI [ s ]
matches any character in
.IR s .
In
.I s
] may only appear as the first letter.
A substring
.IR a \- b ,
with
.I a
and
.I b
in ascending ASCII order,
stands for the inclusive range of ASCII characters.
.TP
(4)
A * matches 0 or more characters.
.PP
.I Glob_compile
compiles a
.I pattern
into an internal form suitable for matching,
placing the result in the character array
.IR buffer .
.I Buffer
must be a character array of size
.BR GLOB_MAX_PATTERN .
.I Glob_compile
returns 0 if the
.I pattern
was compiled successfully;
otherwise a negative error code is returned.
.PP
.I Glob_execute
checks the argument string
.I s
against the compiled
.IR pattern .
.I Glob_execute
returns 1 if the string
.I s
matches the compiled pattern in
.IR buffer ,
0 if the string
.I s
failed to match the compiled pattern in
.IR buffer ,
and a negative error code if the compiled pattern was invalid.
.PP
The strings passed to both
.I glob_compile
and
.I glob_execute
may have trailing or embedded newline characters;
they are terminated by nulls.
.PP
.I Glob_match
compiles
.I pattern
and matches it against the argument string
.IR s .
It returns 1 if the string
.I s
matches the pattern;
0 if the string
.I s
fails to match the pattern
and a negative error code if the pattern was invalid.
.SH AUTHOR
Michael Gorlick, TRW
.SH SEE ALSO
regex(3)
.SH DIAGNOSTICS
The following diagnostic codes are provided:
.TP
GLOB_OK
returned by
.I glob_compile
indicating the pattern compiled successfully;
.TP
GLOB_PATTERN_TOO_BIG
returned by
.I glob_compile
or
.I glob_match
indicating the compiled pattern overflowed the buffer;
.TP
GLOB_PATTERN_EMPTY
returned by
.I glob_compile
or
.I glob_match
indicating the pattern is the empty string;
.TP
GLOB_BRACKET_MISSING
returned by
.I glob_compile
or
.I glob_match
indicating that a set expression
.RI [ s ]
is missing the terminating bracket ];
.TP
GLOB_RANGE_INVERTED
returned by
.I glob_compile
or
.I glob_match
indicating a range expression in a set
is inverted, for example [z-a];
.TP
GLOB_SET_TOO_BIG
returned by
.I glob_compile
or
.I glob_match
indicating a compiled set requires more than 127 bytes
(a single character consumes 2 bytes and a range consumes 3 bytes);
.TP
GLOB_EXECUTION_ERROR
returned by
.I glob_execute
or
.I glob_match
indicating an internal error.