Merge lp:~brianaker/libdrizzle/cleanup-api into lp:libdrizzle

Proposed by Brian Aker
Status: Merged
Approved by: Andrew Hutchings
Approved revision: no longer in the source branch.
Merged at revision: 99
Proposed branch: lp:~brianaker/libdrizzle/cleanup-api
Merge into: lp:libdrizzle
Diff against target: 361 lines (+43/-197)
10 files modified
libdrizzle-5.1/conn.h (+0/-10)
libdrizzle-5.1/query.h (+1/-7)
libdrizzle/conn.cc (+0/-10)
libdrizzle/drizzle_local.h (+5/-0)
libdrizzle/query.cc (+25/-5)
tests/unit/escape.c (+11/-8)
tests/unit/hex.c (+0/-65)
tests/unit/include.am (+0/-10)
tests/unit/passwd.c (+0/-77)
tests/unit/statement_char.c (+1/-5)
To merge this branch: bzr merge lp:~brianaker/libdrizzle/cleanup-api
Reviewer Review Type Date Requested Status
Drizzle Trunk Pending
Review via email: mp+145078@code.launchpad.net
To post a comment you must log in.
lp:~brianaker/libdrizzle/cleanup-api updated
99. By Drizzle Continuous Integration

Merge lp:~brianaker/libdrizzle/cleanup-api Build: jenkins-Libdrizzle-55

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libdrizzle-5.1/conn.h'
--- libdrizzle-5.1/conn.h 2013-01-27 00:09:17 +0000
+++ libdrizzle-5.1/conn.h 2013-01-27 01:59:21 +0000
@@ -105,16 +105,6 @@
105const char *drizzle_error(const drizzle_st *con);105const char *drizzle_error(const drizzle_st *con);
106106
107/**107/**
108 * Value of errno in the case of a DRIZZLE_RETURN_ERRNO return value.
109 *
110 * @param[in] con Connection structure previously initialized with
111 * drizzle_create(), drizzle_clone(), or related functions.
112 * @return An errno value as defined in your system errno.h file.
113 */
114DRIZZLE_API
115int drizzle_errno(const drizzle_st *con);
116
117/**
118 * Get server defined error code for the last result read.108 * Get server defined error code for the last result read.
119 *109 *
120 * @param[in] con Connection structure previously initialized with110 * @param[in] con Connection structure previously initialized with
121111
=== modified file 'libdrizzle-5.1/query.h'
--- libdrizzle-5.1/query.h 2013-01-10 22:14:47 +0000
+++ libdrizzle-5.1/query.h 2013-01-27 01:59:21 +0000
@@ -79,13 +79,7 @@
79 */79 */
8080
81DRIZZLE_API81DRIZZLE_API
82ssize_t drizzle_escape_string(char *to, const size_t max_to_size, const char *from, const size_t from_size);82ssize_t drizzle_escape_string(drizzle_st *con, char **to, const char *from, const size_t from_size);
83
84DRIZZLE_API
85bool drizzle_hex_string(char *to, const unsigned char *from, const size_t from_size);
86
87DRIZZLE_API
88bool drizzle_mysql_password_hash(char *to, const char *from, const size_t from_size);
8983
90/** @} */84/** @} */
9185
9286
=== modified file 'libdrizzle/conn.cc'
--- libdrizzle/conn.cc 2013-01-26 23:31:43 +0000
+++ libdrizzle/conn.cc 2013-01-27 01:59:21 +0000
@@ -270,16 +270,6 @@
270 return (const char *)con->last_error;270 return (const char *)con->last_error;
271}271}
272272
273int drizzle_errno(const drizzle_st *con)
274{
275 if (con == NULL)
276 {
277 return 0;
278 }
279
280 return con->last_errno;
281}
282
283uint16_t drizzle_error_code(const drizzle_st *con)273uint16_t drizzle_error_code(const drizzle_st *con)
284{274{
285 if (con == NULL)275 if (con == NULL)
286276
=== modified file 'libdrizzle/drizzle_local.h'
--- libdrizzle/drizzle_local.h 2013-01-26 23:44:28 +0000
+++ libdrizzle/drizzle_local.h 2013-01-27 01:59:21 +0000
@@ -115,6 +115,11 @@
115 }115 }
116}116}
117117
118bool drizzle_hex_string(char *to, const unsigned char *from, const size_t from_size);
119
120bool drizzle_mysql_password_hash(char *to, const char *from, const size_t from_size);
121
122
118/**123/**
119 * Log an error message, see drizzle_log() for argument details.124 * Log an error message, see drizzle_log() for argument details.
120 */125 */
121126
=== modified file 'libdrizzle/query.cc'
--- libdrizzle/query.cc 2013-01-10 22:14:47 +0000
+++ libdrizzle/query.cc 2013-01-27 01:59:21 +0000
@@ -56,14 +56,26 @@
56 (unsigned char *)query, size, size, ret_ptr);56 (unsigned char *)query, size, size, ret_ptr);
57}57}
5858
59ssize_t drizzle_escape_string(char *to, const size_t max_to_size, const char *from, const size_t from_size)59ssize_t drizzle_escape_string(drizzle_st *con, char **destination, const char *from, const size_t from_size)
60{60{
61 (void)con;
61 const char *end;62 const char *end;
6263
63 if (to == NULL || max_to_size == 0 || from == NULL || from_size == 0)64 if (from == NULL || from_size == 0)
64 {65 {
65 return -1;66 return -1;
66 }67 }
68
69 size_t max_to_size= from_size * 2;
70 *destination= (char*) malloc(max_to_size);
71
72 if (destination == NULL)
73 {
74 return -1;
75 }
76
77 char *to= *destination;
78
6779
68 ssize_t to_size= 0;80 ssize_t to_size= 0;
69 char newchar;81 char newchar;
@@ -104,7 +116,11 @@
104 if (newchar != '\0')116 if (newchar != '\0')
105 {117 {
106 if ((size_t)to_size + 2 > max_to_size)118 if ((size_t)to_size + 2 > max_to_size)
119 {
120 free(to);
121 *destination= NULL;
107 return -1;122 return -1;
123 }
108124
109 *to++= '\\';125 *to++= '\\';
110 *to++= newchar;126 *to++= newchar;
@@ -113,7 +129,11 @@
113 else129 else
114 {130 {
115 if ((size_t)to_size + 1 > max_to_size)131 if ((size_t)to_size + 1 > max_to_size)
132 {
133 free(to);
134 *destination= NULL;
116 return -1;135 return -1;
136 }
117137
118 *to++= *from;138 *to++= *from;
119 }139 }
120140
=== modified file 'tests/unit/escape.c'
--- tests/unit/escape.c 2013-01-12 10:59:06 +0000
+++ tests/unit/escape.c 2013-01-27 01:59:21 +0000
@@ -46,19 +46,22 @@
46int main(int argc, char* argv[])46int main(int argc, char* argv[])
47{47{
48 const char* in= "escape \"this\"\n";48 const char* in= "escape \"this\"\n";
49 char out[255];
50 int out_len;
5149
52 (void) argc;50 (void) argc;
53 (void) argv;51 (void) argv;
5452
55 // Test for data too long53 // Test for data too long
56 out_len= drizzle_escape_string(out, 2, in, strlen(in));54 char *out;
57 ASSERT_EQ(out_len, -1);55 uint64_t out_len= drizzle_escape_string(NULL, &out, in, strlen(in));
5856 ASSERT_EQ_(17, out_len, "drizzle_escape_string(): %u != %u", 17, (unsigned int)(out_len));
59 out_len= drizzle_escape_string(out, 255, in, strlen(in));57
60 ASSERT_EQ_(out_len, 17, "Bad hex length output %d", out_len);58 free(out);
61 ASSERT_EQ_(strcmp(out, "escape \\\"this\\\"\\n"), 0, "Bad hex data output");59
60 out_len= drizzle_escape_string(NULL, &out, in, strlen(in));
61 ASSERT_EQ_(out_len, 17, "Bad hex length output %u", (unsigned int)(out_len));
62 ASSERT_EQ_(0, strcmp(out, "escape \\\"this\\\"\\n"), "Bad hex data output");
63
64 free(out);
6265
63 return EXIT_SUCCESS;66 return EXIT_SUCCESS;
64}67}
6568
=== removed file 'tests/unit/hex.c'
--- tests/unit/hex.c 2013-01-12 10:59:06 +0000
+++ tests/unit/hex.c 1970-01-01 00:00:00 +0000
@@ -1,65 +0,0 @@
1/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Drizzle Client & Protocol Library
4 *
5 * Copyright (C) 2012 Drizzle Developer Group
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#include <yatl/lite.h>
39
40#include <libdrizzle-5.1/libdrizzle.h>
41#include <stdio.h>
42#include <string.h>
43#include <stdlib.h>
44#include <stdint.h>
45
46int main(int argc, char* argv[])
47{
48 const unsigned char in[6]= {0x00, 0xFF, 0x7F, 0x80, 0xB9, 0xC0};
49 char out[255];
50 bool result;
51
52 (void) argc;
53 (void) argv;
54
55 // Test for bad usage
56 result= drizzle_hex_string(out, in, 0);
57 ASSERT_EQ_(false, result, "Bad usage of drizzle_hex_string()");
58
59 result= drizzle_hex_string(out, in, sizeof(in));
60 ASSERT_EQ_(true, result, "Failed to get result");
61
62 ASSERT_STREQ_("00FF7F80B9C0", out, "Bad result data from drizzle_hex_string()");
63
64 return EXIT_SUCCESS;
65}
660
=== modified file 'tests/unit/include.am'
--- tests/unit/include.am 2013-01-26 23:44:28 +0000
+++ tests/unit/include.am 2013-01-27 01:59:21 +0000
@@ -82,16 +82,6 @@
82check_PROGRAMS+= tests/unit/connect_uds82check_PROGRAMS+= tests/unit/connect_uds
83noinst_PROGRAMS+= tests/unit/connect_uds83noinst_PROGRAMS+= tests/unit/connect_uds
8484
85tests_unit_hex_SOURCES= tests/unit/hex.c
86tests_unit_hex_LDADD= libdrizzle/libdrizzle.la
87check_PROGRAMS+= tests/unit/hex
88noinst_PROGRAMS+= tests/unit/hex
89
90tests_unit_passwd_SOURCES= tests/unit/passwd.c
91tests_unit_passwd_LDADD= libdrizzle/libdrizzle.la
92check_PROGRAMS+= tests/unit/passwd
93noinst_PROGRAMS+= tests/unit/passwd
94
95tests_unit_unbuffered_query_SOURCES= tests/unit/unbuffered_query.c85tests_unit_unbuffered_query_SOURCES= tests/unit/unbuffered_query.c
96tests_unit_unbuffered_query_LDADD= libdrizzle/libdrizzle.la86tests_unit_unbuffered_query_LDADD= libdrizzle/libdrizzle.la
97check_PROGRAMS+= tests/unit/unbuffered_query87check_PROGRAMS+= tests/unit/unbuffered_query
9888
=== removed file 'tests/unit/passwd.c'
--- tests/unit/passwd.c 2013-01-12 10:59:06 +0000
+++ tests/unit/passwd.c 1970-01-01 00:00:00 +0000
@@ -1,77 +0,0 @@
1/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Drizzle Client & Protocol Library
4 *
5 * Copyright (C) 2012 Drizzle Developer Group
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#include <yatl/lite.h>
39
40#include <libdrizzle-5.1/libdrizzle.h>
41#include <stdio.h>
42#include <string.h>
43#include <stdlib.h>
44#include <stdint.h>
45#include <string.h>
46
47int main(int argc, char* argv[])
48{
49 const char* in= "a nice passphrase";
50 char out[255];
51 bool result;
52
53 (void) argc;
54 (void) argv;
55
56 // Test for bad usage
57 result= drizzle_mysql_password_hash(out, in, 0);
58 if (result)
59 {
60 printf("Usage test failure\n");
61 return EXIT_FAILURE;
62 }
63
64 result= drizzle_mysql_password_hash(out, in, strlen(in));
65 if (!result)
66 {
67 printf("Didn't get a result failure\n");
68 return EXIT_FAILURE;
69 }
70
71 if (strcmp(out, "597B78D6E0366308739CEBB0E221B246F117E111") != 0)
72 {
73 printf("Password output didn't match\n");
74 return EXIT_FAILURE;
75 }
76 return EXIT_SUCCESS;
77}
780
=== modified file 'tests/unit/statement_char.c'
--- tests/unit/statement_char.c 2013-01-12 13:40:18 +0000
+++ tests/unit/statement_char.c 2013-01-27 01:59:21 +0000
@@ -139,11 +139,7 @@
139 return EXIT_FAILURE;139 return EXIT_FAILURE;
140 }140 }
141 ret = drizzle_stmt_close(stmt);141 ret = drizzle_stmt_close(stmt);
142 if (ret != DRIZZLE_RETURN_OK)142 ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "drizzle_stmt_close() %s", drizzle_error(con));
143 {
144 printf("Statement close failure ret: %d, err: %d, msg: %s\n", ret, drizzle_errno(con), drizzle_error(con));
145 return EXIT_FAILURE;
146 }
147143
148 drizzle_query(con, "DROP TABLE libdrizzle.t1", 0, &ret);144 drizzle_query(con, "DROP TABLE libdrizzle.t1", 0, &ret);
149 ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "DROP TABLE libdrizzle.t1");145 ASSERT_EQ_(DRIZZLE_RETURN_OK, ret, "DROP TABLE libdrizzle.t1");

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: