|
|
| version 1.50, 2007/08/17 09:00:50 | version 1.53, 2008/06/16 12:38:41 |
|---|---|
| Line 283 static void _crypt(Request& r, MethodPar | Line 283 static void _crypt(Request& r, MethodPar |
| } | } |
| static void _md5(Request& r, MethodParams& params) { | static void _md5(Request& r, MethodParams& params) { |
| const char *string=params.as_string(0, "parameter must be string").cstr(); | const char *string=params.as_string(0, PARAMETER_MUST_BE_STRING).cstr(); |
| PA_MD5_CTX context; | PA_MD5_CTX context; |
| unsigned char digest[16]; | unsigned char digest[16]; |
| Line 418 void SHA1PadMessage(SHA1Context *context | Line 418 void SHA1PadMessage(SHA1Context *context |
| static void _sha1(Request& r, MethodParams& params) { | static void _sha1(Request& r, MethodParams& params) { |
| const char *string = params.as_string(0, "parameter must be string").cstr(); | const char *string = params.as_string(0, PARAMETER_MUST_BE_STRING).cstr(); |
| SHA1Context c; | SHA1Context c; |
| SHA1Reset (&c); | SHA1Reset (&c); |
| Line 487 static void _uid64(Request& r, MethodPar | Line 487 static void _uid64(Request& r, MethodPar |
| } | } |
| static void _crc32(Request& r, MethodParams& params) { | static void _crc32(Request& r, MethodParams& params) { |
| const char *string=params.as_string(0, "parameter must be string").cstr(); | const char *string=params.as_string(0, PARAMETER_MUST_BE_STRING).cstr(); |
| r.write_no_lang(*new VInt(pa_crc32(string, strlen(string)))); | r.write_no_lang(*new VInt(pa_crc32(string, strlen(string)))); |
| } | } |
| static void _long2ip(Request& r, MethodParams& params) { | |
| unsigned long l=(unsigned long)trunc(params.as_double(0, "parameter must be expression", r)); | |
| static const int ip_cstr_bufsize=15+1+1; | |
| char* ip_cstr=new(PointerFreeGC) char[ip_cstr_bufsize]; | |
| snprintf(ip_cstr, ip_cstr_bufsize, "%d.%d.%d.%d", | |
| (l>>24) & 0xFF, | |
| (l>>16) & 0xFF, | |
| (l>>8) & 0xFF, | |
| l & 0xFF); | |
| r.write_no_lang(*new String(ip_cstr)); | |
| } | |
| // constructor | // constructor |
| MMath::MMath(): Methoded("math") { | MMath::MMath(): Methoded("math") { |
| Line 542 MMath::MMath(): Methoded("math") { | Line 528 MMath::MMath(): Methoded("math") { |
| // ^math:crc32[string] | // ^math:crc32[string] |
| ADD1(crc32); | ADD1(crc32); |
| ADD1(long2ip); | |
| // ^math:uuid[] | // ^math:uuid[] |
| ADD0(uuid); | ADD0(uuid); |