librsync  2.3.2
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 #include "librsync.h"
22 
23 void rs_hexify(char *to_buf, void const *from, int from_len)
24 {
25  static const char hex_chars[] = "0123456789abcdef";
26  unsigned char const *from_buf = (unsigned char const *)from;
27 
28  while (from_len-- > 0) {
29  *(to_buf++) = hex_chars[((*from_buf) >> 4) & 0xf];
30  *(to_buf++) = hex_chars[(*from_buf) & 0xf];
31  from_buf++;
32  }
33 
34  *to_buf = 0;
35 }
Public header for librsync.
LIBRSYNC_EXPORT 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:23