148905Srnordier/* 248905Srnordier * Copyright (c) 1999 Global Technology Associates, Inc. 348905Srnordier * All rights reserved. 448905Srnordier * 548905Srnordier * Redistribution and use in source and binary forms, with or without 648905Srnordier * modification, are permitted provided that the following conditions 748905Srnordier * are met: 848905Srnordier * 1. Redistributions of source code must retain the above copyright 948905Srnordier * notice, this list of conditions and the following disclaimer. 1048905Srnordier * 2. Redistributions in binary form must reproduce the above copyright 1148905Srnordier * notice, this list of conditions and the following disclaimer in the 1248905Srnordier * documentation and/or other materials provided with the distribution. 1348905Srnordier * 1448905Srnordier * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND 1548905Srnordier * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1648905Srnordier * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1748905Srnordier * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS 1848905Srnordier * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 1948905Srnordier * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 2048905Srnordier * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 2148905Srnordier * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2248905Srnordier * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 2348905Srnordier * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 2448905Srnordier * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2548905Srnordier * 2650479Speter * $FreeBSD$ 2748905Srnordier */ 2848905Srnordier 2948905Srnordier#include "kgz.h" 3048905Srnordier 3168313Srnordier#define F_AOUT 1 /* Format: a.out */ 3268313Srnordier#define F_ELF 2 /* Format: ELF32 */ 3368313Srnordier 3448905Srnordier/* Used by I/O routines */ 3548905Srnordierstruct iodesc { 3648905Srnordier const char *fname; /* File name */ 3748905Srnordier int fd; /* File descriptor */ 3848905Srnordier}; 3948905Srnordier 4048905Srnordierextern const char *loader; /* Default loader */ 4168313Srnordierextern int format; /* Output format */ 4248905Srnordier 4348905Srnordiervoid kgzcmp(struct kgz_hdr *, const char *, const char *); 4448905Srnordiervoid kgzld(struct kgz_hdr *, const char *, const char *); 4548905Srnordier 4648905Srnordiervoid xclose(const struct iodesc *); 4748905Srnordiervoid xcopy(const struct iodesc *, const struct iodesc *, size_t, off_t); 4848905Srnordiervoid xzero(const struct iodesc *, size_t); 4948905Srnordiersize_t xread(const struct iodesc *, void *, size_t, off_t); 5048905Srnordiervoid xwrite(const struct iodesc *, const void *, size_t); 5148905Srnordiervoid xseek(const struct iodesc *, off_t); 52