blob: 42c3b54a899270a149bbde2f31e6dc7ded9cdcb4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set et sw=2 ts=2: */
/***************************************************************************
* asc2bin.h
*
* Thu Sep 5 11:12:50 CEST 2013
* Copyright 2013 Bent Bisballe Nyeng
* deva@aasimon.org
****************************************************************************/
/*
* This file is part of lrtp.
*
* lrtp is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* lrtp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with lrtp; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __LRTP_ASC2BIN_H__
#define __LRTP_ASC2BIN_H__
#include <stdlib.h>
#include "compat.h"
/**
* asc2bin converts a hexadecimal string to a raw octet string.
* @param raw The char buffer that will contain the result.
* @param rawsz The size of the output buffer 'raw'. This size must be at
* least hexlen / 2.
* @param hex The input hex string.
* @param hexlen The length of the hex string.
* @return The length of the resulting raw data. -1 on error.
* Errors are one of the following:
* - Hex string contains invalid hex character (0-9, a-f and A-F allowed).
* - rawsz is less than hexlen / 2.
* - hexlen is not a multiplum of 2 (odd hex string lengths not supported).
*/
ssize_t asc2bin(char *raw, size_t rawsz, const char *hex, size_t hexlen);
#endif/*__LRTP_ASC2BIN_H__*/
|