Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
6b39a7f695 | |||
fd106bccdc | |||
8e54450ca4 | |||
a1b692e60b | |||
![]() |
0c31724556 | ||
![]() |
db5ef5d6fa | ||
265e2769e0 | |||
6edb7a72a1 | |||
00568fc30f | |||
7797b52d36 | |||
9ac121993d | |||
ba88773d13 | |||
bc157ea489 | |||
ef3750600d | |||
f8a3ab2db8 |
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
display.d
|
||||
display.o
|
||||
hexViewer
|
||||
main.d
|
||||
main.o
|
||||
package
|
||||
parameter.d
|
||||
parameter.o
|
93
Makefile
93
Makefile
@ -12,21 +12,12 @@
|
||||
# Concu Pour le projet hexViwer #
|
||||
# #
|
||||
##################################################################################################################
|
||||
export F_GRAS=[1m
|
||||
export F_INVERSER=[7m
|
||||
export F_SOUSLIGNER=[4m
|
||||
export F_NORMALE=[m
|
||||
export F_NOIR=[31m
|
||||
export F_ROUGE=[31m
|
||||
export F_VERT=[32m
|
||||
export F_MARRON=[33m
|
||||
export F_BLUE=[34m
|
||||
export F_VIOLET=[35m
|
||||
export F_CYAN=[36m
|
||||
export F_GRIS=[37m
|
||||
export CADRE_HAUT_BAS=' $(F_INVERSER) $(F_NORMALE)'
|
||||
export CADRE_COTERS='
$(F_INVERSER) $(F_NORMALE) $(F_INVERSER) $(F_NORMALE)'
|
||||
|
||||
VERSION_TAG_SHORT=$(shell git describe --tags --abbrev=0)
|
||||
#$(info $(VERSION_TAG_SHORT))
|
||||
|
||||
VERSION_BUILD_TIME=$(shell date)
|
||||
#$(info $(VERSION_BUILD_TIME))
|
||||
|
||||
CFLAGS= -g -Wall -D_REENTRANT
|
||||
|
||||
@ -37,38 +28,22 @@ LIB= -lpthread -lm
|
||||
CC= g++ $(CFLAGS)
|
||||
LD= g++
|
||||
|
||||
# Liste des fichiers
|
||||
# List of Sources
|
||||
SRC=main.c \
|
||||
display.c \
|
||||
parameter.c
|
||||
|
||||
# Liste des objets
|
||||
# List of Objects
|
||||
OBJ= $(SRC:.c=.o)
|
||||
|
||||
# Liste des dépendances
|
||||
# List of dependances
|
||||
DEP= $(SRC:.c=.d)
|
||||
|
||||
PROG_NAME=hexViewer
|
||||
|
||||
#
|
||||
BIN=hexViewer
|
||||
|
||||
.PHONY: all
|
||||
all: encadrer $(BIN)
|
||||
all: $(PROG_NAME)
|
||||
|
||||
|
||||
encadrer:
|
||||
ifneq ($(COLOR),normal)
|
||||
@echo $(CADRE_HAUT_BAS)
|
||||
@echo $(CADRE_COTERS)
|
||||
@echo ' DEBUT DE COMPILATION DU PROGRAMME :'$(CADRE_COTERS)
|
||||
@echo ' $(F_VIOLET)$(BIN)$(F_NORMALE) '$(CADRE_COTERS)
|
||||
@echo $(CADRE_COTERS)
|
||||
@echo ' $(F_GRIS) Heero Yui Makefile 29-01-2010$(F_NORMALE)'$(CADRE_COTERS)
|
||||
@echo $(CADRE_HAUT_BAS)
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
%.o: %.c
|
||||
@echo $(F_VERT)" (.o) $<"$(F_NORMALE)
|
||||
@$(CC) -o $@ -c $<
|
||||
@ -76,18 +51,52 @@ endif
|
||||
%.d: %.c
|
||||
@echo $(F_BLUE)" (.d) $<"$(F_NORMALE)
|
||||
@$(CC) -MM -MD -o $@ $<
|
||||
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(BIN) $(OBJ) $(DEP) *.i *.s *.bck
|
||||
rm -f $(PROG_NAME) $(OBJ) $(DEP) *.i *.s *.bck
|
||||
|
||||
$(BIN):$(OBJ)
|
||||
$(PROG_NAME):$(OBJ)
|
||||
@echo $(F_ROUGE)" (bin) $@"$(F_NORMALE)
|
||||
@$(LD) -o $@ $^ $(LIB)
|
||||
|
||||
|
||||
|
||||
|
||||
# inclusion des dependances
|
||||
-include $(DEP)
|
||||
|
||||
.PHONY: package
|
||||
# http://alp.developpez.com/tutoriels/debian/creer-paquet/
|
||||
package: all
|
||||
@echo 'Create packages ...'
|
||||
@mkdir -p package/$(PROG_NAME)/DEBIAN/
|
||||
@mkdir -p package/$(PROG_NAME)/usr/bin/
|
||||
@mkdir -p package/$(PROG_NAME)/usr/share/doc/
|
||||
@mkdir -p package/$(PROG_NAME)/usr/share/edn/
|
||||
# Create the control file
|
||||
@echo "Package: "$(PROG_NAME) > package/$(PROG_NAME)/DEBIAN/control
|
||||
@echo "Version: "$(VERSION_TAG_SHORT) >> package/$(PROG_NAME)/DEBIAN/control
|
||||
@echo "Section: Development,Editors" >> package/$(PROG_NAME)/DEBIAN/control
|
||||
@echo "Priority: optional" >>package/$(PROG_NAME)/DEBIAN/control
|
||||
@echo "Architecture: all" >> package/$(PROG_NAME)/DEBIAN/control
|
||||
@echo "Depends: bash" >> package/$(PROG_NAME)/DEBIAN/control
|
||||
@echo "Maintainer: Mr DUPIN Edouard <yui.heero@gmail.com>" >> package/$(PROG_NAME)/DEBIAN/control
|
||||
@echo "Description: Binary comparator for shell console" >> package/$(PROG_NAME)/DEBIAN/control
|
||||
@echo "" >> package/$(PROG_NAME)/DEBIAN/control
|
||||
# Create the PostRm
|
||||
@#echo "#!/bin/bash" > package/$(PROG_NAME)/DEBIAN/postrm
|
||||
@#echo "rm ~/."$(PROG_NAME) >> package/$(PROG_NAME)/DEBIAN/postrm
|
||||
@#echo "" >> package/$(PROG_NAME)/DEBIAN/postrm
|
||||
# Enable Execution in script
|
||||
@#chmod 755 package/$(PROG_NAME)/DEBIAN/post*
|
||||
@#chmod 755 package/$(PROG_NAME)/DEBIAN/pre*
|
||||
# copy licence and information :
|
||||
@cp README package/$(PROG_NAME)/usr/share/doc/README
|
||||
@cp licence.txt package/$(PROG_NAME)/usr/share/doc/copyright
|
||||
@echo "First generation in progress" > package/$(PROG_NAME)/usr/share/doc/changelog
|
||||
@cp -vf $(PROG_NAME) package/$(PROG_NAME)/usr/bin/
|
||||
@#cp -vf data/*.xml package/$(PROG_NAME)/usr/share/edn/
|
||||
@cd package; dpkg-deb --build $(PROG_NAME)
|
||||
|
||||
install:
|
||||
sudo cp -fv hexViewer /usr/bin/hexViewer
|
||||
|
||||
|
||||
|
18
README
18
README
@ -2,20 +2,6 @@ HexViewer (Hexadevimal Viewer) is a FREE software.
|
||||
|
||||
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
|
||||
|
||||
Terms of license:
|
||||
Copyright: 2010 Edouard DUPIN, all right reserved
|
||||
|
||||
You can:
|
||||
- Redistribute the sources code and binaries.
|
||||
- Modify the Sources code.
|
||||
- Use a part of the sources (less than 50%) in an other software, just write somewhere "HexViewer is great" visible by the user (on your product or on your website with a link to my page).
|
||||
- Redistribute the modification only if you want.
|
||||
- Send me the bug-fix (it could be great).
|
||||
- Pay me a beer or some other things.
|
||||
- Print the source code on WC paper ...
|
||||
You can NOT:
|
||||
- Earn money with this Software (But I can).
|
||||
- Add malware in the Sources.
|
||||
- Do something bad with the sources.
|
||||
- Use it to travel in the space with a toaster.
|
||||
|
||||
I reserve the right to change this licence. If it change the version of the copy you have keep its own license
|
||||
License: GNU General Public License (GPL) v3.0
|
||||
|
11
display.h
11
display.h
@ -1,11 +1,11 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file display.h
|
||||
* @brief Editeur De N'ours :
|
||||
* @brief main display system of the hexViewer (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/02/2011
|
||||
* @par Project
|
||||
* Edn tool : hexViewer
|
||||
* hexViewer
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
@ -13,12 +13,7 @@
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
* Licence : GNU Lesser General Public License (LGPL) v3.0
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
78
dump_test.sh
Executable file
78
dump_test.sh
Executable file
@ -0,0 +1,78 @@
|
||||
#! /bin/bash
|
||||
|
||||
DUMP_DIR_EXP=.
|
||||
DUMP_DIR_MATLAB=..
|
||||
|
||||
MATLAB_PREFIX=m__
|
||||
TANGO_PREFIX=exp
|
||||
|
||||
DUMP_FILES=(
|
||||
'WTX_')
|
||||
|
||||
#echo "Dump directory: $DUMP_DIR"
|
||||
#echo "Dump files: ${DUMP_FILES[@]}"
|
||||
|
||||
COLOR_RESET=$(tput sgr0)
|
||||
COLOR_FILENAME=$(tput bold)$(tput setaf 3)
|
||||
COLOR_BIT_EXACT=$(tput bold)$(tput setaf 4)
|
||||
COLOR_DIFFERENT=$(tput bold)$(tput setaf 1)
|
||||
COLOR_ERROR=$(tput bold)$(tput setaf 5)
|
||||
|
||||
for i in "${DUMP_FILES[@]}" ; do
|
||||
for (( FileID=0; FileID<=1000; FileID++ )) ; do
|
||||
VALUE="010"
|
||||
if [ $FileID -lt 10 ] ; then
|
||||
VALUE="00$FileID"
|
||||
elif [ $FileID -lt 100 ] ; then
|
||||
VALUE="0$FileID"
|
||||
else
|
||||
VALUE="$FileID"
|
||||
fi
|
||||
|
||||
MATLAB_DUMP="$DUMP_DIR_MATLAB/$MATLAB_PREFIX$i$VALUE""_*"
|
||||
TANGO_DUMP="$DUMP_DIR_EXP/$TANGO_PREFIX$i$VALUE""_*"
|
||||
|
||||
# TODO : afficher quend un des deux fichier existe
|
||||
|
||||
if [ ! -e "$MATLAB_DUMP" ] ; then
|
||||
finanameLS=`ls $MATLAB_DUMP 2> /dev/null`
|
||||
if [ ! -e "$finanameLS" ] ; then
|
||||
#echo -e -n "$COLOR_ERROR [ ??? ]
"
|
||||
#echo -e -n "\t\t\t\t\t$MATLAB_DUMP$COLOR_RESET\n"
|
||||
#echo -e -n "\t\t\t\t\t\t\t\t\t\t\t$COLOR_FILENAME$TANGO_DUMP$COLOR_RESET\n"
|
||||
continue
|
||||
else
|
||||
MATLAB_DUMP=$finanameLS
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -e "$TANGO_DUMP" ] ; then
|
||||
finanameLS=`ls $TANGO_DUMP 2> /dev/null`
|
||||
if [ ! -e "$finanameLS" ] ; then
|
||||
#echo -e -n "$COLOR_ERROR [ ??? ]
"
|
||||
#echo -e -n "\t\t\t\t\t$COLOR_FILENAME$MATLAB_DUMP$COLOR_RESET
"
|
||||
#echo -e -n "\t\t\t\t\t\t\t\t\t\t\t$COLOR_ERROR$TANGO_DUMP$COLOR_RESET\n"
|
||||
continue
|
||||
else
|
||||
TANGO_DUMP=$finanameLS
|
||||
fi
|
||||
fi
|
||||
|
||||
hexViewer -d $MATLAB_DUMP $TANGO_DUMP > .tmpResultHexViewer.txt
|
||||
VALUE_ERROR=$?
|
||||
RESULT=`cat .tmpResultHexViewer.txt`
|
||||
if [ $VALUE_ERROR -eq '0' ] ; then
|
||||
echo -e -n "$COLOR_ERROR [ OK ] $COLOR_RESET
"
|
||||
echo -e -n "\t\t\t\t\t$COLOR_FILENAME$MATLAB_DUMP$COLOR_RESET
"
|
||||
echo -e -n "\t\t\t\t\t\t\t\t\t\t\t$COLOR_FILENAME$TANGO_DUMP$COLOR_RESET
"
|
||||
echo -e -n "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$RESULT\n"
|
||||
else
|
||||
echo -e -n "$COLOR_DIFFERENT [ERROR] $COLOR_RESET
"
|
||||
echo -e -n "\t\toctet=$VALUE_ERROR
"
|
||||
echo -e -n "\t\t\t\t\t$COLOR_FILENAME$MATLAB_DUMP$COLOR_RESET
"
|
||||
echo -e -n "\t\t\t\t\t\t\t\t\t\t\t$COLOR_FILENAME$TANGO_DUMP$COLOR_RESET
"
|
||||
echo -e -n "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$RESULT\n"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
@ -1,11 +1,11 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file generalDefine.h
|
||||
* @brief Editeur De N'ours :
|
||||
* @brief generic basic defines
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/02/2011
|
||||
* @par Project
|
||||
* Edn tool : hexViewer
|
||||
* hexViewer
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
@ -13,12 +13,7 @@
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
* Licence : GNU Lesser General Public License (LGPL) v3.0
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -32,16 +27,16 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef unsigned char U8;
|
||||
typedef signed char I8;
|
||||
typedef unsigned short int U16;
|
||||
typedef signed short int I16;
|
||||
typedef unsigned long int U32;
|
||||
typedef signed long int I32;
|
||||
typedef unsigned long long int U64;
|
||||
typedef signed long long int I64;
|
||||
//typedef unsigned long long long int U128;
|
||||
//typedef signed long long long int I128;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned short int uint16_t;
|
||||
typedef signed short int int16_t;
|
||||
typedef unsigned long int uint32_t;
|
||||
//typedef signed long int int32_t;
|
||||
typedef unsigned long long int uint64_t;
|
||||
//typedef signed long long int int64_t;
|
||||
//typedef unsigned long long long int uint128_t;
|
||||
//typedef signed long long long int int128_t;
|
||||
|
||||
//regular colors
|
||||
#define COLOR_BLACK "\e[0;30m"
|
||||
@ -75,18 +70,22 @@ typedef signed long long int I64;
|
||||
// Return to the normal color setings
|
||||
#define COLOR_NORMAL "\e[0m"
|
||||
|
||||
#define MOUSE_REPORTING_ENABLE "\e[?9h"
|
||||
#define MOUSE_REPORTING_DISABLE "\e[?9l"
|
||||
|
||||
#define CURSOR_DISPLAY_DISABLE "\e[?25l"
|
||||
#define CURSOR_DISPLAY_ENABLE "\e[?12l\e[?25h"
|
||||
|
||||
//go to the Top of bash
|
||||
#define GO_TOP "\e[0;0f"
|
||||
|
||||
|
||||
#define NB_DATA_PER_LINE (4)
|
||||
#define NB_MAX_LINE (50)
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
SHOW_TYPE_UNKNOW,
|
||||
SHOW_TYPE_HEX,
|
||||
SHOW_TYPE_DECIMAL_SIGNED,
|
||||
SHOW_TYPE_DECIMAL_UNSIGNED
|
||||
@ -94,12 +93,26 @@ typedef enum {
|
||||
|
||||
|
||||
typedef enum {
|
||||
SHOW_TYPE_SIZE_UNKNOW,
|
||||
SHOW_TYPE_SIZE_8,
|
||||
SHOW_TYPE_SIZE_16,
|
||||
SHOW_TYPE_SIZE_32,
|
||||
SHOW_TYPE_SIZE_64,
|
||||
SHOW_TYPE_SIZE_128
|
||||
SHOW_TYPE_SIZE_128,
|
||||
SHOW_TYPE_SIZE_FLOAT,
|
||||
SHOW_TYPE_SIZE_DOUBLE
|
||||
} showTypeSize_te;
|
||||
|
||||
typedef struct {
|
||||
bool availlable;
|
||||
FILE *pointer;
|
||||
uint32_t size;
|
||||
char name[2096];
|
||||
int32_t fileBasicOffset;
|
||||
showType_te type;
|
||||
showTypeSize_te typeSize;
|
||||
int32_t slotSize;
|
||||
int32_t delta;
|
||||
} fileProperties_ts;
|
||||
|
||||
#endif
|
||||
|
165
licence.txt
Normal file
165
licence.txt
Normal file
@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
936
main.c
936
main.c
@ -1,26 +1,19 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file main.c
|
||||
* @brief Editeur De N'ours :
|
||||
* @brief Main function (sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/02/2011
|
||||
* @par Project
|
||||
* Edn tool : hexViewer
|
||||
* hexViewer
|
||||
*
|
||||
* @version $Id$
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This 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 software 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.
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence : GNU Lesser General Public License (LGPL) v3.0
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -29,248 +22,550 @@
|
||||
#include "display.h"
|
||||
|
||||
|
||||
fileProperties_ts fileProp[2];
|
||||
|
||||
FILE *filePointer[2] = {NULL, NULL};
|
||||
U32 filesize[2] = {0, 0};
|
||||
char fileName[2][2096] = {"",""};
|
||||
|
||||
void usage(void)
|
||||
int32_t findFirstDiff(void)
|
||||
{
|
||||
printf("usage : hexViwer [file_1] [file_2]\n");
|
||||
printf("\t[file_1] : Show the first file only\n");
|
||||
printf("\t[file_2] : if it was precise : Show the comparaison with the first file\n");
|
||||
printf("\t\n");
|
||||
printf("\tInside Usage : \n");
|
||||
printf("\t\t[a] Go to the start of the files\n");
|
||||
printf("\t\t[z] Go to the end of the files (the first push is the File 1, the second push is the file 2) \n");
|
||||
printf("\t\t[q] Quit the curent program\n");
|
||||
printf("\t\t[s] Change the view of the propram of the size of interpretation (8 bits, 16 bits, 32 bits)\n");
|
||||
printf("\t\t[t] Change the interpretation of Data (hexedecimal, Signed Decimal, Unigned Decimal)\n");
|
||||
printf("\t\t[f] Find the first Error when comparing the two files\n");
|
||||
printf("\t\t[UP] Go up 5 line in the view\n");
|
||||
printf("\t\t[DOWN] Go down 5 line in the view\n");
|
||||
printf("\t\t[LEFT] Go up 50 line in the view (one screen)\n");
|
||||
printf("\t\t[RIGHT] Go down 50 line in the view (one screen)\n");
|
||||
printf("\t\n");
|
||||
printf("\tTODO : \n");
|
||||
printf("\t\t- The print of 128 bytes\n");
|
||||
printf("\t\t- The print in Octal\n");
|
||||
printf("\t\t- The print in Binary\n");
|
||||
printf("\t\t- The Modification of the file\n");
|
||||
printf("\t\t- The Saving of the file\n");
|
||||
printf("\t\t- The information that one of the files has been update\n");
|
||||
printf("\t\t- To reload the two files ==> [U]\n");
|
||||
printf("\t\t- The windows scroling with the mouse\n");
|
||||
printf("\t\t- The selection with the mouse\n");
|
||||
printf("\t\t- The display on char view\n");
|
||||
printf("\t\t- The scroling Bar on the right\n");
|
||||
printf("\t\t- Add to the croling bar the differences in the two files\n");
|
||||
printf("\t\t- The research of a sequency in the two files ==> [R]\n");
|
||||
printf("\t\t- The jump to an offset directly ==> [J] \n");
|
||||
/*printf("\t\t- \n");*/
|
||||
uint8_t data1, data2;
|
||||
int32_t offset = 0;
|
||||
if( NULL == fileProp[0].pointer
|
||||
|| NULL == fileProp[1].pointer ) {
|
||||
return 0;
|
||||
}
|
||||
int32_t paddingFile = getPaddingOffsetFile();
|
||||
int32_t pad1 = 0;
|
||||
int32_t pad2 = 0;
|
||||
if (paddingFile>0) {
|
||||
pad1 = paddingFile;
|
||||
pad2 = 0;
|
||||
} else {
|
||||
pad1 = 0;
|
||||
pad2 = -1*paddingFile;
|
||||
}
|
||||
if(NULL != fileProp[0].pointer) {
|
||||
fseek ( fileProp[0].pointer , pad1+fileProp[0].fileBasicOffset , SEEK_SET );
|
||||
}
|
||||
if(NULL != fileProp[1].pointer) {
|
||||
fseek ( fileProp[1].pointer , pad2+fileProp[1].fileBasicOffset , SEEK_SET );
|
||||
}
|
||||
while ( fread(&data1, sizeof(uint8_t), 1, fileProp[0].pointer) == 1
|
||||
&& fread(&data2, sizeof(uint8_t), 1, fileProp[1].pointer) == 1)
|
||||
{
|
||||
offset ++;
|
||||
if (data1 != data2) {
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
void AutoSetPadding(void)
|
||||
{
|
||||
displayPaddingOffset(0);
|
||||
if( NULL == fileProp[0].pointer
|
||||
|| NULL == fileProp[1].pointer ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(NULL != fileProp[0].pointer) {
|
||||
fseek ( fileProp[0].pointer , fileProp[0].fileBasicOffset , SEEK_SET );
|
||||
}
|
||||
int32_t offset1 = 0;
|
||||
char data;
|
||||
while(fread(&data, sizeof(uint8_t), 1, fileProp[0].pointer) == 1) {
|
||||
if (data != 0) {
|
||||
break;
|
||||
}
|
||||
offset1 ++;
|
||||
}
|
||||
if(NULL != fileProp[1].pointer) {
|
||||
fseek ( fileProp[1].pointer , fileProp[1].fileBasicOffset , SEEK_SET );
|
||||
}
|
||||
int32_t offset2 = 0;
|
||||
while(fread(&data, sizeof(uint8_t), 1, fileProp[1].pointer) == 1)
|
||||
{
|
||||
if (data != 0) {
|
||||
break;
|
||||
}
|
||||
offset2 ++;
|
||||
}
|
||||
if (offset1 == offset2) {
|
||||
return;
|
||||
}
|
||||
if (0 == offset1) {
|
||||
return;
|
||||
}
|
||||
if (0 == offset2) {
|
||||
return;
|
||||
}
|
||||
|
||||
displayPaddingOffset(offset1 - offset2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
I32 findFirstDiff(void)
|
||||
void UpdateFilesSize(void)
|
||||
{
|
||||
U8 data1, data2;
|
||||
I32 offset = 0;
|
||||
|
||||
while ( fread(&data1, sizeof(U8), 1, filePointer[0]) == 1
|
||||
&& fread(&data2, sizeof(U8), 1, filePointer[1]) == 1)
|
||||
{
|
||||
offset ++;
|
||||
if (data1 != data2)
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
// get size for 2 files
|
||||
int32_t iii=0;
|
||||
for (iii=0; iii<2; iii++) {
|
||||
if ( NULL != fileProp[iii].pointer) {
|
||||
fseek ( fileProp[iii].pointer , 0 , SEEK_END );
|
||||
fileProp[iii].size = ftell (fileProp[iii].pointer) - fileProp[iii].fileBasicOffset;
|
||||
fseek ( fileProp[iii].pointer , 0 , SEEK_SET );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ResetProperties(void)
|
||||
{
|
||||
int32_t iii=0;
|
||||
for (iii=0; iii<2; iii++) {
|
||||
fileProp[iii].availlable = false;
|
||||
fileProp[iii].pointer = NULL;
|
||||
fileProp[iii].size = 0;
|
||||
strcpy(fileProp[iii].name, "No-File");
|
||||
fileProp[iii].fileBasicOffset = 0;
|
||||
fileProp[iii].type = SHOW_TYPE_UNKNOW;
|
||||
fileProp[iii].typeSize = SHOW_TYPE_SIZE_UNKNOW;
|
||||
fileProp[iii].slotSize = 0;
|
||||
fileProp[iii].delta = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OpenFiles(void)
|
||||
{
|
||||
int32_t iii=0;
|
||||
for (iii=0; iii<2; iii++) {
|
||||
if (true == fileProp[iii].availlable) {
|
||||
// Open file 1
|
||||
fileProp[iii].pointer = fopen(fileProp[iii].name, "rb");
|
||||
if ( NULL == fileProp[iii].pointer) {
|
||||
//printf("Can not Open [File_1] = %s\n", fileName[0]);
|
||||
}
|
||||
}
|
||||
if (fileProp[iii].pointer==NULL) {
|
||||
continue;
|
||||
}
|
||||
// check if file has specifi header :
|
||||
char dataheader[128];
|
||||
if(16 == fread(&dataheader, sizeof(uint8_t), 16, fileProp[iii].pointer)) {
|
||||
// parse header
|
||||
if( dataheader[0]=='#'
|
||||
&& dataheader[1]=='M'
|
||||
&& dataheader[2]=='E'
|
||||
&& dataheader[3]=='T') {
|
||||
|
||||
// ==> "#MET %c %s %04d "
|
||||
// type unused ...
|
||||
if( dataheader[5] == 'I'
|
||||
|| dataheader[5] == 'F'
|
||||
|| dataheader[5] == 'D') {
|
||||
fileProp[iii].type = SHOW_TYPE_DECIMAL_SIGNED;
|
||||
} else if (dataheader[5] == 'U') {
|
||||
fileProp[iii].type = SHOW_TYPE_DECIMAL_UNSIGNED;
|
||||
} else if (dataheader[5] == 'U') {
|
||||
fileProp[iii].type = SHOW_TYPE_HEX;
|
||||
} else {
|
||||
printf("Error while parsing the header ... \n");
|
||||
fileProp[iii].type = SHOW_TYPE_UNKNOW;
|
||||
}
|
||||
if (strncmp(&dataheader[6], "08", 2)==0) {
|
||||
fileProp[iii].typeSize = SHOW_TYPE_SIZE_8;
|
||||
} else if (strncmp(&dataheader[6], "16", 2)==0) {
|
||||
fileProp[iii].typeSize = SHOW_TYPE_SIZE_16;
|
||||
} else if (strncmp(&dataheader[6], "32", 2)==0) {
|
||||
fileProp[iii].typeSize = SHOW_TYPE_SIZE_32;
|
||||
} else if (strncmp(&dataheader[6], "64", 2)==0) {
|
||||
fileProp[iii].typeSize = SHOW_TYPE_SIZE_64;
|
||||
} else if (strncmp(&dataheader[6], "28", 2)==0) {
|
||||
fileProp[iii].typeSize = SHOW_TYPE_SIZE_128;
|
||||
} else if (strncmp(&dataheader[6], "LO", 2)==0) {
|
||||
fileProp[iii].typeSize = SHOW_TYPE_SIZE_FLOAT;
|
||||
} else if (strncmp(&dataheader[6], "OU", 2)==0) {
|
||||
fileProp[iii].typeSize = SHOW_TYPE_SIZE_DOUBLE;
|
||||
} else {
|
||||
printf("Error while parsing the header ... \n");
|
||||
fileProp[iii].typeSize = SHOW_TYPE_SIZE_UNKNOW;
|
||||
}
|
||||
char tmpVal[5];
|
||||
tmpVal[0] = dataheader[8];
|
||||
tmpVal[1] = dataheader[9];
|
||||
tmpVal[2] = dataheader[10];
|
||||
tmpVal[3] = dataheader[11];
|
||||
tmpVal[4] = '\0';
|
||||
sscanf(tmpVal, "%04d", &fileProp[iii].slotSize);
|
||||
|
||||
sscanf(&dataheader[12], "%04d", &fileProp[iii].delta);
|
||||
//printf("slot size [%d]=%d\n", iii, fileProp[iii].slotSize);
|
||||
// ofset of the header :
|
||||
fileProp[iii].fileBasicOffset = 16;
|
||||
}
|
||||
} // else : no header present ==> raw file
|
||||
fseek ( fileProp[iii].pointer , fileProp[iii].fileBasicOffset , SEEK_SET );
|
||||
}
|
||||
// check internal properties :
|
||||
if (fileProp[0].fileBasicOffset!=0 && fileProp[1].fileBasicOffset!=0) {
|
||||
if (fileProp[0].typeSize == fileProp[1].typeSize) {
|
||||
setTypeSize(fileProp[0].typeSize);
|
||||
} else {
|
||||
printf("Error The 2 files has not the same header typeSize properties header ... \n");
|
||||
}
|
||||
if (fileProp[0].type == fileProp[1].type) {
|
||||
setType(fileProp[0].type);
|
||||
} else {
|
||||
printf("Error The 2 files has not the same header type properties header ... \n");
|
||||
}
|
||||
if (fileProp[0].slotSize == fileProp[1].slotSize) {
|
||||
setSlotSize(fileProp[0].slotSize);
|
||||
if (fileProp[0].slotSize>0) {
|
||||
setSlotDisplayMode(true);
|
||||
}
|
||||
} else {
|
||||
printf("Error The 2 files has not the same header slotSize properties header ... \n");
|
||||
}
|
||||
} else if (fileProp[0].fileBasicOffset!=0) {
|
||||
setTypeSize(fileProp[0].typeSize);
|
||||
setType(fileProp[0].type);
|
||||
setSlotSize(fileProp[0].slotSize);
|
||||
if (fileProp[0].slotSize>0) {
|
||||
setSlotDisplayMode(true);
|
||||
}
|
||||
} else if (fileProp[1].fileBasicOffset!=0) {
|
||||
setTypeSize(fileProp[1].typeSize);
|
||||
setType(fileProp[1].type);
|
||||
setSlotSize(fileProp[1].slotSize);
|
||||
if (fileProp[1].slotSize>0) {
|
||||
setSlotDisplayMode(true);
|
||||
}
|
||||
}
|
||||
int32_t sizeElement=1;
|
||||
showTypeSize_te tmpType = getTypeSize();
|
||||
switch(tmpType)
|
||||
{
|
||||
default:
|
||||
case SHOW_TYPE_SIZE_8:
|
||||
sizeElement = 1;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_16:
|
||||
sizeElement = 2;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_FLOAT:
|
||||
case SHOW_TYPE_SIZE_32:
|
||||
sizeElement = 4;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_DOUBLE:
|
||||
case SHOW_TYPE_SIZE_64:
|
||||
sizeElement = 8;
|
||||
break;
|
||||
}
|
||||
int32_t tmpDela = (fileProp[1].delta - fileProp[0].delta) * sizeElement;
|
||||
displayPaddingOffset(tmpDela);
|
||||
|
||||
|
||||
UpdateFilesSize();
|
||||
}
|
||||
|
||||
|
||||
void CloseFiles(void)
|
||||
{
|
||||
int32_t iii=0;
|
||||
for (iii=0; iii<2; iii++) {
|
||||
if (NULL != fileProp[iii].pointer) {
|
||||
fclose(fileProp[iii].pointer);
|
||||
}
|
||||
fileProp[iii].pointer = NULL;
|
||||
fileProp[iii].fileBasicOffset = 0;
|
||||
fileProp[iii].type = SHOW_TYPE_UNKNOW;
|
||||
fileProp[iii].typeSize = SHOW_TYPE_SIZE_UNKNOW;
|
||||
fileProp[iii].slotSize = 0;
|
||||
fileProp[iii].delta = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char**argv)
|
||||
{
|
||||
I32 first_Error = 0;
|
||||
if (2 == argc)
|
||||
{
|
||||
filePointer[0] = fopen(argv[1], "rb");
|
||||
strcpy(fileName[0], argv[1]);
|
||||
if ( NULL == filePointer[0])
|
||||
{
|
||||
printf("Can not Open [File_1] = %s\n", argv[1]);
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (3 == argc)
|
||||
{
|
||||
filePointer[0] = fopen(argv[1], "rb");
|
||||
strcpy(fileName[0], argv[1]);
|
||||
filePointer[1] = fopen(argv[2], "rb");
|
||||
strcpy(fileName[1], argv[2]);
|
||||
fseek ( filePointer[0] , 0 , SEEK_END );
|
||||
fseek ( filePointer[1] , 0 , SEEK_END );
|
||||
filesize[0] = ftell (filePointer[0]);
|
||||
filesize[1] = ftell (filePointer[1]);
|
||||
fseek ( filePointer[0] , 0 , SEEK_SET );
|
||||
fseek ( filePointer[1] , 0 , SEEK_SET );
|
||||
first_Error = findFirstDiff();
|
||||
}
|
||||
else
|
||||
{
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// rendre la lecture des données non canonique
|
||||
system("stty -icanon");
|
||||
// supression de l'écho des caractères
|
||||
system("stty -echo");
|
||||
|
||||
system("clear");
|
||||
|
||||
|
||||
/*
|
||||
|
||||
printf(GO_TOP);
|
||||
|
||||
if ( NULL != filePointer[0]
|
||||
&& NULL == filePointer[1] )
|
||||
{
|
||||
showFile(filePointer[0] ,CurentFilePosition);
|
||||
}
|
||||
else if ( NULL != filePointer[0]
|
||||
&& NULL != filePointer[1] )
|
||||
{
|
||||
compareFile(filePointer[0],filePointer[1] ,CurentFilePosition);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int ret = 0;
|
||||
pthread_t HangleThreadDisplay;
|
||||
int32_t first_Error = 0;
|
||||
ResetProperties();
|
||||
UpdateNumberOfRawAndColomn();
|
||||
// check error
|
||||
if (argc < 2) {
|
||||
printf("You set more than 3 argument at the commande line\n");
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
bool directCheckFiles = false;
|
||||
int basicIDParsing = 1;
|
||||
if (0==strcmp("-d",argv[1])) {
|
||||
basicIDParsing++;
|
||||
directCheckFiles = true;
|
||||
}
|
||||
// one file
|
||||
if (basicIDParsing+1 <= argc) {
|
||||
strcpy(fileProp[0].name, argv[basicIDParsing]);
|
||||
fileProp[0].availlable = true;
|
||||
}
|
||||
// a second file
|
||||
if (basicIDParsing+2 <= argc) {
|
||||
strcpy(fileProp[1].name, argv[basicIDParsing+1]);
|
||||
fileProp[1].availlable = true;
|
||||
}
|
||||
// open the files
|
||||
OpenFiles();
|
||||
|
||||
// user requested to have the direct error ID of the file...
|
||||
if (directCheckFiles==true) {
|
||||
|
||||
float dividor = 1;
|
||||
int32_t maxSlot = (fileProp[0].slotSize>fileProp[1].slotSize)?fileProp[0].slotSize:fileProp[1].slotSize;
|
||||
if (0!=maxSlot) {
|
||||
dividor = maxSlot;
|
||||
}
|
||||
|
||||
int32_t idError = findFirstDiff();
|
||||
int minSizeFile = ((fileProp[0].size<fileProp[1].size)?fileProp[0].size:fileProp[1].size) - abs(getPaddingOffsetFile());
|
||||
if (minSizeFile<=idError) {
|
||||
printf(" --- slot=%3d nb frame=%d", (int32_t)dividor, (int32_t)(idError/dividor));
|
||||
CloseFiles();
|
||||
// 0 : no error
|
||||
return 0;
|
||||
} else {
|
||||
int32_t sizeElement = 1;
|
||||
showTypeSize_te tmpType = getTypeSize();
|
||||
switch(tmpType)
|
||||
{
|
||||
default:
|
||||
case SHOW_TYPE_SIZE_8:
|
||||
sizeElement = 1;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_16:
|
||||
sizeElement = 2;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_FLOAT:
|
||||
case SHOW_TYPE_SIZE_32:
|
||||
sizeElement = 4;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_DOUBLE:
|
||||
case SHOW_TYPE_SIZE_64:
|
||||
sizeElement = 8;
|
||||
break;
|
||||
}
|
||||
int32_t elementIDError = idError/sizeElement;
|
||||
float frameRatio = (float)elementIDError/dividor;
|
||||
int32_t idFrame = frameRatio;
|
||||
int32_t idFrameElement = (frameRatio-idFrame)*dividor;
|
||||
printf("%9d / frame=%9.2f ==> frame=%5d element=%5d slot=%3d", elementIDError, frameRatio, idFrame, idFrameElement, (int32_t)dividor);
|
||||
CloseFiles();
|
||||
return idError;
|
||||
}
|
||||
}
|
||||
// rendre la lecture des données non canonique
|
||||
system("stty -icanon");
|
||||
// supression de l'écho des caractères
|
||||
system("stty -echo");
|
||||
// enable mouse event ...
|
||||
printf(MOUSE_REPORTING_ENABLE);
|
||||
// hide cursor ...
|
||||
printf(CURSOR_DISPLAY_DISABLE);
|
||||
system("clear");
|
||||
CleanDisplay();
|
||||
|
||||
|
||||
// Creation du thread du magasin.
|
||||
//printf ("Creation du thread du magasin !\n");
|
||||
ret = pthread_create ( & HangleThreadDisplay, NULL, threadDisplay, NULL );
|
||||
if (! ret)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
U32 inputValue;
|
||||
inputValue = getc (stdin);
|
||||
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
|
||||
switch(inputValue)
|
||||
{
|
||||
case 'q':
|
||||
case 'Q':
|
||||
goto exit_programme;
|
||||
break;
|
||||
//case 0x1B:
|
||||
case '\e':
|
||||
inputValue = getc (stdin);
|
||||
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
|
||||
if (inputValue == 0x5B)
|
||||
{
|
||||
inputValue = getc (stdin);
|
||||
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
|
||||
if ( inputValue == 0x41
|
||||
|| inputValue == 0x42
|
||||
|| inputValue == 0x43
|
||||
|| inputValue == 0x44)
|
||||
{
|
||||
if (inputValue == 0x41)
|
||||
{
|
||||
upDownOfsetFile(-5);
|
||||
}
|
||||
else if ( inputValue == 0x42)
|
||||
{
|
||||
upDownOfsetFile(5);
|
||||
}
|
||||
else if ( inputValue == 0x43)
|
||||
{
|
||||
upDownOfsetFile(NB_MAX_LINE);
|
||||
}
|
||||
else if ( inputValue == 0x44)
|
||||
{
|
||||
upDownOfsetFile(-NB_MAX_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
// change the type of interpretation the file
|
||||
case 't':
|
||||
case 'T':
|
||||
nextType();
|
||||
break;
|
||||
// change the size of showing the file
|
||||
case 's':
|
||||
case 'S':
|
||||
nextTypeSize();
|
||||
break;
|
||||
// find the first ERROR
|
||||
case 'f':
|
||||
case 'F':
|
||||
setOfsetFile((first_Error/16)*16 - 256);
|
||||
break;
|
||||
// find the first ERROR
|
||||
case 'a':
|
||||
case 'A':
|
||||
setOfsetFile(0);
|
||||
break;
|
||||
// go to the end of the file (File 1 and next File 2)
|
||||
case 'z':
|
||||
case 'Z':
|
||||
{
|
||||
static bool whichElement = false;
|
||||
if (whichElement == false)
|
||||
{
|
||||
whichElement = true;
|
||||
setOfsetFile((filesize[0]/16)*16 - 256);
|
||||
}
|
||||
else
|
||||
{
|
||||
whichElement = false;
|
||||
setOfsetFile((filesize[1]/16)*16 - 256);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s", strerror (ret));
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
pthread_t HangleThreadDisplay;
|
||||
|
||||
ret = pthread_create ( & HangleThreadDisplay, NULL, threadDisplay, NULL );
|
||||
if (! ret)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
int32_t inputValue;
|
||||
inputValue = getc(stdin);
|
||||
switch(inputValue)
|
||||
{
|
||||
case 'q':
|
||||
case 'Q':
|
||||
goto exit_programme;
|
||||
break;
|
||||
//case 0x1B:
|
||||
case '\e':
|
||||
inputValue = getc (stdin);
|
||||
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
|
||||
// [ == 0x5B
|
||||
if (inputValue == '[')
|
||||
{
|
||||
inputValue = getc (stdin);
|
||||
char charValue = inputValue;
|
||||
// printf("\n get data : 0x%08x ..... : \\e[%c\n", (unsigned int)inputValue, charValue);
|
||||
if ( charValue == 'A' //0x41 ==> UP
|
||||
|| charValue == 'B' //0x42 ==> DOWN
|
||||
|| charValue == 'C' //0x43 ==> RIGHT
|
||||
|| charValue == 'D' //0x44 ==> LEFT
|
||||
)
|
||||
{
|
||||
//printf("\n get data :\\e[%c ==> MoveKey \n", charValue);
|
||||
if (charValue == 'A') {
|
||||
upDownOfsetFile(-5);
|
||||
} else if ( charValue == 'B') {
|
||||
upDownOfsetFile(5);
|
||||
} else if ( charValue == 'C') {
|
||||
upDownOfsetFile((GetNumberOfRaw()-NB_HEARDER_RAW));
|
||||
} else if ( charValue == 'D') {
|
||||
upDownOfsetFile(-(GetNumberOfRaw()-NB_HEARDER_RAW));
|
||||
}
|
||||
} else if (charValue == 'M' ) { //0x4d ==> mouse
|
||||
//printf("\n get data :\\e[%c ==> Mouse \n", charValue);
|
||||
int32_t button = getc(stdin);
|
||||
int32_t xPos = getc(stdin);
|
||||
xPos -= 0x20;
|
||||
int32_t yPos = getc(stdin);
|
||||
yPos -= 0x20;
|
||||
|
||||
int32_t bt=0;
|
||||
switch (button) {
|
||||
case 97:
|
||||
bt = 4;
|
||||
break;
|
||||
case 96:
|
||||
bt = 5;
|
||||
break;
|
||||
case 32:
|
||||
bt = 1;
|
||||
break;
|
||||
case 33:
|
||||
bt = 3;
|
||||
break;
|
||||
}
|
||||
//printf(" bt=%#x=%d \n", button, bt);
|
||||
//printf(" x=%d y=%d\n", xPos, yPos);
|
||||
if (bt == 4) {
|
||||
upDownOfsetFile(5);
|
||||
} else if (bt == 5) {
|
||||
upDownOfsetFile(-5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
// change the type of interpretation the file
|
||||
case 't':
|
||||
case 'T':
|
||||
nextType();
|
||||
break;
|
||||
// change the size of showing the file
|
||||
case 's':
|
||||
case 'S':
|
||||
nextTypeSize();
|
||||
break;
|
||||
// find the first ERROR
|
||||
case 'f':
|
||||
case 'F':
|
||||
// try to find the first error...
|
||||
first_Error = findFirstDiff();
|
||||
setOfsetFile((first_Error/16)*16 - 128);
|
||||
needRedraw();
|
||||
break;
|
||||
// find the first ERROR
|
||||
case 'a':
|
||||
case 'A':
|
||||
setOfsetFile(0);
|
||||
break;
|
||||
// go to the end of the file (File 1 and next File 2)
|
||||
case 'z':
|
||||
case 'Z':
|
||||
{
|
||||
UpdateFilesSize();
|
||||
static bool whichElement = false;
|
||||
if (whichElement == false) {
|
||||
whichElement = true;
|
||||
setOfsetFile((fileProp[0].size/16)*16 - 256);
|
||||
} else {
|
||||
whichElement = false;
|
||||
setOfsetFile((fileProp[1].size/16)*16 - 256);
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Reload the 2 files
|
||||
case 'r':
|
||||
case 'R':
|
||||
CloseFiles();
|
||||
UpdateNumberOfRawAndColomn();
|
||||
CleanDisplay();
|
||||
OpenFiles();
|
||||
needRedraw();
|
||||
break;
|
||||
// Display Slot mode :
|
||||
case 'j':
|
||||
case 'J':
|
||||
setSlotDisplayMode((getSlotDisplayMode()==true)?false:true);
|
||||
needRedraw();
|
||||
break;
|
||||
case 'U':
|
||||
setSlotSize(getSlotSize()-9);
|
||||
case 'u':
|
||||
setSlotSize(getSlotSize()-1);
|
||||
needRedraw();
|
||||
break;
|
||||
case 'I':
|
||||
setSlotSize(getSlotSize()+9);
|
||||
case 'i':
|
||||
setSlotSize(getSlotSize()+1);
|
||||
needRedraw();
|
||||
break;
|
||||
case 'k':
|
||||
case 'K':
|
||||
setSlotSize(0);
|
||||
setSlotDisplayMode(false);
|
||||
needRedraw();
|
||||
break;
|
||||
// Add padding offset between left an right file
|
||||
case 'o':
|
||||
displayPaddingOffset(-1);
|
||||
break;
|
||||
case 'O':
|
||||
displayPaddingOffset(-16);
|
||||
break;
|
||||
case 'p':
|
||||
displayPaddingOffset(1);
|
||||
break;
|
||||
case 'P':
|
||||
displayPaddingOffset(16);
|
||||
break;
|
||||
// Clear the padding
|
||||
case 'm':
|
||||
case 'M':
|
||||
displayPaddingOffsetClear();
|
||||
break;
|
||||
case 'c':
|
||||
case 'C':
|
||||
AutoSetPadding();
|
||||
break;
|
||||
case 'h':
|
||||
case 'H':
|
||||
setHelpDisplay((getHelpDisplay()==true)?false:true);
|
||||
needRedraw();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf (stderr, "%s", strerror (ret));
|
||||
}
|
||||
|
||||
exit_programme :
|
||||
if (NULL != filePointer[0])
|
||||
{
|
||||
fclose(filePointer[0]);
|
||||
}
|
||||
if (NULL != filePointer[1])
|
||||
{
|
||||
fclose(filePointer[1]);
|
||||
}
|
||||
|
||||
// remettre la lecture des données canonique
|
||||
system("stty icanon");
|
||||
// repositionnement de l'écho des caractères
|
||||
system("stty echo");
|
||||
return 0;
|
||||
CloseFiles();
|
||||
|
||||
// disable mouse event ...
|
||||
printf(MOUSE_REPORTING_DISABLE);
|
||||
// Back cursor ON ...
|
||||
printf(CURSOR_DISPLAY_ENABLE);
|
||||
// remettre la lecture des données canonique
|
||||
system("stty icanon");
|
||||
// repositionnement de l'écho des caractères
|
||||
system("stty echo");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -279,128 +574,81 @@ exit_programme :
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void displayCouleurBash(void)
|
||||
{
|
||||
/* Initialise the main variables
|
||||
* colour: for the 256 colours (0-255)
|
||||
* space: to insert space or newline
|
||||
*/
|
||||
/* Initialise the main variables
|
||||
* colour: for the 256 colours (0-255)
|
||||
* space: to insert space or newline
|
||||
*/
|
||||
|
||||
int colour = 0;
|
||||
int espace = 0;
|
||||
int colour = 0;
|
||||
int espace = 0;
|
||||
|
||||
/* Print the 16 first colours, known as colours system */
|
||||
/* Print the 16 first colours, known as colours system */
|
||||
|
||||
printf("System colours:\n");
|
||||
for( ; colour < 16; colour++)
|
||||
{
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
printf("System colours:\n");
|
||||
for( ; colour < 16; colour++) {
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
|
||||
/* The 216 colours */
|
||||
/* The 216 colours */
|
||||
|
||||
printf("Color cube: 6x6x6\n");
|
||||
for ( ; colour < 232; colour++, espace++)
|
||||
{
|
||||
if ((espace%6) == 0)
|
||||
{
|
||||
printf("\e[0m ");
|
||||
}
|
||||
if ((espace%36 == 0))
|
||||
{
|
||||
printf("\e[0m\n");
|
||||
}
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
printf("Color cube: 6x6x6\n");
|
||||
for ( ; colour < 232; colour++, espace++) {
|
||||
if ((espace%6) == 0) {
|
||||
printf("\e[0m ");
|
||||
}
|
||||
if ((espace%36 == 0)) {
|
||||
printf("\e[0m\n");
|
||||
}
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
|
||||
/* And the grey colours */
|
||||
/* And the grey colours */
|
||||
|
||||
printf("Greyscale ramp\n");
|
||||
for ( ; colour < 256; colour++)
|
||||
{
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
printf("Greyscale ramp\n");
|
||||
for ( ; colour < 256; colour++) {
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
|
||||
/* Initialise the main variables
|
||||
* colour: for the 256 colours (0-255)
|
||||
* space: to insert space or newline
|
||||
*/
|
||||
/* Initialise the main variables
|
||||
* colour: for the 256 colours (0-255)
|
||||
* space: to insert space or newline
|
||||
*/
|
||||
|
||||
|
||||
/* Print the 16 first colours, known as colours system */
|
||||
/* Print the 16 first colours, known as colours system */
|
||||
|
||||
printf("System colours:\n");
|
||||
for( ; colour < 16; colour++)
|
||||
{
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
printf("System colours:\n");
|
||||
for( ; colour < 16; colour++) {
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
|
||||
/* The 216 colours */
|
||||
/* The 216 colours */
|
||||
|
||||
printf("Color cube: 6x6x6\n");
|
||||
for ( ; colour < 232; colour++, espace++)
|
||||
{
|
||||
if ((espace%6) == 0)
|
||||
{
|
||||
printf("\e[0m ");
|
||||
}
|
||||
if ((espace%36 == 0))
|
||||
{
|
||||
printf("\e[0m\n");
|
||||
}
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
printf("Color cube: 6x6x6\n");
|
||||
for ( ; colour < 232; colour++, espace++) {
|
||||
if ((espace%6) == 0) {
|
||||
printf("\e[0m ");
|
||||
}
|
||||
if ((espace%36 == 0)) {
|
||||
printf("\e[0m\n");
|
||||
}
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
|
||||
/* And the grey colours */
|
||||
/* And the grey colours */
|
||||
|
||||
printf("Greyscale ramp\n");
|
||||
for ( ; colour < 256; colour++)
|
||||
{
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
printf("Greyscale ramp\n");
|
||||
for ( ; colour < 256; colour++) {
|
||||
printf("\e[48;5;%dm ", colour);
|
||||
}
|
||||
printf("\e[0m\n\n");
|
||||
|
||||
|
||||
}
|
||||
|
331
parameter.c
331
parameter.c
@ -1,11 +1,11 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parameter.c
|
||||
* @brief Editeur De N'ours :
|
||||
* @brief Parameters area (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/02/2011
|
||||
* @par Project
|
||||
* Edn tool : hexViewer
|
||||
* hexViewer
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
@ -13,20 +13,18 @@
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
* Licence : GNU Lesser General Public License (LGPL) v3.0
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "parameter.h"
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
// Parameter Local Value :
|
||||
|
||||
static U32 fileOfset = 0;
|
||||
static uint32_t fileOfset = 0;
|
||||
static uint32_t paddingOffset = 0;
|
||||
static bool parmamModifier = true;
|
||||
|
||||
|
||||
@ -34,115 +32,266 @@ static showType_te curentType = SHOW_TYPE_HEX;
|
||||
static showTypeSize_te curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||
|
||||
|
||||
extern U32 filesize[2];
|
||||
extern fileProperties_ts fileProp[2];
|
||||
|
||||
void setOfsetFile(I32 offset)
|
||||
void CleanDisplay(void)
|
||||
{
|
||||
if (0 > offset)
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
if ( offset > (I32)filesize[0]
|
||||
&& offset > (I32)filesize[1])
|
||||
{
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
if (offset != (I32)fileOfset)
|
||||
{
|
||||
fileOfset = (U32)offset;
|
||||
parmamModifier = true;
|
||||
}
|
||||
//system("clear");
|
||||
UpdateNumberOfRawAndColomn();
|
||||
printf(GO_TOP);
|
||||
for (int32_t iii=0; iii< GetNumberOfRaw(); iii++) {
|
||||
for (int32_t jjj=0; jjj < GetNumberOfColomn()-1; jjj++) {
|
||||
printf(" ");
|
||||
}
|
||||
if (iii< GetNumberOfRaw()-1) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
printf(GO_TOP);
|
||||
}
|
||||
|
||||
void upDownOfsetFile(I32 offset)
|
||||
|
||||
|
||||
|
||||
void setOfsetFile(int32_t offset)
|
||||
{
|
||||
I32 tmp;
|
||||
tmp = fileOfset + (16 * offset);
|
||||
if (0 > tmp)
|
||||
{
|
||||
setOfsetFile(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
setOfsetFile(tmp);
|
||||
}
|
||||
if (0 > offset) {
|
||||
offset = 0;
|
||||
}
|
||||
if( offset > (int32_t)fileProp[0].size
|
||||
&& offset > (int32_t)fileProp[1].size) {
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
if (offset != (int32_t)fileOfset) {
|
||||
fileOfset = (uint32_t)offset;
|
||||
parmamModifier = true;
|
||||
}
|
||||
}
|
||||
|
||||
U32 getOfsetFile(void)
|
||||
void upDownOfsetFile(int32_t offset)
|
||||
{
|
||||
return fileOfset;
|
||||
int32_t tmp;
|
||||
tmp = fileOfset + (16 * offset);
|
||||
if (0 > tmp) {
|
||||
setOfsetFile(0);
|
||||
} else {
|
||||
setOfsetFile(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getOfsetFile(void)
|
||||
{
|
||||
return fileOfset;
|
||||
}
|
||||
|
||||
void displayPaddingOffset(int32_t size)
|
||||
{
|
||||
paddingOffset += size;
|
||||
parmamModifier = true;
|
||||
}
|
||||
|
||||
void displayPaddingOffsetClear(void)
|
||||
{
|
||||
paddingOffset = 0;
|
||||
parmamModifier = true;
|
||||
}
|
||||
|
||||
int32_t getPaddingOffsetFile(void)
|
||||
{
|
||||
return paddingOffset;
|
||||
}
|
||||
|
||||
|
||||
bool getParamModification()
|
||||
{
|
||||
if (parmamModifier == true)
|
||||
{
|
||||
parmamModifier = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (parmamModifier == true) {
|
||||
parmamModifier = false;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void needRedraw(void) {
|
||||
parmamModifier = true;
|
||||
}
|
||||
|
||||
void nextType(void)
|
||||
{
|
||||
switch(curentType)
|
||||
{
|
||||
case SHOW_TYPE_HEX:
|
||||
curentType = SHOW_TYPE_DECIMAL_SIGNED;
|
||||
break;
|
||||
case SHOW_TYPE_DECIMAL_SIGNED:
|
||||
curentType = SHOW_TYPE_DECIMAL_UNSIGNED;
|
||||
break;
|
||||
case SHOW_TYPE_DECIMAL_UNSIGNED:
|
||||
curentType = SHOW_TYPE_HEX;
|
||||
break;
|
||||
default :
|
||||
curentType = SHOW_TYPE_HEX;
|
||||
break;
|
||||
}
|
||||
system("clear");
|
||||
parmamModifier = true;
|
||||
switch(curentType)
|
||||
{
|
||||
case SHOW_TYPE_HEX:
|
||||
curentType = SHOW_TYPE_DECIMAL_SIGNED;
|
||||
break;
|
||||
case SHOW_TYPE_DECIMAL_SIGNED:
|
||||
curentType = SHOW_TYPE_DECIMAL_UNSIGNED;
|
||||
break;
|
||||
case SHOW_TYPE_DECIMAL_UNSIGNED:
|
||||
curentType = SHOW_TYPE_HEX;
|
||||
break;
|
||||
default :
|
||||
curentType = SHOW_TYPE_HEX;
|
||||
break;
|
||||
}
|
||||
CleanDisplay();
|
||||
parmamModifier = true;
|
||||
}
|
||||
|
||||
showType_te getType(void)
|
||||
{
|
||||
return curentType;
|
||||
return curentType;
|
||||
}
|
||||
|
||||
void setType(showType_te newType)
|
||||
{
|
||||
curentType = newType;
|
||||
parmamModifier = true;
|
||||
}
|
||||
|
||||
void nextTypeSize(void)
|
||||
{
|
||||
switch(curentTypeSize)
|
||||
{
|
||||
case SHOW_TYPE_SIZE_8:
|
||||
curentTypeSize = SHOW_TYPE_SIZE_16;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_16:
|
||||
curentTypeSize = SHOW_TYPE_SIZE_32;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_32:
|
||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_64:
|
||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_128:
|
||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||
break;
|
||||
default :
|
||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||
break;
|
||||
}
|
||||
system("clear");
|
||||
parmamModifier = true;
|
||||
switch(curentTypeSize)
|
||||
{
|
||||
case SHOW_TYPE_SIZE_8:
|
||||
curentTypeSize = SHOW_TYPE_SIZE_16;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_16:
|
||||
curentTypeSize = SHOW_TYPE_SIZE_32;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_32:
|
||||
curentTypeSize = SHOW_TYPE_SIZE_64;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_64:
|
||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||
break;
|
||||
case SHOW_TYPE_SIZE_128:
|
||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||
break;
|
||||
default :
|
||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||
break;
|
||||
}
|
||||
CleanDisplay();
|
||||
parmamModifier = true;
|
||||
}
|
||||
|
||||
showTypeSize_te getTypeSize(void)
|
||||
{
|
||||
return curentTypeSize;
|
||||
return curentTypeSize;
|
||||
}
|
||||
void setTypeSize(showTypeSize_te newType)
|
||||
{
|
||||
curentTypeSize = newType;
|
||||
parmamModifier = true;
|
||||
}
|
||||
|
||||
|
||||
int32_t nbRaw = 20;
|
||||
int32_t nbColomn = 70;
|
||||
|
||||
void UpdateNumberOfRawAndColomn(void)
|
||||
{
|
||||
struct winsize w;
|
||||
ioctl(0, TIOCGWINSZ, &w);
|
||||
nbRaw = w.ws_row;
|
||||
nbColomn = w.ws_col;
|
||||
}
|
||||
|
||||
|
||||
int32_t GetNumberOfRaw(void)
|
||||
{
|
||||
return nbRaw;
|
||||
}
|
||||
|
||||
int32_t GetNumberOfColomn(void)
|
||||
{
|
||||
return nbColomn;
|
||||
}
|
||||
|
||||
|
||||
int32_t slotSize = -1;
|
||||
bool slotEnable = false;
|
||||
int32_t getSlotSize(void)
|
||||
{
|
||||
if (true == slotEnable) {
|
||||
return slotSize;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void setSlotSize(int32_t newSize)
|
||||
{
|
||||
if (newSize<0) {
|
||||
newSize = 0;
|
||||
}
|
||||
slotSize = newSize;
|
||||
}
|
||||
|
||||
void setSlotDisplayMode(bool enable)
|
||||
{
|
||||
slotEnable = enable;
|
||||
}
|
||||
bool getSlotDisplayMode(void)
|
||||
{
|
||||
return slotEnable;
|
||||
}
|
||||
|
||||
bool displayHelp = false;
|
||||
void setHelpDisplay(bool enable)
|
||||
{
|
||||
displayHelp = enable;
|
||||
}
|
||||
bool getHelpDisplay(void)
|
||||
{
|
||||
return displayHelp;
|
||||
}
|
||||
|
||||
void cleanLine(void)
|
||||
{
|
||||
printf(" | | \r");
|
||||
}
|
||||
void endLine(void)
|
||||
{
|
||||
printf(" |-----------------------------------------------------------------------------------------------------------------------------------| \n");
|
||||
}
|
||||
void usage(void)
|
||||
{
|
||||
cleanLine(); printf(" | usage : hexViwer [option] [file_1] [file_2]\n");
|
||||
cleanLine(); printf("\t[option] : options:\n");
|
||||
cleanLine(); printf("\t\t[-d] : direct check of the error ...\n");
|
||||
cleanLine(); printf("\t[file_1] : Show the first file only\n");
|
||||
cleanLine(); printf("\t[file_2] : if it was precise : Show the comparaison with the first file\n");
|
||||
cleanLine(); printf("\t\n");
|
||||
cleanLine(); printf("\tInside Usage : \n");
|
||||
cleanLine(); printf("\t\t[h] diplay/Hide Help\n");
|
||||
cleanLine(); printf("\t\t[a] Go to the start of the files\n");
|
||||
cleanLine(); printf("\t\t[z] Go to the end of the files (the first push is the File 1, the second push is the file 2) \n");
|
||||
cleanLine(); printf("\t\t[q] Quit the curent program\n");
|
||||
cleanLine(); printf("\t\t[s] Change the view of the propram of the size of interpretation (8/16/32/64 bits)\n");
|
||||
cleanLine(); printf("\t\t[t] Change the interpretation of Data (hexedecimal, Signed Decimal, Unigned Decimal)\n");
|
||||
cleanLine(); printf("\t\t[f] Find the first Error when comparing the two files\n");
|
||||
cleanLine(); printf("\t\t[c] Calibrate the delta between the 2 file (fist element !=0)\n");
|
||||
cleanLine(); printf("\t\t[UP] Go up (5 lines)\n");
|
||||
cleanLine(); printf("\t\t[DOWN] Go down (5 lines)\n");
|
||||
cleanLine(); printf("\t\t[LEFT] Go up (one screen)\n");
|
||||
cleanLine(); printf("\t\t[RIGHT] Go down (one screen)\n");
|
||||
cleanLine(); printf("\t\tAdd padding : \n");
|
||||
cleanLine(); printf("\t\t\t[o] Add 1 Byte padding at the left file\n");
|
||||
cleanLine(); printf("\t\t\t[O] Add 16 Bytes padding at the left file\n");
|
||||
cleanLine(); printf("\t\t\t[p] Add 1 Byte padding at the right file\n");
|
||||
cleanLine(); printf("\t\t\t[P] Add 16 Bytes padding at the right file\n");
|
||||
cleanLine(); printf("\t\t\t[m] reset padding\n");
|
||||
cleanLine(); printf("\t\tdiplay slot element\n");
|
||||
cleanLine(); printf("\t\t\t[j] enable/disabe slot display\n");
|
||||
cleanLine(); printf("\t\t\t[u] Decrement slot size -1 \n");
|
||||
cleanLine(); printf("\t\t\t[U] Decrement slot size -10 \n");
|
||||
cleanLine(); printf("\t\t\t[i] Increment slot size +1 \n");
|
||||
cleanLine(); printf("\t\t\t[I] Increment slot size +10\n");
|
||||
cleanLine(); printf("\t\t\t[k] Reset slot display\n");
|
||||
cleanLine(); printf("\t\n");
|
||||
cleanLine(); printf("\tCopyright: 2010 Edouard DUPIN, all right reserved\n");
|
||||
cleanLine(); printf("\tLicense: GNU Lesser General Public License (LGPL) v3.0\n");
|
||||
endLine();
|
||||
}
|
||||
|
||||
|
||||
|
53
parameter.h
53
parameter.h
@ -1,26 +1,19 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parameter.h
|
||||
* @brief Editeur De N'ours :
|
||||
* @brief Parameters area (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/02/2011
|
||||
* @par Project
|
||||
* Edn tool : hexViewer
|
||||
* hexViewer
|
||||
*
|
||||
* @version $Id$
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This 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 software 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.
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence : GNU Lesser General Public License (LGPL) v3.0
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -30,17 +23,45 @@
|
||||
|
||||
#include "generalDefine.h"
|
||||
|
||||
void setOfsetFile(I32 offset);
|
||||
void upDownOfsetFile(I32 offset);
|
||||
U32 getOfsetFile(void);
|
||||
void setOfsetFile(int32_t offset);
|
||||
void upDownOfsetFile(int32_t offset);
|
||||
uint32_t getOfsetFile(void);
|
||||
|
||||
bool getParamModification();
|
||||
|
||||
void needRedraw(void);
|
||||
void nextType(void);
|
||||
showType_te getType(void);
|
||||
void setType(showType_te newType);
|
||||
|
||||
void nextTypeSize(void);
|
||||
showTypeSize_te getTypeSize(void);
|
||||
void setTypeSize(showTypeSize_te newType);
|
||||
|
||||
void displayPaddingOffset(int32_t size);
|
||||
void displayPaddingOffsetClear(void);
|
||||
int32_t getPaddingOffsetFile(void);
|
||||
|
||||
|
||||
#define NB_HEARDER_RAW (8)
|
||||
|
||||
void UpdateNumberOfRawAndColomn(void);
|
||||
int32_t GetNumberOfRaw(void);
|
||||
int32_t GetNumberOfColomn(void);
|
||||
|
||||
void CleanDisplay(void);
|
||||
|
||||
// if 0 ==> disable ...
|
||||
int32_t getSlotSize(void);
|
||||
void setSlotSize(int32_t newSize);
|
||||
void setSlotDisplayMode(bool enable);
|
||||
bool getSlotDisplayMode(void);
|
||||
|
||||
|
||||
|
||||
void setHelpDisplay(bool enable);
|
||||
bool getHelpDisplay(void);
|
||||
|
||||
void usage(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user