summaryrefslogtreecommitdiff
path: root/src/output/mdso_output_expsyms_crc.c
blob: 89d866eac5423d08bcedf7b36bc0151696dba49f (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/****************************************************************/
/*  mdso: midipix dso scavenger                                 */
/*  Copyright (C) 2015--2024  SysDeer Technologies, LLC         */
/*  Released under GPLv2 and GPLv3; see COPYING.MDSO.           */
/****************************************************************/

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>

#include <mdso/mdso.h>
#include <mdso/mdso_output.h>
#include "mdso_driver_impl.h"
#include "mdso_dprintf_impl.h"
#include "mdso_errinfo_impl.h"

static int pretty_expsym_crc32(
	int		fdout,
	const char *	name)
{
	return mdso_dprintf(
		fdout,"%" PRIx32 "  %s\n",
		mdso_crc32_mbstr((const unsigned char *)name,0),
		name);
}

static int pretty_expsym_crc64(
	int		fdout,
	const char *	name)
{
	return mdso_dprintf(
		fdout,"%" PRIx64 "  %s\n",
		mdso_crc64_mbstr((const unsigned char *)name,0),
		name);
}

int mdso_output_expsyms_crc32(
	const struct mdso_driver_ctx *	dctx,
	const struct mdso_unit_ctx *	uctx)
{
	int			fdout;
	const char * const *	sym;

	fdout = mdso_driver_fdout(dctx);

	if (!uctx->syms[0])
		return 0;

	for (sym=uctx->syms; *sym; sym++)
		if ((pretty_expsym_crc32(fdout,*sym)) < 0)
			return MDSO_SYSTEM_ERROR(dctx);

	return 0;
}

int mdso_output_expsyms_crc64(
	const struct mdso_driver_ctx *	dctx,
	const struct mdso_unit_ctx *	uctx)
{
	int			fdout;
	const char * const *	sym;

	fdout = mdso_driver_fdout(dctx);

	if (!uctx->syms[0])
		return 0;

	for (sym=uctx->syms; *sym; sym++)
		if ((pretty_expsym_crc64(fdout,*sym)) < 0)
			return MDSO_SYSTEM_ERROR(dctx);

	return 0;
}