Rev 1229 | Rev 1405 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1229 | Rev 1402 | ||
|---|---|---|---|
| Line 87... | Line 87... | ||
| 87 | myGlobal->Set(String::New("startSocketThread"), FunctionTemplate::New(VirtualMachine::_startSocketThread)); |
87 | myGlobal->Set(String::New("startSocketThread"), FunctionTemplate::New(VirtualMachine::_startSocketThread)); |
| 88 | myGlobal->Set(String::New("stopSocketThread"), FunctionTemplate::New(VirtualMachine::_stopSocketThread)); |
88 | myGlobal->Set(String::New("stopSocketThread"), FunctionTemplate::New(VirtualMachine::_stopSocketThread)); |
| 89 | myGlobal->Set(String::New("sendToSocketThread"), FunctionTemplate::New(VirtualMachine::_sendToSocketThread)); |
89 | myGlobal->Set(String::New("sendToSocketThread"), FunctionTemplate::New(VirtualMachine::_sendToSocketThread)); |
| 90 | myGlobal->Set(String::New("loadDataStore"), FunctionTemplate::New(VirtualMachine::_loadDataStore)); |
90 | myGlobal->Set(String::New("loadDataStore"), FunctionTemplate::New(VirtualMachine::_loadDataStore)); |
| 91 | myGlobal->Set(String::New("getFileContents"), FunctionTemplate::New(VirtualMachine::_getFileContents)); |
91 | myGlobal->Set(String::New("getFileContents"), FunctionTemplate::New(VirtualMachine::_getFileContents)); |
| - | 92 | myGlobal->Set(String::New("system"), FunctionTemplate::New(VirtualMachine::_system)); |
|
| 92 | myGlobal->Set(String::New("uint2hex"), FunctionTemplate::New(VirtualMachine::_uint2hex)); |
93 | myGlobal->Set(String::New("uint2hex"), FunctionTemplate::New(VirtualMachine::_uint2hex)); |
| 93 | myGlobal->Set(String::New("hex2bin"), FunctionTemplate::New(VirtualMachine::_hex2bin)); |
94 | myGlobal->Set(String::New("hex2bin"), FunctionTemplate::New(VirtualMachine::_hex2bin)); |
| 94 | myGlobal->Set(String::New("bin2hex"), FunctionTemplate::New(VirtualMachine::_bin2hex)); |
95 | myGlobal->Set(String::New("bin2hex"), FunctionTemplate::New(VirtualMachine::_bin2hex)); |
| 95 | myGlobal->Set(String::New("bin2float"), FunctionTemplate::New(VirtualMachine::_bin2float)); |
96 | myGlobal->Set(String::New("bin2float"), FunctionTemplate::New(VirtualMachine::_bin2float)); |
| 96 | myGlobal->Set(String::New("float2bin"), FunctionTemplate::New(VirtualMachine::_float2bin)); |
97 | myGlobal->Set(String::New("float2bin"), FunctionTemplate::New(VirtualMachine::_float2bin)); |
| Line 591... | Line 592... | ||
| 591 | } |
592 | } |
| 592 | 593 | ||
| 593 | string content = file_get_contents(*filename); |
594 | string content = file_get_contents(*filename); |
| 594 | 595 | ||
| 595 | return String::New(content.c_str()); |
596 | return String::New(content.c_str()); |
| - | 597 | } |
|
| - | 598 | ||
| - | 599 | #include <string> |
|
| - | 600 | #include <iostream> |
|
| - | 601 | #include <stdio.h> |
|
| - | 602 | ||
| - | 603 | std::string exec(string cmd) { |
|
| - | 604 | FILE* pipe = popen(cmd.c_str(), "r"); |
|
| - | 605 | if (!pipe) return "ERROR"; |
|
| - | 606 | char buffer[128]; |
|
| - | 607 | std::string result = ""; |
|
| - | 608 | while(!feof(pipe)) { |
|
| - | 609 | if(fgets(buffer, 128, pipe) != NULL) |
|
| - | 610 | result += buffer; |
|
| - | 611 | } |
|
| - | 612 | pclose(pipe); |
|
| - | 613 | return result; |
|
| - | 614 | } |
|
| - | 615 | ||
| - | 616 | Handle<Value> VirtualMachine::_system(const Arguments& args) |
|
| - | 617 | { |
|
| - | 618 | String::AsciiValue command(args[0]); |
|
| - | 619 | ||
| - | 620 | string output = exec(*command); |
|
| - | 621 | ||
| - | 622 | return String::New(output.c_str()); |
|
| 596 | } |
623 | } |
| 597 | 624 | ||
| 598 | Handle<Value> VirtualMachine::_uint2hex(const Arguments& args) |
625 | Handle<Value> VirtualMachine::_uint2hex(const Arguments& args) |
| 599 | { |
626 | { |
| 600 | string hex = uint2hex(args[0]->Uint32Value(), args[1]->Uint32Value()); |
627 | string hex = uint2hex(args[0]->Uint32Value(), args[1]->Uint32Value()); |