|
|
| version 1.7, 2015/05/01 21:40:09 | version 1.12, 2016/03/31 21:46:20 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b inet parser class. | Parser: @b inet parser class. |
| Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru>(http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru>(http://paf.design.ru) |
| */ | */ |
| Line 9 | Line 9 |
| #include "pa_request.h" | #include "pa_request.h" |
| #include "pa_vtable.h" | #include "pa_vtable.h" |
| #ifdef _MSC_VER | |
| #include "winsock2.h" | |
| #include "ws2tcpip.h" | |
| #endif | |
| volatile const char * IDENT_INET_C="$Id$"; | volatile const char * IDENT_INET_C="$Id$"; |
| class MInet: public Methoded { | class MInet: public Methoded { |
| Line 18 public: | Line 23 public: |
| // global variables | // global variables |
| DECLARE_CLASS_VAR(inet, new MInet, 0); | DECLARE_CLASS_VAR(inet, new MInet); |
| static void _ntoa(Request& r, MethodParams& params){ | static void _ntoa(Request& r, MethodParams& params){ |
| unsigned long l=(unsigned long)trunc(params.as_double(0, "parameter must be expression", r)); | unsigned long l=(unsigned long)trunc(params.as_double(0, "parameter must be expression", r)); |
| static const int ip_cstr_bufsize=3*4+3+1+1; | static const int ip_cstr_bufsize=3*4+3+1/*zero-teminator*/+1/*for faulty snprintfs*/; |
| char* ip_cstr=new(PointerFreeGC) char[ip_cstr_bufsize]; | char* ip_cstr=new(PointerFreeGC) char[ip_cstr_bufsize]; |
| snprintf(ip_cstr, ip_cstr_bufsize, "%u.%u.%u.%u", (l>>24) & 0xFF, (l>>16) & 0xFF, (l>>8) & 0xFF, l & 0xFF); | snprintf(ip_cstr, ip_cstr_bufsize, "%u.%u.%u.%u", (l>>24) & 0xFF, (l>>16) & 0xFF, (l>>8) & 0xFF, l & 0xFF); |
| r.write_no_lang(*new String(ip_cstr)); | r.write_no_lang(*new String(ip_cstr)); |