summaryrefslogtreecommitdiff
path: root/cmd/cmd_todo.c
blob: 2b3993b486f320eb16c8b8b7f0d6b4603c505054 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "cmd_todo.h"

void *cmd_todo(void *data)
{
  char *ret = NULL;
  char *req_data = NULL;
  int fret;

  rpc_call_request  *req  = NULL;
  rpc_call_response *resp = NULL;
  netbyte_store *nb_req = NULL, *nb_resp=NULL;
  char *nb_buf = NULL;

  PRINT("TODO\n");

  req_data = (char *)data;
  if (!req_data)
  {
    PERM();
    return NULL;
  }

  //----------------------------------------------------------------------------
  //prepare request
  nb_req = malloc(sizeof(netbyte_store));
  nb_init(nb_req);
  nb_load(nb_req, req_data);

  if (nb_req == NULL)
  {
    ERROR("implement response\n");
    return NULL;
  }

  fret = rpc_call_req_unmarsh(nb_req, &req);
  if (fret != 0)
  {
    ERROR("Invalid request format\n");
    return NULL;
  }

  //----------------------------------------------------------------------------
  //main code

  PRINT("%s-%s-%s-%s-%s\n", req->method, req->params, req->user, req->mask, req->server);


  //----------------------------------------------------------------------------
  //prepare response
  nb_resp = malloc(sizeof(netbyte_store));
  nb_init(nb_resp);

  PNL();
  resp = rpc_call_resp_new("Success","None",1);
  resp->user = alloc_new_str(" ");
  resp->server = alloc_new_str(" ");
  resp->mask = alloc_new_str(" ");
  PNL();
  rpc_call_resp_marsh(resp, &nb_resp);

  PNL();
  nb_buf = (char *)nb_create(nb_resp);
  if (nb_buf)
  {
    ret = nb_buf;
  }

  nb_free(nb_resp);
  rpc_call_resp_free(resp);

  return ret;
}