\doxysection{src/parsing.c File Reference} \hypertarget{parsing_8c}{}\label{parsing_8c}\index{src/parsing.c@{src/parsing.c}} Gestion de l\textquotesingle{}interface utilisateur (CLI), du parsing syntaxique de la ligne de commande et de la boucle principale du Shell. {\ttfamily \#include "{}parsing.\+h"{}}\newline {\ttfamily \#include "{}disk.\+h"{}}\newline {\ttfamily \#include "{}exec.\+h"{}}\newline {\ttfamily \#include "{}struct.\+h"{}}\newline {\ttfamily \#include $<$stdio.\+h$>$}\newline {\ttfamily \#include $<$stdlib.\+h$>$}\newline {\ttfamily \#include $<$string.\+h$>$}\newline {\ttfamily \#include $<$unistd.\+h$>$}\newline Include dependency graph for parsing.\+c\+: % FIG 0 \doxysubsubsection*{Functions} \begin{DoxyCompactItemize} \item char \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{parsing_8c_a9e35a75d71f9fc522c563668fbbec457}{read\+\_\+line}} () \begin{DoxyCompactList}\small\item\em Récupère une ligne de texte saisie par l\textquotesingle{}utilisateur sur l\textquotesingle{}entrée standard (stdin). \end{DoxyCompactList}\item \mbox{\hyperlink{structcommand}{command}} \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*} \mbox{\hyperlink{parsing_8c_a464ab1601eda451f2836222bc20a4932}{split\+\_\+line}} (char \texorpdfstring{$\ast$}{*}line) \begin{DoxyCompactList}\small\item\em Analyse une ligne de texte brute et la transforme en un tableau de structures de commandes. \end{DoxyCompactList}\item void \mbox{\hyperlink{parsing_8c_ad74877f90b508ee0351985458b570a98}{shell\+\_\+loop}} (\mbox{\hyperlink{structdisk}{disk}} \texorpdfstring{$\ast$}{*}\mbox{\hyperlink{structdisk}{disk}}) \begin{DoxyCompactList}\small\item\em Boucle d\textquotesingle{}exécution infinie (REPL) régissant le cycle de vie du Shell. \end{DoxyCompactList}\item void \mbox{\hyperlink{parsing_8c_a6aa59f98cad89c73966351ad7afb303c}{signal\+\_\+handler}} (int sig) \begin{DoxyCompactList}\small\item\em Intercepteur (Handler) de signal pour dérouter l\textquotesingle{}action par défaut du signal d\textquotesingle{}interruption SIGINT. \end{DoxyCompactList}\item void \mbox{\hyperlink{parsing_8c_a4208525aa40712ec3f936080773468c8}{open\+\_\+seyshell}} (\mbox{\hyperlink{structdisk}{disk}} \texorpdfstring{$\ast$}{*}\mbox{\hyperlink{structdisk}{disk}}) \begin{DoxyCompactList}\small\item\em Initialise le contexte opérationnel complet et démarre le Shell intégré. \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsection{Detailed Description} Gestion de l\textquotesingle{}interface utilisateur (CLI), du parsing syntaxique de la ligne de commande et de la boucle principale du Shell. Ce fichier implémente l\textquotesingle{}analyseur lexical (tokenizer) et syntaxique basique capable de découper une ligne de texte en commandes interconnectées par des opérateurs de contrôle (\textquotesingle{}\texorpdfstring{$\vert$}{|}\textquotesingle{}, \textquotesingle{}\texorpdfstring{$>$}{>}\textquotesingle{}, \textquotesingle{}\texorpdfstring{$>$}{>}\texorpdfstring{$>$}{>}\textquotesingle{}). \doxysubsection{Function Documentation} \Hypertarget{parsing_8c_a4208525aa40712ec3f936080773468c8}\label{parsing_8c_a4208525aa40712ec3f936080773468c8} \index{parsing.c@{parsing.c}!open\_seyshell@{open\_seyshell}} \index{open\_seyshell@{open\_seyshell}!parsing.c@{parsing.c}} \doxysubsubsection{\texorpdfstring{open\_seyshell()}{open\_seyshell()}} {\footnotesize\ttfamily void open\+\_\+seyshell (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structdisk}{disk}} \texorpdfstring{$\ast$}{*}}]{disk }\end{DoxyParamCaption})} Initialise le contexte opérationnel complet et démarre le Shell intégré. Configure la table des signaux pour immuniser le processus père contre les interruptions de terminal ({\ttfamily SIGINT}), instancie le dictionnaire global des variables d\textquotesingle{}environnement, puis bascule dans la boucle d\textquotesingle{}écoute. \begin{DoxyParams}{Parameters} {\em disk} & Pointeur vers le disque virtuel à attacher au Shell. \\ \hline \end{DoxyParams} \Hypertarget{parsing_8c_a9e35a75d71f9fc522c563668fbbec457}\label{parsing_8c_a9e35a75d71f9fc522c563668fbbec457} \index{parsing.c@{parsing.c}!read\_line@{read\_line}} \index{read\_line@{read\_line}!parsing.c@{parsing.c}} \doxysubsubsection{\texorpdfstring{read\_line()}{read\_line()}} {\footnotesize\ttfamily char \texorpdfstring{$\ast$}{*} read\+\_\+line (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})} Récupère une ligne de texte saisie par l\textquotesingle{}utilisateur sur l\textquotesingle{}entrée standard (stdin). Lit les caractères un par un jusqu\textquotesingle{}à rencontrer un retour à la ligne (\textquotesingle{}~\newline \textquotesingle{}) ou la fin de fichier (EOF). Alloue dynamiquement un tampon mémoire (buffer) et l\textquotesingle{}agrandit par blocs successifs via {\ttfamily realloc} si la taille de la saisie dépasse le volume initial {\ttfamily BUFSIZE}. \begin{DoxyWarning}{Warning} La chaîne renvoyée est allouée dynamiquement. Il incombe à la fonction appelante de libérer la mémoire via {\ttfamily free()}. \end{DoxyWarning} \begin{DoxyReturn}{Returns} char\texorpdfstring{$\ast$}{*} Un pointeur vers la chaîne de caractères lue (terminée par \textquotesingle{}\textbackslash{}0\textquotesingle{}), ou provoque l\textquotesingle{}arrêt du programme en cas d\textquotesingle{}échec d\textquotesingle{}allocation. \end{DoxyReturn} \Hypertarget{parsing_8c_ad74877f90b508ee0351985458b570a98}\label{parsing_8c_ad74877f90b508ee0351985458b570a98} \index{parsing.c@{parsing.c}!shell\_loop@{shell\_loop}} \index{shell\_loop@{shell\_loop}!parsing.c@{parsing.c}} \doxysubsubsection{\texorpdfstring{shell\_loop()}{shell\_loop()}} {\footnotesize\ttfamily void shell\+\_\+loop (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structdisk}{disk}} \texorpdfstring{$\ast$}{*}}]{disk }\end{DoxyParamCaption})} Boucle d\textquotesingle{}exécution infinie (REPL) régissant le cycle de vie du Shell. Cette fonction orchestre en continu les étapes suivantes \+: \begin{DoxyEnumerate} \item Affiche l\textquotesingle{}invite de commande (Prompt) formatée à l\textquotesingle{}aide des variables utilisateur et système. \item Bloque l\textquotesingle{}exécution dans l\textquotesingle{}attente d\textquotesingle{}une entrée utilisateur via {\ttfamily \doxylink{parsing_8c_a9e35a75d71f9fc522c563668fbbec457}{read\+\_\+line()}}. \item Découpe syntaxiquement la chaîne obtenue via {\ttfamily \doxylink{parsing_8c_a464ab1601eda451f2836222bc20a4932}{split\+\_\+line()}}. \item Transmet le résultat au moteur d\textquotesingle{}exécution {\ttfamily \doxylink{exec_8c_a82beace5b13f7e2d89dae34187bb7f46}{execute\+\_\+cmd()}}. \item Libère proprement les structures temporaires avant le tour suivant. \end{DoxyEnumerate} \begin{DoxyParams}{Parameters} {\em disk} & Pointeur vers le disque virtuel sur lequel opèrent les commandes. \\ \hline \end{DoxyParams} \Hypertarget{parsing_8c_a6aa59f98cad89c73966351ad7afb303c}\label{parsing_8c_a6aa59f98cad89c73966351ad7afb303c} \index{parsing.c@{parsing.c}!signal\_handler@{signal\_handler}} \index{signal\_handler@{signal\_handler}!parsing.c@{parsing.c}} \doxysubsubsection{\texorpdfstring{signal\_handler()}{signal\_handler()}} {\footnotesize\ttfamily void signal\+\_\+handler (\begin{DoxyParamCaption}\item[{int}]{sig }\end{DoxyParamCaption})} Intercepteur (Handler) de signal pour dérouter l\textquotesingle{}action par défaut du signal d\textquotesingle{}interruption SIGINT. Empêche le processus parent du Shell de se terminer brutalement lors de la combinaison de touches Ctrl+C. À la place, il effectue un retour à la ligne et réaffiche un prompt propre pour restituer le contrôle à l\textquotesingle{}utilisateur. \begin{DoxyParams}{Parameters} {\em sig} & Numéro du signal reçu (attendu \+: SIGINT). \\ \hline \end{DoxyParams} \Hypertarget{parsing_8c_a464ab1601eda451f2836222bc20a4932}\label{parsing_8c_a464ab1601eda451f2836222bc20a4932} \index{parsing.c@{parsing.c}!split\_line@{split\_line}} \index{split\_line@{split\_line}!parsing.c@{parsing.c}} \doxysubsubsection{\texorpdfstring{split\_line()}{split\_line()}} {\footnotesize\ttfamily \mbox{\hyperlink{structcommand}{command}} \texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*} split\+\_\+line (\begin{DoxyParamCaption}\item[{char \texorpdfstring{$\ast$}{*}}]{line }\end{DoxyParamCaption})} Analyse une ligne de texte brute et la transforme en un tableau de structures de commandes. Le traitement s\textquotesingle{}effectue en deux phases principales \+: \begin{DoxyEnumerate} \item Un découpage lexical premier basé sur l\textquotesingle{}espace ("{} "{}) via {\ttfamily strtok} pour isoler les mots. \item Un découpage syntaxique (parsing) qui regroupe les arguments dans des structures {\ttfamily command}. Les caractères spéciaux comme le tube ({\ttfamily \texorpdfstring{$\vert$}{|}}) créent une nouvelle structure de commande, tandis que les opérateurs de redirection ({\ttfamily \texorpdfstring{$>$}{>}} et {\ttfamily \texorpdfstring{$>$}{>}\texorpdfstring{$>$}{>}}) configurent les champs {\ttfamily redirect\+\_\+out} et {\ttfamily append\+\_\+mode} de la commande courante. \end{DoxyEnumerate} \begin{DoxyParams}{Parameters} {\em line} & La chaîne de caractères brute saisie dans le terminal. \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} command\texorpdfstring{$\ast$}{*}\texorpdfstring{$\ast$}{*} Un tableau de pointeurs vers des structures {\ttfamily command} (le tableau est terminé par un pointeur NULL). Retourne NULL si la ligne est vide. \end{DoxyReturn}