126 lines
7.0 KiB
TeX
126 lines
7.0 KiB
TeX
\doxysection{src/env.c File Reference}
|
|
\hypertarget{env_8c}{}\label{env_8c}\index{src/env.c@{src/env.c}}
|
|
|
|
|
|
Gestionnaire des variables d\textquotesingle{}environnement pour le shell intégré du SGF.
|
|
|
|
|
|
{\ttfamily \#include "{}env.\+h"{}}\newline
|
|
Include dependency graph for env.\+c\+:
|
|
% FIG 0
|
|
\doxysubsubsection*{Functions}
|
|
\begin{DoxyCompactItemize}
|
|
\item
|
|
\mbox{\hyperlink{structenv}{env}} \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{env_8c_a9f03a70f263b1c039d6a3975b02cfadd}{init\+\_\+envs}} ()
|
|
\begin{DoxyCompactList}\small\item\em Initialise le tableau des variables d\textquotesingle{}environnement par défaut. \end{DoxyCompactList}\item
|
|
\mbox{\hyperlink{structenv}{env}} \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{env_8c_a21ed94d5b2eb2f40aaf40cc57d3d6309}{get\+\_\+instance}} ()
|
|
\begin{DoxyCompactList}\small\item\em Récupère l\textquotesingle{}instance unique (Singleton) du tableau des variables d\textquotesingle{}environnement. \end{DoxyCompactList}\item
|
|
int \mbox{\hyperlink{env_8c_a684d25b4cc5d9bf14dd67309de8568bf}{get\+\_\+env\+\_\+len}} (\mbox{\hyperlink{structenv}{env}} \texorpdfstring{$\ast$}{*}envs)
|
|
\begin{DoxyCompactList}\small\item\em Calcule le nombre de variables d\textquotesingle{}environnement actives dans le tableau. \end{DoxyCompactList}\item
|
|
char \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{env_8c_a0ce3d2cd4284dee64477512b489ddb4f}{get\+\_\+env\+\_\+value}} (char \texorpdfstring{$\ast$}{*}key)
|
|
\begin{DoxyCompactList}\small\item\em Recherche et retourne la valeur d\textquotesingle{}une variable d\textquotesingle{}environnement d\textquotesingle{}après sa clé. \end{DoxyCompactList}\item
|
|
int \mbox{\hyperlink{env_8c_a2447e9b952249197b828841281389e8f}{set\+\_\+env\+\_\+value}} (char \texorpdfstring{$\ast$}{*}key, char \texorpdfstring{$\ast$}{*}value)
|
|
\begin{DoxyCompactList}\small\item\em Modifie la valeur d\textquotesingle{}une variable d\textquotesingle{}environnement existante. \end{DoxyCompactList}\end{DoxyCompactItemize}
|
|
|
|
|
|
\doxysubsection{Detailed Description}
|
|
Gestionnaire des variables d\textquotesingle{}environnement pour le shell intégré du SGF.
|
|
|
|
Ce fichier implémente un registre de type dictionnaire (Clé / Valeur) sous forme de Singleton pour suivre l\textquotesingle{}état du shell (répertoire courant PWD, utilisateur, etc.).
|
|
|
|
\doxysubsection{Function Documentation}
|
|
\Hypertarget{env_8c_a684d25b4cc5d9bf14dd67309de8568bf}\label{env_8c_a684d25b4cc5d9bf14dd67309de8568bf}
|
|
\index{env.c@{env.c}!get\_env\_len@{get\_env\_len}}
|
|
\index{get\_env\_len@{get\_env\_len}!env.c@{env.c}}
|
|
\doxysubsubsection{\texorpdfstring{get\_env\_len()}{get\_env\_len()}}
|
|
{\footnotesize\ttfamily int get\+\_\+env\+\_\+len (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structenv}{env}} \texorpdfstring{$\ast$}{*}}]{envs }\end{DoxyParamCaption})}
|
|
|
|
|
|
|
|
Calcule le nombre de variables d\textquotesingle{}environnement actives dans le tableau.
|
|
|
|
Parcourt le tableau de structures jusqu\textquotesingle{}à rencontrer la sentinelle (clé égale à NULL).
|
|
|
|
|
|
\begin{DoxyParams}{Parameters}
|
|
{\em envs} & Pointeur vers le tableau de variables d\textquotesingle{}environnement. \\
|
|
\hline
|
|
\end{DoxyParams}
|
|
\begin{DoxyReturn}{Returns}
|
|
int Le nombre de variables stockées (hors sentinelle).
|
|
\end{DoxyReturn}
|
|
\Hypertarget{env_8c_a0ce3d2cd4284dee64477512b489ddb4f}\label{env_8c_a0ce3d2cd4284dee64477512b489ddb4f}
|
|
\index{env.c@{env.c}!get\_env\_value@{get\_env\_value}}
|
|
\index{get\_env\_value@{get\_env\_value}!env.c@{env.c}}
|
|
\doxysubsubsection{\texorpdfstring{get\_env\_value()}{get\_env\_value()}}
|
|
{\footnotesize\ttfamily char \texorpdfstring{$\ast$}{*} get\+\_\+env\+\_\+value (\begin{DoxyParamCaption}\item[{char \texorpdfstring{$\ast$}{*}}]{key }\end{DoxyParamCaption})}
|
|
|
|
|
|
|
|
Recherche et retourne la valeur d\textquotesingle{}une variable d\textquotesingle{}environnement d\textquotesingle{}après sa clé.
|
|
|
|
|
|
\begin{DoxyParams}{Parameters}
|
|
{\em key} & Le nom de la variable recherchée (ex\+: "{}\+PWD"{}). \\
|
|
\hline
|
|
\end{DoxyParams}
|
|
\begin{DoxyReturn}{Returns}
|
|
char\texorpdfstring{$\ast$}{*} Un pointeur vers la chaîne de caractères contenant la valeur, ou NULL si la clé n\textquotesingle{}a pas été trouvée.
|
|
\end{DoxyReturn}
|
|
\Hypertarget{env_8c_a21ed94d5b2eb2f40aaf40cc57d3d6309}\label{env_8c_a21ed94d5b2eb2f40aaf40cc57d3d6309}
|
|
\index{env.c@{env.c}!get\_instance@{get\_instance}}
|
|
\index{get\_instance@{get\_instance}!env.c@{env.c}}
|
|
\doxysubsubsection{\texorpdfstring{get\_instance()}{get\_instance()}}
|
|
{\footnotesize\ttfamily \mbox{\hyperlink{structenv}{env}} \texorpdfstring{$\ast$}{*} get\+\_\+instance (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}
|
|
|
|
|
|
|
|
Récupère l\textquotesingle{}instance unique (Singleton) du tableau des variables d\textquotesingle{}environnement.
|
|
|
|
Si le tableau n\textquotesingle{}a pas encore été créé, cette fonction appelle \doxylink{env_8c_a9f03a70f263b1c039d6a3975b02cfadd}{init\+\_\+envs()}. Les appels suivants renverront directement la même zone mémoire.
|
|
|
|
\begin{DoxyReturn}{Returns}
|
|
env\texorpdfstring{$\ast$}{*} Pointeur vers l\textquotesingle{}instance unique du tableau d\textquotesingle{}environnement.
|
|
\end{DoxyReturn}
|
|
\Hypertarget{env_8c_a9f03a70f263b1c039d6a3975b02cfadd}\label{env_8c_a9f03a70f263b1c039d6a3975b02cfadd}
|
|
\index{env.c@{env.c}!init\_envs@{init\_envs}}
|
|
\index{init\_envs@{init\_envs}!env.c@{env.c}}
|
|
\doxysubsubsection{\texorpdfstring{init\_envs()}{init\_envs()}}
|
|
{\footnotesize\ttfamily \mbox{\hyperlink{structenv}{env}} \texorpdfstring{$\ast$}{*} init\+\_\+envs (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}
|
|
|
|
|
|
|
|
Initialise le tableau des variables d\textquotesingle{}environnement par défaut.
|
|
|
|
Alloue l\textquotesingle{}espace mémoire pour les variables de base ("{}\+PWD"{}, "{}\+USER"{}, "{}\+HOST"{}) et ajoute une sentinelle NULL à la fin pour permettre un parcours sûr.
|
|
|
|
\begin{DoxyReturn}{Returns}
|
|
env\texorpdfstring{$\ast$}{*} Un pointeur vers le tableau d\textquotesingle{}environnements alloué, ou NULL en cas d\textquotesingle{}échec du malloc.
|
|
\end{DoxyReturn}
|
|
\Hypertarget{env_8c_a2447e9b952249197b828841281389e8f}\label{env_8c_a2447e9b952249197b828841281389e8f}
|
|
\index{env.c@{env.c}!set\_env\_value@{set\_env\_value}}
|
|
\index{set\_env\_value@{set\_env\_value}!env.c@{env.c}}
|
|
\doxysubsubsection{\texorpdfstring{set\_env\_value()}{set\_env\_value()}}
|
|
{\footnotesize\ttfamily int set\+\_\+env\+\_\+value (\begin{DoxyParamCaption}\item[{char \texorpdfstring{$\ast$}{*}}]{key, }\item[{char \texorpdfstring{$\ast$}{*}}]{value }\end{DoxyParamCaption})}
|
|
|
|
|
|
|
|
Modifie la valeur d\textquotesingle{}une variable d\textquotesingle{}environnement existante.
|
|
|
|
\begin{DoxyNote}{Note}
|
|
La nouvelle valeur est dupliquée dynamiquement en mémoire via {\ttfamily strdup}.
|
|
\end{DoxyNote}
|
|
\begin{DoxyWarning}{Warning}
|
|
Cette fonction ne gère pas l\textquotesingle{}ajout d\textquotesingle{}une nouvelle clé si elle n\textquotesingle{}existe pas déjà.
|
|
\end{DoxyWarning}
|
|
|
|
\begin{DoxyParams}{Parameters}
|
|
{\em key} & Le nom de la variable à modifier. \\
|
|
\hline
|
|
{\em value} & La nouvelle chaîne de caractères à affecter. \\
|
|
\hline
|
|
\end{DoxyParams}
|
|
\begin{DoxyReturn}{Returns}
|
|
int 1 si la modification a réussi, 0 si la clé n\textquotesingle{}existe pas dans le tableau.
|
|
\end{DoxyReturn}
|