Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ IsValidCanonical() [2/2]

static unsafe bool System.IPv4AddressHelper.IsValidCanonical ( char * name,
int start,
ref int end,
bool allowIPv6,
bool notImplicitFile )
inlinestaticpackage

Definition at line 66 of file IPv4AddressHelper.cs.

67 {
68 int num = 0;
69 int num2 = 0;
70 bool flag = false;
71 bool flag2 = false;
72 while (start < end)
73 {
74 char c = name[start];
75 if (allowIPv6)
76 {
77 if (c == ']' || c == '/' || c == '%')
78 {
79 break;
80 }
81 }
82 else if (c == '/' || c == '\\' || (notImplicitFile && (c == ':' || c == '?' || c == '#')))
83 {
84 break;
85 }
86 if (c <= '9' && c >= '0')
87 {
88 if (!flag && c == '0')
89 {
90 if (start + 1 < end && name[start + 1] == '0')
91 {
92 return false;
93 }
94 flag2 = true;
95 }
96 flag = true;
97 num2 = num2 * 10 + (name[start] - 48);
98 if (num2 > 255)
99 {
100 return false;
101 }
102 }
103 else
104 {
105 if (c != '.')
106 {
107 return false;
108 }
109 if (!flag || (num2 > 0 && flag2))
110 {
111 return false;
112 }
113 num++;
114 flag = false;
115 num2 = 0;
116 flag2 = false;
117 }
118 start++;
119 }
120 bool flag3 = num == 3 && flag;
121 if (flag3)
122 {
123 end = start;
124 }
125 return flag3;
126 }

References System.start.