1 /* hexedit -- Hexadecimal Editor for Binary Files
2 Copyright (C) 1998 Pixel (Pascal Rigaux)
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/
20 /*******************************************************************************/
21 /* Global variables */
22 /*******************************************************************************/
23 INT lastEditedLoc
, biggestLoc
, fileSize
;
24 INT mark_min
, mark_max
, mark_set
;
26 int normalSpaces
, cursor
, cursorOffset
, hexOrAscii
;
27 int cursor
, blocSize
, lineLength
, colsUsed
, page
;
28 int isReadOnly
, fd
, nbBytes
, oldcursor
, oldattr
, oldcursorOffset
;
29 int sizeCopyBuffer
, *bufferAttr
;
30 char *progName
, *fileName
, *baseName
;
31 unsigned char *buffer
, *copyBuffer
;
34 char *lastFindFile
= NULL
, *lastYankToAFile
= NULL
, *lastAskHexString
= NULL
, *lastAskAsciiString
= NULL
, *lastFillWithStringHexa
= NULL
, *lastFillWithStringAscii
= NULL
;
37 modeParams modes
[LAST
] = {
41 modeType mode
= maximized
;
44 char * usage
= "usage: %s [-s | --sector] [-m | --maximize]"
45 " [--nocolor] [-h | --help] filename\n";
48 /*******************************************************************************/
50 /*******************************************************************************/
51 int main(int argc
, char **argv
)
53 progName
= basename(argv
[0]);
57 for (; argc
> 0; argv
++, argc
--)
59 if (streq(*argv
, "-s") || streq(*argv
, "--sector"))
61 else if (streq(*argv
, "-m") || streq(*argv
, "--maximize"))
63 else if (streq(*argv
, "--nocolor"))
65 else if (streq(*argv
, "--")) {
68 } else if (*argv
[0] == '-')
72 if (argc
> 1) DIE(usage
);
76 fileName
= strdup(*argv
);
80 if (fileName
== NULL
) {
83 DIE("%s: No such file\n");
89 while (key_to_function(getch()));
91 return 0; /* for no warning */
96 /*******************************************************************************/
98 /*******************************************************************************/
101 page
= 0; /* page == 0 means initCurses is not done */
116 FREE(lastFindFile
); FREE(lastYankToAFile
); FREE(lastAskHexString
); FREE(lastAskAsciiString
); FREE(lastFillWithStringHexa
); FREE(lastFillWithStringAscii
);