From 3eb6bae3064701b3b74f11eaf806ab9390b3b023 Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Sun, 27 Jun 2021 14:34:03 -0400 Subject: [PATCH] add introduction and first code example --- doc/Informe.tex | 3 +++ doc/code/loop.txt | 31 +++++++++++++++++++++++++++++++ doc/sections/codigo.tex | 2 ++ doc/sections/codigo/ciclo.tex | 6 ++++++ doc/sections/introduccion.tex | 4 +++- 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 doc/sections/codigo.tex create mode 100644 doc/sections/codigo/ciclo.tex diff --git a/doc/Informe.tex b/doc/Informe.tex index 6a000b9..883df2d 100644 --- a/doc/Informe.tex +++ b/doc/Informe.tex @@ -12,6 +12,7 @@ \usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm,a4paper]{geometry} \usepackage{amsmath} \usepackage{listings} +\usepackage{xcolor} \lstdefinestyle{freefempp}{ language=C, @@ -79,6 +80,8 @@ Carlos Faúndez \include{sections/introduccion} +\include{sections/codigo} + \include{sections/conclusiones} \end{document} diff --git a/doc/code/loop.txt b/doc/code/loop.txt index e69de29..0d606ff 100644 --- a/doc/code/loop.txt +++ b/doc/code/loop.txt @@ -0,0 +1,31 @@ +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 (line != NULL) { + free(line); + line = NULL; + } + + if (args.size == 0) { + continue; + } + + if (is_builtin(args.array[0])) { + run_builtin(&args); + } + + free_string_array(&args); + } +} diff --git a/doc/sections/codigo.tex b/doc/sections/codigo.tex new file mode 100644 index 0000000..b42ba62 --- /dev/null +++ b/doc/sections/codigo.tex @@ -0,0 +1,2 @@ +\section{Código} +\input{sections/codigo/ciclo} \ No newline at end of file diff --git a/doc/sections/codigo/ciclo.tex b/doc/sections/codigo/ciclo.tex new file mode 100644 index 0000000..809bb07 --- /dev/null +++ b/doc/sections/codigo/ciclo.tex @@ -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} \ No newline at end of file diff --git a/doc/sections/introduccion.tex b/doc/sections/introduccion.tex index bdefbcc..5631dbd 100644 --- a/doc/sections/introduccion.tex +++ b/doc/sections/introduccion.tex @@ -1 +1,3 @@ -\section{Introducción} \ No newline at end of file +\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. \ No newline at end of file