pacparser  1.3.7
About: pacparser is a library to parse Proxy Auto-Config (PAC) files (incl. a pactester).
  Fossies Dox: pacparser-1.3.7.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

pacparser

API for pacparser library, a library to use proxy auto-config (PAC) files. See project homepage: http://github.com/pacparser/pacparser for more information. More...

Typedefs

typedef int(* pacparser_error_printer) (const char *fmt, va_list argp)
 Type definition for pacparser_error_printer. More...
 

Functions

int pacparser_init (void)
 Initializes pac parser. More...
 
int pacparser_parse_pac_file (const char *pacfile)
 Parses the given PAC file. More...
 
int pacparser_parse_pac_string (const char *pacstring)
 Parses the given PAC script string. More...
 
int pacparser_parse_pac (const char *pacfile)
 Parses the gievn pac file. More...
 
char * pacparser_find_proxy (const char *url, const char *host)
 Finds proxy for the given URL and Host. More...
 
char * pacparser_just_find_proxy (const char *pacfile, const char *url, const char *host)
 Finds proxy for the given PAC file, URL and Host. More...
 
void pacparser_cleanup (void)
 Destroys JavaSctipt context. More...
 
void pacparser_setmyip (const char *ip)
 Sets my IP address. More...
 
void pacparser_set_error_printer (pacparser_error_printer func)
 Sets error printing function. More...
 
void pacparser_enable_microsoft_extensions (void)
 (Deprecated) Enable Microsoft IPv6 PAC extensions. More...
 
char * pacparser_version (void)
 Returns pacparser version. More...
 

Detailed Description

API for pacparser library, a library to use proxy auto-config (PAC) files. See project homepage: http://github.com/pacparser/pacparser for more information.

Author
Manu Garg manug.nosp@m.arg@.nosp@m.gmail.nosp@m..com

Typedef Documentation

◆ pacparser_error_printer

typedef int(* pacparser_error_printer) (const char *fmt, va_list argp)

Type definition for pacparser_error_printer.

Definition at line 114 of file pacparser.h.

Function Documentation

◆ pacparser_cleanup()

void pacparser_cleanup ( void  )

Destroys JavaSctipt context.

This function should be called once you're done with using pacparser engine.

Definition at line 468 of file pacparser.c.

References _debug(), cx, global, myip, print_error(), and rt.

Referenced by main(), pacparser_just_find_proxy(), and py_pacparser_cleanup().

◆ pacparser_enable_microsoft_extensions()

void pacparser_enable_microsoft_extensions ( void  )

(Deprecated) Enable Microsoft IPv6 PAC extensions.

Deprecated. IPv6 extension (*Ex functions) are enabled by default now.

Definition at line 276 of file pacparser.c.

Referenced by py_pacparser_enable_microsoft_extensions().

◆ pacparser_find_proxy()

char* pacparser_find_proxy ( const char *  url,
const char *  host 
)

Finds proxy for the given URL and Host.

Parameters
urlURL to find proxy for.
hostHost part of the URL.
Returns
proxy string on sucess and NULL on error.

Finds proxy for the given URL and Host. This function should be called only after pacparser engine has been initialized (using pacparser_init) and pac script has been parsed (using pacparser_parse_pac_file or pacparser_parse_pac_string).

Definition at line 409 of file pacparser.c.

References _debug(), cx, global, print_error(), and str_replace().

Referenced by main(), pacparser_just_find_proxy(), and py_pacparser_find_proxy().

◆ pacparser_init()

int pacparser_init ( void  )

Initializes pac parser.

Returns
0 on failure and 1 on success.

Initializes JavaScript engine and does few basic initializations specific to pacparser.

Definition at line 288 of file pacparser.c.

References _debug(), cx, dns_resolve(), dns_resolve_ex(), global, global_class, my_ip(), my_ip_ex(), pacUtils, print_error(), print_jserror(), and rt.

Referenced by main(), pacparser_just_find_proxy(), and py_pacparser_init().

◆ pacparser_just_find_proxy()

char* pacparser_just_find_proxy ( const char *  pacfile,
const char *  url,
const char *  host 
)

Finds proxy for the given PAC file, URL and Host.

Parameters
pacfilePAC file to parse.
urlURL to find proxy for.
hostHost part of the URL.
Returns
proxy string on success and NULL on error.

This function is a wrapper around functions pacparser_init, pacparser_parse_pac_file, pacparser_find_proxy and pacparser_cleanup. If you just want to find out proxy for a given set of pac file, url and host, this is the function to call. This function takes care of all the initialization and cleanup.

Definition at line 492 of file pacparser.c.

References global, pacparser_cleanup(), pacparser_find_proxy(), pacparser_init(), pacparser_parse_pac(), and print_error().

◆ pacparser_parse_pac()

int pacparser_parse_pac ( const char *  pacfile)

Parses the gievn pac file.

Deprecated:
Use pacparser_parse_pac_file instead.
Parameters
pacfilePAC file to parse.
Returns
0 on failure and 1 on success.

Same as pacparser_parse_pac_file. Included only for backward compatibility.

Definition at line 398 of file pacparser.c.

References pacparser_parse_pac_file().

Referenced by pacparser_just_find_proxy().

◆ pacparser_parse_pac_file()

int pacparser_parse_pac_file ( const char *  pacfile)

Parses the given PAC file.

Parameters
pacfilePAC file to parse.
Returns
0 on failure and 1 on success.

Reads the given PAC file and evaluates it in the JavaScript context created by pacparser_init.

Definition at line 373 of file pacparser.c.

References _debug(), pacparser_parse_pac_string(), print_error(), and read_file_into_str().

Referenced by main(), and pacparser_parse_pac().

◆ pacparser_parse_pac_string()

int pacparser_parse_pac_string ( const char *  pacstring)

Parses the given PAC script string.

Parameters
pacstringPAC string to parse.
Returns
0 on failure and 1 on success.

Evaulates the given PAC script string in the JavaScript context created by pacparser_init.

Definition at line 344 of file pacparser.c.

References _debug(), cx, global, and print_error().

Referenced by main(), pacparser_parse_pac_file(), and py_pacparser_parse_pac_string().

◆ pacparser_set_error_printer()

void pacparser_set_error_printer ( pacparser_error_printer  func)

Sets error printing function.

Parameters
funcPrinting function.

Sets error variadic-argument printing function. If not set the messages are printed to stderr. If messages begin with DEBUG: or WARNING:, they are not fatal error messages, otherwise they are. May be called before pacparser_init().

Definition at line 62 of file pacparser.c.

References error_printer_func.

◆ pacparser_setmyip()

void pacparser_setmyip ( const char *  ip)

Sets my IP address.

Parameters
ipCustom IP address.

Sets my IP address to a custom value. This is the IP address returned by myIpAddress() javascript function.

Definition at line 265 of file pacparser.c.

References myip.

Referenced by main(), and py_pacparser_setmyip().

◆ pacparser_version()

char* pacparser_version ( void  )

Returns pacparser version.

Returns
version string if version defined, "" otherwise.

Version string is determined at the time of build. If built from a released package, version corresponds to the latest release (git) tag. If built from the repository, it corresponds to the head revision of the repo.

Definition at line 528 of file pacparser.c.

References print_error(), and QUOTEME.

Referenced by main(), and py_pacparser_version().