summaryrefslogtreecommitdiffstats
path: root/tools/build/src
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-04-19 13:35:24 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-04-19 13:35:24 +0000
commitb6529a34fd5a3b821bfef0cdecea8106a8487ef0 (patch)
tree2d93d2d9b757dbaa87aecd8cf5d8d9c7285bbeb6 /tools/build/src
parentNew file -- automatically generated. (diff)
downloadrtems-b6529a34fd5a3b821bfef0cdecea8106a8487ef0.tar.bz2
Patch from Ralf Corsepius <corsepiu@faw.uni-ulm.de> to reorganize
the build-tools layout to simplify it. This script reorganizes and simpilfies the build-tools subdirectories. It moves all source-files and scripts to c/build-tools/. This will enable use to use this directory directly to refer to the build-tools instead of copying them around in a "preinstall" step in future. However, RTEMS's autoconf Makefile.ins and *.cfg files are not yet prepared to apply this approach and therefore require additional work.
Diffstat (limited to 'tools/build/src')
-rw-r--r--tools/build/src/Makefile.am24
-rw-r--r--tools/build/src/Makefile.in424
-rw-r--r--tools/build/src/cklength.c377
-rw-r--r--tools/build/src/config.h.in4
-rw-r--r--tools/build/src/eolstrip.c366
-rw-r--r--tools/build/src/packhex.c565
-rw-r--r--tools/build/src/stamp-h.in1
-rw-r--r--tools/build/src/unhex.c738
8 files changed, 0 insertions, 2499 deletions
diff --git a/tools/build/src/Makefile.am b/tools/build/src/Makefile.am
deleted file mode 100644
index dcb7062295..0000000000
--- a/tools/build/src/Makefile.am
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# $Id$
-#
-
-AUTOMAKE_OPTIONS = foreign
-
-bin_PROGRAMS=cklength eolstrip packhex unhex
-
-cklength_SOURCES = cklength.c
-eolstrip_SOURCES = eolstrip.c
-packhex_SOURCES = packhex.c
-unhex_SOURCES = unhex.c
-
-#
-# HACK: install to the build-tree
-#
-install-exec-local: $(bin_PROGRAMS)
- $(mkinstalldirs) $(PROJECT_ROOT)/${RTEMS_BSP}/build-tools
- $(INSTALL_PROGRAM) $(bin_PROGRAMS) \
- $(PROJECT_ROOT)/${RTEMS_BSP}/build-tools
-
-preinstall: install-exec-local
-
-include $(top_srcdir)/../../automake/local.am
diff --git a/tools/build/src/Makefile.in b/tools/build/src/Makefile.in
deleted file mode 100644
index ac6655e8a8..0000000000
--- a/tools/build/src/Makefile.in
+++ /dev/null
@@ -1,424 +0,0 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
-
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-#
-# $Id$
-#
-
-
-
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-host_alias = @host_alias@
-host_triplet = @host@
-CC = @CC@
-EXEEXT = @EXEEXT@
-KSH = @KSH@
-MAKEINFO = @MAKEINFO@
-PACKAGE = @PACKAGE@
-PROJECT_ROOT = @PROJECT_ROOT@
-RTEMS_ROOT = @RTEMS_ROOT@
-RTEMS_TOPdir = @RTEMS_TOPdir@
-VERSION = @VERSION@
-
-AUTOMAKE_OPTIONS = foreign
-
-bin_PROGRAMS = cklength eolstrip packhex unhex
-
-cklength_SOURCES = cklength.c
-eolstrip_SOURCES = eolstrip.c
-packhex_SOURCES = packhex.c
-unhex_SOURCES = unhex.c
-mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
-CONFIG_HEADER = config.h
-CONFIG_CLEAN_FILES =
-bin_PROGRAMS = cklength$(EXEEXT) eolstrip$(EXEEXT) packhex$(EXEEXT) \
-unhex$(EXEEXT)
-PROGRAMS = $(bin_PROGRAMS)
-
-
-DEFS = @DEFS@ -I. -I$(srcdir) -I.
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-cklength_OBJECTS = cklength.o
-cklength_LDADD = $(LDADD)
-cklength_DEPENDENCIES =
-cklength_LDFLAGS =
-eolstrip_OBJECTS = eolstrip.o
-eolstrip_LDADD = $(LDADD)
-eolstrip_DEPENDENCIES =
-eolstrip_LDFLAGS =
-packhex_OBJECTS = packhex.o
-packhex_LDADD = $(LDADD)
-packhex_DEPENDENCIES =
-packhex_LDFLAGS =
-unhex_OBJECTS = unhex.o
-unhex_LDADD = $(LDADD)
-unhex_DEPENDENCIES =
-unhex_LDFLAGS =
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in config.h.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
-DEP_FILES = .deps/cklength.P .deps/eolstrip.P .deps/packhex.P \
-.deps/unhex.P
-SOURCES = $(cklength_SOURCES) $(eolstrip_SOURCES) $(packhex_SOURCES) $(unhex_SOURCES)
-OBJECTS = $(cklength_OBJECTS) $(eolstrip_OBJECTS) $(packhex_OBJECTS) $(unhex_OBJECTS)
-
-all: all-redirect
-.SUFFIXES:
-.SUFFIXES: .S .c .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/../../automake/local.am
- cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile
-
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
- cd $(top_builddir) \
- && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-config.h: stamp-h
- @if test ! -f $@; then \
- rm -f stamp-h; \
- $(MAKE) stamp-h; \
- else :; fi
-stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
- cd $(top_builddir) \
- && CONFIG_FILES= CONFIG_HEADERS=src/config.h \
- $(SHELL) ./config.status
- @echo timestamp > stamp-h 2> /dev/null
-$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
- @if test ! -f $@; then \
- rm -f $(srcdir)/stamp-h.in; \
- $(MAKE) $(srcdir)/stamp-h.in; \
- else :; fi
-$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
- cd $(top_srcdir) && $(AUTOHEADER)
- @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
-
-mostlyclean-hdr:
-
-clean-hdr:
-
-distclean-hdr:
- -rm -f config.h
-
-maintainer-clean-hdr:
-
-mostlyclean-binPROGRAMS:
-
-clean-binPROGRAMS:
- -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
-
-distclean-binPROGRAMS:
-
-maintainer-clean-binPROGRAMS:
-
-install-binPROGRAMS: $(bin_PROGRAMS)
- @$(NORMAL_INSTALL)
- $(mkinstalldirs) $(DESTDIR)$(bindir)
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- if test -f $$p; then \
- echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
- $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
- else :; fi; \
- done
-
-uninstall-binPROGRAMS:
- @$(NORMAL_UNINSTALL)
- list='$(bin_PROGRAMS)'; for p in $$list; do \
- rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
- done
-
-.s.o:
- $(COMPILE) -c $<
-
-.S.o:
- $(COMPILE) -c $<
-
-mostlyclean-compile:
- -rm -f *.o core *.core
-
-clean-compile:
-
-distclean-compile:
- -rm -f *.tab.c
-
-maintainer-clean-compile:
-
-cklength$(EXEEXT): $(cklength_OBJECTS) $(cklength_DEPENDENCIES)
- @rm -f cklength$(EXEEXT)
- $(LINK) $(cklength_LDFLAGS) $(cklength_OBJECTS) $(cklength_LDADD) $(LIBS)
-
-eolstrip$(EXEEXT): $(eolstrip_OBJECTS) $(eolstrip_DEPENDENCIES)
- @rm -f eolstrip$(EXEEXT)
- $(LINK) $(eolstrip_LDFLAGS) $(eolstrip_OBJECTS) $(eolstrip_LDADD) $(LIBS)
-
-packhex$(EXEEXT): $(packhex_OBJECTS) $(packhex_DEPENDENCIES)
- @rm -f packhex$(EXEEXT)
- $(LINK) $(packhex_LDFLAGS) $(packhex_OBJECTS) $(packhex_LDADD) $(LIBS)
-
-unhex$(EXEEXT): $(unhex_OBJECTS) $(unhex_DEPENDENCIES)
- @rm -f unhex$(EXEEXT)
- $(LINK) $(unhex_LDFLAGS) $(unhex_OBJECTS) $(unhex_LDADD) $(LIBS)
-
-tags: TAGS
-
-ID: $(HEADERS) $(SOURCES) $(LISP)
- list='$(SOURCES) $(HEADERS)'; \
- unique=`for i in $$list; do echo $$i; done | \
- awk ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- here=`pwd` && cd $(srcdir) \
- && mkid -f$$here/ID $$unique $(LISP)
-
-TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS)'; \
- unique=`for i in $$list; do echo $$i; done | \
- awk ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
- || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
-
-mostlyclean-tags:
-
-clean-tags:
-
-distclean-tags:
- -rm -f TAGS ID
-
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = src
-
-distdir: $(DISTFILES)
- here=`cd $(top_builddir) && pwd`; \
- top_distdir=`cd $(top_distdir) && pwd`; \
- distdir=`cd $(distdir) && pwd`; \
- cd $(top_srcdir) \
- && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign src/Makefile
- @for file in $(DISTFILES); do \
- d=$(srcdir); \
- if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
- else \
- test -f $(distdir)/$$file \
- || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
- || cp -p $$d/$$file $(distdir)/$$file || :; \
- fi; \
- done
-
-DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-
--include $(DEP_FILES)
-
-mostlyclean-depend:
-
-clean-depend:
-
-distclean-depend:
- -rm -rf .deps
-
-maintainer-clean-depend:
-
-%.o: %.c
- @echo '$(COMPILE) -c $<'; \
- $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
- @-cp .deps/$(*F).pp .deps/$(*F).P; \
- tr ' ' '\012' < .deps/$(*F).pp \
- | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
- >> .deps/$(*F).P; \
- rm .deps/$(*F).pp
-
-%.lo: %.c
- @echo '$(LTCOMPILE) -c $<'; \
- $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
- @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
- < .deps/$(*F).pp > .deps/$(*F).P; \
- tr ' ' '\012' < .deps/$(*F).pp \
- | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
- >> .deps/$(*F).P; \
- rm -f .deps/$(*F).pp
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
-check-am: all-am
-check: check-am
-installcheck-am:
-installcheck: installcheck-am
-all-recursive-am: config.h
- $(MAKE) $(AM_MAKEFLAGS) all-recursive
-
-install-exec-am: install-binPROGRAMS install-exec-local
-install-exec: install-exec-am
-
-install-data-am:
-install-data: install-data-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am: uninstall-binPROGRAMS
-uninstall: uninstall-am
-all-am: Makefile $(PROGRAMS) config.h
-all-redirect: all-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
- $(mkinstalldirs) $(DESTDIR)$(bindir)
-
-
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -rm -f Makefile $(CONFIG_CLEAN_FILES)
- -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-
-maintainer-clean-generic:
-mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \
- mostlyclean-compile mostlyclean-tags mostlyclean-depend \
- mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am: clean-hdr clean-binPROGRAMS clean-compile clean-tags \
- clean-depend clean-generic mostlyclean-am
-
-clean: clean-am
-
-distclean-am: distclean-hdr distclean-binPROGRAMS distclean-compile \
- distclean-tags distclean-depend distclean-generic \
- clean-am
-
-distclean: distclean-am
-
-maintainer-clean-am: maintainer-clean-hdr maintainer-clean-binPROGRAMS \
- maintainer-clean-compile maintainer-clean-tags \
- maintainer-clean-depend maintainer-clean-generic \
- distclean-am
- @echo "This command is intended for maintainers to use;"
- @echo "it deletes files that may require special tools to rebuild."
-
-maintainer-clean: maintainer-clean-am
-
-.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
-mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
-maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
-mostlyclean-compile distclean-compile clean-compile \
-maintainer-clean-compile tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir mostlyclean-depend \
-distclean-depend clean-depend maintainer-clean-depend info-am info \
-dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \
-install-exec-local install-exec-am install-exec install-data-am \
-install-data install-am install uninstall-am uninstall all-redirect \
-all-am all installdirs mostlyclean-generic distclean-generic \
-clean-generic maintainer-clean-generic clean mostlyclean distclean \
-maintainer-clean
-
-
-#
-# HACK: install to the build-tree
-#
-install-exec-local: $(bin_PROGRAMS)
- $(mkinstalldirs) $(PROJECT_ROOT)/${RTEMS_BSP}/build-tools
- $(INSTALL_PROGRAM) $(bin_PROGRAMS) \
- $(PROJECT_ROOT)/${RTEMS_BSP}/build-tools
-
-preinstall: install-exec-local
-
-debug-am:
-
-debug: debug-am
-
-debug_install-am:
-
-debug_install: debug_install-am
-
-.PHONY: debug debug_install debug-am
-
-profile-am:
-
-profile: profile-am
-
-profile_install-am:
-
-profile_install: profile_install-am
-
-.PHONY: profile profile_install profile-am
-
-preinstall-am:
-
-preinstall: preinstall-am
-
-.PHONY: preinstall preinstall-am
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/tools/build/src/cklength.c b/tools/build/src/cklength.c
deleted file mode 100644
index 624bf25e70..0000000000
--- a/tools/build/src/cklength.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * cklength - check the length of lines in a file
- *
- * This program check to see if the files passed to it on the command line
- * contain a line which exceeds the maximum allowable length. The default
- * maximum line length is 80.
- *
- * usage: cklength [ -v ] [ arg ... ] files...
- * -l length -- maximum line length
- * -v -- verbose
- *
- * $Id$
- */
-
-#define GETOPTARGS "l:nNv"
-
-char *USAGE = "\
-usage: cklength [ -v ] [ arg ... ] files... \n\
- -l length -- maximum line length\n\
- -n -- report line numbers for offending lines\n\
- -N -- report line numbers and length for offending lines\n\
- -v -- verbose\n\
-\n\
-Print the name of files which have at least 1 line which exceeds the\n\
-maximum line length. The default maximum line length is 80.\n\
-";
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <memory.h>
-#include <stdarg.h>
-#include <errno.h>
-
-#include "config.h"
-
-#ifndef VMS
-#ifndef HAVE_STRERROR
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-#define strerror( _err ) \
- ((_err) < sys_nerr) ? sys_errlist [(_err)] : "unknown error"
-
-#else /* HAVE_STRERROR */
-char *strerror ();
-#endif
-#else /* VMS */
-char *strerror (int,...);
-#endif
-
-
-#define BUFFER_SIZE 512
-
-#define SUCCESS 0
-#define FAILURE -1
-#define Failed(x) (((int) (x)) == FAILURE)
-#define TRUE 1
-#define FALSE 0
-#define STREQ(a,b) (strcmp(a,b) == 0)
-#define NUMELEMS(arr) (sizeof(arr) / sizeof(arr[0]))
-
-/*
- * Definitions for unsigned "ints"; especially for use in data structures
- * that will be shared among (potentially) different cpu's (we punt on
- * byte ordering problems tho)
- */
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned long u32;
-
-/*
- * vars controlled by command line options
- */
-
-int verbose = FALSE; /* be verbose */
-int report_line_numbers = FALSE; /* report line numbers of offenders */
-int report_line_length = FALSE; /* report line length of offenders */
-
-int line_length = 80; /* maximum allowable line length */
-
-extern char *optarg; /* getopt(3) control vars */
-extern int optind, opterr;
-
-char *progname; /* for error() */
-
-int process(char *arg);
-void error(int errn, ...);
-long getparm(char *s, long min, long max, char *msg);
-
-#define ERR_ERRNO (1<<((sizeof(int) * 8) - 2)) /* hi bit; use 'errno' */
-#define ERR_FATAL (ERR_ERRNO / 2) /* fatal error ; no return */
-#define ERR_ABORT (ERR_ERRNO / 4) /* fatal error ; abort */
-#define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */
-
-#define stol(p) strtol(p, (char **) NULL, 0)
-int Open(), Read(), Write();
-
-int main(
- int argc,
- char **argv
-)
-{
- register int c;
- int showusage = FALSE; /* usage error? */
- int rc = 0;
-
- /*
- * figure out invocation leaf-name
- */
-
- if ((progname = strrchr(argv[0], '/')) == (char *) NULL)
- progname = argv[0];
- else
- progname++;
-
- argv[0] = progname; /* for getopt err reporting */
-
- /*
- * Check options and arguments.
- */
-
- opterr = 0; /* we'll report all errors */
- while ((c = getopt(argc, argv, GETOPTARGS)) != EOF)
- switch (c)
- {
- case 'l': /* line length */
- line_length = atoi( optarg );
- if ( line_length < 0 || line_length > BUFFER_SIZE )
- error(ERR_FATAL, "(%d) is illegal line length\n",line_length);
- break;
-
- case 'n': /* toggle report_line_numbers */
- report_line_numbers = ! report_line_numbers;
- break;
-
- case 'N': /* toggle both reports */
- report_line_numbers = ! report_line_numbers;
- report_line_length = ! report_line_length;
- break;
-
- case 'v': /* toggle verbose */
- verbose = ! verbose;
- break;
-
- case '?':
- showusage = TRUE;
- }
-
- if (showusage)
- {
- (void) fprintf(stderr, "%s", USAGE);
- exit(1);
- }
-
- /*
- * traverse and process the arguments
- */
-
- for ( ; argv[optind]; optind++)
- if (Failed(process(argv[optind])))
- rc = FAILURE;
-
- return rc;
-}
-
-
-/*
- * process(arg)
- */
-
-int
-process(char *arg)
-{
- FILE *in;
- char *bptr;
- char buffer[ BUFFER_SIZE ];
- int line_number;
- int length;
- int count;
- int rc = SUCCESS; /* succeed by default */
-
- in = fopen( arg, "r" );
- if (!in)
- error( ERR_ERRNO | ERR_FATAL, "Unable to open file (%s)\n", arg );
-
- count = 0;
-
- for ( line_number=1 ; ; line_number++ ) {
- bptr = fgets( buffer, BUFFER_SIZE, in );
- if (!bptr)
- break;
-
- /*
- * Don't count the carriage return.
- */
-
- length = strlen( buffer ) - 1;
-
- if ( length <= line_length )
- continue;
-
- if ( count == 0 ) {
- fprintf( stderr, "%s\n", arg );
- if ( !report_line_numbers )
- break;
- }
-
- if ( verbose )
- fprintf( stderr, "TOO LONG:%d: %s\n", line_number, buffer );
-
- if ( report_line_numbers ) {
- if ( report_line_length )
- fprintf( stderr, "%d: %d\n" , line_number, length );
- else
- fprintf( stderr, "%d\n" , line_number );
- }
-
- count++;
-
- }
-
- fclose( in );
- return rc;
-}
-
-/*
- * error(errn, arglist)
- * report an error to stderr using printf(3) conventions.
- * Any output is preceded by '<progname>: '
- *
- * Uses ERR_FATAL bit to request exit(errn)
- * ERR_ABORT to request abort()
- * ERR_ERRNO to indicate use of errno instead of argument.
- *
- * If resulting 'errn' is non-zero, it is assumed to be an 'errno' and its
- * associated error message is appended to the output.
- */
-
-/*VARARGS*/
-
-void
-error(int error_flag, ...)
-{
- va_list arglist;
- register char *format;
- int local_errno;
-
- extern int errno;
-
- (void) fflush(stdout); /* in case stdout/stderr same */
-
- local_errno = error_flag & ~ERR_MASK;
- if (error_flag & ERR_ERRNO) /* use errno? */
- local_errno = errno;
-
- va_start(arglist, error_flag);
- format = va_arg(arglist, char *);
- (void) fprintf(stderr, "%s: ", progname);
- (void) vfprintf(stderr, format, arglist);
- va_end(arglist);
-
- if (local_errno)
- (void) fprintf(stderr, " (%s)\n", strerror(local_errno));
-
- (void) fflush(stderr);
-
- if (error_flag & (ERR_FATAL | ERR_ABORT))
- {
- if (error_flag & ERR_FATAL)
- {
- error(0, "fatal error, exiting");
- exit(local_errno ? local_errno : 1);
- }
- else
- {
- error(0, "fatal error, aborting");
- abort();
- }
- }
-}
-
-long
-getparm(char *s,
- long min,
- long max,
- char *msg)
-{
- long val;
-
- if ( ! strchr("0123456789-", *s))
- {
- error(ERR_FATAL, "'%s' is not a number", s);
- return min;
- }
-
- val = strtol(s, (char **) NULL, 0);
- if ((val < min) || (val > max))
- {
- if (min == max)
- error(ERR_FATAL, "%s can only be %ld", s, min);
- else
- error(ERR_FATAL, "%s must be between %ld and %ld", msg, min, max);
- }
-
- return val;
-}
-
-
-/*
- * Open()
- * Perform open(2), returning the file descriptor. Prints
- * error message if open fails.
- */
-
-int
-Open(char *file,
- int oflag,
- int mode)
-{
- int O_fd;
-
- if (Failed(O_fd = open(file, oflag, mode)))
- error(
- ERR_ERRNO | ERR_FATAL,
- "open('%s', 0x%x, 0%o) failed", file, oflag, mode
- );
-
- return O_fd;
-}
-
-/*
- * Read()
- * Perform read(2); prints error message if fails.
- */
-
-int
-Read(int file,
- char *buffer,
- unsigned int count)
-{
- int nbytes;
-
- if (Failed(nbytes = read(file, buffer, count)))
- error(
- ERR_ERRNO | ERR_FATAL,
- "read(%d, 0x%x, %d) failed", file, buffer, count
- );
-
- return nbytes;
-}
-
-/*
- * Write()
- * Perform write(2); prints error message if fails.
- */
-
-int
-Write(int file,
- char *buffer,
- unsigned int count)
-{
- int nbytes;
-
- if (Failed(nbytes = write(file, buffer, count)))
- error(
- ERR_ERRNO | ERR_FATAL,
- "write(%d, 0x%x, %d) failed", file, buffer, count
- );
-
- return nbytes;
-}
diff --git a/tools/build/src/config.h.in b/tools/build/src/config.h.in
deleted file mode 100644
index d5856a079a..0000000000
--- a/tools/build/src/config.h.in
+++ /dev/null
@@ -1,4 +0,0 @@
-/* src/config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if you have the strerror function. */
-#undef HAVE_STRERROR
diff --git a/tools/build/src/eolstrip.c b/tools/build/src/eolstrip.c
deleted file mode 100644
index c944ae6663..0000000000
--- a/tools/build/src/eolstrip.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * eolstrip - strip white space from end of lines
- *
- * This program strips the white space from the end of every line in the
- * specified program.
- *
- * usage: eolstrip [ -v ] [ arg ... ] files...
- * -v -- verbose
- *
- * $Id$
- */
-
-#define GETOPTARGS "vt"
-
-char *USAGE = "\
-usage: cklength [ -v ] [ arg ... ] files... \n\
- -v -- verbose\n\
- -t -- test only .. DO NOT OVERWRITE FILE!!!\n\
-\n\
-Strip the white space from the end of every line on the list of files.\n\
-";
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <memory.h>
-#include <stdarg.h>
-#include <errno.h>
-
-#include "config.h"
-
-#ifndef VMS
-#ifndef HAVE_STRERROR
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-#define strerror( _err ) \
- ((_err) < sys_nerr) ? sys_errlist [(_err)] : "unknown error"
-
-#else /* HAVE_STRERROR */
-char *strerror ();
-#endif
-#else /* VMS */
-char *strerror (int,...);
-#endif
-
-
-#define BUFFER_SIZE 2048
-#define MAX_PATH 2048
-
-#define SUCCESS 0
-#define FAILURE -1
-#define Failed(x) (((int) (x)) == FAILURE)
-#define TRUE 1
-#define FALSE 0
-#define STREQ(a,b) (strcmp(a,b) == 0)
-#define NUMELEMS(arr) (sizeof(arr) / sizeof(arr[0]))
-
-/*
- * Definitions for unsigned "ints"; especially for use in data structures
- * that will be shared among (potentially) different cpu's (we punt on
- * byte ordering problems tho)
- */
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned long u32;
-
-/*
- * vars controlled by command line options
- */
-
-int verbose = FALSE; /* be verbose */
-int test_only = FALSE; /* test only */
-
-extern char *optarg; /* getopt(3) control vars */
-extern int optind, opterr;
-
-char *progname; /* for error() */
-
-int process(char *arg);
-void error(int errn, ...);
-long getparm(char *s, long min, long max, char *msg);
-
-#define ERR_ERRNO (1<<((sizeof(int) * 8) - 2)) /* hi bit; use 'errno' */
-#define ERR_FATAL (ERR_ERRNO / 2) /* fatal error ; no return */
-#define ERR_ABORT (ERR_ERRNO / 4) /* fatal error ; abort */
-#define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */
-
-#define stol(p) strtol(p, (char **) NULL, 0)
-int Open(), Read(), Write();
-
-int main(
- int argc,
- char **argv
-)
-{
- register int c;
- int showusage = FALSE; /* usage error? */
- int rc = 0;
-
- /*
- * figure out invocation leaf-name
- */
-
- if ((progname = strrchr(argv[0], '/')) == (char *) NULL)
- progname = argv[0];
- else
- progname++;
-
- argv[0] = progname; /* for getopt err reporting */
-
- /*
- * Check options and arguments.
- */
-
- opterr = 0; /* we'll report all errors */
- while ((c = getopt(argc, argv, GETOPTARGS)) != EOF)
- switch (c)
- {
- case 't': /* toggle test only mode */
- test_only = ! test_only;
- break;
-
- case 'v': /* toggle verbose */
- verbose = ! verbose;
- break;
-
- case '?':
- showusage = TRUE;
- }
-
- if (showusage)
- {
- (void) fprintf(stderr, "%s", USAGE);
- exit(1);
- }
-
- /*
- * traverse and process the arguments
- */
-
- for ( ; argv[optind]; optind++)
- if (Failed(process(argv[optind])))
- rc = FAILURE;
-
- return rc;
-}
-
-
-/*
- * process(arg)
- */
-
-int
-process(char *arg)
-{
- FILE *in;
- FILE *out = (FILE *) 0;
- char outname[ MAX_PATH ];
- char *bptr;
- char buffer[ BUFFER_SIZE ];
- int length;
- int line_number;
- int rc = SUCCESS; /* succeed by default */
-
- in = fopen( arg, "r" );
- if (!in)
- error( ERR_ERRNO | ERR_FATAL, "Unable to open file (%s)\n", arg );
-
- if ( !test_only ) {
- sprintf( outname, "%s.eoltmp", arg );
-
- out = fopen( outname, "w" );
- if (!out)
- error( ERR_ERRNO | ERR_FATAL, "Unable to open file (%s)\n", arg );
- }
-
- if ( verbose )
- fprintf( stderr, "Processing %s\n", arg );
-
- for ( line_number=1 ; ; line_number++ ) {
- bptr = fgets( buffer, BUFFER_SIZE, in );
- if (!bptr)
- break;
-
- /*
- * Don't count the carriage return.
- */
-
- length = strlen( buffer ) - 1;
-
- if ( buffer[ length ] != '\n' )
- error(ERR_ERRNO|ERR_FATAL, "Line %d too long in %s\n", line_number, arg);
-
- while ( isspace( (int) buffer[ length ] ) )
- buffer[ length-- ] = '\0';
-
- if ( test_only ) {
- fprintf( stderr, "%s\n", arg );
- break;
- }
-
- fprintf( out, "%s\n", buffer );
- }
-
- fclose( in );
- if ( !test_only ) {
- fclose( out );
- rename( outname, arg );
- }
- return rc;
-}
-
-/*
- * error(errn, arglist)
- * report an error to stderr using printf(3) conventions.
- * Any output is preceded by '<progname>: '
- *
- * Uses ERR_FATAL bit to request exit(errn)
- * ERR_ABORT to request abort()
- * ERR_ERRNO to indicate use of errno instead of argument.
- *
- * If resulting 'errn' is non-zero, it is assumed to be an 'errno' and its
- * associated error message is appended to the output.
- */
-
-/*VARARGS*/
-
-void
-error(int error_flag, ...)
-{
- va_list arglist;
- register char *format;
- int local_errno;
-
- extern int errno;
-
- (void) fflush(stdout); /* in case stdout/stderr same */
-
- local_errno = error_flag & ~ERR_MASK;
- if (error_flag & ERR_ERRNO) /* use errno? */
- local_errno = errno;
-
- va_start(arglist, error_flag);
- format = va_arg(arglist, char *);
- (void) fprintf(stderr, "%s: ", progname);
- (void) vfprintf(stderr, format, arglist);
- va_end(arglist);
-
- if (local_errno)
- (void) fprintf(stderr, " (%s)\n", strerror(local_errno));
- else
- (void) fprintf(stderr, "\n");
-
- (void) fflush(stderr);
-
- if (error_flag & (ERR_FATAL | ERR_ABORT))
- {
- if (error_flag & ERR_FATAL)
- {
- error(0, "fatal error, exiting");
- exit(local_errno ? local_errno : 1);
- }
- else
- {
- error(0, "fatal error, aborting");
- abort();
- }
- }
-}
-
-long
-getparm(char *s,
- long min,
- long max,
- char *msg)
-{
- long val;
-
- if ( ! strchr("0123456789-", *s))
- {
- error(ERR_FATAL, "'%s' is not a number", s);
- return min;
- }
-
- val = strtol(s, (char **) NULL, 0);
- if ((val < min) || (val > max))
- {
- if (min == max)
- error(ERR_FATAL, "%s can only be %ld", s, min);
- else
- error(ERR_FATAL, "%s must be between %ld and %ld", msg, min, max);
- }
-
- return val;
-}
-
-
-/*
- * Open()
- * Perform open(2), returning the file descriptor. Prints
- * error message if open fails.
- */
-
-int
-Open(char *file,
- int oflag,
- int mode)
-{
- int O_fd;
-
- if (Failed(O_fd = open(file, oflag, mode)))
- error(
- ERR_ERRNO | ERR_FATAL,
- "open('%s', 0x%x, 0%o) failed", file, oflag, mode
- );
-
- return O_fd;
-}
-
-/*
- * Read()
- * Perform read(2); prints error message if fails.
- */
-
-int
-Read(int file,
- char *buffer,
- unsigned int count)
-{
- int nbytes;
-
- if (Failed(nbytes = read(file, buffer, count)))
- error(
- ERR_ERRNO | ERR_FATAL,
- "read(%d, 0x%x, %d) failed", file, buffer, count
- );
-
- return nbytes;
-}
-
-/*
- * Write()
- * Perform write(2); prints error message if fails.
- */
-
-int
-Write(int file,
- char *buffer,
- unsigned int count)
-{
- int nbytes;
-
- if (Failed(nbytes = write(file, buffer, count)))
- error(
- ERR_ERRNO | ERR_FATAL,
- "write(%d, 0x%x, %d) failed", file, buffer, count
- );
-
- return nbytes;
-}
diff --git a/tools/build/src/packhex.c b/tools/build/src/packhex.c
deleted file mode 100644
index 3b85a7c927..0000000000
--- a/tools/build/src/packhex.c
+++ /dev/null
@@ -1,565 +0,0 @@
-
-/***** P A C K H E X . C ************************************************
- *
- * Packhex is a hex-file compaction utility. It attempts to concatenate
- * hex records to produce more size-efficient packaging.
- *
- * Limitations: Input files must be correctly formatted. This utility
- * is not robust enough to detect hex-record formatting
- * errors.
- *
- * Published: May 1993 Embedded Systems Programming magazine
- * "Creating Faster Hex Files"
- *
- * URL: ESP magazine: http://www.embedded.com
- * Source Code: ftp://ftp.mfi.com/pub/espmag/1993/pakhex.zip
- *
- * Author: Mark Gringrich
- *
- * Compiler: Microsoft C 6.0
- * cl /F 1000 packhex.c
- *
- *
- * $Id$
- *
- **************************************************************************/
-
-
-/* #define SMALLER_RECORDS */
-#ifdef SMALLER_RECORDS
-#define MAX_LEN_S1_RECS 128
-#define MAX_LEN_S2_RECS 128
-#define MAX_LEN_S3_RECS 128
-#else
-#define MAX_LEN_S1_RECS 252
-#define MAX_LEN_S2_RECS 251
-#define MAX_LEN_S3_RECS 250
-#endif
-
-
-/*--------------------------------- includes ---------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "config.h"
-
-#ifndef VMS
-#ifndef HAVE_STRERROR
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-#define strerror( _err ) \
- ((_err) < sys_nerr) ? sys_errlist [(_err)] : "unknown error"
-
-#else /* HAVE_STRERROR */
-char *strerror ();
-#endif
-#else /* VMS */
-char *strerror (int,...);
-#endif
-
-#if defined(__unix__) && !defined(EXIT_FAILURE)
-#define EXIT_FAILURE -1
-#define EXIT_SUCCESS 0
-#endif
-
-/*--------------------------------- defines ----------------------------------*/
-
-#define YES 1
-#define MAX_LINE_SIZE 600
-#define EOS '\0'
-
-
-/*---------------------------------- macros ----------------------------------*/
-
-/* Convert ASCII hexadecimal digit to value. */
-
-#define HEX_DIGIT( C ) ( ( ( ( C ) > '9' ) ? ( C ) + 25 : ( C ) ) & 0xF )
-
-
-/*--------------------------------- typedefs ---------------------------------*/
-
-typedef unsigned char Boolean;
-typedef unsigned char Uchar;
-typedef unsigned int Uint;
-typedef unsigned long Ulong;
-
-typedef struct /* Functions and constant returning Hex-record vital stats. */
-{
- Boolean ( *is_data_record )( char * );
- Ulong ( *get_address )( char * );
- Uint ( *get_data_count )( char * );
- const Uint max_data_count;
- char *( *get_data_start )( char * );
- void ( *put_data_record )( Uint, Ulong, char * );
-} Rec_vitals;
-
-
-/*--------------------------- function prototypes ----------------------------*/
-
-Rec_vitals * identify_first_data_record( char *, int );
-Ulong get_ndigit_hex( char *, int );
-
-
-/*----------------------------- Intel Hex format -----------------------------*/
-
-/*
- * Intel Hex data-record layout
- *
- * :aabbbbccd...dee
- *
- * : - header character
- * aa - record data byte count, a 2-digit hex value
- * bbbb - record address, a 4-digit hex value
- * cc - record type, a 2-digit hex value:
- * "00" is a data record
- * "01" is an end-of-data record
- * "02" is an extended-address record
- * "03" is a start record
- * d...d - data (always an even number of chars)
- * ee - record checksum, a 2-digit hex value
- * checksum = 2's complement
- * [ (sum of bytes: aabbbbccd...d) modulo 256 ]
- */
-
-
-Boolean is_intel_data_rec( char * rec_str )
-{
- return( ( rec_str[ 0 ] == ':' ) && ( rec_str[ 8 ] == '0' ) );
-}
-
-Uint get_intel_rec_data_count( char * rec_str )
-{
- return( ( Uint ) get_ndigit_hex( rec_str + 1, 2 ) );
-}
-
-Ulong get_intel_rec_address( char * rec_str )
-{
- return( get_ndigit_hex( rec_str + 3, 4 ) );
-}
-
-char * get_intel_rec_data_start( char * rec_str )
-{
- return( rec_str + 9 );
-}
-
-void put_intel_data_rec( Uint count, Ulong address, char * data_str )
-{
- char *ptr;
- Uint sum = count + ( address >> 8 & 0xff ) + ( address & 0xff );
-
- for ( ptr = data_str ; *ptr != EOS ; ptr += 2 )
- sum += ( Uint ) get_ndigit_hex( ptr, 2 );
-
- printf(
- ":%02X%04lX00%s%02X\n", count, address, data_str, (~sum + 1) & 0xff
- );
-}
-
-
-Rec_vitals intel_hex =
-{
- is_intel_data_rec,
- get_intel_rec_address,
- get_intel_rec_data_count,
- 255, /* Maximum data bytes in a record. */
- get_intel_rec_data_start,
- put_intel_data_rec
-};
-
-
-/*------------------------- Motorola S1-record format ------------------------*/
-
-/*
- * Motorola S-record data-record layout
- *
- * Sabbc...cd...dee
- *
- * S - header character
- * a - record type, a 1-digit value:
- * "0" is a header record
- * "1" is a 2-byte-address data record
- * "2" is a 3-byte-address data record
- * "3" is a 4-byte-address data record
- * "7" is a 4-byte-address end-of-data record
- * "8" is a 3-byte-address end-of-data record
- * "9" is a 2-byte-address end-of-data record
- * bb - record length in bytes, a 2-digit hex value
- * (record length doesn't count the header/type
- * chars and checksum byte)
- * c...c - record address, a 4-, 6-, or 8-digit value,
- * depending on record type
- * d...d - data (always an even number of chars)
- * ee - record checksum, a 2-digit hex value
- * checksum = 1's complement
- * [ (sum of all bytes: bbc..cd...d) modulo 256 ]
- */
-
-#define S1_COUNT_OFFSET 3
-
-
-Boolean is_moto_s1_data_rec( char * rec_str )
-{
- return ( ( rec_str[ 0 ] == 'S' ) && ( rec_str[ 1 ] == '1' ) );
-}
-
-Uint get_moto_s1_rec_data_count( char * rec_str )
-{
- return( ( Uint ) get_ndigit_hex( rec_str + 2, 2 ) - S1_COUNT_OFFSET );
-}
-
-Ulong get_moto_s1_rec_address( char * rec_str )
-{
- return( get_ndigit_hex( rec_str + 4, 4 ) );
-}
-
-char * get_moto_s1_rec_data_start( char * rec_str )
-{
- return( rec_str + 8 );
-}
-
-void put_moto_s1_data_rec( Uint count, Ulong address, char * data_str )
-{
- char *ptr;
- Uint sum = S1_COUNT_OFFSET + count +
- ( address >> 8 & 0xff ) + ( address & 0xff );
-
- for ( ptr = data_str ; *ptr != EOS ; ptr += 2 )
- sum += ( Uint ) get_ndigit_hex( ptr, 2 );
-
- printf(
- "S1%02X%04lX%s%02X\n",
- count + S1_COUNT_OFFSET, address, data_str, ~sum & 0xff
- );
-}
-
-
-Rec_vitals motorola_s1_rec =
-{
- is_moto_s1_data_rec,
- get_moto_s1_rec_address,
- get_moto_s1_rec_data_count,
- MAX_LEN_S1_RECS, /* Maximum data bytes in a record. */
- get_moto_s1_rec_data_start,
- put_moto_s1_data_rec
-};
-
-
-/*------------------------- Motorola S2-record format ------------------------*/
-
-#define S2_COUNT_OFFSET 4
-
-Boolean is_moto_s2_data_rec( char * rec_str )
-{
- return ( ( rec_str[ 0 ] == 'S' ) && ( rec_str[ 1 ] == '2' ) );
-}
-
-Uint get_moto_s2_rec_data_count( char * rec_str )
-{
- return( ( Uint ) get_ndigit_hex( rec_str + 2, 2 ) - S2_COUNT_OFFSET );
-}
-
-Ulong get_moto_s2_rec_address( char * rec_str )
-{
- return( get_ndigit_hex( rec_str + 4, 6 ) );
-}
-
-char * get_moto_s2_rec_data_start( char * rec_str )
-{
- return( rec_str + 10 );
-}
-
-void put_moto_s2_data_rec( Uint count, Ulong address, char * data_str )
-{
- char *ptr;
- Uint sum = S2_COUNT_OFFSET + count + ( address >> 16 & 0xff ) +
- ( address >> 8 & 0xff ) +
- ( address & 0xff );
-
- for ( ptr = data_str ; *ptr != EOS ; ptr += 2 )
- sum += ( Uint ) get_ndigit_hex( ptr, 2 );
-
- printf(
- "S2%02X%06lX%s%02X\n",
- count + S2_COUNT_OFFSET, address, data_str, ~sum & 0xff
- );
-}
-
-
-Rec_vitals motorola_s2_rec =
-{
- is_moto_s2_data_rec,
- get_moto_s2_rec_address,
- get_moto_s2_rec_data_count,
- MAX_LEN_S2_RECS, /* Maximum data bytes in a record. */
- get_moto_s2_rec_data_start,
- put_moto_s2_data_rec
-};
-
-
-/*------------------------- Motorola S3-record format ------------------------*/
-
-#define S3_COUNT_OFFSET 5
-
-Boolean is_moto_s3_data_rec( char * rec_str )
-{
- return ( ( rec_str[ 0 ] == 'S' ) && ( rec_str[ 1 ] == '3' ) );
-}
-
-Uint get_moto_s3_rec_data_count( char * rec_str )
-{
- return( ( Uint ) get_ndigit_hex( rec_str + 2, 2 ) - S3_COUNT_OFFSET );
-}
-
-Ulong get_moto_s3_rec_address( char * rec_str )
-{
- return( get_ndigit_hex( rec_str + 4, 8 ) );
-}
-
-char * get_moto_s3_rec_data_start( char * rec_str )
-{
- return( rec_str + 12 );
-}
-
-void put_moto_s3_data_rec( Uint count, Ulong address, char * data_str )
-{
- char *ptr;
- Uint sum = S3_COUNT_OFFSET + count + ( address >> 24 & 0xff ) +
- ( address >> 16 & 0xff ) +
- ( address >> 8 & 0xff ) +
- ( address & 0xff );
-
- for ( ptr = data_str ; *ptr != EOS ; ptr += 2 )
- sum += ( Uint ) get_ndigit_hex( ptr, 2 );
-
- printf(
- "S3%02X%08lX%s%02X\n",
- count + S3_COUNT_OFFSET, address, data_str, ~sum & 0xff
- );
-}
-
-
-Rec_vitals motorola_s3_rec =
-{
- is_moto_s3_data_rec,
- get_moto_s3_rec_address,
- get_moto_s3_rec_data_count,
- MAX_LEN_S3_RECS, /* Maximum data bytes in a record. */
- get_moto_s3_rec_data_start,
- put_moto_s3_data_rec
-};
-
-
-/*-------------------- Put your favorite hex format here ---------------------*/
-
-/*
- * * * * The following is a template for an additional hex format: * * *
- *
- *
- * Boolean is_X_data_rec( char * rec_str ) {}
- *
- * Uint get_X_rec_data_count( char * rec_str ) {}
- *
- * Ulong get_X_rec_address( char * rec_str ) {}
- *
- * char * get_X_rec_data_start( char * rec_str ) {}
- *
- * void put_X_data_rec( Uint count, Ulong address, char * data_str ) {}
- *
- * Rec_vitals X_rec =
- * {
- * is_X_data_rec,
- * get_X_rec_address,
- * get_X_rec_data_count,
- * MAXIMUM DATA BYTES IN A RECORD,
- * get_X_rec_data_start,
- * put_X_data_rec
- * };
- *
- */
-
-/*----------------------------------------------------------------------------*/
-
-
-/*
- * Put address of additional Rec_vitals structures
- * in this array, before the NULL entry.
- */
-
-Rec_vitals *formats[] =
-{
- &intel_hex,
- &motorola_s1_rec,
- &motorola_s2_rec,
- &motorola_s3_rec,
- ( Rec_vitals * ) NULL
-};
-
-
-/**** main *****************************************************************
-*
-*
-* Expects: Nothing (no command-line parameters).
-*
-* Returns: Exit status (EXIT_SUCCESS or EXIT_FAILURE).
-*
-* Reads hex records on the standard input and attempts to
-* splice adjacent data fields together. Results appear on
-* the standard output.
-*
-*******************************************************************************/
-
-int main(
- int argc,
- char **argv
-)
-{
-
- char inbuff[ MAX_LINE_SIZE ], outbuff[ MAX_LINE_SIZE ];
- char *in_dptr, *out_dptr;
- int d_total, d_count, d_excess, n;
- int length;
- Ulong in_rec_addr, out_rec_addr = 0;
- Rec_vitals *rptr;
-
-
- /* Sift through file until first hex record is identified. */
-
- rptr = identify_first_data_record( inbuff, MAX_LINE_SIZE );
- if ( rptr == NULL )
- {
- fputs( "No hex records found.\n", stderr );
- exit( EXIT_FAILURE );
- }
-
-
- /* Attempt data-record splicing until end-of-file is reached. */
- d_total = 0;
- for (;;) {
- if ( rptr->is_data_record( inbuff ) == YES )
- { /* Input record is a data record. */
- d_count = rptr->get_data_count( inbuff );
- in_rec_addr = rptr->get_address( inbuff );
- in_dptr = rptr->get_data_start( inbuff );
-
- if ( d_total == 0 || in_rec_addr != out_rec_addr + d_total )
- { /* Begin a new output record. */
- if ( d_total != 0 )
- rptr->put_data_record( d_total, out_rec_addr, outbuff );
- out_dptr = outbuff;
- n = d_total = d_count;
- out_rec_addr = in_rec_addr;
- }
- else if
- ( ( d_excess = d_total + d_count - rptr->max_data_count ) > 0 )
- { /* Output a maximum-length record, then start a new record. */
- strncat( outbuff, in_dptr, 2 * ( d_count - d_excess ) );
- rptr->put_data_record(
- rptr->max_data_count, out_rec_addr, outbuff
- );
- in_dptr += 2 * ( d_count - d_excess );
- out_dptr = outbuff;
- n = d_total = d_excess;
- out_rec_addr += rptr->max_data_count;
- }
- else
- { /* Append input record's data field with accumulated data. */
- out_dptr = outbuff + ( 2 * d_total );
- d_total += n = d_count;
- }
- strncpy( out_dptr, in_dptr, 2 * n );
- out_dptr[ 2 * n ] = EOS;
- }
- else
- { /* Not a data record;
- * flush accumulated data then echo non-data record.
- */
- if ( d_total != 0 )
- {
- rptr->put_data_record( d_total, out_rec_addr, outbuff );
- d_total = 0;
- }
- puts( inbuff );
- }
-
- inbuff[ MAX_LINE_SIZE - 1 ] = '\0';
- if ( !fgets( inbuff, MAX_LINE_SIZE, stdin ) )
- break;
- if ( inbuff[ MAX_LINE_SIZE - 1 ] ) {
- fprintf( stderr, "Input line too long" );
- exit( 1 );
- }
- length = strlen(inbuff);
- inbuff[length - 1] = '\0';
-
- }
-
-
- return ( EXIT_SUCCESS );
-
-}
-
-
-/**** identify_first_data_record *******************************************
-*
-* Expects: Pointer to hex-record line buffer.
-*
-* Returns: Pointer to hex-record structure (NULL if no match found).
-*
-* Reads the standard input, line by line, searching for a valid
-* record header character. If a valid header is found, a pointer
-* to the hex-record's type structure is returned, otherwise NULL.
-*
-* The input-stream pointer is left pointing to the first valid hex record.
-*
-*******************************************************************************/
-
-Rec_vitals * identify_first_data_record( char * buff_ptr, int max_length )
-{
- Rec_vitals ** ptr;
- int length;
-
-
-
- for ( ;; ) {
-
- buff_ptr[ max_length - 1 ] = '\0';
- if ( !fgets( buff_ptr, max_length, stdin ) )
- break;
- if ( buff_ptr[ max_length - 1 ] ) {
- fprintf( stderr, "Input line too long" );
- exit( 1 );
- }
- length = strlen(buff_ptr);
- buff_ptr[length - 1] = '\0';
-
- for ( ptr = formats ; *ptr != ( Rec_vitals * ) NULL ; ptr++ )
- if ( ( *ptr )->is_data_record( buff_ptr ) == YES )
- return( *ptr ); /* Successful return. */
-
- puts( buff_ptr ); /* Echo non-hex-record line. */
- }
-
- return( ( Rec_vitals * ) NULL ); /* Unsuccessful return. */
-}
-
-
-/**** get_ndigit_hex *******************************************************
-*
-* Expects: Pointer to first ASCII hexadecimal digit, number of digits.
-*
-* Returns: Value of hexadecimal string as an unsigned long.
-*
-*******************************************************************************/
-
-Ulong get_ndigit_hex( char * cptr, int digits )
-{
- Ulong value;
-
- for ( value = 0 ; --digits >= 0 ; cptr++ )
- value = ( value * 16L ) + HEX_DIGIT( *cptr );
-
- return( value );
-}
diff --git a/tools/build/src/stamp-h.in b/tools/build/src/stamp-h.in
deleted file mode 100644
index 9788f70238..0000000000
--- a/tools/build/src/stamp-h.in
+++ /dev/null
@@ -1 +0,0 @@
-timestamp
diff --git a/tools/build/src/unhex.c b/tools/build/src/unhex.c
deleted file mode 100644
index 6a75a13ae7..0000000000
--- a/tools/build/src/unhex.c
+++ /dev/null
@@ -1,738 +0,0 @@
-/*
- * unhex
- * convert a hex file to binary equivalent. If more than one file name
- * is given, then the output will be logically concatenated together.
- * stdin and stdout are defaults. Verbose will enable checksum output.
- *
- * Supported input formats are Intel hex, Motorola S records, and TI 'B'
- * records.
- *
- * Intel hex input format is
- * Byte
- * 1 Colon :
- * 2..3 Record length, eg: "20"
- * 4..7 load address nibbles
- * 8..9 record type: "00" (data) or "02" base addr
- * 10..x data bytes in ascii-hex
- * x+1..x+2 cksum (2's compl of (len+addr+data))
- * x+3 \n -- newline
- *
- * $Id$
- */
-
-char *USAGE = "\
-usage: unhex [-va] [ -o file ] [ file [file ... ] ]\n\
- -v -- verbose\n\
- -a base -- 1st byte of output corresponds to this address\n\
- -l -- linear, just writes data out\n\
- -o file -- output file; must not be input file\n\
- -F k_bits -- \"holes\" in input will be filled with 0xFF's\n\
- up to \"k_bits\" * 1024 bits\n\
-";
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <errno.h>
-
-#include "config.h"
-
-#ifndef VMS
-#ifndef HAVE_STRERROR
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-#define strerror( _err ) \
- ((_err) < sys_nerr) ? sys_errlist [(_err)] : "unknown error"
-
-#else /* HAVE_STRERROR */
-char *strerror ();
-#endif
-#else /* VMS */
-char *strerror (int,...);
-#endif
-
-
-#define OK 0
-#define FAILURE (-1)
-#define Failed(x) ((x) == FAILURE)
-#define TRUE 1
-#define FALSE 0
-typedef char bool;
-#define STREQ(a,b) (strcmp(a,b) == 0)
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned long u32;
-
-/*
- * Pick out designated bytes
- */
-
-#define B0(x) ((x) & 0xff)
-#define B1(x) B0((x) >> 8)
-#define B2(x) B0((x) >> 16)
-#define B3(x) B0((x) >> 24)
-
-typedef struct buffer_rec {
- u32 dl_destaddr;
- u32 dl_jumpaddr;
- int dl_count;
- u8 dl_buf[512];
-} buffer_rec;
-
-/*
- * vars controlled by command line options
- */
-
-bool verbose = FALSE; /* be verbose */
-bool linear = FALSE; /* just write out linear data */
-char *outfilename = "-"; /* default output is stdout */
-u32 base = 0L; /* base address */
-u32 FFfill = 0L; /* how far to fill w 0xFF's */
-
-extern char *optarg; /* getopt(3) control vars */
-extern int optind;
-
-char *progname; /* for error() */
-
-void error(int errn, ...);
-#define ERR_ERRNO (1<<((sizeof(int) * 8) - 2)) /* hi bit; use 'errno' */
-#define ERR_FATAL (ERR_ERRNO / 2) /* error is fatal; no return */
-#define ERR_ABORT (ERR_ERRNO / 4) /* error is fatal; abort */
-#define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */
-
-#ifdef HAVE_STRTOUL
-#define stol(p) strtoul(p, (char **) NULL, 0)
-#else
-#define stol(p) strtol(p, (char **) NULL, 0)
-#endif
-
-int unhex(FILE *ifp, char *inm, FILE *ofp, char *onm);
-int convert_Intel_records(FILE *ifp, char *inm, FILE *ofp, char *onm);
-int convert_S_records(FILE *ifp, char *inm, FILE *ofp, char *onm);
-int convert_TI_records(FILE *ifp, char *inm, FILE *ofp, char *onm);
-void write_record(buffer_rec *tb, FILE *fp);
-int getnibble(char **p);
-int getbyte(char **p);
-long getNbytes(char **p, int n);
-void badformat(char *s, char *fname, char *msg);
-
-#define get1bytes(p) ((int) getbyte(p))
-#define get2bytes(p) ((int) getNbytes(p, 2))
-#define get3bytes(p) getNbytes(p, 3)
-#define get4bytes(p) getNbytes(p, 4)
-
-char *BADADDR = "Invalid record address";
-char *BADLEN = "Invalid record length";
-char *BADBASE = "Bad base or starting address";
-char *BADFMT = "Unrecognized record type";
-char *BADDATA = "Invalid data byte";
-char *BADCSUM = "Invalid checksum";
-char *MISCSUM = "Checksum mismatch";
-char *BADTYPE = "Unrecognized record type";
-char *MISTYPE = "Incompatible record types";
-
-int main(
- int argc,
- char **argv
-)
-{
- register int c;
- bool showusage = FALSE; /* usage error? */
- int rc = 0;
- FILE *outfp, *infp;
-
- /*
- * figure out invocation leaf-name
- */
-
- if ((progname = strrchr(argv[0], '/')) == (char *) NULL)
- progname = argv[0];
- else
- progname++;
-
- argv[0] = progname; /* for getopt err reporting */
-
- /*
- * Check options and arguments.
- */
-
- progname = argv[0];
- while ((c = getopt(argc, argv, "F:a:o:vl")) != EOF)
- switch (c)
- {
- case 'a': /* base address */
- base = stol(optarg);
- break;
-
- case 'l': /* linear output */
- linear = TRUE;
- break;
-
- case 'v': /* toggle verbose */
- verbose = ! verbose;
- break;
-
- case 'o': /* output file */
- outfilename = optarg;
- break;
-
- case 'F': /* 0xFF fill amount (bytes) */
- FFfill = stol(optarg) * 1024L / 8L;
- break;
-
- case '?':
- showusage = TRUE;
- }
-
- if (showusage)
- {
- (void) fprintf(stderr, "%s", USAGE);
- exit(1);
- }
-
- if (linear && (base != 0))
- {
- error(0, "-l and -a may not be specified in combination");
- exit(1);
- }
-
- if (STREQ(outfilename, "-"))
- {
- outfp = stdout;
- outfilename = "stdout";
- }
- else
- if ((outfp = fopen(outfilename, "w")) == (FILE *) NULL)
- {
- error(-1, "couldn't open '%s' for output", outfilename);
- exit(1);
- }
-
- /*
- * Now process the input files (or stdin, if none specified)
- */
-
- if (argv[optind] == (char *) NULL) /* just stdin */
- exit(unhex(stdin, "stdin", outfp, outfilename));
- else
- for (; (optarg = argv[optind]); optind++)
- {
- if (STREQ(optarg, "-"))
- rc += unhex(stdin, "stdin", outfp, outfilename);
- else
- {
- if ((infp = fopen(optarg, "r")) == (FILE *) NULL)
- {
- error(-1, "couldn't open '%s' for input", optarg);
- exit(1);
- }
- rc += unhex(infp, optarg, outfp, outfilename);
- }
- }
-
- return(rc);
-}
-
-u16 filesum;
-
-int
-unhex(FILE *ifp,
- char *inm,
- FILE *ofp,
- char *onm)
-{
- int c;
-
- filesum = 0;
-
- /*
- * Make sure holes will be filled with 0xFF's if requested. We
- * do this the easy way by just filling the file with FF's before
- * getting started. To do it more optimally would be quite a bit
- * more difficult since the user can skip around as much as he/she
- * likes in the input hex file addressing.
- *
- * We'll clean this up later (after this program has run) with
- * 'stripffs'
- */
-
- if (FFfill)
- {
- (void) fseek(ofp, 0, 0);
- for (c = FFfill; c > 0; c--)
- (void) fputc(0xFF, ofp);
- }
-
- /*
- * Read the first char from file and determine record types
- */
-
- if ((c = getc(ifp)) != EOF)
- {
- ungetc(c, ifp);
- switch(c)
- {
- case 'S':
- convert_S_records(ifp, inm, ofp, onm);
- break;
-
- case ':':
- convert_Intel_records(ifp, inm, ofp, onm);
- break;
-
- case '9':
- case 'B':
- convert_TI_records(ifp, inm, ofp, onm);
- break;
-
- default:
- {
- char tmp[2];
- tmp[0] = c; tmp[1] = 0;
- badformat(tmp, inm, BADFMT);
- }
- }
- }
-
- if (verbose)
- fprintf(stderr, "'%s' checksum is 0x%04x\n", inm, filesum);
-
- return 0;
-}
-
-int
-convert_Intel_records(
- FILE *ifp,
- char *inm,
- FILE *ofp,
- char *onm)
-{
- char buff[512];
- char *p;
- u8 cksum;
- int incksum;
- int c;
- int rectype; /* record type */
- int len; /* data length of current line */
- u32 addr;
- u32 base_address = 0;
- bool endrecord = FALSE;
- buffer_rec tb;
-
- while ( ! endrecord && (fgets(buff, sizeof(buff), ifp)))
- {
- p = &buff[0];
-
- if (p[strlen(p)-1] == '\n') /* get rid of newline */
- p[strlen(p)-1] = '\0';
-
- if (p[strlen(p)-1] == '\r') /* get rid of any CR */
- p[strlen(p)-1] = '\0';
-
- tb.dl_count = 0;
-
- if (*p != ':')
- badformat(p, inm, BADFMT);
- p++;
-
- if ((len = getbyte(&p)) == -1) /* record len */
- badformat(buff, inm, BADLEN);
-
- if ((addr = get2bytes(&p)) == -1L) /* record addr */
- badformat(buff, inm, BADADDR);
-
- rectype = getbyte(&p);
-
- cksum = len + B0(addr) + B1(addr) + rectype;
-
- switch (rectype)
- {
- case 0x00: /* normal data record */
- tb.dl_destaddr = base_address + addr;
- while (len--)
- {
- if ((c = getbyte(&p)) == -1)
- badformat(buff, inm, BADDATA);
- cksum += c;
- filesum += c;
- tb.dl_buf[tb.dl_count++] = c;
- }
- break;
-
- case 0x01: /* execution start address */
- base_address = addr;
- endrecord = TRUE;
- break;
-
- case 0x02: /* new base */
- if ((base_address = get2bytes(&p)) == -1L)
- badformat(buff, inm, BADBASE);
- cksum += B0(base_address) + B1(base_address);
- base_address <<= 4;
- break;
-
- case 0x03: /* seg/off execution start address */
- {
- u32 seg, off;
-
- seg = get2bytes(&p);
- off = get2bytes(&p);
- if ((seg == -1L) || (off == -1L))
- badformat(buff, inm, BADADDR);
-
- cksum += B0(seg) + B1(seg) + B0(off) + B1(off);
-
- tb.dl_jumpaddr = (seg << 4) + off;
- break;
- }
-
- default:
- error(0, "unknown Intel-hex record type: 0x%02x", rectype);
- badformat(buff, inm, BADTYPE);
- }
-
- /*
- * Verify checksums are correct in file.
- */
-
- cksum = (-cksum) & 0xff;
- if ((incksum = getbyte(&p)) == -1)
- badformat(buff, inm, BADCSUM);
- if (((u8) incksum) != cksum)
- badformat(buff, inm, MISCSUM);
-
- if (tb.dl_count)
- write_record(&tb, ofp);
- }
- return 0;
-}
-
-int
-convert_S_records(
- FILE *ifp,
- char *inm,
- FILE *ofp,
- char *onm)
-{
- char buff[512];
- char *p;
- u8 cksum;
- int incksum;
- int c;
- int len; /* data length of current line */
- int rectype; /* record type */
- u32 addr;
- bool endrecord = FALSE;
- buffer_rec tb;
-
- while ( ! endrecord && (fgets(buff, sizeof(buff), ifp)))
- {
- p = &buff[0];
-
- if (p[strlen(p)-1] == '\n') /* get rid of newline */
- p[strlen(p)-1] = '\0';
-
- if (p[strlen(p)-1] == '\r') /* get rid of any CR */
- p[strlen(p)-1] = '\0';
-
- tb.dl_count = 0;
-
- if (*p != 'S')
- badformat(p, inm, BADFMT);
- p++;
-
- if ((rectype = getnibble(&p)) == -1) /* record type */
- badformat(buff, inm, BADTYPE);
-
- if ((len = getbyte(&p)) == -1) /* record len */
- badformat(buff, inm, BADLEN);
- cksum = len;
-
- switch (rectype)
- {
- case 0x00: /* comment field, ignored */
- goto write_it;
-
- case 0x01: /* data record, 16 bit addr */
- if ((addr = get2bytes(&p)) == -1L)
- badformat(buff, inm, BADADDR);
- len -= 3;
- goto doit;
-
- case 0x02: /* ... 24 bit addr */
- if ((addr = get3bytes(&p)) == -1L)
- badformat(buff, inm, BADADDR);
- len -= 4;
- goto doit;
-
- case 0x03: /* ... 32 bit addr */
- if ((addr = get4bytes(&p)) == -1L)
- badformat(buff, inm, BADADDR);
- len -= 5;
- doit:
- cksum += B0(addr) + B1(addr) + B2(addr) + B3(addr);
-
- tb.dl_destaddr = addr;
- while (len--)
- {
- if ((c = getbyte(&p)) == -1)
- badformat(buff, inm, BADDATA);
- cksum += c;
- filesum += c;
- tb.dl_buf[tb.dl_count++] = c;
- }
- break;
-
- case 0x07: /* 32 bit end record */
- if ((addr = get4bytes(&p)) == -1L)
- badformat(buff, inm, BADADDR);
- goto end_rec;
-
- case 0x08: /* 24 bit end record */
- if ((addr = get3bytes(&p)) == -1L)
- badformat(buff, inm, BADADDR);
- goto end_rec;
-
- case 0x09: /* 16 bit end record */
- if ((addr = get2bytes(&p)) == -1L)
- badformat(buff, inm, BADADDR);
-
-end_rec:
- cksum += B0(addr) + B1(addr) + B2(addr) + B3(addr);
- tb.dl_jumpaddr = addr;
- break;
-
- default:
- error(0, "unknown Motorola-S record type: 0x%02x", rectype);
- badformat(buff, inm, BADTYPE);
- break;
- }
-
- /*
- * Verify checksums are correct in file.
- */
-
- cksum = (~cksum) & 0xff;
- if ((incksum = getbyte(&p)) == -1)
- badformat(buff, inm, BADCSUM);
- if (((u8) incksum) != cksum)
- badformat(buff, inm, MISCSUM);
-
-write_it:
- if (tb.dl_count)
- write_record(&tb, ofp);
- }
- return 0;
-}
-
-int
-convert_TI_records(
- FILE *ifp,
- char *inm,
- FILE *ofp,
- char *onm)
-{
- char buff[512];
- char *p;
- int c;
- bool endrecord = FALSE;
- bool eol;
- buffer_rec tb;
-
- while ( ! endrecord && (fgets(buff, sizeof(buff), ifp)))
- {
- if (p[strlen(p)-1] == '\n') /* get rid of newline */
- p[strlen(p)-1] = '\0';
-
- if (p[strlen(p)-1] == '\r') /* get rid of any CR */
- p[strlen(p)-1] = '\0';
-
- tb.dl_count = 0;
-
- p = &buff[0];
- eol = FALSE;
- while ( ! eol && ! endrecord)
- {
- switch (*p++)
- {
- case '9':
- if (tb.dl_count)
- write_record(&tb, ofp);
- tb.dl_destaddr = get2bytes(&p);
- break;
-
- case 'B':
- c = getbyte(&p);
- filesum += c;
- tb.dl_buf[tb.dl_count++] = c;
- c = getbyte(&p);
- filesum += c;
- tb.dl_buf[tb.dl_count++] = c;
- break;
-
- case 'F':
- eol = TRUE;
- break;
-
- case ':':
- endrecord = TRUE;
- break;
-
- default:
- badformat(p, inm, BADFMT);
- }
- }
- if (tb.dl_count)
- write_record(&tb, ofp);
- }
- return 0;
-}
-
-void
-write_record(buffer_rec *tb,
- FILE *fp)
-{
- if ( ! linear)
- {
- if (tb->dl_destaddr < base)
- error(ERR_FATAL, "record at address 0x%x precedes base of 0x%x",
- tb->dl_destaddr, base);
- (void) fseek(fp, tb->dl_destaddr - base, 0);
- }
-
- (void) fwrite(tb->dl_buf, tb->dl_count, 1, fp);
- tb->dl_destaddr += tb->dl_count;
- tb->dl_count = 0;
-}
-
-int
-getnibble(char **p)
-{
- register int val;
-
- **p = toupper(**p);
- switch (**p)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- val = **p - '0';
- break;
-
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- val = 10 + (**p - 'A');
- break;
-
- default:
- return(-1);
- }
- *p += 1;
-
- return(val & 0x0f);
-}
-
-int
-getbyte(char **p)
-{
- int n0, n1;
-
- if ((n0 = getnibble(p)) == -1)
- return(-1);
- if ((n1 = getnibble(p)) == -1)
- return(-1);
-
- return(((n0 << 4) + n1) & 0xff);
-}
-
-long
-getNbytes(char **p,
- int n)
-{
- int t;
- u32 val = 0;
-
- while (n--)
- {
- if ((t = getbyte(p)) == -1)
- return(-1L);
- val <<= 8;
- val += t;
- }
-
- return(val);
-}
-
-void
-badformat(char *s,
- char *fname,
- char *msg)
-{
- if (s[strlen(s)-1] == '\n') /* get rid of newline */
- s[strlen(s)-1] = '\0';
- error(0, "line '%s'::\n\tfrom file '%s'; %s", s, fname, msg);
- exit(1);
-}
-
-/*
- * error(errn, arglist)
- * report an error to stderr using printf(3) conventions.
- * Any output is preceded by '<progname>: '
- *
- * Uses ERR_EXIT bit to request exit(errn)
- * ERR_ABORT to request abort()
- * ERR_ERRNO to indicate use of errno instead of argument.
- *
- * If resulting 'errn' is non-zero, it is assumed to be an 'errno' and its
- * associated error message is appended to the output.
- */
-
-/*VARARGS*/
-
-void
-error(int error_flag, ...)
-{
- va_list arglist;
- register char *format;
- int local_errno;
-
- extern int errno;
-
- (void) fflush(stdout); /* in case stdout/stderr same */
-
- local_errno = error_flag & ~ERR_MASK;
- if (error_flag & ERR_ERRNO) /* use errno? */
- local_errno = errno;
-
- va_start(arglist, error_flag);
- format = va_arg(arglist, char *);
- (void) fprintf(stderr, "%s: ", progname);
- (void) vfprintf(stderr, format, arglist);
- va_end(arglist);
-
- if (local_errno)
- (void) fprintf(stderr, " (%s)\n", strerror(local_errno));
- else
- (void) fprintf(stderr, "\n");
-
- (void) fflush(stderr);
-
- if (error_flag & (ERR_FATAL | ERR_ABORT))
- {
- if (error_flag & ERR_FATAL)
- {
- error(0, "fatal error, exiting");
- exit(local_errno ? local_errno : 1);
- }
- else
- {
- error(0, "fatal error, aborting");
- abort();
- }
- }
-}
-