<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nsis.sourceforge.io/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Validate_IP_function</id>
	<title>Validate IP function - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://nsis.sourceforge.io/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Validate_IP_function"/>
	<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=Validate_IP_function&amp;action=history"/>
	<updated>2026-06-30T05:30:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://nsis.sourceforge.io/mediawiki/index.php?title=Validate_IP_function&amp;diff=20906&amp;oldid=prev</id>
		<title>203.229.154.129: /* Usage Example */</title>
		<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=Validate_IP_function&amp;diff=20906&amp;oldid=prev"/>
		<updated>2011-09-09T04:32:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Usage Example&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;â† Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:32, 9 September 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l19&quot;&gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Section&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Section&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   Push &amp;quot;192.168.&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;0&lt;/del&gt;.&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;1&lt;/del&gt;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   Push &amp;quot;192.168.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;2&lt;/ins&gt;.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;124&lt;/ins&gt;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   Call ValidateIP&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   Call ValidateIP&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   ${If} ${Errors}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   ${If} ${Errors}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key n22049_wiki-wiki_:diff::1.12:old-11435:rev-20906 --&gt;
&lt;/table&gt;</summary>
		<author><name>203.229.154.129</name></author>
	</entry>
	<entry>
		<id>https://nsis.sourceforge.io/mediawiki/index.php?title=Validate_IP_function&amp;diff=11435&amp;oldid=prev</id>
		<title>Kichik at 11:49, 3 November 2006</title>
		<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=Validate_IP_function&amp;diff=11435&amp;oldid=prev"/>
		<updated>2006-11-03T11:49:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{PageAuthor|kichik}}&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
Checks is a given IP address is valid and sets the error flag accordingly. The test is done in four steps. First, the given string is filtered to validate it contains only numbers and dots. Next, the number of dots is counted to validate it&amp;#039;s 3 and the number of numbers is counted to validate it&amp;#039;s 4. Finally, each number is validated by checking it&amp;#039;s not out of range.&lt;br /&gt;
&lt;br /&gt;
== Usage Example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;!include LogicLib.nsh&lt;br /&gt;
!include ValidateIP.nsh&lt;br /&gt;
&lt;br /&gt;
Name &amp;quot;Validate IP test&amp;quot;&lt;br /&gt;
OutFile test.exe&lt;br /&gt;
&lt;br /&gt;
XPStyle on&lt;br /&gt;
&lt;br /&gt;
ShowInstDetails show&lt;br /&gt;
&lt;br /&gt;
Section&lt;br /&gt;
&lt;br /&gt;
  Push &amp;quot;192.168.0.1&amp;quot;&lt;br /&gt;
  Call ValidateIP&lt;br /&gt;
  ${If} ${Errors}&lt;br /&gt;
    DetailPrint &amp;quot;invalid IP&amp;quot;&lt;br /&gt;
  ${Else}&lt;br /&gt;
    DetailPrint &amp;quot;IP is ok&amp;quot;&lt;br /&gt;
  ${EndIf}&lt;br /&gt;
&lt;br /&gt;
SectionEnd&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Function Code ==&lt;br /&gt;
&lt;br /&gt;
Put this code in a file named ValidateIP.nsh.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;!include LogicLib.nsh&lt;br /&gt;
!include WordFunc.nsh&lt;br /&gt;
&lt;br /&gt;
!insertmacro WordFind&lt;br /&gt;
!insertmacro StrFilter&lt;br /&gt;
&lt;br /&gt;
Function ValidateIP&lt;br /&gt;
&lt;br /&gt;
  Exch $0&lt;br /&gt;
  Push $1&lt;br /&gt;
  Push $2&lt;br /&gt;
&lt;br /&gt;
  ${StrFilter} $0 1 &amp;quot;.&amp;quot; &amp;quot;&amp;quot; $1&lt;br /&gt;
  ${If} $0 != $1&lt;br /&gt;
    # invalid charcaters used&lt;br /&gt;
    #   example: a127.0.0.1&lt;br /&gt;
    Goto error&lt;br /&gt;
  ${EndIf}&lt;br /&gt;
&lt;br /&gt;
  ${WordFind} $0 . &amp;quot;#&amp;quot; $1&lt;br /&gt;
  ${If} $1 != 4&lt;br /&gt;
    # wrong number of numbers&lt;br /&gt;
    #   example: 127.0.0.&lt;br /&gt;
    Goto error&lt;br /&gt;
  ${EndIf}&lt;br /&gt;
&lt;br /&gt;
  ${WordFind} $0 . &amp;quot;*&amp;quot; $1&lt;br /&gt;
  ${If} $1 != 3&lt;br /&gt;
    # wrong number of dots&lt;br /&gt;
    #   example: 127.0.0.1.&lt;br /&gt;
    Goto error&lt;br /&gt;
  ${EndIf}&lt;br /&gt;
&lt;br /&gt;
  ${For} $2 1 4&lt;br /&gt;
    ${WordFind} $0 . +$2 $1&lt;br /&gt;
&lt;br /&gt;
    ${If} $1 &amp;gt; 255&lt;br /&gt;
    ${OrIf} $1 &amp;lt; 0&lt;br /&gt;
      # invalid number&lt;br /&gt;
      #   example: 500.0.0.1&lt;br /&gt;
      Goto error&lt;br /&gt;
    ${EndIf}&lt;br /&gt;
  ${Next}&lt;br /&gt;
&lt;br /&gt;
  Pop $2&lt;br /&gt;
  Pop $1&lt;br /&gt;
  Pop $0&lt;br /&gt;
&lt;br /&gt;
  ClearErrors&lt;br /&gt;
&lt;br /&gt;
  Return&lt;br /&gt;
&lt;br /&gt;
  error:&lt;br /&gt;
&lt;br /&gt;
    Pop $2&lt;br /&gt;
    Pop $1&lt;br /&gt;
    Pop $0&lt;br /&gt;
&lt;br /&gt;
    SetErrors&lt;br /&gt;
&lt;br /&gt;
FunctionEnd&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Internet Functions]]&lt;/div&gt;</summary>
		<author><name>Kichik</name></author>
	</entry>
</feed>