diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..3295faf --- /dev/null +++ b/Doxyfile @@ -0,0 +1,280 @@ +# Doxyfile 1.7.4 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = Shell +PROJECT_NUMBER = +PROJECT_BRIEF = +PROJECT_LOGO = +OUTPUT_DIRECTORY = docs +CREATE_SUBDIRS = YES +OUTPUT_LANGUAGE = Portuguese +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO +EXTENSION_MAPPING = +BUILTIN_STL_SUPPORT = NO +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +INLINE_GROUPED_CLASSES = NO +TYPEDEF_HIDES_STRUCT = NO +SYMBOL_CACHE_SIZE = 0 +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +FORCE_LOCAL_INCLUDES = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +STRICT_PROTO_MATCHING = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = NO +SHOW_FILES = YES +SHOW_NAMESPACES = YES +FILE_VERSION_FILTER = +LAYOUT_FILE = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = +RECURSIVE = NO +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXCLUDE_SYMBOLS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +FILTER_SOURCE_PATTERNS = +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = NO +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_EXTRA_FILES = +HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_GAMMA = 80 +HTML_TIMESTAMP = YES +HTML_ALIGN_MEMBERS = YES +HTML_DYNAMIC_SECTIONS = NO +GENERATE_DOCSET = NO +DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_BUNDLE_ID = org.doxygen.Project +DOCSET_PUBLISHER_ID = org.doxygen.Publisher +DOCSET_PUBLISHER_NAME = Publisher +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +CHM_INDEX_ENCODING = +BINARY_TOC = NO +TOC_EXPAND = NO +GENERATE_QHP = NO +QCH_FILE = +QHP_NAMESPACE = org.doxygen.Project +QHP_VIRTUAL_FOLDER = doc +QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = +QHG_LOCATION = +GENERATE_ECLIPSEHELP = NO +ECLIPSE_DOC_ID = org.doxygen.Project +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +USE_INLINE_TREES = NO +TREEVIEW_WIDTH = 250 +EXT_LINKS_IN_WINDOW = NO +FORMULA_FONTSIZE = 10 +FORMULA_TRANSPARENT = YES +USE_MATHJAX = NO +MATHJAX_RELPATH = http://www.mathjax.org/mathjax +SEARCHENGINE = YES +SERVER_BASED_SEARCH = NO +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4 +EXTRA_PACKAGES = +LATEX_HEADER = +LATEX_FOOTER = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +LATEX_SOURCE_CODE = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +MSCGEN_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +DOT_NUM_THREADS = 0 +DOT_FONTNAME = Helvetica +DOT_FONTSIZE = 10 +DOT_FONTPATH = +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MSCFILE_DIRS = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = YES +GENERATE_LEGEND = YES +DOT_CLEANUP = YES diff --git a/Mainpage.h b/Mainpage.h new file mode 100644 index 0000000..a632b67 --- /dev/null +++ b/Mainpage.h @@ -0,0 +1,42 @@ +/** + * @mainpage Shell + * @author Lucas Lobosque - 6792645 + * @author José Leandro Pozer - 6793222 + * @date 16/11/2011 + * + * @section intro Introdução + * + * @subsection estrutura_basica_subsec Estrutura básica de Arquivos + * Desenvolvemos o shell utilizando 4 arquivos diferentes (e seus headers): + * + * + * + * @subsection estrutura_dados_subsec Estrutura básica de Dados + * No nosso programa, temos três listas ligadas diferentes que são constantemente utilizadas: + * + * + * @section section_toc Características Não Implementadas (limitações). + * Na nossa shell, os seguintes tipos de comando não são possíveis: + * + * Tornou-se uma tarefa complicada para nós lidar com essas peculiaridades de comandos builtin, já que implementamos sem elas em mente, e, quando percebemos que haveriam essas possibilidades, teríamos que mudar muito a estrutura do programa. + * + * @section testes Testes + * Além de exaustivos testes com vários comandos complexos, rodamos nossa shell com o Valgrind e encontramos vários memory leaks (a maioria causada por erros bobos, porém alguns eram bem complexos). + * Arrumamos a maioria deles, mas infelizmente teve um leak que não foi possível concertar, pois ele é causado pela função getlogin(), (implementada na unistd.h). + * @section conclusao Conclusão + * Além de bastante desafiador, o desenvolvimento da shell foi de grande valia para nós, já que nunca tivemos um contato a nível de sistema com o Linux. Depois do desenvolvimento desse programa, arriscamos dizer que entendemos ao menos um pouco de Linux :). +*/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2f52171 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +shell : builtin.o main.o list.o parser.o + gcc obj/builtin.o obj/main.o obj/list.o obj/parser.o -o bin/shell + +builtin.o : builtin.c + gcc -c builtin.c -o obj/builtin.o + +main.o : main.c + gcc -c main.c -o obj/main.o + +list.o : list.c + gcc -c list.c -o obj/list.o + +parser.o : parser.c + gcc -c parser.c -o obj/parser.o diff --git a/README b/README index e69de29..4b07900 100644 --- a/README +++ b/README @@ -0,0 +1,56 @@ +Autores: + Lucas Lobosque - 6792645 + José Leandro Pozer - 6793222 + +Data: + 16/11/2011 + +==Introdução== + +--Estrutura básica de Arquivos-- + + Desenvolvemos o shell utilizando 4 arquivos diferentes (e seus headers): + + * main.c - Arquivo com a função main, onde fica o loop principal e com handlers de sinais como SIGINT, SIGTSTP e SIGCHLD. + * parser.c - Funções relacionadas a transformar a entrada do usuário em uma estrutura compreensível para o programa. + * builtin.c - Aqui estáo todos os comandos builtin e também uma função que checa se um dado comando é builtin ou não. + * list.c - Funções que manipulam as listas usadas pelo programa. + + +--Estrutura básica de Dados-- + + No nosso programa, temos três listas ligadas diferentes que são constantemente utilizadas: + + * history - Esta é a mais simples das três. Guarda strings com os comandos anteriormente utilizados pelo usuário. É usada + pelo comando builtin history. + * childs - Nesta lista ligada armazenamos todos os processos que estão rodando ou estão interrompidos. + * cmdList - Lista responsável por guardar o último comando enviado pelo usuário. Nesta lista, o comando é guardado depois de + "parseado", então todas suas informações são guardadas aqui (roda no background? tem redirecionamento de saída? + pra onde?). Cada item da lista é um comando diferente, sendo que a lista e sempre resetada no loop. Ou seja, + esta lista só conterá mais de um item se houver pipe no comando. + + +==Características Não Implementadas (limitações)== + + Na nossa shell, os seguintes tipos de comando não são possíveis: + + * Comando builtin rodando em background (sempre rodará em foreground). + * Redirecionamento de entrada para comandos builtin (redirecionamento de saída implementado). + * Pipe com comandos builtin + + Tornou-se uma tarefa complicada para nós lidar com essas peculiaridades de comandos builtin, já que implementamos sem elas em mente, e, +quando percebemos que haveriam essas possibilidades, teríamos que mudar muito a estrutura do programa. + + +==Testes== + + Além de exaustivos testes com vários comandos complexos, rodamos nossa shell com o Valgrind e encontramos vários memory leaks (a maioria causada +por erros bobos, porém alguns eram bem complexos). Arrumamos a maioria deles, mas infelizmente teve um leak que não foi possível concertar, pois +ele é causado pela função getlogin(), (implementada na unistd.h). + + +==Conclusão== + + Além de bastante desafiador, o desenvolvimento da shell foi de grande valia para nós, já que nunca tivemos um contato a nível de sistema com +o Linux. Depois do desenvolvimento desse programa, arriscamos dizer que entendemos ao menos um pouco de Linux :). + diff --git a/bin/empty b/bin/empty new file mode 100644 index 0000000..e69de29 diff --git a/builtin.c b/builtin.c old mode 100644 new mode 100755 index abe51f8..8961a6e --- a/builtin.c +++ b/builtin.c @@ -2,48 +2,59 @@ #include #include #include -#include +#include +#include +#include #include "main.h" #include "builtin.h" #include "parser.h" -#include "lista.h" +#include "list.h" int isBuiltIn(char * cmd) { - char * commands[] = {"cd", "history", "pwd", "exit", "jobs", "bg", "fg", "kill", "echo"}; + char * commands[] = {"cd", "history", "pwd", "exit", "jobs", "bg", "fg", "kill", "echo", "about"}; int i; - for (i = 0; i < 9; i++) + for (i = 0; i < 10; i++) if (strcmp(commands[i], cmd) == 0) return i; return -1; } -void callBuiltIn(int cmd_id, char * arg) +void callBuiltIn(int cmd_id, COMMAND *cmd) { switch(cmd_id) { case 0: - cd(); + cd(cmd->args[1]); break; case 1: - print_history(); + print_history(cmd); break; case 2: - pwd(); + pwd(cmd); break; case 3: + ListPurgeCmds(cmdList); + free(cmdLine); + free_memory(); exit(0); break; case 4: - jobs(); + jobs(cmd); break; case 5: - bg(arg); + bg(cmd->args[1]); break; case 6: - fg(arg); + fg(cmd->args[1]); break; case 7: - kill_cmd(arg); + kill_cmd(cmd->args[1]); + break; + case 8: + echo(cmd); + break; + case 9: + about(cmd); break; default: break; @@ -52,11 +63,11 @@ void callBuiltIn(int cmd_id, char * arg) void add_history(char * cmd) { - struct node *tmp = history->next; - struct node *prev = history; + HISTORY *tmp = history->next; + HISTORY *prev = history; if(history->cmd == NULL) { - history->cmd = malloc(strlen(cmd) + 1); + history->cmd = malloc((strlen(cmd) + 1)*sizeof(char)); strcpy(history->cmd, cmd); } else @@ -66,101 +77,206 @@ void add_history(char * cmd) prev = tmp; tmp = tmp->next; } - tmp = malloc(sizeof(struct node)); - tmp->cmd = malloc(strlen(cmd)); + tmp = malloc(sizeof(HISTORY)); + tmp->cmd = malloc((strlen(cmd) + 1)*sizeof(char)); tmp->next = NULL; strcpy(tmp->cmd, cmd); prev->next = tmp; } } -void print_history() +void print_history(COMMAND *cmd) { - struct node *tmp = history; + int n = 10; + char * end; + int fd_out; + int fd_std = dup(STDOUT_FILENO); + if(cmd->output_r) + { + if(cmd->output_r_append) + fd_out = open(cmd->output_r_filename, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + else + fd_out = open(cmd->output_r_filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + dup2(fd_out, 1); + } + if (cmd->args[1] != NULL) n = strtol(cmd->args[1], &end, 10); + HISTORY *tmp = history; int i = 1; printf("%d %s\n", i, tmp->cmd); - while(tmp->next != NULL) + while(tmp->next != NULL && (i < n)) { i++; tmp = tmp->next; printf("%d %s\n", i, tmp->cmd); } + dup2(fd_std, 1); + close(fd_out); +} + +void free_history() +{ + HISTORY *tmp = history; + while(tmp != NULL) + { + free(tmp->cmd); + tmp = tmp->next; + } + free(history); } -void cd() +void cd(char * arg) { int error; - if(parsed[1] == NULL) error = chdir(userdir); - else error = chdir(parsed[1]); - if (error == -1) printf("bash: cd: %s: %s\n", parsed[1],strerror(errno)); + if(arg == NULL) error = chdir(userdir); + else error = chdir(arg); + if (error == -1) printf("bash: cd: %s: %s\n", arg,strerror(errno)); } -void pwd() +void pwd(COMMAND *cmd) { + int fd_out; + int fd_std = dup(STDOUT_FILENO); + if(cmd->output_r) + { + if(cmd->output_r_append) + fd_out = open(cmd->output_r_filename, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + else + fd_out = open(cmd->output_r_filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + dup2(fd_out, 1); + } char path[256]; getcwd(path, 256); printf("%s\n", path); + dup2(fd_std, 1); + close(fd_out); } -void jobs() +void jobs(COMMAND *cmd) { NODE *aux = childs->first; - ITEM * item; + PROCESS * proc; + int fd_out; + int fd_std = dup(STDOUT_FILENO); + if(cmd->output_r) + { + if(cmd->output_r_append) + fd_out = open(cmd->output_r_filename, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + else + fd_out = open(cmd->output_r_filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + dup2(fd_out, 1); + } while (aux != NULL) { - item = aux->item; - printf("[%d] %s %s\n",item->pid, item->status, item->command); + proc = aux->proc; + printf("[%d] %s %s\n",proc->pid, proc->status, proc->command); aux = aux->next; } + dup2(fd_std, 1); + close(fd_out); } void bg(char * arg) { - if(!ListIsEmpty(childs)) { - char * end; + if(!ListIsEmpty(childs)) + { int n; - pid_t pid; + PROCESS *process; if(arg == NULL) - pid = ListLastStoppedToBg(childs); - else { - n = strtol(arg, &end, 10); - printf("n: %d", n); - pid = ListToBg(childs, n); + process = ListGetLastStopped(childs); + else + { + n = strtol(arg, NULL, 10); + process = ListGetProcess(childs, n); } - printf("pid escolhido: %d", pid); - kill(pid, SIGCONT); + if (process) + if(kill(process->pid, SIGCONT) == 0) + { + process->isBackground = 1; + strcpy(process->status, "Running"); + } } } void fg(char * arg) { - if(!ListIsEmpty(childs)) { - char * end; - int n; - pid_t pid, pidfg; - int status; + int n; + pid_t pidfg; + int status; + sigset_t chldMask; + sigemptyset (&chldMask); + sigaddset(&chldMask, SIGCHLD); + PROCESS * process; + if(!ListIsEmpty(childs)) + { if(arg == NULL) - pid = ListLastToFg(childs); - else { - n = strtol(arg, &end, 10); - pid = ListToFg(childs, n); + process = childs->first->proc; + else + { + n = strtol(arg, NULL, 10); + process = ListGetProcess(childs, n); } - child_handler_lock = 1; - pidfg = waitpid(pid, &status, WUNTRACED); - child_handler_lock = 0; - if ((pidfg >= 0) && (WIFSTOPPED(status) == 0)) ListRemoveByPid(childs, childPid); + if(process) + if(kill(process->pid, SIGCONT) == 0) + { + process->isBackground = 0; + strcpy(process->status, "Running"); + sigprocmask(SIG_BLOCK, &chldMask, NULL); + pidfg = waitpid(process->pid, &status, WUNTRACED); + if ((pidfg >= 0) && (WIFSTOPPED(status) == 0)) ListRemoveByPid(childs, pidfg); + sigprocmask(SIG_UNBLOCK, &chldMask, NULL); + } + } } void kill_cmd(char * arg) { - if(!ListIsEmpty(childs)) { + if(!ListIsEmpty(childs)) + { char * end; int n; NODE * aux = childs->last; - if(arg == NULL) n = aux->item->pid; + if(arg == NULL) n = aux->proc->pid; else n = strtol(arg, &end, 10); - kill(n, SIGTERM); + kill(n, SIGTERM); } +} +void echo(COMMAND *cmd) +{ + int i; + int fd_out; + int fd_std = dup(STDOUT_FILENO); + if(cmd->output_r) + { + if(cmd->output_r_append) + fd_out = open(cmd->output_r_filename, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + else + fd_out = open(cmd->output_r_filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + dup2(fd_out, 1); + } + for(i = 1; i < cmd->size; i++) + { + printf("%s ", cmd->args[i]); + } + if (cmd->size > 1) printf("\n"); + dup2(fd_std, 1); + close(fd_out); +} + +void about(COMMAND *cmd) +{ + int fd_out; + int fd_std = dup(STDOUT_FILENO); + if(cmd->output_r) + { + if(cmd->output_r_append) + fd_out = open(cmd->output_r_filename, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + else + fd_out = open(cmd->output_r_filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + dup2(fd_out, 1); + } + printf("Shell para trabalho de SSC0141.\nDesenvolvido por Lucas Lobosque e Leandro Pozer.\n"); + dup2(fd_std, 1); + close(fd_out); } diff --git a/builtin.h b/builtin.h old mode 100644 new mode 100755 index 03391fa..3f25062 --- a/builtin.h +++ b/builtin.h @@ -1,24 +1,121 @@ #ifndef _BUILTIN_H_ #define _BUILTIN_H_ -struct node -{ - char * cmd; - struct node *next; -}; +/** +* @brief Verifica se o comando é BuiltIn +* +* Se o comando for BuiltIn, retorna seu id para ser executado +* posteriormente. +* @param cmd - comando a ser analisado. +* @return Valor do id do comando. +* @retval -1 Se o comando não é BuiltIn. +* +*/ +int isBuiltIn(char * cmd); -struct node *history; +/** +* @brief Executa o comando BuiltIn. +* @param cmd_id - id do comando a ser executado, retorno da função isBuiltIn. +* @param cmd - Estrutura com informações do comando. +* @return void. +* +*/ +void callBuiltIn(int cmd_id, COMMAND *cmd); -pid_t childPid; -int isBuiltIn(char * cmd); -void callBuiltIn(int cmd_id, char * arg); +/** +* @brief Adiciona o comando do usuário na lista do histórico. +* @param cmd - Comando a ser adicionado. +* @return void. +* +*/ void add_history(char * cmd); -void print_history(); -void cd(); -void pwd(); -void jobs(); + +/** +* @brief Imprime os comando armazenados no histórico. +* @param cmd - Estrutura com possível parâmetro do comando, representa +* quantos comandos deseja imprimir, se for NULL imprime os últimos +* 10, que é o valor default. +* @return void. +* +*/ +void print_history(COMMAND *cmd); + +/** +* @brief Libera memória alocada pelo histórico. +* @return void. +* +*/ +void free_history(); + +/** +* @brief Muda o diretório atual no qual o sistema está trabalhando. +* @param arg - Diretorio para o qual deseja mudar. +* @return void. +* +*/ +void cd(char * arg); + +/** +* @brief Mostra o diretório no qual o sistema está trabalhando. +* @param cmd - Estrutura com informações do comando. (Necessário para +* redirecionamento de saída). +* @return void. +* +*/ +void pwd(COMMAND *cmd); + +/** +* @brief Mostra uma lista com os jobs atuais. +* @param cmd - Estrutura com informações do comando. (Necessário para +* redirecionamento de saída). +* @return void. +* +*/ +void jobs(COMMAND *cmd); + +/** +* @brief Coloca um processo em background. +* @param arg - Id do processo a ser colocado em background, se for +* NULL o processo mais recente é colocado em foreground. +* @return void. +* +*/ void bg(char * arg); + +/** +* @brief Coloca um processo suspenso em foreground. +* @param arg - Id do processo a ser colocado em foreground, se for +* NULL o processo suspenso mais recente é colocado em foreground. +* @return void. +* +*/ void fg(char * arg); + +/** +* @brief Manda o sinal SIGTERM para um processo filho +* @param arg - Id do processo a receber o sinal, se for NULL o processo +* mais recente recebe o sinal. +* @return void. +* +*/ void kill_cmd(char * arg); -#endif +/** +* @brief imprime os argumentos enviados na tela. +* @param cmd - Estrutura com informações do comando. Daqui se extrai os +* argumentos a serem imprimidos. (Também necessário para +* redirecionamento de saída). +* @return void. +* +*/ +void echo (COMMAND *cmd); + +/** +* @brief Comando simples que imprime informações sobre os autores. +* @param cmd - Estrutura com informações do comando. (Necessário para +* redirecionamento de saída). +* @return void. +* +*/ +void about(COMMAND *cmd); +#endif diff --git a/docs/annotated.html b/docs/annotated.html new file mode 100644 index 0000000..a864ad8 --- /dev/null +++ b/docs/annotated.html @@ -0,0 +1,90 @@ + + + + +Shell: Estruturas de dados + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+
+
Estruturas de dados
+
+
+
Lista das estruturas de dados com uma breve descrição:
+ + + + + +
COMMANDEstrutura do comando
historyLista simples para uso do comando builtin history
LISTEstrutura da lista em si
NODENó das listas de comandos e processos
PROCESSEstrutura do processo
+
+ + + + +
+ +
+ + + + diff --git a/docs/bc_s.png b/docs/bc_s.png new file mode 100644 index 0000000..e401862 Binary files /dev/null and b/docs/bc_s.png differ diff --git a/docs/classes.html b/docs/classes.html new file mode 100644 index 0000000..4068fec --- /dev/null +++ b/docs/classes.html @@ -0,0 +1,91 @@ + + + + +Shell: Índice das estruturas de dados + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+
+
Índice das estruturas de dados
+
+
+
C | H | L | N | P
+ +
  C  
+
  H  
+
  L  
+
  N  
+
  P  
+
COMMAND   history   LIST   NODE   PROCESS   
C | H | L | N | P
+
+ + + + +
+ +
+ + + + diff --git a/docs/closed.png b/docs/closed.png new file mode 100644 index 0000000..b7d4bd9 Binary files /dev/null and b/docs/closed.png differ diff --git a/docs/d0/d29/main_8c.html b/docs/d0/d29/main_8c.html new file mode 100644 index 0000000..1c86fe7 --- /dev/null +++ b/docs/d0/d29/main_8c.html @@ -0,0 +1,273 @@ + + + + +Shell: Referência ao ficheiro main.c + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência ao ficheiro main.c
+
+
+
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <signal.h>
+#include "main.h"
+#include "parser.h"
+#include "builtin.h"
+#include "list.h"
+
+ + + + + + + + + + + + + + +

+Macros

#define _GNU_SOURCE

+Funções

int main (int argc, char **argv)
void printPrompt ()
 Imprime o prompt na tela (formato copiado do gnome shell).
void termination_handler (int signum)
 Função executada quando usuário manda ctrl+c.
void child_handler (int signum)
 Função executada quando um processo filho termina.
void sigtstop_handler (int signum)
 Função executada quando usuário manda ctrl+z.
void free_memory ()
 Função que libera memória utilizada antes de terminar o programa.
+

Documentação das macros

+ +
+
+ + + + +
#define _GNU_SOURCE
+
+
+ +
+
+

Documentação das funções

+ +
+
+ + + + + + + + +
void child_handler (int signum)
+
+
+ +

Função executada quando um processo filho termina.

+

Esta função só é útil para processos em background, já que ela fica bloqueada quando um processo roda em foreground.

+
Parâmetros:
+ + +
signum- id do sinal.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + +
void free_memory ()
+
+
+ +

Função que libera memória utilizada antes de terminar o programa.

+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
int main (int argc,
char ** argv 
)
+
+
+ +
+
+ +
+
+ + + + + + + +
void printPrompt ()
+
+
+ +

Imprime o prompt na tela (formato copiado do gnome shell).

+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void sigtstop_handler (int signum)
+
+
+ +

Função executada quando usuário manda ctrl+z.

+
Parâmetros:
+ + +
signum- id do sinal.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void termination_handler (int signum)
+
+
+ +

Função executada quando usuário manda ctrl+c.

+
Parâmetros:
+ + +
signum- id do sinal.
+
+
+
Retorna:
void.
+ +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/d1/d2b/Mainpage_8h.html b/docs/d1/d2b/Mainpage_8h.html new file mode 100644 index 0000000..34ebb2e --- /dev/null +++ b/docs/d1/d2b/Mainpage_8h.html @@ -0,0 +1,86 @@ + + + + +Shell: Referência ao ficheiro Mainpage.h + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+
+
Referência ao ficheiro Mainpage.h
+
+ + + + + +
+ +
+ + + + diff --git a/docs/d1/d2b/Mainpage_8h_source.html b/docs/d1/d2b/Mainpage_8h_source.html new file mode 100644 index 0000000..7d23fab --- /dev/null +++ b/docs/d1/d2b/Mainpage_8h_source.html @@ -0,0 +1,83 @@ + + + + +Shell: Mainpage.h Source File + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+
Mainpage.h
+
+ +
+ + + + +
+ +
+ + + + diff --git a/docs/d2/d72/parser_8c.html b/docs/d2/d72/parser_8c.html new file mode 100644 index 0000000..9bc26a7 --- /dev/null +++ b/docs/d2/d72/parser_8c.html @@ -0,0 +1,252 @@ + + + + +Shell: Referência ao ficheiro parser.c + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência ao ficheiro parser.c
+
+
+
#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "parser.h"
+#include "main.h"
+
+ + + + + + + + + + +

+Funções

void imprimir_argv (char **matriz, int tamanho)
int word_count (char *source)
 Conta o número de palavras de uma string.
void getCmds (LIST *cmdList, char *cmdLine)
 Adiciona em uma lista o(s) comando(s) digitado(s) pelo usuário.
void parse (char *cmdLine, COMMAND *cmd)
 Recebe a linha de comando e separa os argumentos.
char * readline ()
 Lê o comando digitado pelo usuário.
+

Documentação das funções

+ +
+
+ + + + + + + + + + + + + + + + + + +
void getCmds (LISTcmdList,
char * cmdLine 
)
+
+
+ +

Adiciona em uma lista o(s) comando(s) digitado(s) pelo usuário.

+

Pega toda a linha de comando digitada e adiciona o comando com seus parâmetros na lista. Em caso de uso do pipe, haverá mais de um comando a ser executado, ela quebrará a linha de comando e colocará cada comando com seus parâmetros em uma lista.

+
Parâmetros:
+ + + +
cmdList- lista onde os comandos serão armazenados
cmdLine- linha de comando digitada pelo usuário
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
void imprimir_argv (char ** matriz,
int tamanho 
)
+
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
void parse (char * cmdLine,
COMMANDcommand 
)
+
+
+ +

Recebe a linha de comando e separa os argumentos.

+

Retira os espaços entre os comandos e seus argumentos, armazena os comandos e seus parâmetros em um vetor de strings, na última posição do vetor coloca NULL, isso para o camando ser interpretado pela função execvp.

+
Parâmetros:
+ + + +
cmdLine- linha de comando que será "parseada".
command- estrutura que receberá cada comando, com suas flags e parâmetros
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + +
char* readline ()
+
+
+ +

Lê o comando digitado pelo usuário.

+
Retorna:
Comando digitado pelo usuário.
+ +
+
+ +
+
+ + + + + + + + +
int word_count (char * source)
+
+
+ +

Conta o número de palavras de uma string.

+
Parâmetros:
+ + +
source- String para contar.
+
+
+
Retorna:
Número de palavras da string passada como parâmetro.
+ +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/d4/dbf/main_8h.html b/docs/d4/dbf/main_8h.html new file mode 100644 index 0000000..74e256e --- /dev/null +++ b/docs/d4/dbf/main_8h.html @@ -0,0 +1,321 @@ + + + + +Shell: Referência ao ficheiro main.h + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência ao ficheiro main.h
+
+
+
#include "list.h"
+
+

Ir para o código fonte deste ficheiro.

+ + + + + + + + + + + + + + + + + + + + +

+Funções

void printPrompt ()
 Imprime o prompt na tela (formato copiado do gnome shell).
void termination_handler (int signum)
 Função executada quando usuário manda ctrl+c.
void child_handler (int signum)
 Função executada quando um processo filho termina.
void sigtstop_handler (int signum)
 Função executada quando usuário manda ctrl+z.
void free_memory ()
 Função que libera memória utilizada antes de terminar o programa.

+Variáveis

char * userdir
char * username
char hostname [256]
char * cmdLine
HISTORYhistory
LISTcmdList
LISTchilds
+

Documentação das funções

+ +
+
+ + + + + + + + +
void child_handler (int signum)
+
+
+ +

Função executada quando um processo filho termina.

+

Esta função só é útil para processos em background, já que ela fica bloqueada quando um processo roda em foreground.

+
Parâmetros:
+ + +
signum- id do sinal.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + +
void free_memory ()
+
+
+ +

Função que libera memória utilizada antes de terminar o programa.

+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + +
void printPrompt ()
+
+
+ +

Imprime o prompt na tela (formato copiado do gnome shell).

+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void sigtstop_handler (int signum)
+
+
+ +

Função executada quando usuário manda ctrl+z.

+
Parâmetros:
+ + +
signum- id do sinal.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void termination_handler (int signum)
+
+
+ +

Função executada quando usuário manda ctrl+c.

+
Parâmetros:
+ + +
signum- id do sinal.
+
+
+
Retorna:
void.
+ +
+
+

Documentação das variáveis

+ +
+
+ + + + +
LIST* childs
+
+
+ +
+
+ +
+
+ + + + +
char* cmdLine
+
+
+ +
+
+ +
+
+ + + + +
LIST* cmdList
+
+
+ +
+
+ +
+
+ + + + +
HISTORY* history
+
+
+ +
+
+ +
+
+ + + + +
char hostname[256]
+
+
+ +
+
+ +
+
+ + + + +
char* userdir
+
+
+ +
+
+ +
+
+ + + + +
char* username
+
+
+ +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/d4/dbf/main_8h_source.html b/docs/d4/dbf/main_8h_source.html new file mode 100644 index 0000000..2b3182d --- /dev/null +++ b/docs/d4/dbf/main_8h_source.html @@ -0,0 +1,106 @@ + + + + +Shell: main.h Source File + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+
main.h
+
+
+Ir para a documentação deste ficheiro.
00001 #ifndef _MAIN_H_
+00002 #define _MAIN_H_
+00003 #include "list.h"
+00004 
+00010 void printPrompt();
+00011 
+00018 void termination_handler(int signum);
+00019 
+00030 void child_handler(int signum);
+00031 
+00038 void sigtstop_handler(int signum);
+00039 
+00046 void free_memory();
+00047 
+00048 char * userdir;
+00049 char * username;
+00050 char hostname[256];
+00051 char * cmdLine;
+00052 
+00053 HISTORY *history;
+00054 LIST * cmdList;
+00055 LIST * childs;
+00056 
+00057 #endif
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/d5/d36/parser_8h.html b/docs/d5/d36/parser_8h.html new file mode 100644 index 0000000..cb1f2cf --- /dev/null +++ b/docs/d5/d36/parser_8h.html @@ -0,0 +1,221 @@ + + + + +Shell: Referência ao ficheiro parser.h + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência ao ficheiro parser.h
+
+
+
#include "list.h"
+
+

Ir para o código fonte deste ficheiro.

+ + + + + + + + + + +

+Funções

int word_count (char *source)
 Conta o número de palavras de uma string.
char * readline ()
 Lê o comando digitado pelo usuário.
void getCmds (LIST *cmdList, char *cmdLine)
 Adiciona em uma lista o(s) comando(s) digitado(s) pelo usuário.
void parse (char *cmdLine, COMMAND *command)
 Recebe a linha de comando e separa os argumentos.
+

Documentação das funções

+ +
+
+ + + + + + + + + + + + + + + + + + +
void getCmds (LISTcmdList,
char * cmdLine 
)
+
+
+ +

Adiciona em uma lista o(s) comando(s) digitado(s) pelo usuário.

+

Pega toda a linha de comando digitada e adiciona o comando com seus parâmetros na lista. Em caso de uso do pipe, haverá mais de um comando a ser executado, ela quebrará a linha de comando e colocará cada comando com seus parâmetros em uma lista.

+
Parâmetros:
+ + + +
cmdList- lista onde os comandos serão armazenados
cmdLine- linha de comando digitada pelo usuário
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
void parse (char * cmdLine,
COMMANDcommand 
)
+
+
+ +

Recebe a linha de comando e separa os argumentos.

+

Retira os espaços entre os comandos e seus argumentos, armazena os comandos e seus parâmetros em um vetor de strings, na última posição do vetor coloca NULL, isso para o camando ser interpretado pela função execvp.

+
Parâmetros:
+ + + +
cmdLine- linha de comando que será "parseada".
command- estrutura que receberá cada comando, com suas flags e parâmetros
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + +
char* readline ()
+
+
+ +

Lê o comando digitado pelo usuário.

+
Retorna:
Comando digitado pelo usuário.
+ +
+
+ +
+
+ + + + + + + + +
int word_count (char * source)
+
+
+ +

Conta o número de palavras de uma string.

+
Parâmetros:
+ + +
source- String para contar.
+
+
+
Retorna:
Número de palavras da string passada como parâmetro.
+ +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/d5/d36/parser_8h_source.html b/docs/d5/d36/parser_8h_source.html new file mode 100644 index 0000000..e09c6cb --- /dev/null +++ b/docs/d5/d36/parser_8h_source.html @@ -0,0 +1,94 @@ + + + + +Shell: parser.h Source File + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+
parser.h
+
+
+Ir para a documentação deste ficheiro.
00001 #ifndef _PARSER_H_
+00002 #define _PARSER_H_
+00003 #include "list.h"
+00010 int word_count(char * source);
+00011 
+00017 char * readline();
+00018 
+00032 void getCmds(LIST *cmdList, char *cmdLine);
+00033 
+00046 void parse(char * cmdLine, COMMAND * command);
+00047 
+00048 #endif
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/d6/dcd/builtin_8h.html b/docs/d6/dcd/builtin_8h.html new file mode 100644 index 0000000..444e51c --- /dev/null +++ b/docs/d6/dcd/builtin_8h.html @@ -0,0 +1,466 @@ + + + + +Shell: Referência ao ficheiro builtin.h + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência ao ficheiro builtin.h
+
+
+ +

Ir para o código fonte deste ficheiro.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Funções

int isBuiltIn (char *cmd)
 Verifica se o comando é BuiltIn.
void callBuiltIn (int cmd_id, COMMAND *cmd)
 Executa o comando BuiltIn.
void add_history (char *cmd)
 Adiciona o comando do usuário na lista do histórico.
void print_history (COMMAND *cmd)
 Imprime os comando armazenados no histórico.
void free_history ()
 Libera memória alocada pelo histórico.
void cd (char *arg)
 Muda o diretório atual no qual o sistema está trabalhando.
void pwd (COMMAND *cmd)
 Mostra o diretório no qual o sistema está trabalhando.
void jobs (COMMAND *cmd)
 Mostra uma lista com os jobs atuais.
void bg (char *arg)
 Coloca um processo em background.
void fg (char *arg)
 Coloca um processo suspenso em foreground.
void kill_cmd (char *arg)
 Manda o sinal SIGTERM para um processo filho.
void echo (COMMAND *cmd)
 imprime os argumentos enviados na tela.
void about (COMMAND *cmd)
 Comando simples que imprime informações sobre os autores.
+

Documentação das funções

+ +
+
+ + + + + + + + +
void about (COMMANDcmd)
+
+
+ +

Comando simples que imprime informações sobre os autores.

+
Parâmetros:
+ + +
cmd- Estrutura com informações do comando. (Necessário para redirecionamento de saída).
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void add_history (char * cmd)
+
+
+ +

Adiciona o comando do usuário na lista do histórico.

+
Parâmetros:
+ + +
cmd- Comando a ser adicionado.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void bg (char * arg)
+
+
+ +

Coloca um processo em background.

+
Parâmetros:
+ + +
arg- Id do processo a ser colocado em background, se for NULL o processo mais recente é colocado em foreground.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
void callBuiltIn (int cmd_id,
COMMANDcmd 
)
+
+
+ +

Executa o comando BuiltIn.

+
Parâmetros:
+ + + +
cmd_id- id do comando a ser executado, retorno da função isBuiltIn.
cmd- Estrutura com informações do comando.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void cd (char * arg)
+
+
+ +

Muda o diretório atual no qual o sistema está trabalhando.

+
Parâmetros:
+ + +
arg- Diretorio para o qual deseja mudar.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void echo (COMMANDcmd)
+
+
+ +

imprime os argumentos enviados na tela.

+
Parâmetros:
+ + +
cmd- Estrutura com informações do comando. Daqui se extrai os argumentos a serem imprimidos. (Também necessário para redirecionamento de saída).
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void fg (char * arg)
+
+
+ +

Coloca um processo suspenso em foreground.

+
Parâmetros:
+ + +
arg- Id do processo a ser colocado em foreground, se for NULL o processo suspenso mais recente é colocado em foreground.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + +
void free_history ()
+
+
+ +

Libera memória alocada pelo histórico.

+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
int isBuiltIn (char * cmd)
+
+
+ +

Verifica se o comando é BuiltIn.

+

Se o comando for BuiltIn, retorna seu id para ser executado posteriormente.

+
Parâmetros:
+ + +
cmd- comando a ser analisado.
+
+
+
Retorna:
Valor do id do comando.
+
Valores retornados:
+ + +
-1Se o comando não é BuiltIn.
+
+
+ +
+
+ +
+
+ + + + + + + + +
void jobs (COMMANDcmd)
+
+
+ +

Mostra uma lista com os jobs atuais.

+
Parâmetros:
+ + +
cmd- Estrutura com informações do comando. (Necessário para redirecionamento de saída).
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void kill_cmd (char * arg)
+
+
+ +

Manda o sinal SIGTERM para um processo filho.

+
Parâmetros:
+ + +
arg- Id do processo a receber o sinal, se for NULL o processo mais recente recebe o sinal.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void print_history (COMMANDcmd)
+
+
+ +

Imprime os comando armazenados no histórico.

+
Parâmetros:
+ + +
cmd- Estrutura com possível parâmetro do comando, representa quantos comandos deseja imprimir, se for NULL imprime os últimos 10, que é o valor default.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void pwd (COMMANDcmd)
+
+
+ +

Mostra o diretório no qual o sistema está trabalhando.

+
Parâmetros:
+ + +
cmd- Estrutura com informações do comando. (Necessário para redirecionamento de saída).
+
+
+
Retorna:
void.
+ +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/d6/dcd/builtin_8h_source.html b/docs/d6/dcd/builtin_8h_source.html new file mode 100644 index 0000000..c034c00 --- /dev/null +++ b/docs/d6/dcd/builtin_8h_source.html @@ -0,0 +1,111 @@ + + + + +Shell: builtin.h Source File + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+
builtin.h
+
+
+Ir para a documentação deste ficheiro.
00001 #ifndef _BUILTIN_H_
+00002 #define _BUILTIN_H_
+00003 
+00014 int isBuiltIn(char * cmd);
+00015 
+00023 void callBuiltIn(int cmd_id, COMMAND *cmd);
+00024 
+00031 void add_history(char * cmd);
+00032 
+00041 void print_history(COMMAND *cmd);
+00042 
+00048 void free_history();
+00049 
+00056 void cd(char * arg);
+00057 
+00065 void pwd(COMMAND *cmd);
+00066 
+00074 void jobs(COMMAND *cmd);
+00075 
+00083 void bg(char * arg);
+00084 
+00092 void fg(char * arg);
+00093 
+00101 void kill_cmd(char * arg);
+00102 
+00111 void echo (COMMAND *cmd);
+00112 
+00120 void about(COMMAND *cmd);
+00121 #endif
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/d7/d40/list_8c.html b/docs/d7/d40/list_8c.html new file mode 100644 index 0000000..46a6f0c --- /dev/null +++ b/docs/d7/d40/list_8c.html @@ -0,0 +1,407 @@ + + + + +Shell: Referência ao ficheiro list.c + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência ao ficheiro list.c
+
+
+
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "list.h"
+
+ + + + + + + + + + + + + + + + + + + +

+Funções

void ListCreate (LIST *list)
 Inicializa a lista para uso posterior.
void initCommand (COMMAND *cmd)
 Inicializa um comando (estrutura) para uso posterior.
int ListIsEmpty (LIST *list)
 Verifica se uma lista está vazia.
int ListInsert (LIST *list, PROCESS *proc, COMMAND *cmd)
 Insere um processo e/ou um comando na lista.
int ListRemoveByPid (LIST *list, pid_t pid)
 Remove um processo da lista pelo seu ID.
PROCESSListGetCurrentProcess (LIST *list)
 Retorna o processo que está rodando em foreground.
PROCESSListGetLastStopped (LIST *list)
 Busca e retorna o processo parado mais recente.
PROCESSListGetProcess (LIST *list, pid_t pid)
 Retorna um processo pelo seu id.
void ListPurgeCmds (LIST *list)
 Libera espaço alocado pela lista de comandos.
+

Documentação das funções

+ +
+
+ + + + + + + + +
void initCommand (COMMANDcmd)
+
+
+ +

Inicializa um comando (estrutura) para uso posterior.

+
Parâmetros:
+ + +
cmd- Ponteiro para comando (estrutura) a ser inicializada.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void ListCreate (LISTlist)
+
+
+ +

Inicializa a lista para uso posterior.

+
Parâmetros:
+ + +
list- Ponteiro para lista a ser inicializada.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
PROCESS* ListGetCurrentProcess (LISTlist)
+
+
+ +

Retorna o processo que está rodando em foreground.

+
Parâmetros:
+ + +
list- Ponteiro para a lista de processos.
+
+
+
Retorna:
Processo em questão. (NULL caso não tenha um).
+ +
+
+ +
+
+ + + + + + + + +
PROCESS* ListGetLastStopped (LISTlist)
+
+
+ +

Busca e retorna o processo parado mais recente.

+
Parâmetros:
+ + +
list- Ponteiro para a lista de processos.
+
+
+
Retorna:
Processo em questão. (NULL caso não tenha um).
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
PROCESS* ListGetProcess (LISTlist,
pid_t pid 
)
+
+
+ +

Retorna um processo pelo seu id.

+
Parâmetros:
+ + + +
list- Ponteiro para a lista.
pid- Id do processo a ser procurado.
+
+
+
Retorna:
Ponteiro para o processo. (NULL caso não encontrado).
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
int ListInsert (LISTlist,
PROCESSproc,
COMMANDcmd 
)
+
+
+ +

Insere um processo e/ou um comando na lista.

+

Na prática, deve ser usada uma lista para comandos e outra para processos. Elas só estão na mesma estrutura para evitar repetição de código. Caso esteja inserindo em uma lista de processos, o argumento cmd deve ser NULL. Caso esteja inserindo em uma lista de comandos, o argumento proc deve ser NULL.

+
Parâmetros:
+ + + + +
list- Ponteiro para a lista.
proc- Ponteiro para processo (estrutura).
cmd- Ponteiro para comando (estrutura).
+
+
+
Retorna:
Se foi possível inserir.
+
Valores retornados:
+ + + +
1- Sim.
0- Não.
+
+
+ +
+
+ +
+
+ + + + + + + + +
int ListIsEmpty (LISTlist)
+
+
+ +

Verifica se uma lista está vazia.

+
Parâmetros:
+ + +
list- Ponteiro para a lista.
+
+
+
Retorna:
Se a lista está vazia.
+
Valores retornados:
+ + + +
1- Sim.
0- Não.
+
+
+ +
+
+ +
+
+ + + + + + + + +
void ListPurgeCmds (LISTlist)
+
+
+ +

Libera espaço alocado pela lista de comandos.

+
Parâmetros:
+ + +
list- Ponteiro para a lista de comandos.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
int ListRemoveByPid (LISTlist,
pid_t pid 
)
+
+
+ +

Remove um processo da lista pelo seu ID.

+
Parâmetros:
+ + + +
list- Ponteiro para a lista de processos.
pid- ID do processo.
+
+
+
Retorna:
Se a remoção foi feita.
+
Valores retornados:
+ + + +
1- Sim.
0- Não.
+
+
+ +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/d8/d91/structLIST.html b/docs/d8/d91/structLIST.html new file mode 100644 index 0000000..d7b0872 --- /dev/null +++ b/docs/d8/d91/structLIST.html @@ -0,0 +1,128 @@ + + + + +Shell: Referência à estrutura LIST + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência à estrutura LIST
+
+
+ +

Estrutura da lista em si. + Mais...

+ +

#include <list.h>

+ + + + +

+Campos de Dados

NODEfirst
NODElast
+

Descrição detalhada

+

Estrutura da lista em si.

+

Documentação dos campos e atributos

+ +
+
+ + + + +
NODE* LIST::first
+
+
+ +
+
+ +
+
+ + + + +
NODE* LIST::last
+
+
+ +
+
+
A documentação para esta estrutura foi gerada a partir do seguinte ficheiro: +
+ + + + +
+ +
+ + + + diff --git a/docs/d9/d2e/structhistory.html b/docs/d9/d2e/structhistory.html new file mode 100644 index 0000000..5dfa6ca --- /dev/null +++ b/docs/d9/d2e/structhistory.html @@ -0,0 +1,128 @@ + + + + +Shell: Referência à estrutura history + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência à estrutura history
+
+
+ +

Lista simples para uso do comando builtin history. + Mais...

+ +

#include <list.h>

+ + + + +

+Campos de Dados

char * cmd
struct historynext
+

Descrição detalhada

+

Lista simples para uso do comando builtin history.

+

Documentação dos campos e atributos

+ +
+
+ + + + +
char* history::cmd
+
+
+ +
+
+ +
+
+ + + + +
struct history* history::next
+
+
+ +
+
+
A documentação para esta estrutura foi gerada a partir do seguinte ficheiro: +
+ + + + +
+ +
+ + + + diff --git a/docs/da/d23/list_8h.html b/docs/da/d23/list_8h.html new file mode 100644 index 0000000..b53913f --- /dev/null +++ b/docs/da/d23/list_8h.html @@ -0,0 +1,457 @@ + + + + +Shell: Referência ao ficheiro list.h + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência ao ficheiro list.h
+
+
+ +

Ir para o código fonte deste ficheiro.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Estruturas de Dados

struct  history
 Lista simples para uso do comando builtin history. Mais...
struct  PROCESS
 Estrutura do processo. Mais...
struct  COMMAND
 Estrutura do comando. Mais...
struct  NODE
 Nó das listas de comandos e processos. Mais...
struct  LIST
 Estrutura da lista em si. Mais...

+Definições de tipos

typedef struct history HISTORY
 Lista simples para uso do comando builtin history.
typedef struct NODE NODE
 Nó das listas de comandos e processos.

+Funções

void ListCreate (LIST *list)
 Inicializa a lista para uso posterior.
void initCommand (COMMAND *cmd)
 Inicializa um comando (estrutura) para uso posterior.
int ListIsEmpty (LIST *list)
 Verifica se uma lista está vazia.
int ListInsert (LIST *list, PROCESS *proc, COMMAND *cmd)
 Insere um processo e/ou um comando na lista.
int ListRemoveByPid (LIST *list, pid_t pid)
 Remove um processo da lista pelo seu ID.
PROCESSListGetCurrentProcess (LIST *list)
 Retorna o processo que está rodando em foreground.
PROCESSListGetLastStopped (LIST *list)
 Busca e retorna o processo parado mais recente.
PROCESSListGetProcess (LIST *list, pid_t pid)
 Retorna um processo pelo seu id.
void ListPurgeCmds (LIST *list)
 Libera espaço alocado pela lista de comandos.
+

Documentação dos tipos

+ +
+
+ + + + +
typedef struct history HISTORY
+
+
+ +

Lista simples para uso do comando builtin history.

+ +
+
+ +
+
+ + + + +
typedef struct NODE NODE
+
+
+ +

Nó das listas de comandos e processos.

+

Temos na mesma estrutura de nó um ponteiro para comando e outro para processo. Isso foi feito para facilitar a implementação, os dois não devem ser usados juntos.

+ +
+
+

Documentação das funções

+ +
+
+ + + + + + + + +
void initCommand (COMMANDcmd)
+
+
+ +

Inicializa um comando (estrutura) para uso posterior.

+
Parâmetros:
+ + +
cmd- Ponteiro para comando (estrutura) a ser inicializada.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void ListCreate (LISTlist)
+
+
+ +

Inicializa a lista para uso posterior.

+
Parâmetros:
+ + +
list- Ponteiro para lista a ser inicializada.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
PROCESS* ListGetCurrentProcess (LISTlist)
+
+
+ +

Retorna o processo que está rodando em foreground.

+
Parâmetros:
+ + +
list- Ponteiro para a lista de processos.
+
+
+
Retorna:
Processo em questão. (NULL caso não tenha um).
+ +
+
+ +
+
+ + + + + + + + +
PROCESS* ListGetLastStopped (LISTlist)
+
+
+ +

Busca e retorna o processo parado mais recente.

+
Parâmetros:
+ + +
list- Ponteiro para a lista de processos.
+
+
+
Retorna:
Processo em questão. (NULL caso não tenha um).
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
PROCESS* ListGetProcess (LISTlist,
pid_t pid 
)
+
+
+ +

Retorna um processo pelo seu id.

+
Parâmetros:
+ + + +
list- Ponteiro para a lista.
pid- Id do processo a ser procurado.
+
+
+
Retorna:
Ponteiro para o processo. (NULL caso não encontrado).
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
int ListInsert (LISTlist,
PROCESSproc,
COMMANDcmd 
)
+
+
+ +

Insere um processo e/ou um comando na lista.

+

Na prática, deve ser usada uma lista para comandos e outra para processos. Elas só estão na mesma estrutura para evitar repetição de código. Caso esteja inserindo em uma lista de processos, o argumento cmd deve ser NULL. Caso esteja inserindo em uma lista de comandos, o argumento proc deve ser NULL.

+
Parâmetros:
+ + + + +
list- Ponteiro para a lista.
proc- Ponteiro para processo (estrutura).
cmd- Ponteiro para comando (estrutura).
+
+
+
Retorna:
Se foi possível inserir.
+
Valores retornados:
+ + + +
1- Sim.
0- Não.
+
+
+ +
+
+ +
+
+ + + + + + + + +
int ListIsEmpty (LISTlist)
+
+
+ +

Verifica se uma lista está vazia.

+
Parâmetros:
+ + +
list- Ponteiro para a lista.
+
+
+
Retorna:
Se a lista está vazia.
+
Valores retornados:
+ + + +
1- Sim.
0- Não.
+
+
+ +
+
+ +
+
+ + + + + + + + +
void ListPurgeCmds (LISTlist)
+
+
+ +

Libera espaço alocado pela lista de comandos.

+
Parâmetros:
+ + +
list- Ponteiro para a lista de comandos.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
int ListRemoveByPid (LISTlist,
pid_t pid 
)
+
+
+ +

Remove um processo da lista pelo seu ID.

+
Parâmetros:
+ + + +
list- Ponteiro para a lista de processos.
pid- ID do processo.
+
+
+
Retorna:
Se a remoção foi feita.
+
Valores retornados:
+ + + +
1- Sim.
0- Não.
+
+
+ +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/da/d23/list_8h_source.html b/docs/da/d23/list_8h_source.html new file mode 100644 index 0000000..78f6340 --- /dev/null +++ b/docs/da/d23/list_8h_source.html @@ -0,0 +1,149 @@ + + + + +Shell: list.h Source File + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+
list.h
+
+
+Ir para a documentação deste ficheiro.
00001 #ifndef _LISTA_H_
+00002 #define _LISTA_H_
+00003 
+00007 typedef struct history
+00008 {
+00009     char * cmd;
+00010     struct history *next;
+00011 } HISTORY;
+00012 
+00019 typedef struct
+00020 {
+00021     pid_t pid;
+00022     char command[256];
+00023     char status[100];
+00024     int isBackground;
+00025 } PROCESS;
+00026 
+00037 typedef struct
+00038 {
+00039     char **args;
+00040     int isBackground;
+00041     int input_r;
+00042     int output_r;
+00043     int output_r_append;
+00044     int size;
+00045     char * output_r_filename;
+00046     char * input_r_filename;
+00047     int id;
+00048     int pipe[2];
+00049     pid_t pid;
+00050 } COMMAND;
+00051 
+00059 typedef struct NODE
+00060 {
+00061     PROCESS *proc;
+00062     COMMAND *cmd;
+00063     struct NODE *next;
+00064     struct NODE *prev;
+00065 } NODE;
+00066 
+00067 
+00071 typedef struct
+00072 {
+00073     NODE *first;
+00074     NODE *last;
+00075 } LIST;
+00076 
+00077 
+00082 void ListCreate(LIST *list);
+00083 
+00090 void initCommand(COMMAND *cmd);
+00091 
+00098 int ListIsEmpty(LIST *list);
+00099 
+00117 int ListInsert(LIST *list, PROCESS *proc, COMMAND *cmd);
+00118 
+00126 int ListRemoveByPid(LIST *list, pid_t pid);
+00127 
+00132 PROCESS *ListGetCurrentProcess(LIST *list);
+00133 
+00138 PROCESS * ListGetLastStopped(LIST *list);
+00139 
+00146 PROCESS * ListGetProcess(LIST *list, pid_t pid);
+00147 
+00152 void ListPurgeCmds(LIST *list);
+00153 
+00154 #endif
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/db/d62/structNODE.html b/docs/db/d62/structNODE.html new file mode 100644 index 0000000..97208da --- /dev/null +++ b/docs/db/d62/structNODE.html @@ -0,0 +1,157 @@ + + + + +Shell: Referência à estrutura NODE + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência à estrutura NODE
+
+
+ +

Nó das listas de comandos e processos. + Mais...

+ +

#include <list.h>

+ + + + + + +

+Campos de Dados

PROCESSproc
COMMANDcmd
struct NODEnext
struct NODEprev
+

Descrição detalhada

+

Nó das listas de comandos e processos.

+

Temos na mesma estrutura de nó um ponteiro para comando e outro para processo. Isso foi feito para facilitar a implementação, os dois não devem ser usados juntos.

+

Documentação dos campos e atributos

+ +
+
+ + + + +
COMMAND* NODE::cmd
+
+
+ +
+
+ +
+
+ + + + +
struct NODE* NODE::next
+
+
+ +
+
+ +
+
+ + + + +
struct NODE* NODE::prev
+
+
+ +
+
+ +
+
+ + + + +
PROCESS* NODE::proc
+
+
+ +
+
+
A documentação para esta estrutura foi gerada a partir do seguinte ficheiro: +
+ + + + +
+ +
+ + + + diff --git a/docs/dc/d56/structCOMMAND.html b/docs/dc/d56/structCOMMAND.html new file mode 100644 index 0000000..df437f2 --- /dev/null +++ b/docs/dc/d56/structCOMMAND.html @@ -0,0 +1,255 @@ + + + + +Shell: Referência à estrutura COMMAND + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência à estrutura COMMAND
+
+
+ +

Estrutura do comando. + Mais...

+ +

#include <list.h>

+ + + + + + + + + + + + + +

+Campos de Dados

char ** args
int isBackground
int input_r
int output_r
int output_r_append
int size
char * output_r_filename
char * input_r_filename
int id
int pipe [2]
pid_t pid
+

Descrição detalhada

+

Estrutura do comando.

+

Esta estrutura guarda todas as informações pertinentes de um comando. Nesta implementação, um comando é definido como um execultável ou builtin e seus argumentos. cat arquivo | grep palavra | cut -c 1-6 tem 3 comandos, por exemplo.

+

Documentação dos campos e atributos

+ +
+
+ + + + +
char** COMMAND::args
+
+
+ +
+
+ +
+
+ + + + +
int COMMAND::id
+
+
+ +
+
+ +
+
+ + + + +
int COMMAND::input_r
+
+
+ +
+
+ +
+
+ + + + +
char* COMMAND::input_r_filename
+
+
+ +
+
+ +
+
+ + + + +
int COMMAND::isBackground
+
+
+ +
+
+ +
+
+ + + + +
int COMMAND::output_r
+
+
+ +
+
+ +
+
+ + + + +
int COMMAND::output_r_append
+
+
+ +
+
+ +
+
+ + + + +
char* COMMAND::output_r_filename
+
+
+ +
+
+ +
+
+ + + + +
pid_t COMMAND::pid
+
+
+ +
+
+ +
+
+ + + + +
int COMMAND::pipe[2]
+
+
+ +
+
+ +
+
+ + + + +
int COMMAND::size
+
+
+ +
+
+
A documentação para esta estrutura foi gerada a partir do seguinte ficheiro: +
+ + + + +
+ +
+ + + + diff --git a/docs/dc/dd8/structPROCESS.html b/docs/dc/dd8/structPROCESS.html new file mode 100644 index 0000000..fb3923c --- /dev/null +++ b/docs/dc/dd8/structPROCESS.html @@ -0,0 +1,157 @@ + + + + +Shell: Referência à estrutura PROCESS + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência à estrutura PROCESS
+
+
+ +

Estrutura do processo. + Mais...

+ +

#include <list.h>

+ + + + + + +

+Campos de Dados

pid_t pid
char command [256]
char status [100]
int isBackground
+

Descrição detalhada

+

Estrutura do processo.

+

Esta estrutura guarda todas as informações pertinentes de um processo.

+

Documentação dos campos e atributos

+ +
+
+ + + + +
char PROCESS::command[256]
+
+
+ +
+
+ +
+
+ + + + +
int PROCESS::isBackground
+
+
+ +
+
+ +
+
+ + + + +
pid_t PROCESS::pid
+
+
+ +
+
+ +
+
+ + + + +
char PROCESS::status[100]
+
+
+ +
+
+
A documentação para esta estrutura foi gerada a partir do seguinte ficheiro: +
+ + + + +
+ +
+ + + + diff --git a/docs/dd/da0/todo.html b/docs/dd/da0/todo.html new file mode 100644 index 0000000..37c8976 --- /dev/null +++ b/docs/dd/da0/todo.html @@ -0,0 +1,82 @@ + + + + +Shell: Lista de tarefas + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ +
+
+
+
Lista de tarefas
+
+
+

+
+
page Eina
+
add debug function
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/df/d8a/builtin_8c.html b/docs/df/d8a/builtin_8c.html new file mode 100644 index 0000000..ca96261 --- /dev/null +++ b/docs/df/d8a/builtin_8c.html @@ -0,0 +1,475 @@ + + + + +Shell: Referência ao ficheiro builtin.c + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+ +
+
Referência ao ficheiro builtin.c
+
+
+
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <wait.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "main.h"
+#include "builtin.h"
+#include "parser.h"
+#include "list.h"
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Funções

int isBuiltIn (char *cmd)
 Verifica se o comando é BuiltIn.
void callBuiltIn (int cmd_id, COMMAND *cmd)
 Executa o comando BuiltIn.
void add_history (char *cmd)
 Adiciona o comando do usuário na lista do histórico.
void print_history (COMMAND *cmd)
 Imprime os comando armazenados no histórico.
void free_history ()
 Libera memória alocada pelo histórico.
void cd (char *arg)
 Muda o diretório atual no qual o sistema está trabalhando.
void pwd (COMMAND *cmd)
 Mostra o diretório no qual o sistema está trabalhando.
void jobs (COMMAND *cmd)
 Mostra uma lista com os jobs atuais.
void bg (char *arg)
 Coloca um processo em background.
void fg (char *arg)
 Coloca um processo suspenso em foreground.
void kill_cmd (char *arg)
 Manda o sinal SIGTERM para um processo filho.
void echo (COMMAND *cmd)
 imprime os argumentos enviados na tela.
void about (COMMAND *cmd)
 Comando simples que imprime informações sobre os autores.
+

Documentação das funções

+ +
+
+ + + + + + + + +
void about (COMMANDcmd)
+
+
+ +

Comando simples que imprime informações sobre os autores.

+
Parâmetros:
+ + +
cmd- Estrutura com informações do comando. (Necessário para redirecionamento de saída).
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void add_history (char * cmd)
+
+
+ +

Adiciona o comando do usuário na lista do histórico.

+
Parâmetros:
+ + +
cmd- Comando a ser adicionado.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void bg (char * arg)
+
+
+ +

Coloca um processo em background.

+
Parâmetros:
+ + +
arg- Id do processo a ser colocado em background, se for NULL o processo mais recente é colocado em foreground.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
void callBuiltIn (int cmd_id,
COMMANDcmd 
)
+
+
+ +

Executa o comando BuiltIn.

+
Parâmetros:
+ + + +
cmd_id- id do comando a ser executado, retorno da função isBuiltIn.
cmd- Estrutura com informações do comando.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void cd (char * arg)
+
+
+ +

Muda o diretório atual no qual o sistema está trabalhando.

+
Parâmetros:
+ + +
arg- Diretorio para o qual deseja mudar.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void echo (COMMANDcmd)
+
+
+ +

imprime os argumentos enviados na tela.

+
Parâmetros:
+ + +
cmd- Estrutura com informações do comando. Daqui se extrai os argumentos a serem imprimidos. (Também necessário para redirecionamento de saída).
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void fg (char * arg)
+
+
+ +

Coloca um processo suspenso em foreground.

+
Parâmetros:
+ + +
arg- Id do processo a ser colocado em foreground, se for NULL o processo suspenso mais recente é colocado em foreground.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + +
void free_history ()
+
+
+ +

Libera memória alocada pelo histórico.

+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
int isBuiltIn (char * cmd)
+
+
+ +

Verifica se o comando é BuiltIn.

+

Se o comando for BuiltIn, retorna seu id para ser executado posteriormente.

+
Parâmetros:
+ + +
cmd- comando a ser analisado.
+
+
+
Retorna:
Valor do id do comando.
+
Valores retornados:
+ + +
-1Se o comando não é BuiltIn.
+
+
+ +
+
+ +
+
+ + + + + + + + +
void jobs (COMMANDcmd)
+
+
+ +

Mostra uma lista com os jobs atuais.

+
Parâmetros:
+ + +
cmd- Estrutura com informações do comando. (Necessário para redirecionamento de saída).
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void kill_cmd (char * arg)
+
+
+ +

Manda o sinal SIGTERM para um processo filho.

+
Parâmetros:
+ + +
arg- Id do processo a receber o sinal, se for NULL o processo mais recente recebe o sinal.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void print_history (COMMANDcmd)
+
+
+ +

Imprime os comando armazenados no histórico.

+
Parâmetros:
+ + +
cmd- Estrutura com possível parâmetro do comando, representa quantos comandos deseja imprimir, se for NULL imprime os últimos 10, que é o valor default.
+
+
+
Retorna:
void.
+ +
+
+ +
+
+ + + + + + + + +
void pwd (COMMANDcmd)
+
+
+ +

Mostra o diretório no qual o sistema está trabalhando.

+
Parâmetros:
+ + +
cmd- Estrutura com informações do comando. (Necessário para redirecionamento de saída).
+
+
+
Retorna:
void.
+ +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/doxygen.css b/docs/doxygen.css new file mode 100644 index 0000000..74445fe --- /dev/null +++ b/docs/doxygen.css @@ -0,0 +1,835 @@ +/* The standard CSS for doxygen */ + +body, table, div, p, dl { + font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size: 12px; +} + +/* @group Heading Levels */ + +h1 { + font-size: 150%; +} + +.title { + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} + +h2 { + font-size: 120%; +} + +h3 { + font-size: 100%; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd, p.starttd { + margin-top: 2px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + padding: 2px; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #ffffff; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #ffffff; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code { + color: #4665A2; +} + +a.codeRef { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +.fragment { + font-family: monospace, fixed; + font-size: 105%; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; +} + +div.ah { + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 10px; + margin-right: 5px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memItemLeft, .memItemRight, .memTemplParams { + border-top: 1px solid #C4CFE5; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memItemRight { + width: 100%; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.mempage { + width: 100%; +} + +.memitem { + padding: 0; + margin-bottom: 10px; + margin-right: 5px; +} + +.memname { + white-space: nowrap; + font-weight: bold; + margin-left: 6px; +} + +.memproto { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + /* opera specific markup */ + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 8px; + border-top-left-radius: 8px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 8px; + -moz-border-radius-topleft: 8px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 8px; + -webkit-border-top-left-radius: 8px; + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + +} + +.memdoc { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 2px 5px; + background-color: #FBFCFD; + border-top-width: 0; + /* opera specific markup */ + border-bottom-left-radius: 8px; + border-bottom-right-radius: 8px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 8px; + -moz-border-radius-bottomright: 8px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F7F8FB 95%, #EEF1F7); + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 8px; + -webkit-border-bottom-right-radius: 8px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F7F8FB), to(#EEF1F7)); +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} + +.params, .retval, .exception, .tparams { + border-spacing: 6px 2px; +} + +.params .paramname, .retval .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir { + font-family: "courier new",courier,monospace; + vertical-align: top; +} + + + + +/* @end */ + +/* @group Directory (tree) */ + +/* for the tree view */ + +.ftvtree { + font-family: sans-serif; + margin: 0px; +} + +/* these are for tree view when used as main index */ + +.directory { + font-size: 9pt; + font-weight: bold; + margin: 5px; +} + +.directory h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +/* +The following two styles can be used to replace the root node title +with an image of your choice. Simply uncomment the next two styles, +specify the name of your image and be sure to set 'height' to the +proper pixel height of your image. +*/ + +/* +.directory h3.swap { + height: 61px; + background-repeat: no-repeat; + background-image: url("yourimage.gif"); +} +.directory h3.swap span { + display: none; +} +*/ + +.directory > h3 { + margin-top: 0; +} + +.directory p { + margin: 0px; + white-space: nowrap; +} + +.directory div { + display: none; + margin: 0px; +} + +.directory img { + vertical-align: -30%; +} + +/* these are for tree view when not used as main index */ + +.directory-alt { + font-size: 100%; + font-weight: bold; +} + +.directory-alt h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +.directory-alt > h3 { + margin-top: 0; +} + +.directory-alt p { + margin: 0px; + white-space: nowrap; +} + +.directory-alt div { + display: none; + margin: 0px; +} + +.directory-alt img { + vertical-align: -30%; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable { + border-collapse:collapse; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; +} + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right:15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath li.navelem a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; +} + +.navpath li.navelem a:hover +{ + color:#6884BD; +} + +.navpath li.footer +{ + list-style-type:none; + float:right; + padding-left:10px; + padding-right:15px; + background-image:none; + background-repeat:no-repeat; + background-position:right; + color:#364D7C; + font-size: 8pt; +} + + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +div.ingroups +{ + font-size: 8pt; + padding-left: 5px; + width: 50%; + text-align: left; +} + +div.ingroups a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + +dl +{ + padding: 0 0 0 10px; +} + +dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug +{ + border-left:4px solid; + padding: 0 0 0 6px; +} + +dl.note +{ + border-color: #D0C000; +} + +dl.warning, dl.attention +{ + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant +{ + border-color: #00D000; +} + +dl.deprecated +{ + border-color: #505050; +} + +dl.todo +{ + border-color: #00C0E0; +} + +dl.test +{ + border-color: #3030E0; +} + +dl.bug +{ + border-color: #C08050; +} + +#projectlogo +{ + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img +{ + border: 0px none; +} + +#projectname +{ + font: 300% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font: 120% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#projectnumber +{ + font: 50% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#titlearea +{ + padding: 0px; + margin: 0px; + width: 100%; + border-bottom: 1px solid #5373B4; +} + +.image +{ + text-align: center; +} + +.dotgraph +{ + text-align: center; +} + +.mscgraph +{ + text-align: center; +} + +.caption +{ + font-weight: bold; +} + diff --git a/docs/doxygen.png b/docs/doxygen.png new file mode 100644 index 0000000..635ed52 Binary files /dev/null and b/docs/doxygen.png differ diff --git a/docs/files.html b/docs/files.html new file mode 100644 index 0000000..214ca2f --- /dev/null +++ b/docs/files.html @@ -0,0 +1,93 @@ + + + + +Shell: Lista de ficheiros + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + +
+
+
+
Lista de ficheiros
+
+
+
Lista de todos os ficheiros com uma breve descrição:
+ + + + + + + + + +
builtin.c
builtin.h [código]
list.c
list.h [código]
main.c
main.h [código]
Mainpage.h [código]
parser.c
parser.h [código]
+
+ + + + +
+ +
+ + + + diff --git a/docs/functions.html b/docs/functions.html new file mode 100644 index 0000000..ff2d05c --- /dev/null +++ b/docs/functions.html @@ -0,0 +1,148 @@ + + + + +Shell: Campos de dados + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + + +
+
+
Lista de todas as estruturas e campos de uniões com referência para as estruturas/uniões a que pertencem:
+
+ + + + +
+ +
+ + + + diff --git a/docs/functions_vars.html b/docs/functions_vars.html new file mode 100644 index 0000000..1ca2b3a --- /dev/null +++ b/docs/functions_vars.html @@ -0,0 +1,148 @@ + + + + +Shell: Campos de dados - Variáveis + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + + +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/globals.html b/docs/globals.html new file mode 100644 index 0000000..d8200ea --- /dev/null +++ b/docs/globals.html @@ -0,0 +1,351 @@ + + + + +Shell: Globais + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + + + +
+
+
Lista de todas as funções, variáveis, definições, enumerações e definições de tipo com referência para o ficheiro a que pertecem:
+ +

- _ -

+ + +

- a -

+ + +

- b -

+ + +

- c -

+ + +

- e -

+ + +

- f -

+ + +

- g -

+ + +

- h -

+ + +

- i -

+ + +

- j -

+ + +

- k -

+ + +

- l -

+ + +

- m -

+ + +

- n -

+ + +

- p -

+ + +

- r -

+ + +

- s -

+ + +

- t -

+ + +

- u -

+ + +

- w -

+
+ + + + +
+ +
+ + + + diff --git a/docs/globals_defs.html b/docs/globals_defs.html new file mode 100644 index 0000000..03ac738 --- /dev/null +++ b/docs/globals_defs.html @@ -0,0 +1,92 @@ + + + + +Shell: Globais + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + + +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/globals_func.html b/docs/globals_func.html new file mode 100644 index 0000000..7b0eac7 --- /dev/null +++ b/docs/globals_func.html @@ -0,0 +1,301 @@ + + + + +Shell: Globais + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + + + +
+
+  + +

- a -

+ + +

- b -

+ + +

- c -

+ + +

- e -

+ + +

- f -

+ + +

- g -

+ + +

- i -

+ + +

- j -

+ + +

- k -

+ + +

- l -

+ + +

- m -

+ + +

- p -

+ + +

- r -

+ + +

- s -

+ + +

- t -

+ + +

- w -

+
+ + + + +
+ +
+ + + + diff --git a/docs/globals_type.html b/docs/globals_type.html new file mode 100644 index 0000000..92a4d69 --- /dev/null +++ b/docs/globals_type.html @@ -0,0 +1,95 @@ + + + + +Shell: Globais + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + + +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/globals_vars.html b/docs/globals_vars.html new file mode 100644 index 0000000..9b94934 --- /dev/null +++ b/docs/globals_vars.html @@ -0,0 +1,110 @@ + + + + +Shell: Globais + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ + + +
+
+
+ + + + +
+ +
+ + + + diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..64cfa21 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,124 @@ + + + + +Shell: Shell + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ +
+
+
+
Shell
+
+
+
Autor:
Lucas Lobosque - 6792645
+
+José Leandro Pozer - 6793222
+
Data:
16/11/2011
+

+Introdução

+

+Estrutura básica de Arquivos

+

Desenvolvemos o shell utilizando 4 arquivos diferentes (e seus headers):

+
    +
  • +main.c - Arquivo com a função main, onde fica o loop principal e com handlers de sinais como SIGINT, SIGTSTP e SIGCHLD.
  • +
  • +parser.c - Funções relacionadas a transformar a entrada do usuário em uma estrutura compreensível para o programa.
  • +
  • +builtin.c - Aqui estáo todos os comandos builtin e também uma função que checa se um dado comando é builtin ou não.
  • +
  • +list.c - Funções que manipulam as listas usadas pelo programa.
  • +
+

+Estrutura básica de Dados

+

No nosso programa, temos três listas ligadas diferentes que são constantemente utilizadas:

+
    +
  • +history - Esta é a mais simples das três. Guarda strings com os comandos anteriormente utilizados pelo usuário. É usada pelo comando builtin history.
  • +
  • +childs - Nesta lista ligada armazenamos todos os processos que estão rodando ou estão interrompidos.
  • +
  • +cmdList - Lista responsável por guardar o último comando enviado pelo usuário. Nesta lista, o comando é guardado depois de "parseado", então todas suas informações são guardadas aqui (roda no background? tem redirecionamento de saída? pra onde?). Cada item da lista é um comando diferente, sendo que a lista e sempre resetada no loop. Ou seja, esta lista só conterá mais de um item se houver pipe no comando.
  • +
+

+Características Não Implementadas (limitações).

+

Na nossa shell, os seguintes tipos de comando não são possíveis:

+
    +
  • +Comando builtin rodando em background (sempre rodará em foreground).
  • +
  • +Redirecionamento de entrada para comandos builtin (redirecionamento de saída implementado).
  • +
  • +Pipe com comandos builtin
  • +
+

Tornou-se uma tarefa complicada para nós lidar com essas peculiaridades de comandos builtin, já que implementamos sem elas em mente, e, quando percebemos que haveriam essas possibilidades, teríamos que mudar muito a estrutura do programa.

+

+Testes

+

Além de exaustivos testes com vários comandos complexos, rodamos nossa shell com o Valgrind e encontramos vários memory leaks (a maioria causada por erros bobos, porém alguns eram bem complexos). Arrumamos a maioria deles, mas infelizmente teve um leak que não foi possível concertar, pois ele é causado pela função getlogin(), (implementada na unistd.h).

+

+Conclusão

+

Além de bastante desafiador, o desenvolvimento da shell foi de grande valia para nós, já que nunca tivemos um contato a nível de sistema com o Linux. Depois do desenvolvimento desse programa, arriscamos dizer que entendemos ao menos um pouco de Linux :).

+
+ + + + +
+ +
+ + + + diff --git a/docs/installdox b/docs/installdox new file mode 100755 index 0000000..edf5bbf --- /dev/null +++ b/docs/installdox @@ -0,0 +1,112 @@ +#!/usr/bin/perl + +%subst = ( ); +$quiet = 0; + +while ( @ARGV ) { + $_ = shift @ARGV; + if ( s/^-// ) { + if ( /^l(.*)/ ) { + $v = ($1 eq "") ? shift @ARGV : $1; + ($v =~ /\/$/) || ($v .= "/"); + $_ = $v; + if ( /(.+)\@(.+)/ ) { + if ( exists $subst{$1} ) { + $subst{$1} = $2; + } else { + print STDERR "Unknown tag file $1 given with option -l\n"; + &usage(); + } + } else { + print STDERR "Argument $_ is invalid for option -l\n"; + &usage(); + } + } + elsif ( /^q/ ) { + $quiet = 1; + } + elsif ( /^\?|^h/ ) { + &usage(); + } + else { + print STDERR "Illegal option -$_\n"; + &usage(); + } + } + else { + push (@files, $_ ); + } +} + +foreach $sub (keys %subst) +{ + if ( $subst{$sub} eq "" ) + { + print STDERR "No substitute given for tag file `$sub'\n"; + &usage(); + } + elsif ( ! $quiet && $sub ne "_doc" && $sub ne "_cgi" ) + { + print "Substituting $subst{$sub} for each occurrence of tag file $sub\n"; + } +} + +if ( ! @files ) { + if (opendir(D,".")) { + foreach $file ( readdir(D) ) { + $match = ".html"; + next if ( $file =~ /^\.\.?$/ ); + ($file =~ /$match/) && (push @files, $file); + ($file =~ /\.svg/) && (push @files, $file); + ($file =~ "navtree.js") && (push @files, $file); + } + closedir(D); + } +} + +if ( ! @files ) { + print STDERR "Warning: No input files given and none found!\n"; +} + +foreach $f (@files) +{ + if ( ! $quiet ) { + print "Editing: $f...\n"; + } + $oldf = $f; + $f .= ".bak"; + unless (rename $oldf,$f) { + print STDERR "Error: cannot rename file $oldf\n"; + exit 1; + } + if (open(F,"<$f")) { + unless (open(G,">$oldf")) { + print STDERR "Error: opening file $oldf for writing\n"; + exit 1; + } + if ($oldf ne "tree.js") { + while () { + s/doxygen\=\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\" (xlink:href|href|src)=\"\2/doxygen\=\"$1:$subst{$1}\" \3=\"$subst{$1}/g; + print G "$_"; + } + } + else { + while () { + s/\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\", \"\2/\"$1:$subst{$1}\" ,\"$subst{$1}/g; + print G "$_"; + } + } + } + else { + print STDERR "Warning file $f does not exist\n"; + } + unlink $f; +} + +sub usage { + print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n"; + print STDERR "Options:\n"; + print STDERR " -l tagfile\@linkName tag file + URL or directory \n"; + print STDERR " -q Quiet mode\n\n"; + exit 1; +} diff --git a/docs/jquery.js b/docs/jquery.js new file mode 100644 index 0000000..c052173 --- /dev/null +++ b/docs/jquery.js @@ -0,0 +1,54 @@ +/* + * jQuery JavaScript Library v1.3.2 + * http://jquery.com/ + * + * Copyright (c) 2009 John Resig + * Dual licensed under the MIT and GPL licenses. + * http://docs.jquery.com/License + * + * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009) + * Revision: 6246 + */ +(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("",""]||!O.indexOf("",""]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"","
"]||!O.indexOf("",""]||(!O.indexOf("",""]||!O.indexOf("",""]||!o.support.htmlSerialize&&[1,"div
","
"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}}); +/* + * Sizzle CSS Selector Engine - v0.9.3 + * Copyright 2009, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return UT[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="

";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="
";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0) +{I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("
").append(M.responseText.replace(//g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function() +{G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='
';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})(); +/* + * jQuery UI 1.7.2 + * + * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI + */ +jQuery.ui||(function(c){var i=c.fn.remove,d=c.browser.mozilla&&(parseFloat(c.browser.version)<1.9);c.ui={version:"1.7.2",plugin:{add:function(k,l,n){var m=c.ui[k].prototype;for(var j in n){m.plugins[j]=m.plugins[j]||[];m.plugins[j].push([l,n[j]])}},call:function(j,l,k){var n=j.plugins[l];if(!n||!j.element[0].parentNode){return}for(var m=0;m0){return true}m[j]=1;l=(m[j]>0);m[j]=0;return l},isOverAxis:function(k,j,l){return(k>j)&&(k<(j+l))},isOver:function(o,k,n,m,j,l){return c.ui.isOverAxis(o,n,j)&&c.ui.isOverAxis(k,m,l)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(d){var f=c.attr,e=c.fn.removeAttr,h="http://www.w3.org/2005/07/aaa",a=/^aria-/,b=/^wairole:/;c.attr=function(k,j,l){var m=l!==undefined;return(j=="role"?(m?f.call(this,k,j,"wairole:"+l):(f.apply(this,arguments)||"").replace(b,"")):(a.test(j)?(m?k.setAttributeNS(h,j.replace(a,"aaa:"),l):f.call(this,k,j.replace(a,"aaa:"))):f.apply(this,arguments)))};c.fn.removeAttr=function(j){return(a.test(j)?this.each(function(){this.removeAttributeNS(h,j.replace(a,""))}):e.call(this,j))}}c.fn.extend({remove:function(){c("*",this).add(this).each(function(){c(this).triggerHandler("remove")});return i.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var j;if((c.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){j=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(c.curCSS(this,"position",1))&&(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}else{j=this.parents().filter(function(){return(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!j.length?c(document):j}});c.extend(c.expr[":"],{data:function(l,k,j){return !!c.data(l,j[3])},focusable:function(k){var l=k.nodeName.toLowerCase(),j=c.attr(k,"tabindex");return(/input|select|textarea|button|object/.test(l)?!k.disabled:"a"==l||"area"==l?k.href||!isNaN(j):!isNaN(j))&&!c(k)["area"==l?"parents":"closest"](":hidden").length},tabbable:function(k){var j=c.attr(k,"tabindex");return(isNaN(j)||j>=0)&&c(k).is(":focusable")}});function g(m,n,o,l){function k(q){var p=c[m][n][q]||[];return(typeof p=="string"?p.split(/,?\s+/):p)}var j=k("getter");if(l.length==1&&typeof l[0]=="string"){j=j.concat(k("getterSetter"))}return(c.inArray(o,j)!=-1)}c.widget=function(k,j){var l=k.split(".")[0];k=k.split(".")[1];c.fn[k]=function(p){var n=(typeof p=="string"),o=Array.prototype.slice.call(arguments,1);if(n&&p.substring(0,1)=="_"){return this}if(n&&g(l,k,p,o)){var m=c.data(this[0],k);return(m?m[p].apply(m,o):undefined)}return this.each(function(){var q=c.data(this,k);(!q&&!n&&c.data(this,k,new c[l][k](this,p))._init());(q&&n&&c.isFunction(q[p])&&q[p].apply(q,o))})};c[l]=c[l]||{};c[l][k]=function(o,n){var m=this;this.namespace=l;this.widgetName=k;this.widgetEventPrefix=c[l][k].eventPrefix||k;this.widgetBaseClass=l+"-"+k;this.options=c.extend({},c.widget.defaults,c[l][k].defaults,c.metadata&&c.metadata.get(o)[k],n);this.element=c(o).bind("setData."+k,function(q,p,r){if(q.target==o){return m._setData(p,r)}}).bind("getData."+k,function(q,p){if(q.target==o){return m._getData(p)}}).bind("remove",function(){return m.destroy()})};c[l][k].prototype=c.extend({},c.widget.prototype,j);c[l][k].getterSetter="option"};c.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").removeAttr("aria-disabled")},option:function(l,m){var k=l,j=this;if(typeof l=="string"){if(m===undefined){return this._getData(l)}k={};k[l]=m}c.each(k,function(n,o){j._setData(n,o)})},_getData:function(j){return this.options[j]},_setData:function(j,k){this.options[j]=k;if(j=="disabled"){this.element[k?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",k)}},enable:function(){this._setData("disabled",false)},disable:function(){this._setData("disabled",true)},_trigger:function(l,m,n){var p=this.options[l],j=(l==this.widgetEventPrefix?l:this.widgetEventPrefix+l);m=c.Event(m);m.type=j;if(m.originalEvent){for(var k=c.event.props.length,o;k;){o=c.event.props[--k];m[o]=m.originalEvent[o]}}this.element.trigger(m,n);return !(c.isFunction(p)&&p.call(this.element[0],m,n)===false||m.isDefaultPrevented())}};c.widget.defaults={disabled:false};c.ui.mouse={_mouseInit:function(){var j=this;this.element.bind("mousedown."+this.widgetName,function(k){return j._mouseDown(k)}).bind("click."+this.widgetName,function(k){if(j._preventClickEvent){j._preventClickEvent=false;k.stopImmediatePropagation();return false}});if(c.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(c.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},_mouseDown:function(l){l.originalEvent=l.originalEvent||{};if(l.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(l));this._mouseDownEvent=l;var k=this,m=(l.which==1),j=(typeof this.options.cancel=="string"?c(l.target).parents().add(l.target).filter(this.options.cancel).length:false);if(!m||j||!this._mouseCapture(l)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){k.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(l)&&this._mouseDelayMet(l)){this._mouseStarted=(this._mouseStart(l)!==false);if(!this._mouseStarted){l.preventDefault();return true}}this._mouseMoveDelegate=function(n){return k._mouseMove(n)};this._mouseUpDelegate=function(n){return k._mouseUp(n)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(c.browser.safari||l.preventDefault());l.originalEvent.mouseHandled=true;return true},_mouseMove:function(j){if(c.browser.msie&&!j.button){return this._mouseUp(j)}if(this._mouseStarted){this._mouseDrag(j);return j.preventDefault()}if(this._mouseDistanceMet(j)&&this._mouseDelayMet(j)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,j)!==false);(this._mouseStarted?this._mouseDrag(j):this._mouseUp(j))}return !this._mouseStarted},_mouseUp:function(j){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(j.target==this._mouseDownEvent.target);this._mouseStop(j)}return false},_mouseDistanceMet:function(j){return(Math.max(Math.abs(this._mouseDownEvent.pageX-j.pageX),Math.abs(this._mouseDownEvent.pageY-j.pageY))>=this.options.distance)},_mouseDelayMet:function(j){return this.mouseDelayMet},_mouseStart:function(j){},_mouseDrag:function(j){},_mouseStop:function(j){},_mouseCapture:function(j){return true}};c.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery);;/* * jQuery UI Resizable 1.7.2 + * + * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Resizables + * + * Depends: + * ui.core.js + */ +(function(c){c.widget("ui.resizable",c.extend({},c.ui.mouse,{_init:function(){var e=this,j=this.options;this.element.addClass("ui-resizable");c.extend(this,{_aspectRatio:!!(j.aspectRatio),aspectRatio:j.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:j.helper||j.ghost||j.animate?j.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){if(/relative/.test(this.element.css("position"))&&c.browser.opera){this.element.css({position:"relative",top:"auto",left:"auto"})}this.element.wrap(c('
').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=j.handles||(!c(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all"){this.handles="n,e,s,w,se,sw,ne,nw"}var k=this.handles.split(",");this.handles={};for(var f=0;f
');if(/sw|se|ne|nw/.test(h)){g.css({zIndex:++j.zIndex})}if("se"==h){g.addClass("ui-icon ui-icon-gripsmall-diagonal-se")}this.handles[h]=".ui-resizable-"+h;this.element.append(g)}}this._renderAxis=function(p){p=p||this.element;for(var m in this.handles){if(this.handles[m].constructor==String){this.handles[m]=c(this.handles[m],this.element).show()}if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var n=c(this.handles[m],this.element),o=0;o=/sw|ne|nw|se|n|s/.test(m)?n.outerHeight():n.outerWidth();var l=["padding",/ne|nw|n/.test(m)?"Top":/se|sw|s/.test(m)?"Bottom":/^e$/.test(m)?"Right":"Left"].join("");p.css(l,o);this._proportionallyResize()}if(!c(this.handles[m]).length){continue}}};this._renderAxis(this.element);this._handles=c(".ui-resizable-handle",this.element).disableSelection();this._handles.mouseover(function(){if(!e.resizing){if(this.className){var i=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}e.axis=i&&i[1]?i[1]:"se"}});if(j.autoHide){this._handles.hide();c(this.element).addClass("ui-resizable-autohide").hover(function(){c(this).removeClass("ui-resizable-autohide");e._handles.show()},function(){if(!e.resizing){c(this).addClass("ui-resizable-autohide");e._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var d=function(f){c(f).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){d(this.element);var e=this.element;e.parent().append(this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")})).end().remove()}this.originalElement.css("resize",this.originalResizeStyle);d(this.originalElement)},_mouseCapture:function(e){var f=false;for(var d in this.handles){if(c(this.handles[d])[0]==e.target){f=true}}return this.options.disabled||!!f},_mouseStart:function(f){var i=this.options,e=this.element.position(),d=this.element;this.resizing=true;this.documentScroll={top:c(document).scrollTop(),left:c(document).scrollLeft()};if(d.is(".ui-draggable")||(/absolute/).test(d.css("position"))){d.css({position:"absolute",top:e.top,left:e.left})}if(c.browser.opera&&(/relative/).test(d.css("position"))){d.css({position:"relative",top:"auto",left:"auto"})}this._renderProxy();var j=b(this.helper.css("left")),g=b(this.helper.css("top"));if(i.containment){j+=c(i.containment).scrollLeft()||0;g+=c(i.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:j,top:g};this.size=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:j,top:g};this.sizeDiff={width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:f.pageX,top:f.pageY};this.aspectRatio=(typeof i.aspectRatio=="number")?i.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);var h=c(".ui-resizable-"+this.axis).css("cursor");c("body").css("cursor",h=="auto"?this.axis+"-resize":h);d.addClass("ui-resizable-resizing");this._propagate("start",f);return true},_mouseDrag:function(d){var g=this.helper,f=this.options,l={},p=this,i=this.originalMousePosition,m=this.axis;var q=(d.pageX-i.left)||0,n=(d.pageY-i.top)||0;var h=this._change[m];if(!h){return false}var k=h.apply(this,[d,q,n]),j=c.browser.msie&&c.browser.version<7,e=this.sizeDiff;if(this._aspectRatio||d.shiftKey){k=this._updateRatio(k,d)}k=this._respectSize(k,d);this._propagate("resize",d);g.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!this._helper&&this._proportionallyResizeElements.length){this._proportionallyResize()}this._updateCache(k);this._trigger("resize",d,this.ui());return false},_mouseStop:function(g){this.resizing=false;var h=this.options,l=this;if(this._helper){var f=this._proportionallyResizeElements,d=f.length&&(/textarea/i).test(f[0].nodeName),e=d&&c.ui.hasScroll(f[0],"left")?0:l.sizeDiff.height,j=d?0:l.sizeDiff.width;var m={width:(l.size.width-j),height:(l.size.height-e)},i=(parseInt(l.element.css("left"),10)+(l.position.left-l.originalPosition.left))||null,k=(parseInt(l.element.css("top"),10)+(l.position.top-l.originalPosition.top))||null;if(!h.animate){this.element.css(c.extend(m,{top:k,left:i}))}l.helper.height(l.size.height);l.helper.width(l.size.width);if(this._helper&&!h.animate){this._proportionallyResize()}}c("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",g);if(this._helper){this.helper.remove()}return false},_updateCache:function(d){var e=this.options;this.offset=this.helper.offset();if(a(d.left)){this.position.left=d.left}if(a(d.top)){this.position.top=d.top}if(a(d.height)){this.size.height=d.height}if(a(d.width)){this.size.width=d.width}},_updateRatio:function(g,f){var h=this.options,i=this.position,e=this.size,d=this.axis;if(g.height){g.width=(e.height*this.aspectRatio)}else{if(g.width){g.height=(e.width/this.aspectRatio)}}if(d=="sw"){g.left=i.left+(e.width-g.width);g.top=null}if(d=="nw"){g.top=i.top+(e.height-g.height);g.left=i.left+(e.width-g.width)}return g},_respectSize:function(k,f){var i=this.helper,h=this.options,q=this._aspectRatio||f.shiftKey,p=this.axis,s=a(k.width)&&h.maxWidth&&(h.maxWidthk.width),r=a(k.height)&&h.minHeight&&(h.minHeight>k.height);if(g){k.width=h.minWidth}if(r){k.height=h.minHeight}if(s){k.width=h.maxWidth}if(l){k.height=h.maxHeight}var e=this.originalPosition.left+this.originalSize.width,n=this.position.top+this.size.height;var j=/sw|nw|w/.test(p),d=/nw|ne|n/.test(p);if(g&&j){k.left=e-h.minWidth}if(s&&j){k.left=e-h.maxWidth}if(r&&d){k.top=n-h.minHeight}if(l&&d){k.top=n-h.maxHeight}var m=!k.width&&!k.height;if(m&&!k.left&&k.top){k.top=null}else{if(m&&!k.top&&k.left){k.left=null}}return k},_proportionallyResize:function(){var j=this.options;if(!this._proportionallyResizeElements.length){return}var f=this.helper||this.element;for(var e=0;e');var d=c.browser.msie&&c.browser.version<7,f=(d?1:0),g=(d?2:-1);this.helper.addClass(this._helper).css({width:this.element.outerWidth()+g,height:this.element.outerHeight()+g,position:"absolute",left:this.elementOffset.left-f+"px",top:this.elementOffset.top-f+"px",zIndex:++h.zIndex});this.helper.appendTo("body").disableSelection()}else{this.helper=this.element}},_change:{e:function(f,e,d){return{width:this.originalSize.width+e}},w:function(g,e,d){var i=this.options,f=this.originalSize,h=this.originalPosition;return{left:h.left+e,width:f.width-e}},n:function(g,e,d){var i=this.options,f=this.originalSize,h=this.originalPosition;return{top:h.top+d,height:f.height-d}},s:function(f,e,d){return{height:this.originalSize.height+d}},se:function(f,e,d){return c.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[f,e,d]))},sw:function(f,e,d){return c.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[f,e,d]))},ne:function(f,e,d){return c.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[f,e,d]))},nw:function(f,e,d){return c.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[f,e,d]))}},_propagate:function(e,d){c.ui.plugin.call(this,e,[d,this.ui()]);(e!="resize"&&this._trigger(e,d,this.ui()))},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}));c.extend(c.ui.resizable,{version:"1.7.2",eventPrefix:"resize",defaults:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,cancel:":input,option",containment:false,delay:0,distance:1,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1000}});c.ui.plugin.add("resizable","alsoResize",{start:function(e,f){var d=c(this).data("resizable"),g=d.options;_store=function(h){c(h).each(function(){c(this).data("resizable-alsoresize",{width:parseInt(c(this).width(),10),height:parseInt(c(this).height(),10),left:parseInt(c(this).css("left"),10),top:parseInt(c(this).css("top"),10)})})};if(typeof(g.alsoResize)=="object"&&!g.alsoResize.parentNode){if(g.alsoResize.length){g.alsoResize=g.alsoResize[0];_store(g.alsoResize)}else{c.each(g.alsoResize,function(h,i){_store(h)})}}else{_store(g.alsoResize)}},resize:function(f,h){var e=c(this).data("resizable"),i=e.options,g=e.originalSize,k=e.originalPosition;var j={height:(e.size.height-g.height)||0,width:(e.size.width-g.width)||0,top:(e.position.top-k.top)||0,left:(e.position.left-k.left)||0},d=function(l,m){c(l).each(function(){var p=c(this),q=c(this).data("resizable-alsoresize"),o={},n=m&&m.length?m:["width","height","top","left"];c.each(n||["width","height","top","left"],function(r,t){var s=(q[t]||0)+(j[t]||0);if(s&&s>=0){o[t]=s||null}});if(/relative/.test(p.css("position"))&&c.browser.opera){e._revertToRelativePosition=true;p.css({position:"absolute",top:"auto",left:"auto"})}p.css(o)})};if(typeof(i.alsoResize)=="object"&&!i.alsoResize.nodeType){c.each(i.alsoResize,function(l,m){d(l,m)})}else{d(i.alsoResize)}},stop:function(e,f){var d=c(this).data("resizable");if(d._revertToRelativePosition&&c.browser.opera){d._revertToRelativePosition=false;el.css({position:"relative"})}c(this).removeData("resizable-alsoresize-start")}});c.ui.plugin.add("resizable","animate",{stop:function(h,m){var n=c(this).data("resizable"),i=n.options;var g=n._proportionallyResizeElements,d=g.length&&(/textarea/i).test(g[0].nodeName),e=d&&c.ui.hasScroll(g[0],"left")?0:n.sizeDiff.height,k=d?0:n.sizeDiff.width;var f={width:(n.size.width-k),height:(n.size.height-e)},j=(parseInt(n.element.css("left"),10)+(n.position.left-n.originalPosition.left))||null,l=(parseInt(n.element.css("top"),10)+(n.position.top-n.originalPosition.top))||null;n.element.animate(c.extend(f,l&&j?{top:l,left:j}:{}),{duration:i.animateDuration,easing:i.animateEasing,step:function(){var o={width:parseInt(n.element.css("width"),10),height:parseInt(n.element.css("height"),10),top:parseInt(n.element.css("top"),10),left:parseInt(n.element.css("left"),10)};if(g&&g.length){c(g[0]).css({width:o.width,height:o.height})}n._updateCache(o);n._propagate("resize",h)}})}});c.ui.plugin.add("resizable","containment",{start:function(e,q){var s=c(this).data("resizable"),i=s.options,k=s.element;var f=i.containment,j=(f instanceof c)?f.get(0):(/parent/.test(f))?k.parent().get(0):f;if(!j){return}s.containerElement=c(j);if(/document/.test(f)||f==document){s.containerOffset={left:0,top:0};s.containerPosition={left:0,top:0};s.parentData={element:c(document),left:0,top:0,width:c(document).width(),height:c(document).height()||document.body.parentNode.scrollHeight}}else{var m=c(j),h=[];c(["Top","Right","Left","Bottom"]).each(function(p,o){h[p]=b(m.css("padding"+o))});s.containerOffset=m.offset();s.containerPosition=m.position();s.containerSize={height:(m.innerHeight()-h[3]),width:(m.innerWidth()-h[1])};var n=s.containerOffset,d=s.containerSize.height,l=s.containerSize.width,g=(c.ui.hasScroll(j,"left")?j.scrollWidth:l),r=(c.ui.hasScroll(j)?j.scrollHeight:d);s.parentData={element:j,left:n.left,top:n.top,width:g,height:r}}},resize:function(f,p){var s=c(this).data("resizable"),h=s.options,e=s.containerSize,n=s.containerOffset,l=s.size,m=s.position,q=s._aspectRatio||f.shiftKey,d={top:0,left:0},g=s.containerElement;if(g[0]!=document&&(/static/).test(g.css("position"))){d=n}if(m.left<(s._helper?n.left:0)){s.size.width=s.size.width+(s._helper?(s.position.left-n.left):(s.position.left-d.left));if(q){s.size.height=s.size.width/h.aspectRatio}s.position.left=h.helper?n.left:0}if(m.top<(s._helper?n.top:0)) +{s.size.height=s.size.height+(s._helper?(s.position.top-n.top):s.position.top);if(q){s.size.width=s.size.height*h.aspectRatio}s.position.top=s._helper?n.top:0}s.offset.left=s.parentData.left+s.position.left;s.offset.top=s.parentData.top+s.position.top;var k=Math.abs((s._helper?s.offset.left-d.left:(s.offset.left-d.left))+s.sizeDiff.width),r=Math.abs((s._helper?s.offset.top-d.top:(s.offset.top-n.top))+s.sizeDiff.height);var j=s.containerElement.get(0)==s.element.parent().get(0),i=/relative|absolute/.test(s.containerElement.css("position"));if(j&&i){k-=s.parentData.left}if(k+s.size.width>=s.parentData.width){s.size.width=s.parentData.width-k;if(q){s.size.height=s.size.width/s.aspectRatio}}if(r+s.size.height>=s.parentData.height){s.size.height=s.parentData.height-r;if(q){s.size.width=s.size.height*s.aspectRatio}}},stop:function(e,m){var p=c(this).data("resizable"),f=p.options,k=p.position,l=p.containerOffset,d=p.containerPosition,g=p.containerElement;var i=c(p.helper),q=i.offset(),n=i.outerWidth()-p.sizeDiff.width,j=i.outerHeight()-p.sizeDiff.height;if(p._helper&&!f.animate&&(/relative/).test(g.css("position"))){c(this).css({left:q.left-d.left-l.left,width:n,height:j})}if(p._helper&&!f.animate&&(/static/).test(g.css("position"))){c(this).css({left:q.left-d.left-l.left,width:n,height:j})}}});c.ui.plugin.add("resizable","ghost",{start:function(f,g){var d=c(this).data("resizable"),h=d.options,e=d.size;d.ghost=d.originalElement.clone();d.ghost.css({opacity:0.25,display:"block",position:"relative",height:e.height,width:e.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof h.ghost=="string"?h.ghost:"");d.ghost.appendTo(d.helper)},resize:function(e,f){var d=c(this).data("resizable"),g=d.options;if(d.ghost){d.ghost.css({position:"relative",height:d.size.height,width:d.size.width})}},stop:function(e,f){var d=c(this).data("resizable"),g=d.options;if(d.ghost&&d.helper){d.helper.get(0).removeChild(d.ghost.get(0))}}});c.ui.plugin.add("resizable","grid",{resize:function(d,l){var n=c(this).data("resizable"),g=n.options,j=n.size,h=n.originalSize,i=n.originalPosition,m=n.axis,k=g._aspectRatio||d.shiftKey;g.grid=typeof g.grid=="number"?[g.grid,g.grid]:g.grid;var f=Math.round((j.width-h.width)/(g.grid[0]||1))*(g.grid[0]||1),e=Math.round((j.height-h.height)/(g.grid[1]||1))*(g.grid[1]||1);if(/^(se|s|e)$/.test(m)){n.size.width=h.width+f;n.size.height=h.height+e}else{if(/^(ne)$/.test(m)){n.size.width=h.width+f;n.size.height=h.height+e;n.position.top=i.top-e}else{if(/^(sw)$/.test(m)){n.size.width=h.width+f;n.size.height=h.height+e;n.position.left=i.left-f}else{n.size.width=h.width+f;n.size.height=h.height+e;n.position.top=i.top-e;n.position.left=i.left-f}}}}});var b=function(d){return parseInt(d,10)||0};var a=function(d){return !isNaN(parseInt(d,10))}})(jQuery);; +/** + * jQuery.ScrollTo - Easy element scrolling using jQuery. + * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com + * Licensed under GPL license (http://www.opensource.org/licenses/gpl-license.php). + * Date: 2/8/2008 + * @author Ariel Flesler + * @version 1.3.2 + */ +;(function($){var o=$.scrollTo=function(a,b,c){o.window().scrollTo(a,b,c)};o.defaults={axis:'y',duration:1};o.window=function(){return $($.browser.safari?'body':'html')};$.fn.scrollTo=function(l,m,n){if(typeof m=='object'){n=m;m=0}n=$.extend({},o.defaults,n);m=m||n.speed||n.duration;n.queue=n.queue&&n.axis.length>1;if(n.queue)m/=2;n.offset=j(n.offset);n.over=j(n.over);return this.each(function(){var a=this,b=$(a),t=l,c,d={},w=b.is('html,body');switch(typeof t){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(t)){t=j(t);break}t=$(t,this);case'object':if(t.is||t.style)c=(t=$(t)).offset()}$.each(n.axis.split(''),function(i,f){var P=f=='x'?'Left':'Top',p=P.toLowerCase(),k='scroll'+P,e=a[k],D=f=='x'?'Width':'Height';if(c){d[k]=c[p]+(w?0:e-b.offset()[p]);if(n.margin){d[k]-=parseInt(t.css('margin'+P))||0;d[k]-=parseInt(t.css('border'+P+'Width'))||0}d[k]+=n.offset[p]||0;if(n.over[p])d[k]+=t[D.toLowerCase()]()*n.over[p]}else d[k]=t[p];if(/^\d+$/.test(d[k]))d[k]=d[k]<=0?0:Math.min(d[k],h(D));if(!i&&n.queue){if(e!=d[k])g(n.onAfterFirst);delete d[k]}});g(n.onAfter);function g(a){b.animate(d,m,n.easing,a&&function(){a.call(this,l)})};function h(D){var b=w?$.browser.opera?document.body:document.documentElement:a;return b['scroll'+D]-b['client'+D]}})};function j(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery); + diff --git a/docs/nav_f.png b/docs/nav_f.png new file mode 100644 index 0000000..1b07a16 Binary files /dev/null and b/docs/nav_f.png differ diff --git a/docs/nav_h.png b/docs/nav_h.png new file mode 100644 index 0000000..01f5fa6 Binary files /dev/null and b/docs/nav_h.png differ diff --git a/docs/open.png b/docs/open.png new file mode 100644 index 0000000..7b35d2c Binary files /dev/null and b/docs/open.png differ diff --git a/docs/pages.html b/docs/pages.html new file mode 100644 index 0000000..c663764 --- /dev/null +++ b/docs/pages.html @@ -0,0 +1,81 @@ + + + + +Shell: Páginas relacionadas + + + + + + + + +
+
+ + + + + + +
+
Shell
+
+
+ +
+
+
+
Páginas relacionadas
+
+
+
Lista de documentação relacionada:
+
+ + + + +
+ +
+ + + + diff --git a/docs/search/all_5f.html b/docs/search/all_5f.html new file mode 100644 index 0000000..fcadb85 --- /dev/null +++ b/docs/search/all_5f.html @@ -0,0 +1,26 @@ + + + + + + + +
+
Loading...
+
+
+ _GNU_SOURCE + main.c +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_61.html b/docs/search/all_61.html new file mode 100644 index 0000000..eedd8f3 --- /dev/null +++ b/docs/search/all_61.html @@ -0,0 +1,44 @@ + + + + + + + +
+
Loading...
+ + +
+
+ args + COMMAND +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_62.html b/docs/search/all_62.html new file mode 100644 index 0000000..4d4aa73 --- /dev/null +++ b/docs/search/all_62.html @@ -0,0 +1,39 @@ + + + + + + + +
+
Loading...
+ +
+
+ builtin.c +
+
+
+
+ builtin.h +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_63.html b/docs/search/all_63.html new file mode 100644 index 0000000..fbde031 --- /dev/null +++ b/docs/search/all_63.html @@ -0,0 +1,83 @@ + + + + + + + +
+
Loading...
+ + + +
+
+ childs + main.h +
+
+
+ +
+
+
+ cmdLine + main.h +
+
+
+
+ cmdList + main.h +
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_65.html b/docs/search/all_65.html new file mode 100644 index 0000000..98ef9d1 --- /dev/null +++ b/docs/search/all_65.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_66.html b/docs/search/all_66.html new file mode 100644 index 0000000..ab841c8 --- /dev/null +++ b/docs/search/all_66.html @@ -0,0 +1,53 @@ + + + + + + + +
+
Loading...
+ +
+
+ first + LIST +
+
+ + +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_67.html b/docs/search/all_67.html new file mode 100644 index 0000000..6824140 --- /dev/null +++ b/docs/search/all_67.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_68.html b/docs/search/all_68.html new file mode 100644 index 0000000..c71b7df --- /dev/null +++ b/docs/search/all_68.html @@ -0,0 +1,36 @@ + + + + + + + +
+
Loading...
+ +
+
+ hostname + main.h +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_69.html b/docs/search/all_69.html new file mode 100644 index 0000000..f1fa5d6 --- /dev/null +++ b/docs/search/all_69.html @@ -0,0 +1,71 @@ + + + + + + + +
+
Loading...
+
+
+ id + COMMAND +
+
+
+
+ imprimir_argv + parser.c +
+
+ +
+
+ input_r + COMMAND +
+
+
+
+ input_r_filename + COMMAND +
+
+ + +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_6a.html b/docs/search/all_6a.html new file mode 100644 index 0000000..be9587a --- /dev/null +++ b/docs/search/all_6a.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_6b.html b/docs/search/all_6b.html new file mode 100644 index 0000000..cfceb40 --- /dev/null +++ b/docs/search/all_6b.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_6c.html b/docs/search/all_6c.html new file mode 100644 index 0000000..be76bc7 --- /dev/null +++ b/docs/search/all_6c.html @@ -0,0 +1,113 @@ + + + + + + + + + + diff --git a/docs/search/all_6d.html b/docs/search/all_6d.html new file mode 100644 index 0000000..4931189 --- /dev/null +++ b/docs/search/all_6d.html @@ -0,0 +1,41 @@ + + + + + + + +
+
Loading...
+
+
+ main + main.c +
+
+
+
+ main.c +
+
+
+
+ main.h +
+
+
+ +
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_6e.html b/docs/search/all_6e.html new file mode 100644 index 0000000..e93b089 --- /dev/null +++ b/docs/search/all_6e.html @@ -0,0 +1,38 @@ + + + + + + + +
+
Loading...
+ +
+
+ NODE + +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_6f.html b/docs/search/all_6f.html new file mode 100644 index 0000000..275ca78 --- /dev/null +++ b/docs/search/all_6f.html @@ -0,0 +1,38 @@ + + + + + + + +
+
Loading...
+
+
+ output_r + COMMAND +
+
+
+
+ output_r_append + COMMAND +
+
+
+
+ output_r_filename + COMMAND +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_70.html b/docs/search/all_70.html new file mode 100644 index 0000000..df011ca --- /dev/null +++ b/docs/search/all_70.html @@ -0,0 +1,98 @@ + + + + + + + +
+
Loading...
+ +
+
+ parser.c +
+
+
+
+ parser.h +
+
+ +
+
+ pipe + COMMAND +
+
+
+
+ prev + NODE +
+
+ + +
+
+ proc + NODE +
+
+
+
+ PROCESS +
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_72.html b/docs/search/all_72.html new file mode 100644 index 0000000..0515695 --- /dev/null +++ b/docs/search/all_72.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_73.html b/docs/search/all_73.html new file mode 100644 index 0000000..54a915b --- /dev/null +++ b/docs/search/all_73.html @@ -0,0 +1,41 @@ + + + + + + + +
+
Loading...
+ +
+
+ size + COMMAND +
+
+
+
+ status + PROCESS +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_74.html b/docs/search/all_74.html new file mode 100644 index 0000000..da28034 --- /dev/null +++ b/docs/search/all_74.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_75.html b/docs/search/all_75.html new file mode 100644 index 0000000..2e40578 --- /dev/null +++ b/docs/search/all_75.html @@ -0,0 +1,32 @@ + + + + + + + +
+
Loading...
+
+
+ userdir + main.h +
+
+
+
+ username + main.h +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/all_77.html b/docs/search/all_77.html new file mode 100644 index 0000000..310c5f3 --- /dev/null +++ b/docs/search/all_77.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/classes_63.html b/docs/search/classes_63.html new file mode 100644 index 0000000..bf09ff0 --- /dev/null +++ b/docs/search/classes_63.html @@ -0,0 +1,25 @@ + + + + + + + +
+
Loading...
+
+
+ COMMAND +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/classes_68.html b/docs/search/classes_68.html new file mode 100644 index 0000000..1ec1c3d --- /dev/null +++ b/docs/search/classes_68.html @@ -0,0 +1,25 @@ + + + + + + + +
+
Loading...
+
+
+ history +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/classes_6c.html b/docs/search/classes_6c.html new file mode 100644 index 0000000..183f604 --- /dev/null +++ b/docs/search/classes_6c.html @@ -0,0 +1,25 @@ + + + + + + + +
+
Loading...
+
+
+ LIST +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/classes_6e.html b/docs/search/classes_6e.html new file mode 100644 index 0000000..1bca842 --- /dev/null +++ b/docs/search/classes_6e.html @@ -0,0 +1,25 @@ + + + + + + + +
+
Loading...
+
+
+ NODE +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/classes_70.html b/docs/search/classes_70.html new file mode 100644 index 0000000..f8dd44e --- /dev/null +++ b/docs/search/classes_70.html @@ -0,0 +1,25 @@ + + + + + + + +
+
Loading...
+
+
+ PROCESS +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/close.png b/docs/search/close.png new file mode 100644 index 0000000..9342d3d Binary files /dev/null and b/docs/search/close.png differ diff --git a/docs/search/defines_5f.html b/docs/search/defines_5f.html new file mode 100644 index 0000000..fcadb85 --- /dev/null +++ b/docs/search/defines_5f.html @@ -0,0 +1,26 @@ + + + + + + + +
+
Loading...
+
+
+ _GNU_SOURCE + main.c +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/files_62.html b/docs/search/files_62.html new file mode 100644 index 0000000..51777cd --- /dev/null +++ b/docs/search/files_62.html @@ -0,0 +1,30 @@ + + + + + + + +
+
Loading...
+
+
+ builtin.c +
+
+
+
+ builtin.h +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/files_6c.html b/docs/search/files_6c.html new file mode 100644 index 0000000..470befb --- /dev/null +++ b/docs/search/files_6c.html @@ -0,0 +1,30 @@ + + + + + + + +
+
Loading...
+
+
+ list.c +
+
+
+
+ list.h +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/files_6d.html b/docs/search/files_6d.html new file mode 100644 index 0000000..f2680f7 --- /dev/null +++ b/docs/search/files_6d.html @@ -0,0 +1,35 @@ + + + + + + + +
+
Loading...
+
+
+ main.c +
+
+
+
+ main.h +
+
+
+ +
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/files_70.html b/docs/search/files_70.html new file mode 100644 index 0000000..6cd1c43 --- /dev/null +++ b/docs/search/files_70.html @@ -0,0 +1,30 @@ + + + + + + + +
+
Loading...
+
+
+ parser.c +
+
+
+
+ parser.h +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_61.html b/docs/search/functions_61.html new file mode 100644 index 0000000..eba40a7 --- /dev/null +++ b/docs/search/functions_61.html @@ -0,0 +1,38 @@ + + + + + + + +
+
Loading...
+ + +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_62.html b/docs/search/functions_62.html new file mode 100644 index 0000000..e8e9c16 --- /dev/null +++ b/docs/search/functions_62.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_63.html b/docs/search/functions_63.html new file mode 100644 index 0000000..2ee43dc --- /dev/null +++ b/docs/search/functions_63.html @@ -0,0 +1,47 @@ + + + + + + + +
+
Loading...
+ + + +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_65.html b/docs/search/functions_65.html new file mode 100644 index 0000000..98ef9d1 --- /dev/null +++ b/docs/search/functions_65.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_66.html b/docs/search/functions_66.html new file mode 100644 index 0000000..0b5272f --- /dev/null +++ b/docs/search/functions_66.html @@ -0,0 +1,47 @@ + + + + + + + +
+
Loading...
+ + + +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_67.html b/docs/search/functions_67.html new file mode 100644 index 0000000..6824140 --- /dev/null +++ b/docs/search/functions_67.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_69.html b/docs/search/functions_69.html new file mode 100644 index 0000000..2208e30 --- /dev/null +++ b/docs/search/functions_69.html @@ -0,0 +1,44 @@ + + + + + + + +
+
Loading...
+
+
+ imprimir_argv + parser.c +
+
+ + +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_6a.html b/docs/search/functions_6a.html new file mode 100644 index 0000000..be9587a --- /dev/null +++ b/docs/search/functions_6a.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_6b.html b/docs/search/functions_6b.html new file mode 100644 index 0000000..cfceb40 --- /dev/null +++ b/docs/search/functions_6b.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_6c.html b/docs/search/functions_6c.html new file mode 100644 index 0000000..1436775 --- /dev/null +++ b/docs/search/functions_6c.html @@ -0,0 +1,92 @@ + + + + + + + + + + diff --git a/docs/search/functions_6d.html b/docs/search/functions_6d.html new file mode 100644 index 0000000..ce11213 --- /dev/null +++ b/docs/search/functions_6d.html @@ -0,0 +1,26 @@ + + + + + + + +
+
Loading...
+
+
+ main + main.c +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_70.html b/docs/search/functions_70.html new file mode 100644 index 0000000..1c080c5 --- /dev/null +++ b/docs/search/functions_70.html @@ -0,0 +1,56 @@ + + + + + + + +
+
Loading...
+ + + + +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_72.html b/docs/search/functions_72.html new file mode 100644 index 0000000..0515695 --- /dev/null +++ b/docs/search/functions_72.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_73.html b/docs/search/functions_73.html new file mode 100644 index 0000000..f568391 --- /dev/null +++ b/docs/search/functions_73.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_74.html b/docs/search/functions_74.html new file mode 100644 index 0000000..da28034 --- /dev/null +++ b/docs/search/functions_74.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/functions_77.html b/docs/search/functions_77.html new file mode 100644 index 0000000..310c5f3 --- /dev/null +++ b/docs/search/functions_77.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/mag_sel.png b/docs/search/mag_sel.png new file mode 100644 index 0000000..81f6040 Binary files /dev/null and b/docs/search/mag_sel.png differ diff --git a/docs/search/nomatches.html b/docs/search/nomatches.html new file mode 100644 index 0000000..b1ded27 --- /dev/null +++ b/docs/search/nomatches.html @@ -0,0 +1,12 @@ + + + + + + + +
+
No Matches
+
+ + diff --git a/docs/search/search.css b/docs/search/search.css new file mode 100644 index 0000000..50249e5 --- /dev/null +++ b/docs/search/search.css @@ -0,0 +1,240 @@ +/*---------------- Search Box */ + +#FSearchBox { + float: left; +} + +#searchli { + float: right; + display: block; + width: 170px; + height: 36px; +} + +#MSearchBox { + white-space : nowrap; + position: absolute; + float: none; + display: inline; + margin-top: 8px; + right: 0px; + width: 170px; + z-index: 102; +} + +#MSearchBox .left +{ + display:block; + position:absolute; + left:10px; + width:20px; + height:19px; + background:url('search_l.png') no-repeat; + background-position:right; +} + +#MSearchSelect { + display:block; + position:absolute; + width:20px; + height:19px; +} + +.left #MSearchSelect { + left:4px; +} + +.right #MSearchSelect { + right:5px; +} + +#MSearchField { + display:block; + position:absolute; + height:19px; + background:url('search_m.png') repeat-x; + border:none; + width:116px; + margin-left:20px; + padding-left:4px; + color: #909090; + outline: none; + font: 9pt Arial, Verdana, sans-serif; +} + +#FSearchBox #MSearchField { + margin-left:15px; +} + +#MSearchBox .right { + display:block; + position:absolute; + right:10px; + top:0px; + width:20px; + height:19px; + background:url('search_r.png') no-repeat; + background-position:left; +} + +#MSearchClose { + display: none; + position: absolute; + top: 4px; + background : none; + border: none; + margin: 0px 4px 0px 0px; + padding: 0px 0px; + outline: none; +} + +.left #MSearchClose { + left: 6px; +} + +.right #MSearchClose { + right: 2px; +} + +.MSearchBoxActive #MSearchField { + color: #000000; +} + +/*---------------- Search filter selection */ + +#MSearchSelectWindow { + display: none; + position: absolute; + left: 0; top: 0; + border: 1px solid #90A5CE; + background-color: #F9FAFC; + z-index: 1; + padding-top: 4px; + padding-bottom: 4px; + -moz-border-radius: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + -webkit-border-bottom-left-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); +} + +.SelectItem { + font: 8pt Arial, Verdana, sans-serif; + padding-left: 2px; + padding-right: 12px; + border: 0px; +} + +span.SelectionMark { + margin-right: 4px; + font-family: monospace; + outline-style: none; + text-decoration: none; +} + +a.SelectItem { + display: block; + outline-style: none; + color: #000000; + text-decoration: none; + padding-left: 6px; + padding-right: 12px; +} + +a.SelectItem:focus, +a.SelectItem:active { + color: #000000; + outline-style: none; + text-decoration: none; +} + +a.SelectItem:hover { + color: #FFFFFF; + background-color: #3D578C; + outline-style: none; + text-decoration: none; + cursor: pointer; + display: block; +} + +/*---------------- Search results window */ + +iframe#MSearchResults { + width: 60ex; + height: 15em; +} + +#MSearchResultsWindow { + display: none; + position: absolute; + left: 0; top: 0; + border: 1px solid #000; + background-color: #EEF1F7; +} + +/* ----------------------------------- */ + + +#SRIndex { + clear:both; + padding-bottom: 15px; +} + +.SREntry { + font-size: 10pt; + padding-left: 1ex; +} + +.SRPage .SREntry { + font-size: 8pt; + padding: 1px 5px; +} + +body.SRPage { + margin: 5px 2px; +} + +.SRChildren { + padding-left: 3ex; padding-bottom: .5em +} + +.SRPage .SRChildren { + display: none; +} + +.SRSymbol { + font-weight: bold; + color: #425E97; + font-family: Arial, Verdana, sans-serif; + text-decoration: none; + outline: none; +} + +a.SRScope { + display: block; + color: #425E97; + font-family: Arial, Verdana, sans-serif; + text-decoration: none; + outline: none; +} + +a.SRSymbol:focus, a.SRSymbol:active, +a.SRScope:focus, a.SRScope:active { + text-decoration: underline; +} + +.SRPage .SRStatus { + padding: 2px 5px; + font-size: 8pt; + font-style: italic; +} + +.SRResult { + display: none; +} + +DIV.searchresults { + margin-left: 10px; + margin-right: 10px; +} diff --git a/docs/search/search.js b/docs/search/search.js new file mode 100644 index 0000000..2a014c2 --- /dev/null +++ b/docs/search/search.js @@ -0,0 +1,738 @@ +// Search script generated by doxygen +// Copyright (C) 2009 by Dimitri van Heesch. + +// The code in this file is loosly based on main.js, part of Natural Docs, +// which is Copyright (C) 2003-2008 Greg Valure +// Natural Docs is licensed under the GPL. + +var indexSectionsWithContent = +{ + 0: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010111011111111111101111010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + 1: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000010001010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + 2: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000001100100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + 3: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111011101111100101110010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + 4: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101001011001011100101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + 5: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + 6: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +}; + +var indexSectionNames = +{ + 0: "all", + 1: "classes", + 2: "files", + 3: "functions", + 4: "variables", + 5: "typedefs", + 6: "defines" +}; + +function convertToId(search) +{ + var result = ''; + for (i=0;i do a search + { + this.Search(); + } + } + + this.OnSearchSelectKey = function(evt) + { + var e = (evt) ? evt : window.event; // for IE + if (e.keyCode==40 && this.searchIndex0) // Up + { + this.searchIndex--; + this.OnSelectItem(this.searchIndex); + } + else if (e.keyCode==13 || e.keyCode==27) + { + this.OnSelectItem(this.searchIndex); + this.CloseSelectionWindow(); + this.DOMSearchField().focus(); + } + return false; + } + + // --------- Actions + + // Closes the results window. + this.CloseResultsWindow = function() + { + this.DOMPopupSearchResultsWindow().style.display = 'none'; + this.DOMSearchClose().style.display = 'none'; + this.Activate(false); + } + + this.CloseSelectionWindow = function() + { + this.DOMSearchSelectWindow().style.display = 'none'; + } + + // Performs a search. + this.Search = function() + { + this.keyTimeout = 0; + + // strip leading whitespace + var searchValue = this.DOMSearchField().value.replace(/^ +/, ""); + + var code = searchValue.toLowerCase().charCodeAt(0); + var hexCode; + if (code<16) + { + hexCode="0"+code.toString(16); + } + else + { + hexCode=code.toString(16); + } + + var resultsPage; + var resultsPageWithSearch; + var hasResultsPage; + + if (indexSectionsWithContent[this.searchIndex].charAt(code) == '1') + { + resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html'; + resultsPageWithSearch = resultsPage+'?'+escape(searchValue); + hasResultsPage = true; + } + else // nothing available for this search term + { + resultsPage = this.resultsPath + '/nomatches.html'; + resultsPageWithSearch = resultsPage; + hasResultsPage = false; + } + + window.frames.MSearchResults.location.href = resultsPageWithSearch; + var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow(); + + if (domPopupSearchResultsWindow.style.display!='block') + { + var domSearchBox = this.DOMSearchBox(); + this.DOMSearchClose().style.display = 'inline'; + if (this.insideFrame) + { + var domPopupSearchResults = this.DOMPopupSearchResults(); + domPopupSearchResultsWindow.style.position = 'relative'; + domPopupSearchResultsWindow.style.display = 'block'; + var width = document.body.clientWidth - 8; // the -8 is for IE :-( + domPopupSearchResultsWindow.style.width = width + 'px'; + domPopupSearchResults.style.width = width + 'px'; + } + else + { + var domPopupSearchResults = this.DOMPopupSearchResults(); + var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth; + var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1; + domPopupSearchResultsWindow.style.display = 'block'; + left -= domPopupSearchResults.offsetWidth; + domPopupSearchResultsWindow.style.top = top + 'px'; + domPopupSearchResultsWindow.style.left = left + 'px'; + } + } + + this.lastSearchValue = searchValue; + this.lastResultsPage = resultsPage; + } + + // -------- Activation Functions + + // Activates or deactivates the search panel, resetting things to + // their default values if necessary. + this.Activate = function(isActive) + { + if (isActive || // open it + this.DOMPopupSearchResultsWindow().style.display == 'block' + ) + { + this.DOMSearchBox().className = 'MSearchBoxActive'; + + var searchField = this.DOMSearchField(); + + if (searchField.value == this.searchLabel) // clear "Search" term upon entry + { + searchField.value = ''; + this.searchActive = true; + } + } + else if (!isActive) // directly remove the panel + { + this.DOMSearchBox().className = 'MSearchBoxInactive'; + this.DOMSearchField().value = this.searchLabel; + this.searchActive = false; + this.lastSearchValue = '' + this.lastResultsPage = ''; + } + } +} + +// ----------------------------------------------------------------------- + +// The class that handles everything on the search results page. +function SearchResults(name) +{ + // The number of matches from the last run of . + this.lastMatchCount = 0; + this.lastKey = 0; + this.repeatOn = false; + + // Toggles the visibility of the passed element ID. + this.FindChildElement = function(id) + { + var parentElement = document.getElementById(id); + var element = parentElement.firstChild; + + while (element && element!=parentElement) + { + if (element.nodeName == 'DIV' && element.className == 'SRChildren') + { + return element; + } + + if (element.nodeName == 'DIV' && element.hasChildNodes()) + { + element = element.firstChild; + } + else if (element.nextSibling) + { + element = element.nextSibling; + } + else + { + do + { + element = element.parentNode; + } + while (element && element!=parentElement && !element.nextSibling); + + if (element && element!=parentElement) + { + element = element.nextSibling; + } + } + } + } + + this.Toggle = function(id) + { + var element = this.FindChildElement(id); + if (element) + { + if (element.style.display == 'block') + { + element.style.display = 'none'; + } + else + { + element.style.display = 'block'; + } + } + } + + // Searches for the passed string. If there is no parameter, + // it takes it from the URL query. + // + // Always returns true, since other documents may try to call it + // and that may or may not be possible. + this.Search = function(search) + { + if (!search) // get search word from URL + { + search = window.location.search; + search = search.substring(1); // Remove the leading '?' + search = unescape(search); + } + + search = search.replace(/^ +/, ""); // strip leading spaces + search = search.replace(/ +$/, ""); // strip trailing spaces + search = search.toLowerCase(); + search = convertToId(search); + + var resultRows = document.getElementsByTagName("div"); + var matches = 0; + + var i = 0; + while (i < resultRows.length) + { + var row = resultRows.item(i); + if (row.className == "SRResult") + { + var rowMatchName = row.id.toLowerCase(); + rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_' + + if (search.length<=rowMatchName.length && + rowMatchName.substr(0, search.length)==search) + { + row.style.display = 'block'; + matches++; + } + else + { + row.style.display = 'none'; + } + } + i++; + } + document.getElementById("Searching").style.display='none'; + if (matches == 0) // no results + { + document.getElementById("NoMatches").style.display='block'; + } + else // at least one result + { + document.getElementById("NoMatches").style.display='none'; + } + this.lastMatchCount = matches; + return true; + } + + // return the first item with index index or higher that is visible + this.NavNext = function(index) + { + var focusItem; + while (1) + { + var focusName = 'Item'+index; + focusItem = document.getElementById(focusName); + if (focusItem && focusItem.parentNode.parentNode.style.display=='block') + { + break; + } + else if (!focusItem) // last element + { + break; + } + focusItem=null; + index++; + } + return focusItem; + } + + this.NavPrev = function(index) + { + var focusItem; + while (1) + { + var focusName = 'Item'+index; + focusItem = document.getElementById(focusName); + if (focusItem && focusItem.parentNode.parentNode.style.display=='block') + { + break; + } + else if (!focusItem) // last element + { + break; + } + focusItem=null; + index--; + } + return focusItem; + } + + this.ProcessKeys = function(e) + { + if (e.type == "keydown") + { + this.repeatOn = false; + this.lastKey = e.keyCode; + } + else if (e.type == "keypress") + { + if (!this.repeatOn) + { + if (this.lastKey) this.repeatOn = true; + return false; // ignore first keypress after keydown + } + } + else if (e.type == "keyup") + { + this.lastKey = 0; + this.repeatOn = false; + } + return this.lastKey!=0; + } + + this.Nav = function(evt,itemIndex) + { + var e = (evt) ? evt : window.event; // for IE + if (e.keyCode==13) return true; + if (!this.ProcessKeys(e)) return false; + + if (this.lastKey==38) // Up + { + var newIndex = itemIndex-1; + var focusItem = this.NavPrev(newIndex); + if (focusItem) + { + var child = this.FindChildElement(focusItem.parentNode.parentNode.id); + if (child && child.style.display == 'block') // children visible + { + var n=0; + var tmpElem; + while (1) // search for last child + { + tmpElem = document.getElementById('Item'+newIndex+'_c'+n); + if (tmpElem) + { + focusItem = tmpElem; + } + else // found it! + { + break; + } + n++; + } + } + } + if (focusItem) + { + focusItem.focus(); + } + else // return focus to search field + { + parent.document.getElementById("MSearchField").focus(); + } + } + else if (this.lastKey==40) // Down + { + var newIndex = itemIndex+1; + var focusItem; + var item = document.getElementById('Item'+itemIndex); + var elem = this.FindChildElement(item.parentNode.parentNode.id); + if (elem && elem.style.display == 'block') // children visible + { + focusItem = document.getElementById('Item'+itemIndex+'_c0'); + } + if (!focusItem) focusItem = this.NavNext(newIndex); + if (focusItem) focusItem.focus(); + } + else if (this.lastKey==39) // Right + { + var item = document.getElementById('Item'+itemIndex); + var elem = this.FindChildElement(item.parentNode.parentNode.id); + if (elem) elem.style.display = 'block'; + } + else if (this.lastKey==37) // Left + { + var item = document.getElementById('Item'+itemIndex); + var elem = this.FindChildElement(item.parentNode.parentNode.id); + if (elem) elem.style.display = 'none'; + } + else if (this.lastKey==27) // Escape + { + parent.searchBox.CloseResultsWindow(); + parent.document.getElementById("MSearchField").focus(); + } + else if (this.lastKey==13) // Enter + { + return true; + } + return false; + } + + this.NavChild = function(evt,itemIndex,childIndex) + { + var e = (evt) ? evt : window.event; // for IE + if (e.keyCode==13) return true; + if (!this.ProcessKeys(e)) return false; + + if (this.lastKey==38) // Up + { + if (childIndex>0) + { + var newIndex = childIndex-1; + document.getElementById('Item'+itemIndex+'_c'+newIndex).focus(); + } + else // already at first child, jump to parent + { + document.getElementById('Item'+itemIndex).focus(); + } + } + else if (this.lastKey==40) // Down + { + var newIndex = childIndex+1; + var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex); + if (!elem) // last child, jump to parent next parent + { + elem = this.NavNext(itemIndex+1); + } + if (elem) + { + elem.focus(); + } + } + else if (this.lastKey==27) // Escape + { + parent.searchBox.CloseResultsWindow(); + parent.document.getElementById("MSearchField").focus(); + } + else if (this.lastKey==13) // Enter + { + return true; + } + return false; + } +} diff --git a/docs/search/search_l.png b/docs/search/search_l.png new file mode 100644 index 0000000..c872f4d Binary files /dev/null and b/docs/search/search_l.png differ diff --git a/docs/search/search_m.png b/docs/search/search_m.png new file mode 100644 index 0000000..b429a16 Binary files /dev/null and b/docs/search/search_m.png differ diff --git a/docs/search/search_r.png b/docs/search/search_r.png new file mode 100644 index 0000000..97ee8b4 Binary files /dev/null and b/docs/search/search_r.png differ diff --git a/docs/search/typedefs_68.html b/docs/search/typedefs_68.html new file mode 100644 index 0000000..fd7f942 --- /dev/null +++ b/docs/search/typedefs_68.html @@ -0,0 +1,26 @@ + + + + + + + +
+
Loading...
+
+
+ HISTORY + list.h +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/typedefs_6e.html b/docs/search/typedefs_6e.html new file mode 100644 index 0000000..723717c --- /dev/null +++ b/docs/search/typedefs_6e.html @@ -0,0 +1,26 @@ + + + + + + + +
+
Loading...
+
+
+ NODE + list.h +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_61.html b/docs/search/variables_61.html new file mode 100644 index 0000000..2eeb27f --- /dev/null +++ b/docs/search/variables_61.html @@ -0,0 +1,26 @@ + + + + + + + +
+
Loading...
+
+
+ args + COMMAND +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_63.html b/docs/search/variables_63.html new file mode 100644 index 0000000..9c04985 --- /dev/null +++ b/docs/search/variables_63.html @@ -0,0 +1,53 @@ + + + + + + + +
+
Loading...
+
+
+ childs + main.h +
+
+
+ +
+
+
+ cmdLine + main.h +
+
+
+
+ cmdList + main.h +
+
+
+
+ command + PROCESS +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_66.html b/docs/search/variables_66.html new file mode 100644 index 0000000..b3d350f --- /dev/null +++ b/docs/search/variables_66.html @@ -0,0 +1,26 @@ + + + + + + + +
+
Loading...
+
+
+ first + LIST +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_68.html b/docs/search/variables_68.html new file mode 100644 index 0000000..1ec8749 --- /dev/null +++ b/docs/search/variables_68.html @@ -0,0 +1,32 @@ + + + + + + + +
+
Loading...
+
+
+ history + main.h +
+
+
+
+ hostname + main.h +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_69.html b/docs/search/variables_69.html new file mode 100644 index 0000000..4142911 --- /dev/null +++ b/docs/search/variables_69.html @@ -0,0 +1,47 @@ + + + + + + + +
+
Loading...
+
+
+ id + COMMAND +
+
+
+
+ input_r + COMMAND +
+
+
+
+ input_r_filename + COMMAND +
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_6c.html b/docs/search/variables_6c.html new file mode 100644 index 0000000..343bda4 --- /dev/null +++ b/docs/search/variables_6c.html @@ -0,0 +1,26 @@ + + + + + + + +
+
Loading...
+
+
+ last + LIST +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_6e.html b/docs/search/variables_6e.html new file mode 100644 index 0000000..7021a68 --- /dev/null +++ b/docs/search/variables_6e.html @@ -0,0 +1,29 @@ + + + + + + + +
+
Loading...
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_6f.html b/docs/search/variables_6f.html new file mode 100644 index 0000000..275ca78 --- /dev/null +++ b/docs/search/variables_6f.html @@ -0,0 +1,38 @@ + + + + + + + +
+
Loading...
+
+
+ output_r + COMMAND +
+
+
+
+ output_r_append + COMMAND +
+
+
+
+ output_r_filename + COMMAND +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_70.html b/docs/search/variables_70.html new file mode 100644 index 0000000..c2a3eb4 --- /dev/null +++ b/docs/search/variables_70.html @@ -0,0 +1,47 @@ + + + + + + + +
+
Loading...
+ +
+
+ pipe + COMMAND +
+
+
+
+ prev + NODE +
+
+
+
+ proc + NODE +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_73.html b/docs/search/variables_73.html new file mode 100644 index 0000000..6340274 --- /dev/null +++ b/docs/search/variables_73.html @@ -0,0 +1,32 @@ + + + + + + + +
+
Loading...
+
+
+ size + COMMAND +
+
+
+
+ status + PROCESS +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/search/variables_75.html b/docs/search/variables_75.html new file mode 100644 index 0000000..2e40578 --- /dev/null +++ b/docs/search/variables_75.html @@ -0,0 +1,32 @@ + + + + + + + +
+
Loading...
+
+
+ userdir + main.h +
+
+
+
+ username + main.h +
+
+
Searching...
+
No Matches
+ +
+ + diff --git a/docs/tab_a.png b/docs/tab_a.png new file mode 100644 index 0000000..2d99ef2 Binary files /dev/null and b/docs/tab_a.png differ diff --git a/docs/tab_b.png b/docs/tab_b.png new file mode 100644 index 0000000..b2c3d2b Binary files /dev/null and b/docs/tab_b.png differ diff --git a/docs/tab_h.png b/docs/tab_h.png new file mode 100644 index 0000000..c11f48f Binary files /dev/null and b/docs/tab_h.png differ diff --git a/docs/tab_s.png b/docs/tab_s.png new file mode 100644 index 0000000..978943a Binary files /dev/null and b/docs/tab_s.png differ diff --git a/docs/tabs.css b/docs/tabs.css new file mode 100644 index 0000000..2192056 --- /dev/null +++ b/docs/tabs.css @@ -0,0 +1,59 @@ +.tabs, .tabs2, .tabs3 { + background-image: url('tab_b.png'); + width: 100%; + z-index: 101; + font-size: 13px; +} + +.tabs2 { + font-size: 10px; +} +.tabs3 { + font-size: 9px; +} + +.tablist { + margin: 0; + padding: 0; + display: table; +} + +.tablist li { + float: left; + display: table-cell; + background-image: url('tab_b.png'); + line-height: 36px; + list-style: none; +} + +.tablist a { + display: block; + padding: 0 20px; + font-weight: bold; + background-image:url('tab_s.png'); + background-repeat:no-repeat; + background-position:right; + color: #283A5D; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + text-decoration: none; + outline: none; +} + +.tabs3 .tablist a { + padding: 0 10px; +} + +.tablist a:hover { + background-image: url('tab_h.png'); + background-repeat:repeat-x; + color: #fff; + text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); + text-decoration: none; +} + +.tablist li.current a { + background-image: url('tab_a.png'); + background-repeat:repeat-x; + color: #fff; + text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); +} diff --git a/list.c b/list.c old mode 100644 new mode 100755 index 77a4916..66888ac --- a/list.c +++ b/list.c @@ -1,7 +1,7 @@ #include #include #include -#include "lista.h" +#include "list.h" void ListCreate(LIST *list) { @@ -9,6 +9,19 @@ void ListCreate(LIST *list) list->last = NULL; } +void initCommand(COMMAND *cmd) +{ + cmd->isBackground = 0; + cmd->input_r = 0; + cmd->output_r = 0; + cmd->output_r_append = 0; + cmd->size = 0; + cmd->id = -1; + cmd->pid = -1; + cmd->pipe[0] = -1; + cmd->pipe[1] = -1; +} + int ListIsEmpty(LIST *list) { if(list->first == NULL) return 1; @@ -16,13 +29,14 @@ int ListIsEmpty(LIST *list) } -int ListInsert(LIST *list, ITEM *item) +int ListInsert(LIST *list, PROCESS *proc, COMMAND *cmd) { NODE *newNode = (NODE *)malloc(sizeof(NODE)); if (newNode != NULL) { - newNode->item = item; + newNode->proc = proc; + newNode->cmd = cmd; newNode->next = NULL; newNode->prev = list->last; @@ -37,47 +51,13 @@ int ListInsert(LIST *list, ITEM *item) return 0; } -int ListGetByPid(LIST *list, pid_t pid, ITEM *item) -{ - NODE *aux = list->first; - while (aux != NULL) - { - if (aux->item->pid == pid) - { - item = aux->item; - return 1; - } - aux = aux->next; - } - - return 0; -} - -int ListGetRunningProcess(LIST *list, ITEM *item) -{ - NODE *aux = list->first; - while (aux != NULL) - { - if(strcmp(aux->item->status, "Running") == 0) - { - strcpy(aux->item->status, "Stopped"); - item = aux->item; - return 1; - } - aux = aux->next; - } - return 0; -} - - int ListRemoveByPid(LIST *list, pid_t pid) { if (!ListIsEmpty(list)) { - int i; NODE *aux = list->first; - while(aux->item->pid != pid) + while(aux->proc->pid != pid) { if (aux != list->last) aux = aux->next; @@ -94,7 +74,7 @@ int ListRemoveByPid(LIST *list, pid_t pid) else aux->next->prev = aux->prev; - free(aux->item); + free(aux->proc); free(aux); return 1; @@ -102,73 +82,63 @@ int ListRemoveByPid(LIST *list, pid_t pid) return 0; } -pid_t ListLastStoppedToBg(LIST *list) +PROCESS *ListGetCurrentProcess(LIST *list) { - if(!ListIsEmpty(list)) { - NODE *aux = list->last; - while (aux != NULL) - { - if(strcmp(aux->item->status, "Stopped") == 0) - { - aux->item->isBackground = 1; - strcpy(aux->item->status, "Running"); - return aux->item->pid; - } - aux = aux->prev; - } + NODE *aux = list->first; + while (aux != NULL) + { + if((strcmp(aux->proc->status, "Running") == 0) && !aux->proc->isBackground) + return aux->proc; + aux = aux->next; } - return -1; + return NULL; } -pid_t ListToBg(LIST *list, pid_t pid) +PROCESS * ListGetLastStopped(LIST *list) { - if(!ListIsEmpty(list)) { + if(!ListIsEmpty(list)) + { NODE *aux = list->last; while (aux != NULL) { - if(aux->item->pid == pid) - { - aux->item->isBackground = 1; - strcpy(aux->item->status, "Running"); - return aux->item->pid; - } + if(strcmp(aux->proc->status, "Stopped") == 0) + return aux->proc; aux = aux->prev; } } - return -1; + return NULL; } -pid_t ListLastToFg(LIST *list) +PROCESS * ListGetProcess(LIST *list, pid_t pid) { - if(!ListIsEmpty(list)) { + if(!ListIsEmpty(list)) + { NODE *aux = list->last; - if (aux != NULL) + while (aux != NULL) { - aux->item->isBackground = 0; - strcpy(aux->item->status, "Running"); - return aux->item->pid; + if(aux->proc->pid == pid) + return aux->proc; + aux = aux->prev; } - aux = aux->prev; } - return -1; + return NULL; } -pid_t ListToFg(LIST *list, pid_t pid) +void ListPurgeCmds(LIST *list) { - if(!ListIsEmpty(list)) { - NODE *aux = list->last; - while (aux != NULL) + if(!ListIsEmpty(list)) + { + NODE *aux = list->first; + while(aux != NULL) { - if(aux->item->pid == pid) - { - aux->item->isBackground = 0; - strcpy(aux->item->status, "Running"); - return aux->item->pid; - } - aux = aux->prev; + int i; + for(i = 0; i < aux->cmd->size; i++) + free(aux->cmd->args[i]); + free(aux->cmd->args); + free(aux->cmd); + aux = aux->next; } + ListCreate(list); } - return -1; } - diff --git a/list.h b/list.h old mode 100644 new mode 100755 index b5072a2..3958b8d --- a/list.h +++ b/list.h @@ -1,36 +1,154 @@ #ifndef _LISTA_H_ #define _LISTA_H_ + +/** @brief Lista simples para uso do comando builtin history. +* +*/ +typedef struct history +{ + char * cmd; + struct history *next; +} HISTORY; + +/** @brief Estrutura do processo. +* +* Esta estrutura guarda todas as informações +* pertinentes de um processo. +* +*/ typedef struct { pid_t pid; char command[256]; char status[100]; int isBackground; -} ITEM; +} PROCESS; +/** @brief Estrutura do comando. +* +* Esta estrutura guarda todas as informações +* pertinentes de um comando. +* Nesta implementação, um comando é definido +* como um execultável ou builtin e seus argumentos. +* cat arquivo | grep palavra | cut -c 1-6 tem 3 comandos, +* por exemplo. +* +*/ +typedef struct +{ + char **args; + int isBackground; + int input_r; + int output_r; + int output_r_append; + int size; + char * output_r_filename; + char * input_r_filename; + int id; + int pipe[2]; + pid_t pid; +} COMMAND; + +/** @brief Nó das listas de comandos e processos. +* +* Temos na mesma estrutura de nó um ponteiro para comando +* e outro para processo. Isso foi feito para facilitar a +* implementação, os dois não devem ser usados juntos. +* +*/ typedef struct NODE { - ITEM *item; + PROCESS *proc; + COMMAND *cmd; struct NODE *next; struct NODE *prev; } NODE; + +/** @brief Estrutura da lista em si. +* +*/ typedef struct { NODE *first; NODE *last; } LIST; + +/** @brief Inicializa a lista para uso posterior. +* @param list - Ponteiro para lista a ser inicializada. +* @return void. +*/ void ListCreate(LIST *list); + +/** @brief Inicializa um comando (estrutura) para +* uso posterior. +* @param cmd - Ponteiro para comando (estrutura) +* a ser inicializada. +* @return void. +*/ +void initCommand(COMMAND *cmd); + +/** @brief Verifica se uma lista está vazia. +* @param list - Ponteiro para a lista. +* @return Se a lista está vazia. +* @retval 1 - Sim. +* @retval 0 - Não. +*/ int ListIsEmpty(LIST *list); -int ListInsert(LIST *list, ITEM *item); -int ListGetByPid(LIST *list, pid_t pid, ITEM *item); -int ListGetRunningProcess(LIST *list, ITEM *item); + +/** @brief Insere um processo e/ou um comando na lista. +* +* Na prática, deve ser usada uma lista para +* comandos e outra para processos. +* Elas só estão na mesma estrutura para evitar +* repetição de código. +* Caso esteja inserindo em uma lista de processos, +* o argumento cmd deve ser NULL. +* Caso esteja inserindo em uma lista de comandos, +* o argumento proc deve ser NULL. +* @param list - Ponteiro para a lista. +* @param proc - Ponteiro para processo (estrutura). +* @param cmd - Ponteiro para comando (estrutura). +* @return Se foi possível inserir. +* @retval 1 - Sim. +* @retval 0 - Não. +*/ +int ListInsert(LIST *list, PROCESS *proc, COMMAND *cmd); + +/** @brief Remove um processo da lista pelo seu ID. +* @param list - Ponteiro para a lista de processos. +* @param pid - ID do processo. +* @return Se a remoção foi feita. +* @retval 1 - Sim. +* @retval 0 - Não. +*/ int ListRemoveByPid(LIST *list, pid_t pid); -pid_t ListLastStoppedToBg(LIST *list); -pid_t ListToBg(LIST *list, pid_t n); -pid_t ListLastToFg(LIST *list); -pid_t ListToFg(LIST *list, pid_t n); -LIST * childs; +/** @brief Retorna o processo que está rodando em foreground. +* @param list - Ponteiro para a lista de processos. +* @return Processo em questão. (NULL caso não tenha um). +*/ +PROCESS *ListGetCurrentProcess(LIST *list); + +/** @brief Busca e retorna o processo parado mais recente. +* @param list - Ponteiro para a lista de processos. +* @return Processo em questão. (NULL caso não tenha um). +*/ +PROCESS * ListGetLastStopped(LIST *list); + +/** @brief Retorna um processo pelo seu id. +* @param list - Ponteiro para a lista. +* @param pid - Id do processo a ser procurado. +* @return Ponteiro para o processo. (NULL caso +* não encontrado). +*/ +PROCESS * ListGetProcess(LIST *list, pid_t pid); + +/** @brief Libera espaço alocado pela lista de comandos. +* @param list - Ponteiro para a lista de comandos. +* @return void. +*/ +void ListPurgeCmds(LIST *list); + #endif diff --git a/main.c b/main.c old mode 100644 new mode 100755 index ecd7f72..0983e8d --- a/main.c +++ b/main.c @@ -1,7 +1,7 @@ +#define _GNU_SOURCE #include #include #include -#include #include #include #include @@ -9,72 +9,23 @@ #include "main.h" #include "parser.h" #include "builtin.h" -#include "lista.h" - -void printPrompt(char* username, char* hostname) -{ - char path[256]; - getcwd(path, 256); - if(strcmp(path, userdir) == 0) - printf("%s@%s:~$ ", username, hostname); - else - printf("%s@%s:%s$ ", username, hostname, path); -} - -void execute(char ** cmd) -{ - -} - -void termination_handler (int signum) -{ - if (fgChildPid != 0) - { - kill(fgChildPid, signum); - fgChildPid = 0; - } -} - -void child_handler(int signum) -{ - if(child_handler_lock == 0) { - int status; - pid_t pid; - pid = waitpid(0, &status, WNOHANG|WUNTRACED); - if((pid >= 0) && (WIFSTOPPED(status) == 0)) ListRemoveByPid(childs, pid); - } - -} - -void sigtstop_handler(int signum) { - ITEM *item; - item = malloc(sizeof(ITEM)); - ListGetRunningProcess(childs, item); - kill(childPid, SIGSTOP); -} +#include "list.h" int main (int argc, char **argv) { + int fd_in; + int fd_out; + sigset_t chldMask; + sigemptyset (&chldMask); + sigaddset(&chldMask, SIGCHLD); - char * cmdLine; - char * username; - char ** cmd; - char hostname[256]; - size_t len = 256; struct sigaction new_action, old_action; - /* Inicializa a lista que guarda os processos que rodam em background */ - childs = malloc(sizeof(LIST)); - ListCreate(childs); - /* Inicializa a variável que guarda o ID do processo atual do foreground */ - fgChildPid = 0; - child_handler_lock = 0; - /* Set up the structure to specify the new action. */ + /* Setup dos sinais utilizados */ new_action.sa_handler = termination_handler; sigemptyset (&new_action.sa_mask); new_action.sa_flags = 0; - sigaction (SIGINT, NULL, &old_action); if (old_action.sa_handler != SIG_IGN) sigaction (SIGINT, &new_action, NULL); @@ -88,7 +39,6 @@ int main (int argc, char **argv) new_action.sa_handler = child_handler; sigemptyset (&new_action.sa_mask); new_action.sa_flags = 0; - sigaction (SIGCHLD, NULL, &old_action); if (old_action.sa_handler != SIG_IGN) sigaction (SIGCHLD, &new_action, NULL); @@ -96,81 +46,191 @@ int main (int argc, char **argv) new_action.sa_handler = sigtstop_handler; sigemptyset (&new_action.sa_mask); new_action.sa_flags = 0; - sigaction (SIGTSTP, NULL, &old_action); if (old_action.sa_handler != SIG_IGN) sigaction (SIGTSTP, &new_action, NULL); - /*inicializa lista que guarda o historico de comandos */ - history = malloc(sizeof(struct node)); + + /*Setup das listas utilizadas */ + childs = malloc(sizeof(LIST)); + ListCreate(childs); + cmdList = malloc(sizeof(LIST)); + ListCreate(cmdList); + + history = malloc(sizeof(HISTORY)); history->cmd = NULL; history->next = NULL; - /* Pega o nome do usuario atual e da máquina */ username = getlogin(); - gethostname(hostname, len); + gethostname(hostname, 256); asprintf(&userdir, "/home/%s", username); /* Coloca o diretório do usuário como diretório inicial */ chdir(userdir); + /*Loop Principal */ while (1) { - printPrompt(username, hostname); - output_r = input_r = 0; - rewind(stdin); + printPrompt(); cmdLine = readline(); if(strcmp(cmdLine, "") != 0) { add_history(cmdLine); - cmd = parse(cmdLine); - int cmd_id = isBuiltIn(cmd[0]); - if(cmd_id >= 0) callBuiltIn(cmd_id, cmd[1]); - else + getCmds(cmdList, cmdLine); + NODE *aux = cmdList->first; + while (aux != NULL) { - if((childPid = fork()) == 0) + aux->cmd->id = isBuiltIn(aux->cmd->args[0]); + if(aux->cmd->id >= 0) callBuiltIn(aux->cmd->id, aux->cmd); + else { - if(output_r) - { - fd_out = open(output_r_filename, O_WRONLY, 0666); - dup2(fd_out, 0); - } - if(input_r) - { - fd_in = open(input_r_filename, O_RDONLY, 0666); - dup2(fd_in, 1); - } - fgChildPid = childPid; - int i = execvp(cmd[0], cmd); - if (output_r) close(fd_out); - if (input_r) close(fd_in); - if(i < 0) + if(aux->next != NULL) + pipe(aux->cmd->pipe); + aux->cmd->pid = fork(); + if(aux->cmd->pid == 0) { - printf("%s: command not found\n", cmd[0]); - exit(101); + if(aux->prev != NULL || aux->next != NULL) + { + if(aux->prev == NULL) + dup2(aux->cmd->pipe[1], 1); + else if(aux->next == NULL) + dup2(aux->prev->cmd->pipe[0], 0); + else + { + dup2(aux->prev->cmd->pipe[0], 0); + dup2(aux->cmd->pipe[1], 1); + } + NODE * aux2 = cmdList->first; + while(aux2->next != NULL) // Fecha o pipe + { + close(aux2->cmd->pipe[0]); + close(aux2->cmd->pipe[1]); + aux2 = aux2->next; + } + } + if(aux->cmd->output_r) + { + if(aux->cmd->output_r_append) + fd_out = open(aux->cmd->output_r_filename, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + else + fd_out = open(aux->cmd->output_r_filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR, 0666); + dup2(fd_out, 1); + } + if(aux->cmd->input_r) + { + fd_in = open(aux->cmd->input_r_filename, O_RDONLY, 0666); + dup2(fd_in, 0); + } + signal(SIGTSTP, SIG_IGN); //Ignora sinal de parada. Tratado pelo pai + int i = execvp(aux->cmd->args[0], aux->cmd->args); + if (aux->cmd->output_r) close(fd_out); + if (aux->cmd->input_r) close(fd_in); + if(i < 0) + { + printf("%s: command not found\n", aux->cmd->args[0]); + exit(0); + } } } - else + aux = aux->next; + } + aux = cmdList->first; + while (aux->next != NULL) //Fecha o pipe + { + close(aux->cmd->pipe[0]); + close(aux->cmd->pipe[1]); + aux = aux->next; + } + aux = cmdList->first; + int count = 0; + while (aux != NULL) + { + if(isBuiltIn(aux->cmd->args[0]) == -1) { - /*Após criar o processo filho, o pai insere em uma lista ligada o novo processo */ - int status; - pid_t pidfg; - ITEM * p; - p = malloc(sizeof(ITEM)); - p->pid = childPid; - p->isBackground = isBackground; + if(aux->cmd->isBackground == 0) count++; + setpgid(aux->cmd->pid, cmdList->first->cmd->pid); + PROCESS * p; + p = malloc(sizeof(PROCESS)); + p->pid = aux->cmd->pid; + p->isBackground = aux->cmd->isBackground; strcpy(p->status, "Running"); - strcpy(p->command, cmdLine); - ListInsert(childs, p); - isBackground = 0; - /*E espera ele terminar, caso seja um processo de foreground */ - if(!p->isBackground) { - child_handler_lock = 1; - pidfg = waitpid(childPid, &status, WUNTRACED); - child_handler_lock = 0; - if ((pidfg >= 0) && (WIFSTOPPED(status) == 0)) ListRemoveByPid(childs, childPid); - } + strcpy(p->command, aux->cmd->args[0]); + sigprocmask(SIG_BLOCK, &chldMask, NULL); //Atrasa sinal para evitar problemas de concorrência + ListInsert(childs, p, NULL); + sigprocmask(SIG_UNBLOCK, &chldMask, NULL); } + aux = aux->next; + } + int i; + int status; + sigprocmask(SIG_BLOCK, &chldMask, NULL); //Atrasa sinal para evitar problemas de concorrência + for (i = 0; i < count; i++) //Espera por todos os processos do grupo terminar + { + pid_t pidfg = waitpid(-cmdList->first->cmd->pid, &status, WUNTRACED); + if ((pidfg >= 0) && (WIFSTOPPED(status) == 0)) ListRemoveByPid(childs, pidfg); } - free_parse(); - free(cmdLine); + sigprocmask(SIG_UNBLOCK, &chldMask, NULL); + + } + ListPurgeCmds(cmdList); + free(cmdLine); + } + free_history(); + return 0; +} + +void printPrompt() +{ + char path[256]; + getcwd(path, 256); + if(strcmp(path, userdir) == 0) + printf("%s@%s:~$ ", username, hostname); + else if(strstr(path, userdir)) + printf("%s@%s:~%s$ ", username, hostname, path + strlen(userdir)); + else + printf("%s@%s:%s$ ", username, hostname, path); + +} + +void termination_handler(int signum) +{ + printf("\n"); + NODE *aux = childs->first; + while(aux != NULL) + { + if (!aux->proc->isBackground) + { + kill(-aux->proc->pid, signum); + break; } + aux = aux->next; + } +} + +void child_handler(int signum) +{ + int status; + pid_t pid; + pid = waitpid(-1, &status, WNOHANG|WUNTRACED); + if((pid >= 0) && (WIFSTOPPED(status) == 0)) ListRemoveByPid(childs, pid); +} + +void sigtstop_handler(int signum) +{ + printf("\n"); + PROCESS * process; + if(!ListIsEmpty(childs)) + { + process = ListGetCurrentProcess(childs); + if(process) + if(kill(process->pid, SIGSTOP) == 0) + strcpy(process->status, "Stopped"); } + else + printPrompt(); +} + +void free_memory() +{ + free(childs); + free(cmdList); + free_history(); + } diff --git a/main.h b/main.h old mode 100644 new mode 100755 index 4b53068..5d702cd --- a/main.h +++ b/main.h @@ -1,14 +1,57 @@ #ifndef _MAIN_H_ #define _MAIN_H_ +#include "list.h" + +/** +* @brief Imprime o prompt na tela (formato copiado do gnome shell). +* @return void. +* +*/ +void printPrompt(); + +/** +* @brief Função executada quando usuário manda ctrl+c. +* @param signum - id do sinal. +* @return void. +* +*/ +void termination_handler(int signum); + +/** +* @brief Função executada quando um processo filho termina. +* +* Esta função só é útil para processos em background, +* já que ela fica bloqueada quando um processo roda +* em foreground. +* @param signum - id do sinal. +* @return void. +* +*/ +void child_handler(int signum); + +/** +* @brief Função executada quando usuário manda ctrl+z. +* @param signum - id do sinal. +* @return void. +* +*/ +void sigtstop_handler(int signum); + +/** +* @brief Função que libera memória utilizada antes de terminar +* o programa. +* @return void. +* +*/ +void free_memory(); + char * userdir; +char * username; +char hostname[256]; +char * cmdLine; + +HISTORY *history; +LIST * cmdList; +LIST * childs; -int output_r; -int input_r; -char output_r_filename[100]; -char input_r_filename[100]; -int fd_out; -int fd_in; -pid_t fgChildPid; -int isBackground; -int child_handler_lock; #endif diff --git a/obj/empty b/obj/empty new file mode 100644 index 0000000..e69de29 diff --git a/parser.c b/parser.c old mode 100644 new mode 100755 index 3aaa24c..8b99faa --- a/parser.c +++ b/parser.c @@ -5,13 +5,14 @@ #include "parser.h" #include "main.h" -void imprimir_argv(char ** matriz, int tamanho){ - int i = 0; - for(i = 0; i <= tamanho; i++){ - printf("%s ", matriz[i]); - } - +void imprimir_argv(char ** matriz, int tamanho) +{ + int i = 0; + for(i = 0; i <= tamanho; i++) + { + printf("%s ", matriz[i]); } +} int word_count(char * source) { @@ -30,34 +31,65 @@ int word_count(char * source) return words; } -char ** parse(char * cmdLine) { - int words = word_count(cmdLine); - char * cmds; - int i; - parsed = (char**)malloc((words+1)*sizeof(char*)); - cmds = strtok(cmdLine, " "); +void getCmds(LIST *cmdList, char *cmdLine) +{ + char *cmds; + char * saveptr; + cmds = strtok_r(cmdLine, "|", &saveptr); + while(cmds != NULL) + { + COMMAND * cmd = malloc(sizeof(COMMAND)); + initCommand(cmd); + parse(cmds, cmd); + ListInsert(cmdList, NULL, cmd); + cmds = strtok_r(NULL, "|", &saveptr); + } +} - for(i = 0; cmds != NULL; i++) { - if((strcmp("&", cmds) == 0)) { - isBackground = 1; - words--; + +void parse(char * cmdLine, COMMAND * cmd) +{ + char * cmds; + int i = 0; + char *saveptr; + int cmd_len; + cmd_len = word_count(cmdLine); + cmd->args = (char**)malloc((cmd_len+1)*sizeof(char*)); + cmds = strtok_r(cmdLine, " ", &saveptr); + while(cmds != NULL) + { + if((strcmp("&", cmds) == 0)) + { + cmd->isBackground = 1; + } + else if((strcmp("<", cmds) == 0)) + { + cmd->input_r = 1; + cmd->input_r_filename = strtok_r(NULL, " ", &saveptr); + } + else if((strcmp(">", cmds) == 0)) + { + cmd->output_r = 1; + cmd->output_r_filename = strtok_r(NULL, " ", &saveptr); } - else { - parsed[i] = malloc(strlen(cmds)); - strcpy(parsed[i], cmds); + else if((strcmp(">>", cmds) == 0)) + { + cmd->output_r_append = 1; + cmd->output_r = 1; + cmd->output_r_filename = strtok_r(NULL, " ", &saveptr); } - cmds = strtok(NULL, " "); + else + { + cmd->args[i] = malloc((strlen(cmds)+1)*sizeof(char)); + strcpy(cmd->args[i], cmds); + i++; + } + cmds = strtok_r(NULL, " ", &saveptr); } - parsed[words] = (char *)0; - //imprimir_argv(parsed, words); - return parsed; -} - -void free_parse() { - int i; - for(i = 0; parsed[i] != NULL; i++) free(parsed[i]); - free(parsed); + cmd->args[i] = (char *)0; + cmd->args = (char**)realloc(cmd->args, (i+1)*sizeof(char*)); + cmd->size = i; } char* readline() @@ -68,8 +100,11 @@ char* readline() c = getchar(); while (c != '\n') { - input[i] = c; - i++; + if(c > 31) //Com esta condição, evitamos lixo na entrada. + { + input[i] = c; + i++; + } c = getchar(); } input[i] = '\0'; diff --git a/parser.h b/parser.h index 8f4a7e6..bd10355 100644 --- a/parser.h +++ b/parser.h @@ -1,12 +1,48 @@ #ifndef _PARSER_H_ #define _PARSER_H_ +#include "list.h" +/** +* @brief Conta o número de palavras de uma string. +* @param source - String para contar. +* @return Número de palavras da string passada como parâmetro. +* +*/ +int word_count(char * source); -char ** parsed; +/** +* @brief Lê o comando digitado pelo usuário. +* @return Comando digitado pelo usuário. +* +*/ +char * readline(); -void imprimir_argv(char ** matriz, int tamanho); -int word_count(char * source); -char * readline(void); -char ** parse(char * cmdLine); -void free_parse(); +/** +* @brief Adiciona em uma lista o(s) comando(s) digitado(s) pelo usuário. +* +* Pega toda a linha de comando digitada e adiciona o comando com +* seus parâmetros na lista. +* Em caso de uso do pipe, haverá mais de um comando a ser executado, +* ela quebrará a linha de comando e colocará cada comando com seus +* parâmetros em uma lista. +* @param cmdList - lista onde os comandos serão armazenados +* @param cmdLine - linha de comando digitada pelo usuário +* @return void. +* +*/ +void getCmds(LIST *cmdList, char *cmdLine); + +/** +* @brief Recebe a linha de comando e separa os argumentos. +* +* Retira os espaços entre os comandos e seus argumentos, +* armazena os comandos e seus parâmetros em um vetor de strings, +* na última posição do vetor coloca NULL, isso para o camando ser +* interpretado pela função execvp. +* @param cmdLine - linha de comando que será "parseada". +* @param command - estrutura que receberá cada comando, com suas flags e parâmetros +* @return void. +* +*/ +void parse(char * cmdLine, COMMAND * command); #endif diff --git a/shell - es.zip b/shell - es.zip deleted file mode 100644 index 9817e26..0000000 Binary files a/shell - es.zip and /dev/null differ