Key Pages: [ Rope Home Page | Basics (tutorial) | Language Reference | Download ]
The lift_while action lifts data from the packet, one byte at a time and submits each one to a block for checking. If the block leaves a TRUE value on the stack, then lift_while advances to the next byte, but if the block leaves a FALSE value, then lift_while stops scanning.
All the bytes thus collected are pushed onto the stack as a single string.
For example:
lift_while( { isdigit } )
lifts digit characters in the packet at $offset. The $offset is left pointing to the first non-digit in the packet and the collected digits are pushed onto the stack as a single string. It is possible that the string will be empty if no digits were found.
If the block to be executed contains just one action keyword, and the action is from the set of character tests in the "is....." set (like isdigit, isalpha .. etc) then lift_while doesnt actually call the block at all, but uses the matching C language function internally - this means that the lift loop is highly optimised in these cases.
For example..
lift_while( {isdigit} ) -- optimized
lift_while( {dup isdigit isalpha or} ) -- not optimized
lift_while( {isalnum} ) -- optimized
From version 20041201 onwards, the use of "not" with an "is..." function is also optimised in this same way. For example..
lift_while( {isdigit not} )
Lowth.com: [ Home | Rope | P2PWall | LinWiz | cutter | Protector - Free Antivirus software | TapeIO ]