+/* Convert files for Emacs Hexl mode.
+ Copyright (C) 1989, 2001-2011 Free Software Foundation, Inc.
+
+Author: Keith Gabryelski
+(according to authors.el)
+
+This file is not considered part of GNU Emacs.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <stdio.h>
#include <ctype.h>
-#ifdef MSDOS
+#ifdef DOS_NT
#include <fcntl.h>
#if __DJGPP__ >= 2
#include <io.h>
#endif
#endif
+#ifdef WINDOWSNT
+#include <io.h>
+#endif
#define DEFAULT_GROUPING 0x01
#define DEFAULT_BASE 16
int group_by = DEFAULT_GROUPING;
char *progname;
-void usage();
+void usage(void) NO_RETURN;
int
-main (argc, argv)
- int argc;
- char *argv[];
+main (int argc, char **argv)
{
register long address;
char string[18];
** <filename> dump filename
** - (as filename == stdin)
*/
-
+
while (*argv && *argv[0] == '-' && (*argv)[1])
{
/* A switch! */
{
char buf[18];
-#ifdef MSDOS
-#if __DJGPP__ >= 2
+#ifdef DOS_NT
+#if (__DJGPP__ >= 2) || (defined WINDOWSNT)
if (!isatty (fileno (stdout)))
setmode (fileno (stdout), O_BINARY);
#else
#endif
for (;;)
{
- register int i, c, d;
+ register int i, c = 0, d;
#define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10)
- fread (buf, 1, 10, fp); /* skip 10 bytes */
+ /* Skip 10 bytes. */
+ if (fread (buf, 1, 10, fp) != 10)
+ break;
for (i=0; i < 16; ++i)
{
if (i < 16)
break;
- fread (buf, 1, 18, fp); /* skip 18 bytes */
+ /* Skip 18 bytes. */
+ if (fread (buf, 1, 18, fp) != 18)
+ break;
}
}
}
else
{
-#ifdef MSDOS
-#if __DJGPP__ >= 2
+#ifdef DOS_NT
+#if (__DJGPP__ >= 2) || (defined WINDOWSNT)
if (!isatty (fileno (fp)))
setmode (fileno (fp), O_BINARY);
#else
string[17] = '\0';
for (;;)
{
- register int i, c;
+ register int i, c = 0;
for (i=0; i < 16; ++i)
{
else
{
if (!i)
- printf ("%08x: ", address);
+ printf ("%08lx: ", address);
if (iso_flag)
string[i+1] =
fclose (fp);
} while (*argv != NULL);
- return 0;
+ return EXIT_SUCCESS;
}
void
-usage ()
+usage (void)
{
fprintf (stderr, "usage: %s [-de] [-iso]\n", progname);
- exit (1);
+ exit (EXIT_FAILURE);
}
+
+
+/* hexl.c ends here */