Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface mbed-rpc mbed-rtos mbed
Diff: RPCCommand.cpp
- Revision:
- 4:624527ebc0fa
- Parent:
- 3:fb0a778f2480
- Child:
- 5:8ab27ca793cd
--- a/RPCCommand.cpp Wed Jul 17 11:07:06 2013 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-#include "RPCCommand.h"
-#include "mbed.h"
-#include "RPCType.h"
-
-
-RPCCommand::RPCCommand():
-cmd(),
-obj_name(NULL),
-func_name(NULL)
-{
-
-}
-
-bool RPCCommand::decode(char *buffer)
-{
- if(buffer == NULL)
- return false;
- if(buffer[0] != '/')
- return false;
-
- ++buffer;
- char *tmp = strchr(buffer ,'/');
-
- if(tmp == NULL)
- return false;
- if(tmp == buffer)
- return false;
-
- tmp[0] = '\0';
- obj_name = buffer;
-
- buffer = tmp+1;
-
- if(buffer[0] == '\0' || buffer[0] == '?')
- return false;
-
- func_name = buffer;
-
- tmp = strchr(buffer, '?');
- if(tmp != NULL)
- {
- if(tmp[1] == '\0')
- return false;
- tmp[0] = '\0';
- }
-
- cmd[0] = '\0';
- strcat(cmd, "/");
- strcat(cmd, obj_name);
- strcat(cmd, "/");
- strcat(cmd, func_name);
-
- if(tmp == NULL)
- return true;
-
- buffer = tmp+1;
- do
- {
- tmp = strchr(buffer, '&');
-
- if(tmp != NULL)
- {
- if(tmp[1] == '\0' || buffer == tmp)
- return false;
- tmp[0] = '\0';
- }
-
- char *sep = strchr(buffer, '=');
- if(sep == NULL)
- return false;
- if(sep == buffer)
- return false;
- if(sep[1] == '\0' || sep[1] == '&')
- return false;
-
- strcat(cmd, " ");
- strcat(cmd, sep+1);
-
- if(tmp != NULL)
- buffer = tmp+1;
- else
- buffer = NULL;
- }while(buffer);
-
- return true;
-}
-
-
-
-char* RPCCommand::get_cmd() const
-{
- return (char*)cmd;
-}
-
-RPC_COMMAND_TYPE RPCCommand::get_type() const
-{
- if(!strcmp(func_name, "new") && RPCType::instance().is_supported_type(obj_name))
- return CREATE;
-
- RPC* r = RPC::lookup(obj_name);
- if(r == NULL)
- return INVALID;
-
- if(!strcmp(func_name, "delete"))
- return DELETE;
-
- const struct rpc_method *methods = r->get_rpc_methods();
- int i = 0;
- while(methods[i].name != NULL)
- {
- if(!strcmp(func_name, methods[i].name))
- {
- return FUNCTION_CALL;
- }
- ++i;
- }
-
- return INVALID;
-}
-
-char* RPCCommand::get_obj_name() const
-{
- return obj_name;
-}
-
-char* RPCCommand::get_func_name() const
-{
- return func_name;
-}
-