Commit b5692bbd authored by Peter Pentchev's avatar Peter Pentchev

Import the stock sources of hexer-0.1.4c.

Obtained from:	ftp://ftp.netsw.org/system/tools/fileutils/edit/
parents
Copyright (c) 1995,1996 Sascha Demetrio
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
If you modify any part of HEXER and resitribute it, you must add
a notice to the `README' file and the modified source files containing
information about the changes you made. I do not want to take
credit or be blamed for your modifications.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
If you modify any part of HEXER and resitribute it in binary form,
you must supply a `README' file containing information about the
changes you made.
3. The name of the developer may not be used to endorse or promote
products derived from this software without specific prior written
permission.
HEXER WAS DEVELOPED BY SASCHA DEMETRIO.
THIS SOFTWARE SHOULD NOT BE CONSIDERED TO BE A COMMERCIAL PRODUCT.
THE DEVELOPER URGES THAT USERS WHO REQUIRE A COMMERCIAL PRODUCT
NOT MAKE USE OF THIS WORK.
DISCLAIMER:
THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
# Makefile for hexer version 0.1.4c
# It might be helpful to read the `README'-file first.
# -- Where? --
# The following lines determine where the binaries and manual pages for
# hexer are gonna live.
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/man/man1
# -- Which terminal library? --
# (It's probably save to leave the following lines unchanged.)
#
# Use the following two lines, if you want to use the termcap-library.
TERMLIB =
TERMCAP = -ltermcap -lm
#
# Uncomment these if you want to use curses.
#TERMLIB =
#TERMCAP = -lcurses
#
# Uncomment the following two lines if you want to use the termlib code
# supplied with the package (not recommended).
#TERMLIB = termlib.o
#TERMCAP =
# If you want to add some system specific defines, it's probably more
# appropriate to put them into `config.h'.
DEFINES = -DHEXER_VERSION=\"0.1.4c\"
# -- Which compiler? --
CC = cc
CFLAGS = -O $(DEFINES)
LDFLAGS =
LDLIBS = $(TERMCAP)
#
# Uncomment the following lines if you want to use the GNU compiler.
#CC = gcc
#CFLAGS = -O6 $(DEFINES)
#LDFALGS =
#LDLIBS = $(TERMCAP)
# -- Which installer? --
INSTALL = install
INSTALLBIN = $(INSTALL) -s
INSTALLMAN = $(INSTALL) -m 644
#
# Uncomment these if you don't have an installer.
#INSTALL = cp
#INSTALLBIN = $(INSTALL)
#INSTALLMAN = $(INSTALL)
### It shouldn't be necessary to change anything below this line.
HEXER = hexer
MYC = myc
CTAGS = ctags -tawf tags
OBJECTS = buffer.o tio.o edit.o main.o hexer.o readline.o regex.o port.o \
exh.o set.o map.o signal.o util.o commands.o helptext.o calc.o \
$(TERMLIB)
all: config.check $(HEXER)
config.check:
@{ if [ ! -f config.h ]; then \
echo '***' Please read the file README on how to configure and; \
echo '***' compile hexer.\ Thank you.; \
exit 1; \
fi; }
$(HEXER): $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS)
$(MYC): calc.c
$(CC) $(LDFLAGS) $(CFLAGS) -DMYCALC=1 -o $@ calc.c -lm
bin2c: bin2c.c
$(CC) -o $@ bin2c.c
helptext.c: help.txt bin2c
./bin2c -n helptext -o $@ help.txt
tags: *.c *.h
-@{ \
echo Creating tags...; \
rm -f tags; \
for i in *.c *.h; do \
echo $(CTAGS) $$i; \
$(CTAGS) $$i; \
done; \
}
dep: depend
depend: *.c *.h
-rm -f Makefile~
sed '/\#\#\# DO NOT DELETE THIS LINE \#\#\#/q' \
< Makefile > Makefile~
-echo >> Makefile~
-echo '#' Dependencies: >> Makefile~
-echo >> Makefile~
@{ for i in *.c; do \
echo $(CC) -MM $(CINCLUDE) $(CFLAGS) $$i '>>' Makefile~; \
$(CC) -MM $(CINCLUDE) $(CFLAGS) $$i >> Makefile~; \
done; }
-echo >> Makefile~
mv -f Makefile~ Makefile
-touch depend
clean:
-rm -f $(HEXER)
-rm -f $(MYC)
-rm -f TESTFILE
-rm -f gen_testfile
-rm -f $(OBJECTS)
-rm -f tags
-rm -f core
-rm -f *.bak
distclean: clean
-rm -f Makefile~
sed '/\#\#\# DO NOT DELETE THIS LINE \#\#\#/q' \
< Makefile > Makefile~
-echo >> Makefile~
mv -f Makefile~ Makefile
-rm -f depend
install: all
@{ echo installing $(HEXER) in $(BINDIR); \
$(INSTALLBIN) $(HEXER) $(BINDIR); \
echo installing $(HEXER).1 in $(MANDIR); \
$(INSTALLMAN) $(HEXER).1 $(MANDIR); \
if [ -f $(MYC) ]; then \
echo installing $(MYC) in $(BINDIR); \
$(INSTALLBIN) $(MYC) $(BINDIR); \
echo installing $(MYC).1 in $(MANDIR); \
$(INSTALLMAN) $(MYC).1 $(MANDIR); \
fi; }
### DO NOT DELETE THIS LINE ###
README for Hexer version 0.1.4c
Hexer is a multi buffer editor for binary files for UN*X that displays its
buffer(s) as hex dump. The user interface is kept similar to vi/ex.
The following systems are supported:
- SunOS 4.x.x
- Linux
- FreeBSD
- Irix
If you port Hexer to a different platform, please send an email-message
telling what changes you made (if any).
Please read the files `COPYRIGHT' and `hexer.doc'.
INSTALL:
- To unpack hexer (you've probably done this already), type
gunzip < hexer-0.1.4c.tar.gz | tar -xvf -
where xxx is the version number. This will create a subdirectory
`hexer-xxx'. Change into that directory.
- There are several configuration files named `config.xxx' where
xxx is the name of the operation system. Check if theres a
config-file for your system and copy it to `config.h'. If there's
no config-file for your system, you can use `config.any' and
modify it appropriately.
- Skim trough `config.h' and `Makefile'.
- Type `make'.
- If you want a command line version of the builtin calculator "myc",
type `make myc'.
- Type `make install' to install the binaries and the manual.
Feel free to send comments, bug reports and suggestions to:
demetrio@cs.uni-sb.de
Sascha Demetrio
/* bin2c.c 4/9/1996
* convert a binary (or text) file to C.
*/
/* Copyright (c) 1995,1996 Sascha Demetrio
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* If you modify any part of HEXER and resitribute it, you must add
* a notice to the `README' file and the modified source files containing
* information about the changes you made. I do not want to take
* credit or be blamed for your modifications.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* If you modify any part of HEXER and resitribute it in binary form,
* you must supply a `README' file containing information about the
* changes you made.
* 3. The name of the developer may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* HEXER WAS DEVELOPED BY SASCHA DEMETRIO.
* THIS SOFTWARE SHOULD NOT BE CONSIDERED TO BE A COMMERCIAL PRODUCT.
* THE DEVELOPER URGES THAT USERS WHO REQUIRE A COMMERCIAL PRODUCT
* NOT MAKE USE OF THIS WORK.
*
* DISCLAIMER:
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
static char *usage = "\
usage: bin2c [-t] [-h] [-o outputfile] [-n name] [inputfile]\n\
-t you can use this option if the inputfile is a small (< 1K) textfile.\n\
-h display this help message.\n\
-o outputfile\n\
write the output to outputfile. the default is <stdout>.\n\
-n name\n\
the name of the C variable generated. the default is `data'\n\
if no inputfile is specified, the input is read from <stdin>.\n\
";
int
main(argc, argv)
int argc;
char **argv;
{
char *name = "data";
FILE *in = stdin, *out = stdout;
int text_f = 0;
char *outfile = 0;
char c;
int i;
extern char *optarg;
extern optind;
while ((c = getopt(argc, argv, "htn:o:")) != -1)
switch (c) {
case 't': /* generate a C string. this option useful only
* for *very* small text files, since some compilers
* refuse to compile extremely long strings. */
++text_f;
break;
case 'n': /* select the name of the output C array. */
name = optarg;
break;
case 'o': /* select the name of the output file. */
outfile = optarg;
break;
default:
fprintf(stderr, "%s: invalid option -- -%c\n", *argv, (char)c);
case 'h':
case '?':
fputs(usage, stderr);
exit(1);
}
if (argc - optind > 1) {
fputs(usage, stderr);
exit(1);
} else if (argc - optind == 1)
if (!(in = fopen(argv[optind], "r"))) {
perror(argv[optind]);
exit(1);
}
if (outfile)
if (!(out = fopen(outfile, "w"))) {
perror(outfile);
exit(1);
}
fprintf(out, "/* %s.c\n * generated by bin2c - do not edit!\n */\n\n", name);
/* Copyright (c) 1995,1996 Sascha Demetrio
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* If you modify any part of HEXER and resitribute it, you must add
* a notice to the `README' file and the modified source files containing
* information about the changes you made. I do not want to take
* credit or be blamed for your modifications.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* If you modify any part of HEXER and resitribute it in binary form,
* you must supply a `README' file containing information about the
* changes you made.
* 3. The name of the developer may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* HEXER WAS DEVELOPED BY SASCHA DEMETRIO.
* THIS SOFTWARE SHOULD NOT BE CONSIDERED TO BE A COMMERCIAL PRODUCT.
* THE DEVELOPER URGES THAT USERS WHO REQUIRE A COMMERCIAL PRODUCT
* NOT MAKE USE OF THIS WORK.
*
* DISCLAIMER:
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
if (text_f) {
fprintf(out, "char %s[] = \"\\\n", name);
for (;;) {
c = getc(in);
if (feof(in)) break;
if (!isprint(c))
switch (c) {
case '\n':
fprintf(out, "\\n\\\n");
break;
case '\b':
fprintf(out, "\\b");
break;
default:
fprintf(out, "\\%o", (int)(unsigned char)c);
}
else
switch (c) {
case '\\':
fprintf(out, "\\\\");
break;
case '\"':
fprintf(out, "\\\"");
break;
default:
putc(c, out);
}
}
fprintf(out, "\";\n\n");
} else {
fprintf(out, "char %s[] = {", name);
for (i = 0;; ++i) {
c = getc(in);
if (feof(in)) break;
if (!(i % 8)) fprintf(out, "\n ");
fprintf(out, " 0x%02x,", (int)(unsigned char)c);
}
if (!(i % 8)) fprintf(out, "\n ");
fprintf(out, " 0\n};\n\n");
/* we write a trailing 0 so the array can be used as a sting. */
}
fprintf(out, "/* end of %s.c */\n\n", name);
return 0;
}
/* main */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Configuration file
*/
#define HAVE_STRCMP 0
#define HAVE_STRCASECMP 0
#define HAVE_SIGTYPE_INT 0
#define HAVE_CONST 0
#define HAVE_NCURSES 0
#define HAVE_USLEEP 0
#define HAVE_FLOAT_H 0
#define HAVE_ALLOCA 0
#define NEED_ALLOCA_H 0
#define USE_STDARG 0
/* Configuration file
*/
#define HAVE_STRCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_SIGTYPE_INT 0
#define HAVE_CONST 0
#define HAVE_NCURSES 0
#define HAVE_USLEEP 1
#define HAVE_FLOAT_H 1
#define HAVE_ALLOCA 0
#define NEED_ALLOCA_H 0
#define USE_STDARG 1
/* Configuration file for Linux
*/
#define HAVE_STRCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_SIGTYPE_INT 0
#define HAVE_CONST 1
#define HAVE_NCURSES 1
#define HAVE_USLEEP 1
#define HAVE_FLOAT_H 1
#define HAVE_ALLOCA 1
#define NEED_ALLOCA_H 0
#define USE_STDARG 0
/* Configuration file for SunOS
*/
#define HAVE_STRCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_SIGTYPE_INT 0
#define HAVE_CONST 0
#define HAVE_NCURSES 0
#define HAVE_USLEEP 1
#define HAVE_FLOAT_H 0
#define HAVE_ALLOCA 1
#define NEED_ALLOCA_H 1
#define USE_STDARG 0
/* defs.h:
*/
/*
* General settings:
*/
#define TMP_DIR "/tmp"
/*
* Buffer: (defaults)
*/
#define BUFFER_BLOCKSIZE 4096
#define BUFFER_OPT 0
#define BUFFER_MAX_BLOCKS 16 /* NIY */
/*
* Fifo: (defaults)
*/
#define FIFO_BLOCKSIZE 1547
/* I/O settings (for tio.c):
*/
#define STDOUT_BUFFER_SIZE 8192
#define TERMINAL_CANT "Terminal can't"
/* hexer:
*/
#define HE_ANYCHAR '.'
#define HE_DEFAULT_PAGER "more"
#define HEXERINIT_FILE ".hexerrc"
#define TIO_READWAIT_TIMEOUT -1
#if !HAVE_CONST
#define const
#endif
/* end of defs.h */
/* VIM configuration: (do not delete this line)
*
* vim:aw:bk:bdir=./bak:ch=2:nodg:ef=make.log:efm=%f\:%l\:%m:et:hid:icon:
* vim:sw=2:sc:sm:si:textwidth=79:to:ul=1024:wh=12:wrap:wb:
*/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* main.c 8/19/1995
* The `main()' function for `hexer'.
*/
/* Copyright (c) 1995,1996 Sascha Demetrio
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* If you modify any part of HEXER and resitribute it, you must add
* a notice to the `README' file and the modified source files containing
* information about the changes you made. I do not want to take
* credit or be blamed for your modifications.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* If you modify any part of HEXER and resitribute it in binary form,
* you must supply a `README' file containing information about the
* changes you made.
* 3. The name of the developer may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* HEXER WAS DEVELOPED BY SASCHA DEMETRIO.
* THIS SOFTWARE SHOULD NOT BE CONSIDERED TO BE A COMMERCIAL PRODUCT.
* THE DEVELOPER URGES THAT USERS WHO REQUIRE A COMMERCIAL PRODUCT
* NOT MAKE USE OF THIS WORK.
*
* DISCLAIMER:
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#ifndef HEXER_LONG_OPTIONS
#define HEXER_LONG_OPTIONS 0
#endif
#if HEXER_LONG_OPTIONS
#include <getopt.h>
#endif
#ifndef HEXER_MAX_STARTUP_COMMANDS
#define HEXER_MAX_STARTUP_COMMANDS 256
#endif
#include "hexer.h"
static char *usage_message = "\
hexer - a binary file editor\n\
usage: hexer [options] [file [...]]\n\
-R/--readonly\n\
-v/--view\n\
Edit files in read only mode.\n\
-r/--recover filename\n\
Recover the file filename after a crash. (not implemented)\n\
-c/--command command\n\
Start the editing session by executing the editor command\n\
`command'. If command contains whitespace, the whitespace\n\
should be quoted.\n\
-t/--tite\n\
Turn off the usage of the termcap/terminfo ti/te sequence.\n\
-h/--help\n\
Print out a short help message and exit.\n\
+command\n\
This is equivalent to the -c option.\n\
Note: The long options are not availabe on all systems.\n";
#if HEXER_LONG_OPTIONS
static struct option longopts[] = {
{ "readonly", 0, 0, 'R' },
{ "view", 0, 0, 'v' },
{ "recover", 1, 0, 'r' }, /* recover from the given file. */
{ "command", 1, 0, 'c' }, /* the given comand is executed in the first
* buffer. */
{ "help", 0, 0, 'h' }, /* print a short help message to `stdout'. */
{ "tite", 0, 0, 't' }, /* tite - turn off the ti/te sequence. */
{ 0, 0, 0, 0 }
};
#endif /* HEXER_LONG_OPTIONS */
static char *shortopts = "Rvr:c:dth";
static int hexer_readonly;
static char *startup_commands[HEXER_MAX_STARTUP_COMMANDS];
static int startup_commands_n = 0;
static int
process_args(argc, argv)
int argc;
char **argv;
{
extern char *optarg;
extern int optind;
extern tio_tite_f;
int c, i;
int exit_f = 0;
char *first_buffer = 0;
extern void exh_command( /* struct he_s *hedit, char *cmd, int *kcmd */ );
extern void hexer_init( /* void */ );
int open_f = 0;
#if HEXER_LONG_OPTIONS
int longopt_idx;
#endif
/* set default options */
hexer_readonly = 0;
for (; !exit_f;) {
if (optind >= argc) break;
if (*argv[optind] == '+') {
if (!argv[optind][1])
startup_commands[startup_commands_n++] = argv[++optind];
else
startup_commands[startup_commands_n++] = argv[optind] + 1;
++optind;
continue;
}
#if HEXER_LONG_OPTIONS
c = getopt_long(argc, argv, shortopts, longopts, &longopt_idx);
#else
c = getopt(argc, argv, shortopts);
#endif
if (c < 0) break;
switch (c) {
case 'v':
case 'R': /* readonly */
hexer_readonly = 1;
break;
case 'r': /* recover */
printf("recover from file `%s'.\n", optarg);
break;
case 'c': /* command */
startup_commands[startup_commands_n++] = optarg;
break;
case 'd': /* debug */
setbuf(stdout, 0);
break;
case 't': /* tite - turn off the ti/te sequence */
++tio_tite_f;
break;
case 'h': /* help */
default:
puts(usage_message);
exit_f = 1;
break;
}
}
if (!exit_f) {
if (optind < argc) /* read the files */
while (optind < argc) {
if (!he_open_buffer(argv[optind], argv[optind])) {
open_f = 1;
if (!first_buffer) first_buffer = argv[optind];
if (hexer_readonly) he_set_buffer_readonly(argv[optind]);
}
++optind;
}
if (!open_f) /* create an empty buffer */
he_open_buffer("*scratch*", 0);
if (first_buffer) he_select_buffer(first_buffer);
/* execute the startup commands (if any). some of the startup commands
* may open or close buffers or even quit the editor, so we have to
* check if `current_buffer' is 0 after each command. */
hexer_init();
if (startup_commands_n && current_buffer)
for (i = 0; i < startup_commands_n; ++i) {
exh_command(current_buffer->hedit, startup_commands[i], 0, 0);
if (!current_buffer) break;
}
if (current_buffer) he_status_message(0);
}
return exit_f;
}
/* process_args */
static void
setup_screen()
{
int fg, bg;
if (tio_have_color()) {
fg = s_get_option_integer("fg");
bg = s_get_option_integer("bg");
tio_set_colors(fg, bg);
tio_flush();
}
}
/* setup_screen */
extern char **
exh_completer( /* char *, char *, char *, int */ );