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 #
|
# 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
|
CFLAGS= -g -Wall -D_REENTRANT
|
||||||
|
|
||||||
@ -37,38 +28,22 @@ LIB= -lpthread -lm
|
|||||||
CC= g++ $(CFLAGS)
|
CC= g++ $(CFLAGS)
|
||||||
LD= g++
|
LD= g++
|
||||||
|
|
||||||
# Liste des fichiers
|
# List of Sources
|
||||||
SRC=main.c \
|
SRC=main.c \
|
||||||
display.c \
|
display.c \
|
||||||
parameter.c
|
parameter.c
|
||||||
|
|
||||||
# Liste des objets
|
# List of Objects
|
||||||
OBJ= $(SRC:.c=.o)
|
OBJ= $(SRC:.c=.o)
|
||||||
|
|
||||||
# Liste des dépendances
|
# List of dependances
|
||||||
DEP= $(SRC:.c=.d)
|
DEP= $(SRC:.c=.d)
|
||||||
|
|
||||||
|
PROG_NAME=hexViewer
|
||||||
|
|
||||||
#
|
|
||||||
BIN=hexViewer
|
|
||||||
|
|
||||||
.PHONY: all
|
.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
|
%.o: %.c
|
||||||
@echo $(F_VERT)" (.o) $<"$(F_NORMALE)
|
@echo $(F_VERT)" (.o) $<"$(F_NORMALE)
|
||||||
@$(CC) -o $@ -c $<
|
@$(CC) -o $@ -c $<
|
||||||
@ -76,18 +51,52 @@ endif
|
|||||||
%.d: %.c
|
%.d: %.c
|
||||||
@echo $(F_BLUE)" (.d) $<"$(F_NORMALE)
|
@echo $(F_BLUE)" (.d) $<"$(F_NORMALE)
|
||||||
@$(CC) -MM -MD -o $@ $<
|
@$(CC) -MM -MD -o $@ $<
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
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)
|
@echo $(F_ROUGE)" (bin) $@"$(F_NORMALE)
|
||||||
@$(LD) -o $@ $^ $(LIB)
|
@$(LD) -o $@ $^ $(LIB)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# inclusion des dependances
|
# inclusion des dependances
|
||||||
-include $(DEP)
|
-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.
|
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:
|
License: GNU General Public License (GPL) v3.0
|
||||||
- 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
|
|
||||||
|
11
display.h
11
display.h
@ -1,11 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
* @file display.h
|
* @file display.h
|
||||||
* @brief Editeur De N'ours :
|
* @brief main display system of the hexViewer (Header)
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
* @date 05/02/2011
|
* @date 05/02/2011
|
||||||
* @par Project
|
* @par Project
|
||||||
* Edn tool : hexViewer
|
* hexViewer
|
||||||
*
|
*
|
||||||
* @par Copyright
|
* @par Copyright
|
||||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
* 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
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY.
|
* ANY WARRANTY.
|
||||||
*
|
*
|
||||||
* Licence summary :
|
* Licence : GNU Lesser General Public License (LGPL) v3.0
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
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
|
* @file generalDefine.h
|
||||||
* @brief Editeur De N'ours :
|
* @brief generic basic defines
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
* @date 05/02/2011
|
* @date 05/02/2011
|
||||||
* @par Project
|
* @par Project
|
||||||
* Edn tool : hexViewer
|
* hexViewer
|
||||||
*
|
*
|
||||||
* @par Copyright
|
* @par Copyright
|
||||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
* 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
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY.
|
* ANY WARRANTY.
|
||||||
*
|
*
|
||||||
* Licence summary :
|
* Licence : GNU Lesser General Public License (LGPL) v3.0
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
@ -32,16 +27,16 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
typedef unsigned char U8;
|
typedef unsigned char uint8_t;
|
||||||
typedef signed char I8;
|
typedef signed char int8_t;
|
||||||
typedef unsigned short int U16;
|
typedef unsigned short int uint16_t;
|
||||||
typedef signed short int I16;
|
typedef signed short int int16_t;
|
||||||
typedef unsigned long int U32;
|
typedef unsigned long int uint32_t;
|
||||||
typedef signed long int I32;
|
//typedef signed long int int32_t;
|
||||||
typedef unsigned long long int U64;
|
typedef unsigned long long int uint64_t;
|
||||||
typedef signed long long int I64;
|
//typedef signed long long int int64_t;
|
||||||
//typedef unsigned long long long int U128;
|
//typedef unsigned long long long int uint128_t;
|
||||||
//typedef signed long long long int I128;
|
//typedef signed long long long int int128_t;
|
||||||
|
|
||||||
//regular colors
|
//regular colors
|
||||||
#define COLOR_BLACK "\e[0;30m"
|
#define COLOR_BLACK "\e[0;30m"
|
||||||
@ -75,18 +70,22 @@ typedef signed long long int I64;
|
|||||||
// Return to the normal color setings
|
// Return to the normal color setings
|
||||||
#define COLOR_NORMAL "\e[0m"
|
#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
|
//go to the Top of bash
|
||||||
#define GO_TOP "\e[0;0f"
|
#define GO_TOP "\e[0;0f"
|
||||||
|
|
||||||
|
|
||||||
#define NB_DATA_PER_LINE (4)
|
#define NB_DATA_PER_LINE (4)
|
||||||
#define NB_MAX_LINE (50)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
SHOW_TYPE_UNKNOW,
|
||||||
SHOW_TYPE_HEX,
|
SHOW_TYPE_HEX,
|
||||||
SHOW_TYPE_DECIMAL_SIGNED,
|
SHOW_TYPE_DECIMAL_SIGNED,
|
||||||
SHOW_TYPE_DECIMAL_UNSIGNED
|
SHOW_TYPE_DECIMAL_UNSIGNED
|
||||||
@ -94,12 +93,26 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
SHOW_TYPE_SIZE_UNKNOW,
|
||||||
SHOW_TYPE_SIZE_8,
|
SHOW_TYPE_SIZE_8,
|
||||||
SHOW_TYPE_SIZE_16,
|
SHOW_TYPE_SIZE_16,
|
||||||
SHOW_TYPE_SIZE_32,
|
SHOW_TYPE_SIZE_32,
|
||||||
SHOW_TYPE_SIZE_64,
|
SHOW_TYPE_SIZE_64,
|
||||||
SHOW_TYPE_SIZE_128
|
SHOW_TYPE_SIZE_128,
|
||||||
|
SHOW_TYPE_SIZE_FLOAT,
|
||||||
|
SHOW_TYPE_SIZE_DOUBLE
|
||||||
} showTypeSize_te;
|
} 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
|
#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
|
* @file main.c
|
||||||
* @brief Editeur De N'ours :
|
* @brief Main function (sources)
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
* @date 05/02/2011
|
* @date 05/02/2011
|
||||||
* @par Project
|
* @par Project
|
||||||
* Edn tool : hexViewer
|
* hexViewer
|
||||||
*
|
*
|
||||||
* @version $Id$
|
|
||||||
*
|
|
||||||
* @par Copyright
|
* @par Copyright
|
||||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
* 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
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* ANY WARRANTY.
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
*
|
||||||
* for more details.
|
* Licence : GNU Lesser General Public License (LGPL) v3.0
|
||||||
*
|
*
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
@ -29,248 +22,550 @@
|
|||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
|
|
||||||
|
fileProperties_ts fileProp[2];
|
||||||
|
|
||||||
FILE *filePointer[2] = {NULL, NULL};
|
int32_t findFirstDiff(void)
|
||||||
U32 filesize[2] = {0, 0};
|
|
||||||
char fileName[2][2096] = {"",""};
|
|
||||||
|
|
||||||
void usage(void)
|
|
||||||
{
|
{
|
||||||
printf("usage : hexViwer [file_1] [file_2]\n");
|
uint8_t data1, data2;
|
||||||
printf("\t[file_1] : Show the first file only\n");
|
int32_t offset = 0;
|
||||||
printf("\t[file_2] : if it was precise : Show the comparaison with the first file\n");
|
if( NULL == fileProp[0].pointer
|
||||||
printf("\t\n");
|
|| NULL == fileProp[1].pointer ) {
|
||||||
printf("\tInside Usage : \n");
|
return 0;
|
||||||
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");
|
int32_t paddingFile = getPaddingOffsetFile();
|
||||||
printf("\t\t[q] Quit the curent program\n");
|
int32_t pad1 = 0;
|
||||||
printf("\t\t[s] Change the view of the propram of the size of interpretation (8 bits, 16 bits, 32 bits)\n");
|
int32_t pad2 = 0;
|
||||||
printf("\t\t[t] Change the interpretation of Data (hexedecimal, Signed Decimal, Unigned Decimal)\n");
|
if (paddingFile>0) {
|
||||||
printf("\t\t[f] Find the first Error when comparing the two files\n");
|
pad1 = paddingFile;
|
||||||
printf("\t\t[UP] Go up 5 line in the view\n");
|
pad2 = 0;
|
||||||
printf("\t\t[DOWN] Go down 5 line in the view\n");
|
} else {
|
||||||
printf("\t\t[LEFT] Go up 50 line in the view (one screen)\n");
|
pad1 = 0;
|
||||||
printf("\t\t[RIGHT] Go down 50 line in the view (one screen)\n");
|
pad2 = -1*paddingFile;
|
||||||
printf("\t\n");
|
}
|
||||||
printf("\tTODO : \n");
|
if(NULL != fileProp[0].pointer) {
|
||||||
printf("\t\t- The print of 128 bytes\n");
|
fseek ( fileProp[0].pointer , pad1+fileProp[0].fileBasicOffset , SEEK_SET );
|
||||||
printf("\t\t- The print in Octal\n");
|
}
|
||||||
printf("\t\t- The print in Binary\n");
|
if(NULL != fileProp[1].pointer) {
|
||||||
printf("\t\t- The Modification of the file\n");
|
fseek ( fileProp[1].pointer , pad2+fileProp[1].fileBasicOffset , SEEK_SET );
|
||||||
printf("\t\t- The Saving of the file\n");
|
}
|
||||||
printf("\t\t- The information that one of the files has been update\n");
|
while ( fread(&data1, sizeof(uint8_t), 1, fileProp[0].pointer) == 1
|
||||||
printf("\t\t- To reload the two files ==> [U]\n");
|
&& fread(&data2, sizeof(uint8_t), 1, fileProp[1].pointer) == 1)
|
||||||
printf("\t\t- The windows scroling with the mouse\n");
|
{
|
||||||
printf("\t\t- The selection with the mouse\n");
|
offset ++;
|
||||||
printf("\t\t- The display on char view\n");
|
if (data1 != data2) {
|
||||||
printf("\t\t- The scroling Bar on the right\n");
|
return offset;
|
||||||
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");
|
return offset;
|
||||||
/*printf("\t\t- \n");*/
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void UpdateFilesSize(void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
I32 findFirstDiff(void)
|
|
||||||
{
|
{
|
||||||
U8 data1, data2;
|
// get size for 2 files
|
||||||
I32 offset = 0;
|
int32_t iii=0;
|
||||||
|
for (iii=0; iii<2; iii++) {
|
||||||
while ( fread(&data1, sizeof(U8), 1, filePointer[0]) == 1
|
if ( NULL != fileProp[iii].pointer) {
|
||||||
&& fread(&data2, sizeof(U8), 1, filePointer[1]) == 1)
|
fseek ( fileProp[iii].pointer , 0 , SEEK_END );
|
||||||
{
|
fileProp[iii].size = ftell (fileProp[iii].pointer) - fileProp[iii].fileBasicOffset;
|
||||||
offset ++;
|
fseek ( fileProp[iii].pointer , 0 , SEEK_SET );
|
||||||
if (data1 != data2)
|
}
|
||||||
{
|
}
|
||||||
return offset;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
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)
|
int main (int argc, char**argv)
|
||||||
{
|
{
|
||||||
I32 first_Error = 0;
|
int32_t first_Error = 0;
|
||||||
if (2 == argc)
|
ResetProperties();
|
||||||
{
|
UpdateNumberOfRawAndColomn();
|
||||||
filePointer[0] = fopen(argv[1], "rb");
|
// check error
|
||||||
strcpy(fileName[0], argv[1]);
|
if (argc < 2) {
|
||||||
if ( NULL == filePointer[0])
|
printf("You set more than 3 argument at the commande line\n");
|
||||||
{
|
usage();
|
||||||
printf("Can not Open [File_1] = %s\n", argv[1]);
|
return -1;
|
||||||
usage();
|
}
|
||||||
return -1;
|
bool directCheckFiles = false;
|
||||||
}
|
int basicIDParsing = 1;
|
||||||
}
|
if (0==strcmp("-d",argv[1])) {
|
||||||
else if (3 == argc)
|
basicIDParsing++;
|
||||||
{
|
directCheckFiles = true;
|
||||||
filePointer[0] = fopen(argv[1], "rb");
|
}
|
||||||
strcpy(fileName[0], argv[1]);
|
// one file
|
||||||
filePointer[1] = fopen(argv[2], "rb");
|
if (basicIDParsing+1 <= argc) {
|
||||||
strcpy(fileName[1], argv[2]);
|
strcpy(fileProp[0].name, argv[basicIDParsing]);
|
||||||
fseek ( filePointer[0] , 0 , SEEK_END );
|
fileProp[0].availlable = true;
|
||||||
fseek ( filePointer[1] , 0 , SEEK_END );
|
}
|
||||||
filesize[0] = ftell (filePointer[0]);
|
// a second file
|
||||||
filesize[1] = ftell (filePointer[1]);
|
if (basicIDParsing+2 <= argc) {
|
||||||
fseek ( filePointer[0] , 0 , SEEK_SET );
|
strcpy(fileProp[1].name, argv[basicIDParsing+1]);
|
||||||
fseek ( filePointer[1] , 0 , SEEK_SET );
|
fileProp[1].availlable = true;
|
||||||
first_Error = findFirstDiff();
|
}
|
||||||
}
|
// open the files
|
||||||
else
|
OpenFiles();
|
||||||
{
|
|
||||||
usage();
|
// user requested to have the direct error ID of the file...
|
||||||
return -1;
|
if (directCheckFiles==true) {
|
||||||
}
|
|
||||||
|
float dividor = 1;
|
||||||
// rendre la lecture des données non canonique
|
int32_t maxSlot = (fileProp[0].slotSize>fileProp[1].slotSize)?fileProp[0].slotSize:fileProp[1].slotSize;
|
||||||
system("stty -icanon");
|
if (0!=maxSlot) {
|
||||||
// supression de l'écho des caractères
|
dividor = maxSlot;
|
||||||
system("stty -echo");
|
}
|
||||||
|
|
||||||
system("clear");
|
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();
|
||||||
printf(GO_TOP);
|
// 0 : no error
|
||||||
|
return 0;
|
||||||
if ( NULL != filePointer[0]
|
} else {
|
||||||
&& NULL == filePointer[1] )
|
int32_t sizeElement = 1;
|
||||||
{
|
showTypeSize_te tmpType = getTypeSize();
|
||||||
showFile(filePointer[0] ,CurentFilePosition);
|
switch(tmpType)
|
||||||
}
|
{
|
||||||
else if ( NULL != filePointer[0]
|
default:
|
||||||
&& NULL != filePointer[1] )
|
case SHOW_TYPE_SIZE_8:
|
||||||
{
|
sizeElement = 1;
|
||||||
compareFile(filePointer[0],filePointer[1] ,CurentFilePosition);
|
break;
|
||||||
}
|
case SHOW_TYPE_SIZE_16:
|
||||||
*/
|
sizeElement = 2;
|
||||||
|
break;
|
||||||
|
case SHOW_TYPE_SIZE_FLOAT:
|
||||||
|
case SHOW_TYPE_SIZE_32:
|
||||||
|
sizeElement = 4;
|
||||||
|
break;
|
||||||
int ret = 0;
|
case SHOW_TYPE_SIZE_DOUBLE:
|
||||||
pthread_t HangleThreadDisplay;
|
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.
|
int ret = 0;
|
||||||
//printf ("Creation du thread du magasin !\n");
|
pthread_t HangleThreadDisplay;
|
||||||
ret = pthread_create ( & HangleThreadDisplay, NULL, threadDisplay, NULL );
|
|
||||||
if (! ret)
|
ret = pthread_create ( & HangleThreadDisplay, NULL, threadDisplay, NULL );
|
||||||
{
|
if (! ret)
|
||||||
while (1)
|
{
|
||||||
{
|
while (1)
|
||||||
U32 inputValue;
|
{
|
||||||
inputValue = getc (stdin);
|
int32_t inputValue;
|
||||||
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
|
inputValue = getc(stdin);
|
||||||
switch(inputValue)
|
switch(inputValue)
|
||||||
{
|
{
|
||||||
case 'q':
|
case 'q':
|
||||||
case 'Q':
|
case 'Q':
|
||||||
goto exit_programme;
|
goto exit_programme;
|
||||||
break;
|
break;
|
||||||
//case 0x1B:
|
//case 0x1B:
|
||||||
case '\e':
|
case '\e':
|
||||||
inputValue = getc (stdin);
|
inputValue = getc (stdin);
|
||||||
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
|
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
|
||||||
if (inputValue == 0x5B)
|
// [ == 0x5B
|
||||||
{
|
if (inputValue == '[')
|
||||||
inputValue = getc (stdin);
|
{
|
||||||
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
|
inputValue = getc (stdin);
|
||||||
if ( inputValue == 0x41
|
char charValue = inputValue;
|
||||||
|| inputValue == 0x42
|
// printf("\n get data : 0x%08x ..... : \\e[%c\n", (unsigned int)inputValue, charValue);
|
||||||
|| inputValue == 0x43
|
if ( charValue == 'A' //0x41 ==> UP
|
||||||
|| inputValue == 0x44)
|
|| charValue == 'B' //0x42 ==> DOWN
|
||||||
{
|
|| charValue == 'C' //0x43 ==> RIGHT
|
||||||
if (inputValue == 0x41)
|
|| charValue == 'D' //0x44 ==> LEFT
|
||||||
{
|
)
|
||||||
upDownOfsetFile(-5);
|
{
|
||||||
}
|
//printf("\n get data :\\e[%c ==> MoveKey \n", charValue);
|
||||||
else if ( inputValue == 0x42)
|
if (charValue == 'A') {
|
||||||
{
|
upDownOfsetFile(-5);
|
||||||
upDownOfsetFile(5);
|
} else if ( charValue == 'B') {
|
||||||
}
|
upDownOfsetFile(5);
|
||||||
else if ( inputValue == 0x43)
|
} else if ( charValue == 'C') {
|
||||||
{
|
upDownOfsetFile((GetNumberOfRaw()-NB_HEARDER_RAW));
|
||||||
upDownOfsetFile(NB_MAX_LINE);
|
} else if ( charValue == 'D') {
|
||||||
}
|
upDownOfsetFile(-(GetNumberOfRaw()-NB_HEARDER_RAW));
|
||||||
else if ( inputValue == 0x44)
|
}
|
||||||
{
|
} else if (charValue == 'M' ) { //0x4d ==> mouse
|
||||||
upDownOfsetFile(-NB_MAX_LINE);
|
//printf("\n get data :\\e[%c ==> Mouse \n", charValue);
|
||||||
}
|
int32_t button = getc(stdin);
|
||||||
}
|
int32_t xPos = getc(stdin);
|
||||||
}
|
xPos -= 0x20;
|
||||||
break;
|
int32_t yPos = getc(stdin);
|
||||||
// change the type of interpretation the file
|
yPos -= 0x20;
|
||||||
case 't':
|
|
||||||
case 'T':
|
int32_t bt=0;
|
||||||
nextType();
|
switch (button) {
|
||||||
break;
|
case 97:
|
||||||
// change the size of showing the file
|
bt = 4;
|
||||||
case 's':
|
break;
|
||||||
case 'S':
|
case 96:
|
||||||
nextTypeSize();
|
bt = 5;
|
||||||
break;
|
break;
|
||||||
// find the first ERROR
|
case 32:
|
||||||
case 'f':
|
bt = 1;
|
||||||
case 'F':
|
break;
|
||||||
setOfsetFile((first_Error/16)*16 - 256);
|
case 33:
|
||||||
break;
|
bt = 3;
|
||||||
// find the first ERROR
|
break;
|
||||||
case 'a':
|
}
|
||||||
case 'A':
|
//printf(" bt=%#x=%d \n", button, bt);
|
||||||
setOfsetFile(0);
|
//printf(" x=%d y=%d\n", xPos, yPos);
|
||||||
break;
|
if (bt == 4) {
|
||||||
// go to the end of the file (File 1 and next File 2)
|
upDownOfsetFile(5);
|
||||||
case 'z':
|
} else if (bt == 5) {
|
||||||
case 'Z':
|
upDownOfsetFile(-5);
|
||||||
{
|
}
|
||||||
static bool whichElement = false;
|
}
|
||||||
if (whichElement == false)
|
}
|
||||||
{
|
|
||||||
whichElement = true;
|
break;
|
||||||
setOfsetFile((filesize[0]/16)*16 - 256);
|
// change the type of interpretation the file
|
||||||
}
|
case 't':
|
||||||
else
|
case 'T':
|
||||||
{
|
nextType();
|
||||||
whichElement = false;
|
break;
|
||||||
setOfsetFile((filesize[1]/16)*16 - 256);
|
// change the size of showing the file
|
||||||
}
|
case 's':
|
||||||
}
|
case 'S':
|
||||||
break;
|
nextTypeSize();
|
||||||
}
|
break;
|
||||||
}
|
// find the first ERROR
|
||||||
}
|
case 'f':
|
||||||
else
|
case 'F':
|
||||||
{
|
// try to find the first error...
|
||||||
fprintf (stderr, "%s", strerror (ret));
|
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 :
|
exit_programme :
|
||||||
if (NULL != filePointer[0])
|
CloseFiles();
|
||||||
{
|
|
||||||
fclose(filePointer[0]);
|
// disable mouse event ...
|
||||||
}
|
printf(MOUSE_REPORTING_DISABLE);
|
||||||
if (NULL != filePointer[1])
|
// Back cursor ON ...
|
||||||
{
|
printf(CURSOR_DISPLAY_ENABLE);
|
||||||
fclose(filePointer[1]);
|
// remettre la lecture des données canonique
|
||||||
}
|
system("stty icanon");
|
||||||
|
// repositionnement de l'écho des caractères
|
||||||
// remettre la lecture des données canonique
|
system("stty echo");
|
||||||
system("stty icanon");
|
return 0;
|
||||||
// repositionnement de l'écho des caractères
|
|
||||||
system("stty echo");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -279,128 +574,81 @@ exit_programme :
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void displayCouleurBash(void)
|
void displayCouleurBash(void)
|
||||||
{
|
{
|
||||||
/* Initialise the main variables
|
/* Initialise the main variables
|
||||||
* colour: for the 256 colours (0-255)
|
* colour: for the 256 colours (0-255)
|
||||||
* space: to insert space or newline
|
* space: to insert space or newline
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int colour = 0;
|
int colour = 0;
|
||||||
int espace = 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");
|
printf("System colours:\n");
|
||||||
for( ; colour < 16; colour++)
|
for( ; colour < 16; colour++) {
|
||||||
{
|
printf("\e[48;5;%dm ", colour);
|
||||||
printf("\e[48;5;%dm ", colour);
|
}
|
||||||
}
|
printf("\e[0m\n\n");
|
||||||
printf("\e[0m\n\n");
|
|
||||||
|
|
||||||
/* The 216 colours */
|
/* The 216 colours */
|
||||||
|
|
||||||
printf("Color cube: 6x6x6\n");
|
printf("Color cube: 6x6x6\n");
|
||||||
for ( ; colour < 232; colour++, espace++)
|
for ( ; colour < 232; colour++, espace++) {
|
||||||
{
|
if ((espace%6) == 0) {
|
||||||
if ((espace%6) == 0)
|
printf("\e[0m ");
|
||||||
{
|
}
|
||||||
printf("\e[0m ");
|
if ((espace%36 == 0)) {
|
||||||
}
|
printf("\e[0m\n");
|
||||||
if ((espace%36 == 0))
|
}
|
||||||
{
|
printf("\e[48;5;%dm ", colour);
|
||||||
printf("\e[0m\n");
|
}
|
||||||
}
|
printf("\e[0m\n\n");
|
||||||
printf("\e[48;5;%dm ", colour);
|
|
||||||
}
|
|
||||||
printf("\e[0m\n\n");
|
|
||||||
|
|
||||||
/* And the grey colours */
|
/* And the grey colours */
|
||||||
|
|
||||||
printf("Greyscale ramp\n");
|
printf("Greyscale ramp\n");
|
||||||
for ( ; colour < 256; colour++)
|
for ( ; colour < 256; colour++) {
|
||||||
{
|
printf("\e[48;5;%dm ", colour);
|
||||||
printf("\e[48;5;%dm ", colour);
|
}
|
||||||
}
|
printf("\e[0m\n\n");
|
||||||
printf("\e[0m\n\n");
|
|
||||||
|
|
||||||
/* Initialise the main variables
|
/* Initialise the main variables
|
||||||
* colour: for the 256 colours (0-255)
|
* colour: for the 256 colours (0-255)
|
||||||
* space: to insert space or newline
|
* 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");
|
printf("System colours:\n");
|
||||||
for( ; colour < 16; colour++)
|
for( ; colour < 16; colour++) {
|
||||||
{
|
printf("\e[48;5;%dm ", colour);
|
||||||
printf("\e[48;5;%dm ", colour);
|
}
|
||||||
}
|
printf("\e[0m\n\n");
|
||||||
printf("\e[0m\n\n");
|
|
||||||
|
|
||||||
/* The 216 colours */
|
/* The 216 colours */
|
||||||
|
|
||||||
printf("Color cube: 6x6x6\n");
|
printf("Color cube: 6x6x6\n");
|
||||||
for ( ; colour < 232; colour++, espace++)
|
for ( ; colour < 232; colour++, espace++) {
|
||||||
{
|
if ((espace%6) == 0) {
|
||||||
if ((espace%6) == 0)
|
printf("\e[0m ");
|
||||||
{
|
}
|
||||||
printf("\e[0m ");
|
if ((espace%36 == 0)) {
|
||||||
}
|
printf("\e[0m\n");
|
||||||
if ((espace%36 == 0))
|
}
|
||||||
{
|
printf("\e[48;5;%dm ", colour);
|
||||||
printf("\e[0m\n");
|
}
|
||||||
}
|
printf("\e[0m\n\n");
|
||||||
printf("\e[48;5;%dm ", colour);
|
|
||||||
}
|
|
||||||
printf("\e[0m\n\n");
|
|
||||||
|
|
||||||
/* And the grey colours */
|
/* And the grey colours */
|
||||||
|
|
||||||
printf("Greyscale ramp\n");
|
printf("Greyscale ramp\n");
|
||||||
for ( ; colour < 256; colour++)
|
for ( ; colour < 256; colour++) {
|
||||||
{
|
printf("\e[48;5;%dm ", colour);
|
||||||
printf("\e[48;5;%dm ", colour);
|
}
|
||||||
}
|
printf("\e[0m\n\n");
|
||||||
printf("\e[0m\n\n");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
331
parameter.c
331
parameter.c
@ -1,11 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
* @file parameter.c
|
* @file parameter.c
|
||||||
* @brief Editeur De N'ours :
|
* @brief Parameters area (Sources)
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
* @date 05/02/2011
|
* @date 05/02/2011
|
||||||
* @par Project
|
* @par Project
|
||||||
* Edn tool : hexViewer
|
* hexViewer
|
||||||
*
|
*
|
||||||
* @par Copyright
|
* @par Copyright
|
||||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
* 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
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY.
|
* ANY WARRANTY.
|
||||||
*
|
*
|
||||||
* Licence summary :
|
* Licence : GNU Lesser General Public License (LGPL) v3.0
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "parameter.h"
|
#include "parameter.h"
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <stdio.h>
|
||||||
// Parameter Local Value :
|
// Parameter Local Value :
|
||||||
|
|
||||||
static U32 fileOfset = 0;
|
static uint32_t fileOfset = 0;
|
||||||
|
static uint32_t paddingOffset = 0;
|
||||||
static bool parmamModifier = true;
|
static bool parmamModifier = true;
|
||||||
|
|
||||||
|
|
||||||
@ -34,115 +32,266 @@ static showType_te curentType = SHOW_TYPE_HEX;
|
|||||||
static showTypeSize_te curentTypeSize = SHOW_TYPE_SIZE_8;
|
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)
|
//system("clear");
|
||||||
{
|
UpdateNumberOfRawAndColomn();
|
||||||
offset = 0;
|
printf(GO_TOP);
|
||||||
}
|
for (int32_t iii=0; iii< GetNumberOfRaw(); iii++) {
|
||||||
if ( offset > (I32)filesize[0]
|
for (int32_t jjj=0; jjj < GetNumberOfColomn()-1; jjj++) {
|
||||||
&& offset > (I32)filesize[1])
|
printf(" ");
|
||||||
{
|
}
|
||||||
// nothing to do
|
if (iii< GetNumberOfRaw()-1) {
|
||||||
return;
|
printf("\n");
|
||||||
}
|
}
|
||||||
if (offset != (I32)fileOfset)
|
}
|
||||||
{
|
printf(GO_TOP);
|
||||||
fileOfset = (U32)offset;
|
|
||||||
parmamModifier = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void upDownOfsetFile(I32 offset)
|
|
||||||
|
|
||||||
|
|
||||||
|
void setOfsetFile(int32_t offset)
|
||||||
{
|
{
|
||||||
I32 tmp;
|
if (0 > offset) {
|
||||||
tmp = fileOfset + (16 * offset);
|
offset = 0;
|
||||||
if (0 > tmp)
|
}
|
||||||
{
|
if( offset > (int32_t)fileProp[0].size
|
||||||
setOfsetFile(0);
|
&& offset > (int32_t)fileProp[1].size) {
|
||||||
}
|
// nothing to do
|
||||||
else
|
return;
|
||||||
{
|
}
|
||||||
setOfsetFile(tmp);
|
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()
|
bool getParamModification()
|
||||||
{
|
{
|
||||||
if (parmamModifier == true)
|
if (parmamModifier == true) {
|
||||||
{
|
parmamModifier = false;
|
||||||
parmamModifier = false;
|
return true;
|
||||||
return true;
|
} else {
|
||||||
}
|
return false;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void needRedraw(void) {
|
||||||
|
parmamModifier = true;
|
||||||
|
}
|
||||||
|
|
||||||
void nextType(void)
|
void nextType(void)
|
||||||
{
|
{
|
||||||
switch(curentType)
|
switch(curentType)
|
||||||
{
|
{
|
||||||
case SHOW_TYPE_HEX:
|
case SHOW_TYPE_HEX:
|
||||||
curentType = SHOW_TYPE_DECIMAL_SIGNED;
|
curentType = SHOW_TYPE_DECIMAL_SIGNED;
|
||||||
break;
|
break;
|
||||||
case SHOW_TYPE_DECIMAL_SIGNED:
|
case SHOW_TYPE_DECIMAL_SIGNED:
|
||||||
curentType = SHOW_TYPE_DECIMAL_UNSIGNED;
|
curentType = SHOW_TYPE_DECIMAL_UNSIGNED;
|
||||||
break;
|
break;
|
||||||
case SHOW_TYPE_DECIMAL_UNSIGNED:
|
case SHOW_TYPE_DECIMAL_UNSIGNED:
|
||||||
curentType = SHOW_TYPE_HEX;
|
curentType = SHOW_TYPE_HEX;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
curentType = SHOW_TYPE_HEX;
|
curentType = SHOW_TYPE_HEX;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
system("clear");
|
CleanDisplay();
|
||||||
parmamModifier = true;
|
parmamModifier = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
showType_te getType(void)
|
showType_te getType(void)
|
||||||
{
|
{
|
||||||
return curentType;
|
return curentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setType(showType_te newType)
|
||||||
|
{
|
||||||
|
curentType = newType;
|
||||||
|
parmamModifier = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nextTypeSize(void)
|
void nextTypeSize(void)
|
||||||
{
|
{
|
||||||
switch(curentTypeSize)
|
switch(curentTypeSize)
|
||||||
{
|
{
|
||||||
case SHOW_TYPE_SIZE_8:
|
case SHOW_TYPE_SIZE_8:
|
||||||
curentTypeSize = SHOW_TYPE_SIZE_16;
|
curentTypeSize = SHOW_TYPE_SIZE_16;
|
||||||
break;
|
break;
|
||||||
case SHOW_TYPE_SIZE_16:
|
case SHOW_TYPE_SIZE_16:
|
||||||
curentTypeSize = SHOW_TYPE_SIZE_32;
|
curentTypeSize = SHOW_TYPE_SIZE_32;
|
||||||
break;
|
break;
|
||||||
case SHOW_TYPE_SIZE_32:
|
case SHOW_TYPE_SIZE_32:
|
||||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
curentTypeSize = SHOW_TYPE_SIZE_64;
|
||||||
break;
|
break;
|
||||||
case SHOW_TYPE_SIZE_64:
|
case SHOW_TYPE_SIZE_64:
|
||||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||||
break;
|
break;
|
||||||
case SHOW_TYPE_SIZE_128:
|
case SHOW_TYPE_SIZE_128:
|
||||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
curentTypeSize = SHOW_TYPE_SIZE_8;
|
curentTypeSize = SHOW_TYPE_SIZE_8;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
system("clear");
|
CleanDisplay();
|
||||||
parmamModifier = true;
|
parmamModifier = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
showTypeSize_te getTypeSize(void)
|
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
|
* @file parameter.h
|
||||||
* @brief Editeur De N'ours :
|
* @brief Parameters area (header)
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
* @date 05/02/2011
|
* @date 05/02/2011
|
||||||
* @par Project
|
* @par Project
|
||||||
* Edn tool : hexViewer
|
* hexViewer
|
||||||
*
|
*
|
||||||
* @version $Id$
|
|
||||||
*
|
|
||||||
* @par Copyright
|
* @par Copyright
|
||||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
* 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
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* ANY WARRANTY.
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
*
|
||||||
* for more details.
|
* Licence : GNU Lesser General Public License (LGPL) v3.0
|
||||||
*
|
*
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
@ -30,17 +23,45 @@
|
|||||||
|
|
||||||
#include "generalDefine.h"
|
#include "generalDefine.h"
|
||||||
|
|
||||||
void setOfsetFile(I32 offset);
|
void setOfsetFile(int32_t offset);
|
||||||
void upDownOfsetFile(I32 offset);
|
void upDownOfsetFile(int32_t offset);
|
||||||
U32 getOfsetFile(void);
|
uint32_t getOfsetFile(void);
|
||||||
|
|
||||||
bool getParamModification();
|
bool getParamModification();
|
||||||
|
void needRedraw(void);
|
||||||
void nextType(void);
|
void nextType(void);
|
||||||
showType_te getType(void);
|
showType_te getType(void);
|
||||||
|
void setType(showType_te newType);
|
||||||
|
|
||||||
void nextTypeSize(void);
|
void nextTypeSize(void);
|
||||||
showTypeSize_te getTypeSize(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
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user