Gentee Programming Language > Documentation > Libraries Download documentation

Data search

The spattern type is used to search through the buffer for another one. Before search start-up, call the spattern.init method in order to initialize the search pattern.
 
uint spattern.search(
      uint   src,
      uint   size
)

Parameters

srcPointer to the beginning of data in order to start a search.
sizeData size.

Return value

The offset of the found fragment. If the offset is equal to size, no fragment is found.



 
uint spattern.search(
      buf   src,
      uint   offset
)

Parameters

srcBuffer where the specified data (search pattern) will be searched.
offsetOffset where the search must be started or proceeded.

Return value

The offset of the found fragment. If the offset is equal to the buffer size, no fragment is found.

spattern sp
buf pattern src
...
sp.init( pattern, 0 )
if sp.search( src, 0 ) < *src 
{
   print("The pattern has been found in src buffer!\n")
}

See also

    Buffer - binary data


 Copyright © 2004-2006 Gentee Inc. All rights reserved.