NsisUrlLib plug-in

From NSIS Wiki

Author: Kamyar (talk, contrib)


Links

NsisUrlLib.zip (5 KB)

Nsis UrlLib plugin page on SourceForge

Description

Version: 1.0.2

NsisIIS plugin to fetch content (usually xml/html) from an http/https url.

Instructions:
- Copy NsisUrlLib.dll to Pluginsfolder of Nsis - Read this readme and example files.

Functions

NsisUrlLib::UrlOpen

tries to fetch content from URL given. Currently supports http and https. This version uses system default proxy (or none).

After calling, the returned message in stack shows if the function has been successful. You MUST pop the message to care stack. The URL is a standard form, which means can accept the standard URL format of: protocol:://address:port/content in which address can be both domain name and IP address.

After successful calling of this function, the plug-in saves the result into a variable, so that you can get in further calling of extra functions. Note that for this process to take place, you must use /NOUNLOAD switch, which makes the plug-in reside the memory until end of setup program.

Example:

NsisUrlLib::UrlOpen /NOUNLOAD "http://www.mydomain.com/content.html"

NsisUrlLib::IterateLine

After successful calling of UrlOpen function, you can use this function to get a single line of text (not binary) data, each time. It means by putting the function in a loop, you can read the whole text file.

Example:

${Do}
  NsisUrlLib::IterateLine /NOUNLOAD
  Pop $1
  # Do something with $1, which is now a single line of the content.
  StrLen $2 $1
${LoopUntil} $2 = 0

NsisUrlLib::IterateChunk

After successful calling of UrlOpen function, you can use this function to get a 1024 bytes (maximum NSIS variable limit) of binary data file each time. It means by putting the function in a loop, you can read the whole binaryfile. Note that this plug-in is not intended for reading large amounts of (binary) data. You can use this function for example if you are using a special binary protocol for RPC and so.

Example:

${Do}
  NsisUrlLib::IterateChunk /NOUNLOAD
  Pop $1
  # Do something with $1, which is now a 1K.Byte chunk of data.
  StrLen $2 $1
${LoopUntil} $2 = 0

TODO

  • Adding support for ftp and ftps protocols.
  • Adding support for custom proxy server.

History

  • 03/02/2010 Released version 1.0.1 & used in my installer.
  • 03/10/2010 Corrected exploit vulnerability, replaced sscanf with sscanf_s
Personal tools
donate
ads