Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
2428fb5c
Commit
2428fb5c
authored
Oct 19, 2004
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libmysql.c:
New function mysql_hex_string() libmysql/libmysql.c: New function mysql_hex_string()
parent
38e717ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
libmysql/libmysql.c
libmysql/libmysql.c
+33
-0
No files found.
libmysql/libmysql.c
View file @
2428fb5c
...
...
@@ -3153,6 +3153,39 @@ void my_net_local_init(NET *net)
net
->
max_packet_size
=
max
(
net_buffer_length
,
max_allowed_packet
);
}
/*
This function is used to create HEX string that you
can use in a SQL statement in of the either ways:
INSERT INTO blob_column VALUES (0xAABBCC); (any MySQL version)
INSERT INTO blob_column VALUES (X'AABBCC'); (4.1 and higher)
The string in "from" is encoded to a HEX string.
The result is placed in "to" and a terminating null byte is appended.
The string pointed to by "from" must be "length" bytes long.
You must allocate the "to" buffer to be at least length*2+1 bytes long.
Each character needs two bytes, and you need room for the terminating
null byte. When mysql_hex_string() returns, the contents of "to" will
be a null-terminated string. The return value is the length of the
encoded string, not including the terminating null character.
*/
unsigned
long
mysql_hex_string
(
char
*
to
,
const
char
*
from
,
unsigned
long
length
)
{
char
*
to0
=
to
;
const
char
*
end
;
static
char
hex
[]
=
"0123456789ABCDEF"
;
for
(
end
=
from
+
length
;
from
<
end
;
from
++
)
{
*
to
++=
hex
[((
unsigned
char
)
*
from
)
>>
4
];
*
to
++=
hex
[((
unsigned
char
)
*
from
)
&
0x0F
];
}
*
to
=
'\0'
;
return
to
-
to0
;
}
/*
Add escape characters to a string (blob?) to make it suitable for a insert
to should at least have place for length*2+1 chars
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment