Discussion:
[ragel-users] How to check if a list of strings exist?
dinesh rtp
2014-05-19 19:36:51 UTC
Permalink
Hi,
I am new to ragel and finding it difficult to solve this problem.
I need to check if certain headers exists in the input to ragel machine. The easier way is to parse header and check if the header I am looking for is present or not. The problem with this, I need to compare every header that is present in the input to figure if the headers I am looking for is present. Is there a way in ragel to say "Given a list of headers are these headers present in any order" ?
For example:
Input:Content-Description: Delivery report
Content-Type: message/delivery-status

Reporting-MTA: dns; xxx
Arrival-Date: Fri, 04 May 2012 15:25:09 +0200

Final-Recipient: rfc822; test-dsn-failure at gmail.com
Status: 5.1.1
Action: failed
Last-Attempt-Date: Fri, 04 May 2012 15:25:09 +0200
Diagnostic-Code: smtp; 550-5.1.1 The email account that you tried to reach does not exist. Please try
550-5.1.1 double-checking the recipient's email address for typos or
550-5.1.1 unnecessary spaces. Learn more at
550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 t12si10077186weq.36
I just need to check if the headers:Reporting-MTA:Final-Recipient:Status:Action:
are present.
For now I have come with the following:
key = print - [:];action headerName {headerName.append(1,fc);}action onHeader { if (headerName.compare("Reporting-MTA") == 0) { cout << "Reporting-MTA header is present" << endl; } else if ...}header = key+ @headerName ':' @onHeader;
Is there a easier way to check if these headers exist?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.complang.org/pipermail/ragel-users/attachments/20140519/8422b376/attachment.html>
Adrian Thurston
2014-06-29 14:55:29 UTC
Permalink
Hi Dinesh,

The basic approach would be to write a parser for headers and union the
pattern for header names with specific header name values. Have a look
at mailbox1.rl in the test case directory. It is close to what you want.

Regards,
Adrian
Post by dinesh rtp
Hi,
I am new to ragel and finding it difficult to solve this problem.
I need to check if certain headers exists in the input to ragel machine.
The easier way is to parse header and check if the header I am looking
for is present or not. The problem with this, I need to compare every
header that is present in the input to figure if the headers I am
looking for is present. Is there a way in ragel to say "Given a list of
headers are these headers present in any order" ?
|Content-Description: Delivery report
Content-Type: message/delivery-status
Reporting-MTA: dns; xxx
Arrival-Date: Fri, 04 May 2012 15:25:09 +0200
Final-Recipient: rfc822; test-dsn-failure at gmail.com
Status: 5.1.1
Action: failed
Last-Attempt-Date: Fri, 04 May 2012 15:25:09 +0200
Diagnostic-Code: smtp; 550-5.1.1 The email account that you tried to reach does not exist. Please try
550-5.1.1 double-checking the recipient's email addressfor typosor
550-5.1.1 unnecessary spaces. Learn more at
550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 t12si10077186weq.36
|
|I just need to check if the headers:|
|Reporting-MTA:|
|Final-Recipient:|
are present.
key = print - [:];
action headerName {headerName.append(1,fc);}
action onHeader {
if (headerName.compare("Reporting-MTA") == 0) {
cout << "Reporting-MTA header is present" << endl;
} else if ...
}
Is there a easier way to check if these headers exist?
_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users
Loading...