Merge pull request 'report' (#10) from report into master

Reviewed-on: #10
This commit is contained in:
Chris Cromer 2021-06-27 15:30:12 -04:00
commit fef8a085ec
10 changed files with 86 additions and 13 deletions

View File

@ -9,17 +9,33 @@
\usepackage{array}
\usepackage{adjustbox}
\usepackage{titling}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm,a4paper]{geometry}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm,letterpaper]{geometry}
\usepackage{amsmath}
\usepackage{listings}
\usepackage{xcolor}
\lstdefinestyle{freefempp}{
language=C,
basicstyle=\scriptsize\ttfamily,
commentstyle=\itshape\color{gray},
keywordstyle=\color{blue},
numberstyle=\color{red},
stringstyle=\color{red},
identifierstyle=\color{violet},
showstringspaces=false,
%float,
%frame=single,
%numbers=left
}
\lstset{
basicstyle=\small\ttfamily,
columns=flexible,
breaklines=true,
inputencoding=utf8,
extendedchars=true,
literate={á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1 {ñ}{{\~n}}1 {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 {Ñ}{{\~N}}1
basicstyle=\footnotesize\ttfamily,
columns=flexible,
breaklines=true,
inputencoding=utf8,
extendedchars=true,
literate={á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1 {ñ}{{\~n}}1 {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 {Ñ}{{\~N}}1,
style=freefempp
}
\usepackage{hyperref}
@ -62,11 +78,11 @@ Carlos Faúndez
\hypersetup{pageanchor=true}
\pagenumbering{arabic}
\newpage
\section{Introducción}
\include{sections/introduccion}
\newpage
\section{Conclusiones}
\include{sections/codigo}
\include{sections/conclusiones}
\end{document}

View File

@ -4,6 +4,6 @@ informe:
pdflatex -synctex=1 -interaction=nonstopmode "Informe.tex"
clean:
rm -f *.log *.toc *.gz *.aux *.out Informe.pdf
rm -f *.log *.toc *.gz *.aux sections/*.aux *.out Informe.pdf
.PHONY: informe clean

9
doc/code/builtins.txt Normal file
View File

@ -0,0 +1,9 @@
void run_builtin(StringArray *args) {
if (strcmp(args->array[0], "exit") == 0) {
exit_shell(args);
}
}
void exit_shell(StringArray *args) {
exit(EXIT_SUCCESS);
}

25
doc/code/loop.txt Normal file
View File

@ -0,0 +1,25 @@
void loop() {
while (1) {
print_input_line();
char *line = get_console_input();
StringArray args;
create_string_array(&args);
char *saveptr = NULL;
char *token = strtok_r(line, " ", &saveptr);
while (token) {
insert_string_array(&args, token);
token = strtok_r(NULL, " ", &saveptr);
}
if (args.size == 0) {
continue;
}
if (is_builtin(args.array[0])) {
run_builtin(&args);
}
}
}

3
doc/sections/codigo.tex Normal file
View File

@ -0,0 +1,3 @@
\section{Código}
\input{sections/codigo/ciclo}
\input{sections/codigo/builtins}

View File

@ -0,0 +1,5 @@
\subsection{Builtins}
Los builtins son comandos que son parte del shell, por lo tanto el sistema operativo no los proporciona. Un ejemplo es el comando\
''exit''. Este comando no existe en el sistema operativo, por lo tanto el shell debe actuar cuando el usuario lo escribe en vez\
de lanzar un proceso nuevo.
\lstinputlisting{code/builtins.txt}

View File

@ -0,0 +1,6 @@
\subsection{Ciclo principal}
El ciclo principal controla todo la funcionamiento del shell. El ciclo debe correr infinitamente hasta que recibe un señal o un\
comando de salir(exit). La primera cosa que tiene que hacer en el ciclo es mostrar un mensaje de entrada y esperar que el\
usuario ingresa un comando. Luego separar la entrada en varios argumentos. Finalmente interpretar los argumentos y decidir que\
hacer con ellos.
\lstinputlisting{code/loop.txt}

View File

@ -0,0 +1,5 @@
\section{Conclusiones}
Lo cosa mas importante que se puede aprender del proyecto es que el shell es un puente entre el usuario y el sistema operativo.\
El shell es responsable para lanzar programas, interpretar comandos y un shells mas avanzados interpretar un lenguaje de\
scripting para poder facilitar tareas o automatizarlas. Por lo tanto el shell es una parte integral para el sistema operativo\
especialmente en sistemas como GNU/Linux o BSD.

View File

@ -0,0 +1,3 @@
\section{Introducción}
El propósito del proyecto semestral es crear un shell básico para aprender los básicos de que hace un shell en un sistema\
operativo. Hay varios partes que son importante como la creación de procesos, redireccionamiento y el entorno.

View File

@ -19,6 +19,7 @@
/**
* The main entry point to the program.
* @param argc The number of arguments passed.
* @param argv An array with the arguments passed.
* @return Returns 0 on success or an error code on failure.
*/
int main(int argc, char **argv) {