[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



But what about:

$ perl -le 'print "a" x 2047,  "\xff" x 16, "b" x 512' > foo
$ perl -lne 'BEGIN{$/=\1024} print "hit byte ", ($.-1) * 1024 + $-[0] if /\xff{16}/' foo
$

^^^^^^ No hit byte found :(

Not being fluent in perl, I have no idea how this would be fixed.

Yet another alternative would be to create a simple scanner using 
flex.  Put the following in a file "scan.lex", then run "flex 
scan.lex; gcc lex.yy.c -o scan".  The result is an executable called 
"scan" which reads data from standard input. 

--Joe

%{
#include <stdio.h>
int  fpos = 0;
%}
%option noyywrap
%option nounput

%%
\xff{16}     printf ("Offset: %d\n", fpos); fpos+= 16;
.|\n       ++fpos;

%%
void main(void)
{
        yylex();
}





</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00756" href="msg00756.html">[ale] Binary Grep</a></strong>
<ul><li><em>From:</em> greg.freemyer at gmail.com (Greg Freemyer)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00752.html">[ale] problems with Cendyne 32x10x40 USB CD-RW with SUSE 9.2 and FC3</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00754.html">[ale] Three d[a]emonic questions</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00751.html">[ale] Binary Grep</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00756.html">[ale] Binary Grep</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00753"><strong>Date</strong></a></li>
<li><a href="threads.html#00753"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>