File: util.c

package info (click to toggle)
ekeyd 1.1.3-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 628 kB
  • ctags: 859
  • sloc: ansic: 5,189; sh: 271; makefile: 199; perl: 148
file content (28 lines) | stat: -rw-r--r-- 557 bytes parent folder | download | duplicates (5)
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
/* daemon/util.c
 *
 * Entropy key daemon utility functions
 *
 * Copyright 2009 Simtec Electronics
 *
 * For licence terms refer to the COPYING file.
 */

#include <stdint.h>

#include "util.h"

static char hexa[16] = "0123456789ABCDEF";

/* exported interface, documented in util.h */
char *
phex(uint8_t *c, int l)
{
    static char text[128];
    int loop;
    for (loop = 0 ; loop < l ; loop++) {
        text[(loop * 2) + 1] = hexa[(c[loop] & 0xF)];
        text[loop * 2] = hexa[(c[loop] & 0xF0) >> 4];
    }
    text[loop*2] = 0;
    return text;
}