Appendix B - Format checking tools
This section includes the source for format checking tools for the two proformas. The tools are written as Bourne shell scripts for UNIX systems.
- Object class format checker
sed 's/ *: */:/' |
awk '
BEGIN {
state = "initial"
}
/^$/ {
next
}
/^Object Class:/ {
n = index($0, ":")
if (state != "initial")
{
print "Already got object class " oc
print "Got another object class " substr($0, n+1)
state = "notOK"
exit 1
}
oc = substr($0, n+1)
state = "gotOC"
next
}
/^Description:/ {
n = index($0, ":")
if (state != "gotOC")
{
print "Got Description: " substr($0, n+1)
for (i = 0; i < 2 && getline > 0; i++)
print $0
print "..."
if (state == "initial")
print "Expecting Object Class:"
else
print "Expecting ASN1OCMacro:"
state = "notOK"
exit 1
}
while (getline > 0)
if (length($0) > 0)
continue
else
break
state = "gotDesc"
next
}
/^ASN1OCMacro:/ {
n = index($0, ":")
if (state != "gotDesc")
{
print "Got ASN1Macro: " substr($0, n+1)
for (i = 0; i < 2 && getline > 0; i++)
print $0
print "..."
if (state == "initial")
print "Expecting Object Class:"
else
print "Expecting Description:"
state = "notOK"
exit 1
}
state = "OK"
exit 0
}
{
print "Parsing has got confused on seeing line: " $0
state = "notOK"
exit 1
}
END {
if (state == "OK")
print "Input looks OK"
}
- Attribute Type format checker
sed 's/ *: */:/' |
awk '
BEGIN {
state = "initial"
}
/^$/ {
next
}
/^Attribute Type:/ {
n = index($0, ":")
if (state != "initial")
{
got = "Attribute Type:"
exit 1
}
state = "gotAT"
next
}
/^Description:/ {
n = index($0, ":")
if (state != "gotAT")
{
got = "Description:"
exit 1
}
while (getline > 0)
if (length($0) > 0)
continue
else
break
state = "gotDesc"
next
}
/^OCMust:/ {
n = index($0, ":")
if (state != "gotDesc")
{
got = "OCMust:"
exit 1
}
state = "gotOCMust"
next
}
/^OCMay:/ {
n = index($0, ":")
if (state != "gotOCMust")
{
got = "OCMay:"
exit 1
}
state = "gotOCMay"
next
}
/^ASN1ATMacro:/ {
n = index($0, ":")
if (state != "gotOCMay")
{
got = "ASN1ATMacro:"
exit 1
}
state = "OK"
exit 0
}
{
print "Parsing has got confused on seeing line: " $0
state = "notOK"
exit 1
}
END {
if (state == "initial")
print "Expecting Attribute Type:"
else if (state == "gotAT")
print "Expecting Description:"
else if (state == "gotDesc")
print "Expecting OCMust:"
else if (state == "gotOCMust")
print "Expecting OCMay:"
else if (state == "gotOCMay")
print "Expecting ASN1ATMacro:"
if (state != "OK")
print "Got " got
else
print "Input looks OK"
}