Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

poslib/lexfn.h File Reference

lexical functions More...

Go to the source code of this file.


Classes

class   addrrange
  Address range class. More...


Defines

#define  sz_iprange   8
  Size of an IP range buffer.

#define  sz_ip6range   32
  Size of an IPv6 range buffer.

#define  sz_addrrange   33
  Size of an generic address range buffer.


Functions

bool  txt_to_bool (const char *buff)
  convert text to boolean

int  txt_to_negint (const char *buff)
  convert text to numbers

int  txt_to_int (const char *buff)
  convert text to numbers

int  txt_to_ip (char ip[4], const char *buff, bool do_portion=false)
  convert text to ipv4

void  txt_to_iprange (char *iprange, const char *val)
  Convert text to an IP range.

bool  iprange_matches (char *iprange, char *ip)
  Checks for IPv4 ranges.

int  txt_to_ipv6 (char ipv6[16], const char *buff, bool do_portion=false)
  convert text to ipv6

void  txt_to_ip6range (char *iprange, const char *val)
  Convert text to an IPv6 range.

bool  ip6range_matches (char *iprange, char *ip)
  Checks for IPv6 ranges.

void  txt_to_addrrange (char *iprange, const char *val)
  Convert text to an address range.

bool  addrrange_matches (char *iprange, _addr *a)
  Checks for range matches.

bool  in_addrrange_list (stl_list(addrrange)&lst, _addr *a)
  looks item up in match list

bool  in_addr_list (stl_list(_addr)&lst, _addr *a, bool match_port=false)
  looks item up in address list

void  txt_to_email (char *target, const char *src, const _domain origin=NULL)
  convert e-mail address to binary domain name

void  txt_to_dname (char *target, const char *src, const _domain origin=NULL)
  convert text domain name to binary domain name

void  txt_to_addr (_addr *ret, const char *addr, int default_port=DNS_PORT, bool is_client=true)
  convert text to address

void  txt_to_loc (char *res, char *&src)
  convert text to LOC RR

stl_string  str_type (u_int16 type)
stl_string  str_qtype (u_int16 qtype)
stl_string  str_class (u_int16 ctype)
stl_string  str_qclass (u_int16 qctype)
stl_string  str_opcode (u_int16 opcode)
stl_string  str_rcode (int rcode)
stl_string  str_ttl (uint32_t ttl)
stl_string  str_loc (char *rr)

Detailed Description

lexical functions

Functions for converting free-form text to various types of data.

Definition in file lexfn.h.


Define Documentation

#define sz_addrrange   33
 

Size of an generic address range buffer.

The size, in characters, of an generic address range buffer.

Definition at line 155 of file lexfn.h.

#define sz_ip6range   32
 

Size of an IPv6 range buffer.

The size, in characters, of an IPv6 range buffer.

Definition at line 128 of file lexfn.h.

#define sz_iprange   8
 

Size of an IP range buffer.

The size, in characters, of an IP range buffer.

Definition at line 86 of file lexfn.h.


Function Documentation

bool addrrange_matches char *  iprange,
_addr a
 

Checks for range matches.

Returns true if the given address number is in the given IP range.

Parameters:
iprange  The address range
a  The address
Returns:
true if the ip is within the range
See also:
txt_to_addrrange

bool in_addr_list stl_list(_addr)&  lst,
_addr a,
bool  match_port = false
 

looks item up in address list

This function returns true if the given address is one of the addresses in the address match list.

Parameters:
lst  Address list
a  Address to check
match_port  Whether the port should also match
Returns:
true if the address matches one of the items in the list

bool in_addrrange_list stl_list(addrrange)&  lst,
_addr a
 

looks item up in match list

This function returns true if the given address matches one of the address match items of the address match list.

Parameters:
lst  Address range list
a  Address to check
Returns:
true if the address matches one of the items in the list

bool ip6range_matches char *  iprange,
char *  ip
 

Checks for IPv6 ranges.

Returns true if the given IPv6 number is in the given IP range.

Parameters:
iprange  The IPv6 range
ip  The IPv6 number
Returns:
true if the ip is within the range
See also:
txt_to_ipv6, txt_to_ip6range

bool iprange_matches char *  iprange,
char *  ip
 

Checks for IPv4 ranges.

Returns true if the given IP number is in the given IP range.

Parameters:
iprange  The IP range
ip  The IPv4 number
Returns:
true if the ip is within the range
See also:
txt_to_ip, txt_to_iprange

stl_string str_class u_int16  ctype  ) 
 

Returns string representation for the RR CLASS.

stl_string str_loc char *  rr  ) 
 

Returns string representation for a LOC RR

stl_string str_opcode u_int16  opcode  ) 
 

Returns string representation for the OPCODE.

stl_string str_qclass u_int16  qctype  ) 
 

Returns string representation for the QCLASS.

stl_string str_qtype u_int16  qtype  ) 
 

Returns string representation for the QTYPE.

stl_string str_rcode int  rcode  ) 
 

Returns string representation for the RCODE.

stl_string str_ttl uint32_t  ttl  ) 
 

Returns string representation for the ttl (e.g. 2h1m)

stl_string str_type u_int16  type  ) 
 

Returns string representation for the RR type.

void txt_to_addr _addr ret,
const char *  addr,
int  default_port = DNS_PORT,
bool  is_client = true
 

convert text to address

Converts the text pointed to by addr to an _addr address structure. If the client parameter is set to true, the default IP is 127.0.0.1, else it is 0.0.0.0 . Addresses can be given by only an address, only a port, or a combination separated by a # . Being based on the txt_to_ip and txt_to_ipv6 functions, this function also supports the literval values any , local, :any and :local .

Parameters:
ret  Memory to store result in
addr  Text describing the address
default_port  Default port if none is given
client  Influences default address

void txt_to_addrrange char *  iprange,
const char *  val
 

Convert text to an address range.

Converts the buffer to an address IP range, in the form of ip[/nsig].

Parameters:
iprange  Result buffer (should be of size sz_addrrange).
val  String value describing the range

bool txt_to_bool const char *  buff  ) 
 

convert text to boolean

Converts text to a boolean value. The following positive values are supported: yes true 1 on yo absolutely . The following negative values are supported: no false 0 off nope never .

Parameters:
buff  Buffer containing boolean
Returns:
Either true or false.

void txt_to_dname char *  target,
const char *  src,
const _domain  origin = NULL
 

convert text domain name to binary domain name

Converts the domain name or in src to a binary domain name.

Parameters:
target  Target
src  Source
origin  Origin for relative domain names

void txt_to_email char *  target,
const char *  src,
const _domain  origin = NULL
 

convert e-mail address to binary domain name

Converts the domain name or email address in src to a binary domain name.

Parameters:
target  Target
src  Source
origin  Origin for relative domain names

int txt_to_int const char *  buff  ) 
 

convert text to numbers

Converts text to a number. This function uses postfix operators. It doesn't support negative numbers.

Parameters:
buff  Buffer containing text
Returns:
Numeric value of the buffer
See also:
txt_to_negint

int txt_to_ip char  ip[4],
const char *  buff,
bool  do_portion = false
 

convert text to ipv4

Converts the text to an IPv4 address. As an extension, Poslib also supports the literal any value, which maps to 0.0.0.0 and the local value, which maps to 127.0.0.1 .

Parameters:
ip  Target
buff  Source
do_portion  If true, also accept portions such as 192.*.
Returns:
The number of nodes of the address (4 for a complete one)

void txt_to_ip6range char *  iprange,
const char *  val
 

Convert text to an IPv6 range.

Converts the buffer to an IPv6 IP range, in the form of ip[/nsig].

Parameters:
iprange  Result buffer (should be of size sz_ip6range).
val  String value describing the range

void txt_to_iprange char *  iprange,
const char *  val
 

Convert text to an IP range.

Converts the buffer to an IPv4 IP range, in the form of ip[/nsig].

Parameters:
iprange  Result buffer (should be of size sz_iprange).
val  String value describing the range

int txt_to_ipv6 char  ipv6[16],
const char *  buff,
bool  do_portion = false
 

convert text to ipv6

Converts the text to an IPv6 address. As an extension, Poslib also supports the literal :any value, mapping to ::0 and the :local value, mapping to ::1 .

Parameters:
ipv6  Target
buff  Source
do_portion  If true, also accepts portions such as dead:beef:*
Returns:
The number of nodes of the address (16 for a complete one)

void txt_to_loc char *  res,
char *&  src
 

convert text to LOC RR

Converts the text pointed to by rr to LOC information as described in RFC 1876.

Parameters:
ret  Memory to store result in (should be >= 16 bytes)
rr  String containing the data (after processing, this will point to the end of the RR)

int txt_to_negint const char *  buff  ) 
 

convert text to numbers

Converts text to a number. This function uses postfix operators, and can also handle negative amounts.

Parameters:
buff  Buffer containing text
Returns:
Numeric value of the buffer
See also:
txt_to_int

Generated on Fri Dec 24 19:55:15 2004 for Poslib by doxygen 1.3.7