librsync
2.0.2
src
hex.c
1
/*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*-
2
*
3
* Copyright (C) 2000, 2001 by Martin Pool <mbp@sourcefrog.net>
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Lesser General Public License as published by
7
* the Free Software Foundation; either version 2.1 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
*/
19
20
#include "config.h"
21
22
#include <assert.h>
23
#include <sys/types.h>
24
#ifdef HAVE_INTTYPES_H
25
# include <inttypes.h>
26
#endif
27
#include <stdlib.h>
28
#include <stdio.h>
29
30
#include "
librsync.h
"
31
32
void
rs_hexify
(
char
*to_buf,
void
const
*from,
int
from_len)
33
{
34
static
const
char
hex_chars[] =
"0123456789abcdef"
;
35
unsigned
char
const
*from_buf = (
unsigned
char
const
*)from;
36
37
while
(from_len-- > 0) {
38
*(to_buf++) = hex_chars[((*from_buf) >> 4) & 0xf];
39
*(to_buf++) = hex_chars[(*from_buf) & 0xf];
40
from_buf++;
41
}
42
43
*to_buf = 0;
44
}
rs_hexify
void rs_hexify(char *to_buf, void const *from_buf, int from_len)
Convert from_len bytes at from_buf into a hex representation in to_buf, which must be twice as long p...
Definition:
hex.c:32
librsync.h
Public header for librsync.
Generated on Sat Nov 2 2019 03:51:41 for librsync by
1.8.14