Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
L
LEPL1503-2022-skeleton
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Valentin Decat
LEPL1503-2022-skeleton
Validations
3d73bab4
Valider
3d73bab4
rédigé
3 years ago
par
Valentin Decat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Update main.c
parent
0dc009a0
Branches
vadecat-main-patch-18005
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
main.c
+73
-2
73 ajouts, 2 suppressions
main.c
avec
73 ajouts
et
2 suppressions
main.c
+
73
−
2
Voir le fichier @
3d73bab4
...
@@ -9,9 +9,11 @@
...
@@ -9,9 +9,11 @@
#include
<inttypes.h>
#include
<inttypes.h>
#include
<stdbool.h>
#include
<stdbool.h>
#include
"headers/tinymt32.h"
#include
"headers/tinymt32.h"
//includes ajoutés
#include
<math.h>
typedef
struct
typedef
struct
{
// Comment
{
DIR
*
input_dir
;
DIR
*
input_dir
;
char
input_dir_path
[
PATH_MAX
];
char
input_dir_path
[
PATH_MAX
];
FILE
*
output_stream
;
FILE
*
output_stream
;
...
@@ -138,8 +140,77 @@ int main(int argc, char *argv[])
...
@@ -138,8 +140,77 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"Successfully opened the file %s
\n
"
,
full_path
);
fprintf
(
stderr
,
"Successfully opened the file %s
\n
"
,
full_path
);
}
}
//---------------------------------------------------------------------------------------------------------
// TODO: parse the input binary file, decode the encoded message with RLC and write the output in the output stream following the statement
// TODO: parse the input binary file, decode the encoded message with RLC and write the output in the output stream following the statement
// BEAUCOUP de choses à corriger !
message_t
*
mymessage
=
???
;
get_file_infos
(
binary_data
[
:
24
],
message
);
//erreur sur le [:24] fread(24)
if
(
verbose
){
printf
(
"Seed : %i , block_size : %i , word_size : %i, redundancy : %i"
,
seed
,
block_size
,
word_size
,
redundancy
)
}
binary_data
=
binary_data
[
24
:
];
//erreur sur le [:24] et type de binary_data
// Génère les coefficients
coeffs
=
gen_coeffs
(
seed
,
nss
,
nrs
);
//que vaut nrs et nss?
if
(
verbose
){
print_coeffs
();
printf
(
"%i"
,
binary_data
);
}
int
step
=
word_size
*
(
block_size
+
redundancy
);
// Taille de bloc en bytes
size_t
length
=
strlen
(
binary_data
);
// Ecrit la taille du titre et du contenu du message
// Ecrit le nom du fichier dans l'output
if
(
output_fd
==
sys
.
stdout
||
output_fd
==
sys
.
stderr
){
//sys.stdout et sys.stderr?
printf
(
"%i "
,
strlen
(
filename
));
printf
(
"%i "
,
message_size
);
printf
(
"%s "
,
filename
);
//on fait quoi de file=output_fd?
}
else
{
output_fd
.
write
(
len
(
filename
).
to_bytes
(
4
,
"big"
))
//Pas fait
output_fd
.
write
(
message_size
.
to_bytes
(
8
,
"big"
))
//Pas fait
output_fd
.
write
(
filename
.
encode
(
"ASCII"
))
//Pas fait
}
// Contient le nombre de blocs complets (sans le dernier bloc s'il n'est pas complet)
uint8_t
nb_blocks
=
ceil
(
length
/
step
);
//ceil calcule la division et return le nombre supérieur si le resultat n'est pas entier.
uint8_t
contains_uncomplete_block
=
0
;
if
(
message_size
!=
nb_blocks
*
block_size
*
word_size
){
// Dernier bloc non complet (i.e., moins de block_size symboles)
nb_blocks
-=
1
contains_uncomplete_block
=
1
;
}
int
readed
=
0
// Nombre de bytes lus jusqu'à présent
uint8_t
**
current_block
;
//Il faut intialiser current_block
uint8_t
**
response
;
//Il faut intialiser response
for
(
int
i
=
0
;
i
<
nb_blocks
;
i
++
){
current_block
=
make_block
(
binary_data
[
i
*
step
:
(
i
+
1
)
*
step
],
block_size
);
//changer [i * step:(i + 1) * step]
response
=
process_block
(
current_block
,
block_size
);
if
(
verbose
){
printf
(
"%i "
current_block
);
//on peut pas print uint8_t **
printf
(
"%c "
block_to_string
(
response
,
block_size
));
}
write_block
(
output_fd
,
response
,
block_size
,
word_size
);
//output_fd ??
readed
+=
step
;
}
int
readed_symbols
=
block_size
*
word_size
*
nb_blocks
;
int
nb_remaining_symbols
=
((
int
)
strlen
(
binary_data
[
readed
:
])
/
word_size
)
-
redundancy
;
//[readed:]
if
(
contains_uncomplete_block
){
uint8_t
**
last_block
=
make_block
(
binary_data
[
readed
:
],
nb_remaining_symbols
);
//[readed:]
uint8_t
**
decoded
=
process_block
(
last_block
,
nb_remaining_symbols
);
// Le dernier symbole peut ne pas etre complet et contenir du padding
// => on utilise la taille totale du fichier pour retirer le padding
int
padding
=
readed_symbols
+
nb_remaining_symbols
*
word_size
-
message_size
;
int
true_length_last_symbol
=
word_size
-
padding
;
if
(
verbose
){
printf
(
"%i"
,
last_block
);
//on peut pas print uint8_t **
}
write_last_block
(
output_fd
,
decoded
,
nb_remaining_symbols
,
word_size
,
true_length_last_symbol
);
//Pas fait
}
//-----------------------------------------------------------------------------------------------------------
// You may modify or delete the following lines. This is just an example of how to use tinymt32
// You may modify or delete the following lines. This is just an example of how to use tinymt32
uint32_t
seed
=
42
;
// Replace with the seed from the instance file!
uint32_t
seed
=
42
;
// Replace with the seed from the instance file!
...
@@ -187,4 +258,4 @@ file_read_error:
...
@@ -187,4 +258,4 @@ file_read_error:
fclose
(
args
.
output_stream
);
fclose
(
args
.
output_stream
);
}
}
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
\ No newline at end of file
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter