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

◆ ProcessRead()

unsafe int System.Net.Mail.SmtpReplyReaderFactory.ProcessRead ( byte[] buffer,
int offset,
int read,
bool readLine )
inlineprivate

Definition at line 239 of file SmtpReplyReaderFactory.cs.

240 {
241 if (read == 0)
242 {
244 }
245 fixed (byte* ptr = buffer)
246 {
247 byte* ptr2 = ptr + offset;
248 byte* ptr3 = ptr2;
249 byte* ptr4 = ptr3 + read;
250 switch (_readState)
251 {
252 case ReadState.Status0:
253 if (ptr3 < ptr4)
254 {
255 byte b = *(ptr3++);
256 if (b < 48 && b > 57)
257 {
258 throw new FormatException(System.SR.SmtpInvalidResponse);
259 }
260 _statusCode = (SmtpStatusCode)(100 * (b - 48));
261 goto case ReadState.Status1;
262 }
263 _readState = ReadState.Status0;
264 break;
265 case ReadState.Status1:
266 if (ptr3 < ptr4)
267 {
268 byte b3 = *(ptr3++);
269 if (b3 < 48 && b3 > 57)
270 {
271 throw new FormatException(System.SR.SmtpInvalidResponse);
272 }
273 _statusCode += 10 * (b3 - 48);
274 goto case ReadState.Status2;
275 }
276 _readState = ReadState.Status1;
277 break;
278 case ReadState.Status2:
279 if (ptr3 < ptr4)
280 {
281 byte b2 = *(ptr3++);
282 if (b2 < 48 && b2 > 57)
283 {
284 throw new FormatException(System.SR.SmtpInvalidResponse);
285 }
286 _statusCode += b2 - 48;
287 goto case ReadState.ContinueFlag;
288 }
289 _readState = ReadState.Status2;
290 break;
291 case ReadState.ContinueFlag:
292 if (ptr3 < ptr4)
293 {
294 byte b4 = *(ptr3++);
295 if (b4 != 32)
296 {
297 if (b4 != 45)
298 {
299 throw new FormatException(System.SR.SmtpInvalidResponse);
300 }
301 goto case ReadState.ContinueCR;
302 }
303 goto case ReadState.LastCR;
304 }
305 _readState = ReadState.ContinueFlag;
306 break;
307 case ReadState.ContinueCR:
308 while (ptr3 < ptr4)
309 {
310 if (*(ptr3++) != 13)
311 {
312 continue;
313 }
314 goto case ReadState.ContinueLF;
315 }
316 _readState = ReadState.ContinueCR;
317 break;
318 case ReadState.ContinueLF:
319 if (ptr3 < ptr4)
320 {
321 if (*(ptr3++) != 10)
322 {
323 throw new FormatException(System.SR.SmtpInvalidResponse);
324 }
325 if (readLine)
326 {
327 _readState = ReadState.Status0;
328 return (int)(ptr3 - ptr2);
329 }
330 goto case ReadState.Status0;
331 }
332 _readState = ReadState.ContinueLF;
333 break;
334 case ReadState.LastCR:
335 while (ptr3 < ptr4)
336 {
337 if (*(ptr3++) != 13)
338 {
339 continue;
340 }
341 goto case ReadState.LastLF;
342 }
343 _readState = ReadState.LastCR;
344 break;
345 case ReadState.LastLF:
346 if (ptr3 < ptr4)
347 {
348 if (*(ptr3++) != 10)
349 {
350 throw new FormatException(System.SR.SmtpInvalidResponse);
351 }
352 goto case ReadState.Done;
353 }
354 _readState = ReadState.LastLF;
355 break;
356 case ReadState.Done:
357 {
358 int result = (int)(ptr3 - ptr2);
359 _readState = ReadState.Done;
360 return result;
361 }
362 }
363 return (int)(ptr3 - ptr2);
364 }
365 }
static string net_io_readfailure
Definition SR.cs:158
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_io_connectionclosed
Definition SR.cs:160
static string SmtpInvalidResponse
Definition SR.cs:162
Definition SR.cs:7

References System.Net.Mail.SmtpReplyReaderFactory._readState, System.Net.Mail.SmtpReplyReaderFactory._statusCode, System.buffer, System.SR.Format(), System.SR.net_io_connectionclosed, System.SR.net_io_readfailure, System.offset, and System.SR.SmtpInvalidResponse.

Referenced by System.Net.Mail.SmtpReplyReaderFactory.ReadLinesAsyncResult.ProcessRead(), System.Net.Mail.SmtpReplyReaderFactory.Read(), and System.Net.Mail.SmtpReplyReaderFactory.ReadLines().