~percona-dev/percona-server/release-5.5.11-20.2-fix-bug-764138

« back to all changes in this revision

Viewing changes to HandlerSocket-Plugin-for-MySQL/libhsclient/escape.hpp

  • Committer: Ignacio Nin
  • Date: 2011-03-13 17:18:23 UTC
  • mfrom: (33.3.17 release-5.5.8-20)
  • Revision ID: ignacio.nin@percona.com-20110313171823-m06xs104nekulywb
Merge changes from release-5.5.8-20 to 5.5.9

Merge changes from the release branch of 5.5.8 to 5.5.9. These include
the HandlerSocket and UDF directories and the building scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
// vim:sw=2:ai
 
3
 
 
4
/*
 
5
 * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
 
6
 * See COPYRIGHT.txt for details.
 
7
 */
 
8
 
 
9
#include <stdint.h>
 
10
 
 
11
#include "string_buffer.hpp"
 
12
#include "string_ref.hpp"
 
13
#include "string_util.hpp"
 
14
 
 
15
#ifndef DENA_ESCAPE_HPP
 
16
#define DENA_ESCAPE_HPP
 
17
 
 
18
namespace dena {
 
19
 
 
20
void escape_string(char *& wp, const char *start, const char *finish);
 
21
void escape_string(string_buffer& ar, const char *start, const char *finish);
 
22
bool unescape_string(char *& wp, const char *start, const char *finish);
 
23
  /* unescaped_string() works even if wp == start */
 
24
bool unescape_string(string_buffer& ar, const char *start, const char *finish);
 
25
 
 
26
uint32_t read_ui32(char *& start, char *finish);
 
27
void write_ui32(string_buffer& buf, uint32_t v);
 
28
 
 
29
inline bool
 
30
is_null_expression(const char *start, const char *finish)
 
31
{
 
32
  return (finish == start + 1 && start[0] == 0);
 
33
}
 
34
 
 
35
inline void
 
36
read_token(char *& start, char *finish)
 
37
{
 
38
  char *const p = memchr_char(start, '\t', finish - start);
 
39
  if (p == 0) {
 
40
    start = finish;
 
41
  } else {
 
42
    start = p;
 
43
  }
 
44
}
 
45
 
 
46
inline void
 
47
skip_token_delim_fold(char *& start, char *finish)
 
48
{
 
49
  while (start != finish && start[0] == '\t') {
 
50
    ++start;
 
51
  }
 
52
}
 
53
 
 
54
inline void
 
55
skip_one(char *& start, char *finish)
 
56
{
 
57
  if (start != finish) {
 
58
    ++start;
 
59
  }
 
60
}
 
61
 
 
62
};
 
63
 
 
64
#endif
 
65