summaryrefslogtreecommitdiff
path: root/rsync/hex.c
Unidiff
Diffstat (limited to 'rsync/hex.c') (more/less context) (ignore whitespace changes)
-rw-r--r--rsync/hex.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/rsync/hex.c b/rsync/hex.c
new file mode 100644
index 0000000..e10b686
--- a/dev/null
+++ b/rsync/hex.c
@@ -0,0 +1,46 @@
1/*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 * rproxy -- dynamic caching and delta update in HTTP
3 * $Id$
4 *
5 * Copyright (C) 2000, 2001 by Martin Pool <mbp@samba.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <config_rsync.h>
23
24#include <assert.h>
25#include <sys/types.h>
26#include <inttypes.h>
27#include <stdlib.h>
28#include <stdio.h>
29
30#include "rsync.h"
31
32
33void
34rs_hexify(char *to_buf, void const *from, int from_len)
35{
36 static const char hex_chars[] = "0123456789abcdef";
37 unsigned char const *from_buf = (unsigned char const *) from;
38
39 while (from_len-- > 0) {
40 *(to_buf++) = hex_chars[((*from_buf) >> 4) & 0xf];
41 *(to_buf++) = hex_chars[(*from_buf) & 0xf];
42 from_buf++;
43 }
44
45 *to_buf = 0;
46}