× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hey, all.

Just wondering if there are any tools one can use to search a stream file
for a string and return the position of the string where found. (case
insensitive would be best)

Basically what I'm doing is parsing a MIME type file (with X12 data) and
sections in for each piece of data (yes, it's a very old system... state
stuff)

So I need to be able to find the beginning of each section of the file to
get certain data.

Example:

--f3LPjiHdeXYvMZtHYAOefPpq1FxNrNF1QU
Content-Disposition: form-data; name="CheckSum"
Content-Type: text/plain;charset=UTF-8
Content-Length: 40

76b63d77b64ef6ea8b31e24f1092cd7306b8d1f5
--f3LPjiHdeXYvMZtHYAOefPpq1FxNrNF1QU
Content-Disposition: form-data; name="Payload";
filename="R201229014950..834-.tar"
Content-Type: application/x-tar
Content-Length: 71680

<DATA Could be any length>
--f3LPjiHdeXYvMZtHYAOefPpq1FxNrNF1QU
Content-Disposition: form-data; name="ErrorCode"
Content-Type: text/plain;charset=UTF-8
Content-Length: 7

Success
--f3LPjiHdeXYvMZtHYAOefPpq1FxNrNF1QU
Content-Disposition: form-data; name="ErrorMessage"
Content-Type: text/plain;charset=UTF-8
Content-Length: 4

None
--f3LPjiHdeXYvMZtHYAOefPpq1FxNrNF1QU--

so I'd like a way to say:

rc = findInIFSFile(myfile:'Content-Disposition: form-data;
name="ErrorCode"');

Then if found rc would be the position and I could use lseek to position to
it. Then I read the content length and from there it's easy to parse
things out, no matter the size.

Of course reading in sections at a time and scanning for strings may not
work if I end up reading in a buffer that is half way through a label. I'd
rather not use HUGE strings either (1 meg at most), and even if I did there
is a chance the payload would be larger than the biggest RPG field.

I thought about reading through it, converting to JSON, then using YAJL but
that may be a last resort.

Thanks!

Bradley V. Stone
www.bvstools.com
Native IBM i e-Mail solutions for Microsoft Office 365, Gmail, or any Cloud
Provider!

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.