blob: 2bbd5ceae9abc6f1c66eac919c0af2263c72c2d8 (
plain) (
blame)
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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <ctype.h>
# QP_PARSE -- Parse a QPOE/QPIO specification into the root (poefile) name
# and event list filter expression fields.
#
# Syntax: root[filter]
#
# where the filter spec is optional.
procedure qp_parse (qpspec, root, sz_root, filter, sz_filter)
char qpspec[ARB] #I full event list specification
char root[sz_root] #O receives root name
int sz_root #I max chars in root name
char filter[sz_filter] #O receives filter
int sz_filter #I max chars in filter name
int level, ip, op, ch
begin
ip = 1
op = 1
# Extract root name. The first (unescaped) [ marks the start of
# the filter field.
for (ch=qpspec[ip]; ch != EOS && ch != '['; ch=qpspec[ip]) {
if (ch == '\\' && qpspec[ip+1] == '[') {
root[op] = '\\'
op = op + 1
root[op] = '['
ip = ip + 1
} else
root[op] = ch
op = min (sz_root, op + 1)
ip = ip + 1
}
root[op] = EOS
level = 0
op = 1
# Extract the [] bracketed filter expression, allowing for nested
# brackets.
for (ch=qpspec[ip]; ch != EOS; ch=qpspec[ip]) {
if (ch == '[')
level = level + 1
else if (ch == ']')
level = level - 1
filter[op] = ch
op = min (sz_filter, op + 1)
ip = ip + 1
if (level <= 0)
break
}
# Add closing brace if the user left it off.
if (op > 1 && ch != ']') {
filter[op] = ']'
op = min (sz_filter, op + 1)
}
filter[op] = EOS
end
|