Exemple #1
0
static int
stomp_parse(stomp_msg_t *msg, char *buf, int len, stomp_command_t *cmdtable, int numtable)
{
    memset(msg, 0, sizeof(*msg));
    msg->sm_buf = buf;
    msg->sm_len = len;
    stomp_parse_lines(msg, buf, len);

    if (cmdtable != NULL) {
        if ((msg->sm_cmd = stomp_parse_command(buf, len, cmdtable, numtable)) == NULL)
            return -1;
    }

    return 0;
}
Exemple #2
0
int
stomp_parse_frame(GString *data, stomp_frame *frame)
{
  char *pos;
  int res;

  res = stomp_parse_command(data->str, data->len, frame, &pos);
  if (!res)
    return FALSE;

  res = stomp_parse_header(pos, data->str + data->len - pos, frame, &pos);
  while (res == STOMP_PARSE_HEADER)
    {
      res = stomp_parse_header(pos, data->str + data->len - pos, frame, &pos);
    }
  frame->body = g_strndup(pos, data->len - (pos - data->str));
  return TRUE;
}