gelf_checksum.c revision 260684
10SN/A/*-
2474SN/A * Copyright (c) 2006,2008 Joseph Koshy
30SN/A * All rights reserved.
40SN/A *
50SN/A * Redistribution and use in source and binary forms, with or without
60SN/A * modification, are permitted provided that the following conditions
7157SN/A * are met:
80SN/A * 1. Redistributions of source code must retain the above copyright
9157SN/A *    notice, this list of conditions and the following disclaimer.
100SN/A * 2. Redistributions in binary form must reproduce the above copyright
110SN/A *    notice, this list of conditions and the following disclaimer in the
120SN/A *    documentation and/or other materials provided with the distribution.
130SN/A *
140SN/A * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
150SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
160SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
170SN/A * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
180SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
190SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
200SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21157SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22157SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23157SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
240SN/A * SUCH DAMAGE.
250SN/A */
260SN/A
270SN/A#include <sys/cdefs.h>
280SN/A
290SN/A#include <gelf.h>
300SN/A#include <libelf.h>
310SN/A
320SN/A#include "_libelf.h"
330SN/A
340SN/AELFTC_VCSID("$Id: gelf_checksum.c 2225 2011-11-26 18:55:54Z jkoshy $");
350SN/A
360SN/Along
370SN/Aelf32_checksum(Elf *e)
380SN/A{
390SN/A	return (_libelf_checksum(e, ELFCLASS32));
400SN/A}
410SN/A
420SN/Along
430SN/Aelf64_checksum(Elf *e)
440SN/A{
450SN/A	return (_libelf_checksum(e, ELFCLASS64));
460SN/A}
470SN/A
480SN/Along
490SN/Agelf_checksum(Elf *e)
500SN/A{
510SN/A	int ec;
520SN/A	if (e == NULL ||
530SN/A	    ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64)) {
540SN/A		LIBELF_SET_ERROR(ARGUMENT, 0);
550SN/A		return (0L);
560SN/A	}
570SN/A	return (_libelf_checksum(e, ec));
580SN/A}
590SN/A