<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-16984085</id><updated>2011-12-14T23:48:38.990-03:00</updated><category term='autoconf'/><category term='autotools'/><category term='gobject'/><category term='google treasure hunt'/><category term='ltp'/><category term='jboss seam'/><category term='acl'/><category term='wan'/><category term='autogen'/><category term='ospf'/><category term='gnu'/><category term='depth-first search'/><category term='coverage testing'/><category term='algorithms'/><category term='programação'/><category term='access control list'/><category term='software development'/><category term='ip'/><category term='ccna'/><category term='ppp'/><category term='gmyth'/><category term='cisco'/><category term='genhtml'/><category term='make'/><category term='frame relay'/><category term='makefile'/><category term='coverage test'/><category term='roteador'/><category term='jee'/><category term='doctor dobbs'/><category term='c++'/><category term='gcov'/><category term='router'/><category term='hibernate'/><category term='lcov'/><category term='hdlc'/><category term='java'/><category term='software deployment'/><category term='link state routing'/><category term='desenvolvimento de software'/><category term='lucene'/><category term='programming contest'/><category term='mythtv'/><category term='autoscan'/><category term='blog'/><category term='digital tv'/><category term='tcp'/><category term='automake'/><category term='tests'/><category term='java enterprise'/><category term='glib'/><category term='gcc'/><category term='full text search engine'/><category term='network'/><category term='qt'/><category term='testing'/><category term='google'/><title type='text'>typedef void (*Garoto_Hipotenusa)(void *)</title><subtitle type='html'>Sucintas Descrições Pseudo-Randômicas em um Domínio Computacional-Valorado sobre Programação e Software Livre...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>27</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-16984085.post-3159959494172127052</id><published>2010-04-28T10:37:00.005-03:00</published><updated>2010-05-01T13:32:53.735-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='hibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='lucene'/><category scheme='http://www.blogger.com/atom/ns#' term='depth-first search'/><category scheme='http://www.blogger.com/atom/ns#' term='jee'/><category scheme='http://www.blogger.com/atom/ns#' term='jboss seam'/><category scheme='http://www.blogger.com/atom/ns#' term='java enterprise'/><category scheme='http://www.blogger.com/atom/ns#' term='full text search engine'/><title type='text'>Lucene Search</title><content type='html'>Para quem precisa disponibilizar um mecanismo de busca para um site, que permita indexação de conteúdos em diversos formatos (&lt;span style="font-weight: bold; font-style: italic;"&gt;PDF, ODT, DOC, registros de banco de dados, etc.)&lt;/span&gt;, a solução&lt;span style="font-weight: bold;"&gt; Lucene Search&lt;/span&gt;, da &lt;span style="font-style: italic;"&gt;Apache Foundation&lt;/span&gt; (&lt;a href="http://lucene.apache.org/"&gt;http://lucene.apache.org/&lt;/a&gt;) supre eficientemente essa demanda.&lt;br /&gt;&lt;br /&gt;Nesse post, pretendo mostrar, de forma sucinta, como o recurso de indexação e busca pode ser implementado com &lt;span style="font-weight: bold;"&gt;Lucene Search&lt;/span&gt;, usando um framework &lt;span style="font-weight: bold;"&gt;JEE&lt;/span&gt;, no caso, o &lt;span style="font-weight: bold;"&gt;JBoss Seam&lt;/span&gt; (&lt;a href="http://seamframework.org/"&gt;http://seamframework.org&lt;/a&gt;), ou outro qualquer de interesse do desenvolvedor.&lt;br /&gt;Primeiro, é preciso permitir que as suas entidades (&lt;span style="font-weight: bold;"&gt;JPA ou Hibernate&lt;/span&gt;) tenham a capacidade de gerar informações de índice (&lt;span style="font-weight: bold;"&gt;metadados&lt;/span&gt;), que serão gravados em disco,  a cada vez que um dado for alterado no banco. Haverá, é lógico, uma preocupação sobre quais campos da entidade (digamos, o tipo Pessoa será indexado unicamente pelo campo str_nome da tabela pessoa) serão indexados. Para configurar os eventos do&lt;span style="font-weight: bold;"&gt; Lucene Search&lt;/span&gt;, de forma que eventos de escrita no banco atualizem os "listenes" do Lucene, é preciso configurar o arquivo &lt;span style="font-weight: bold;"&gt;"ejb-jar.xml"&lt;/span&gt; ou o &lt;span style="font-weight: bold;"&gt;"hibernate.cfg.xml"&lt;/span&gt;, com os seguintes itens de configuração:&lt;br /&gt;&lt;blockquote&gt; &lt;span style="font-weight: bold;"&gt;&amp;lt;property name="hibernate.search.default.indexBase"&amp;gt; value="./lucene_indexes/"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;         &amp;lt;property name="hibernate.ejb.event.post-insert"            value="org.hibernate.search.event.FullTextIndexEventListener"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;         &amp;lt;property name="hibernate.ejb.event.post-update"     value="org.hibernate.search.event.FullTextIndexEventListener"/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;         &amp;lt;property name="hibernate.ejb.event.post-delete"    value="org.hibernate.search.event.FullTextIndexEventListener"/&amp;gt;&lt;/span&gt;  &lt;/blockquote&gt;&lt;br /&gt;No caso, a propriedade &lt;span style="font-weight: bold;"&gt;"hibernate.search.default.indexBase"&lt;/span&gt; configura o diretório onde serão gravados os índices. É permitido usar diretórios relativos, como no caso acima, que configura o diretório de índices para o caminho &lt;span style="font-weight: bold;"&gt;lucene_indexes&lt;/span&gt;, que será referenciado dentro do path atual configurado para esse contexto. Dependendo do servidor de aplicação, o diretório "." pode referenciar o diretório server, do diretório padrão de instalação do &lt;span style="font-weight: bold;"&gt;JBoss&lt;/span&gt;, ou o server/default/deploy. Caso não exista o diretório acima, será automaticamente criado (criará o diretório &lt;span style="font-weight: bold;"&gt;server/default/deploy/lucene_indexes&lt;/span&gt;).&lt;br /&gt;Outro passo importante é copiar as bibliotecas do Lucene e do &lt;span style="font-weight: bold;"&gt;Hibernate Search&lt;/span&gt; (que serão adicionados no arquivo &lt;span style="font-weight: bold;"&gt;MANIFEST.MF&lt;/span&gt;, no diretório META-INF):&lt;br /&gt;&lt;blockquote&gt; &lt;span style="font-style: italic; font-weight: bold;"&gt;lucene-core.jar &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt; hibernate-search.jar &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt; hibernate-commons-annotations.jar&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt; hibernate-annotations.jar &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt; lucene-highlighter-2.1.0.jar&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;Após isso, é necessário inserir as anotações específicas do Lucene e do Hibernate Search. A primeira indicará, na declaração da sua classe &lt;span style="font-weight: bold;"&gt;POJO &lt;/span&gt;(JPA/Hibernate) que ela será indexada:&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="font-weight: bold;"&gt;@Entity&lt;br /&gt;&lt;span style="font-style: italic;"&gt;@Indexed&lt;/span&gt;&lt;br /&gt;@Table(name = "relator", schema = "juris")&lt;br /&gt;public class Relator implements java.io.Serializable {&lt;br /&gt;...&lt;/blockquote&gt;É preciso marcar o campo da entidade que representa o índice. Na verdade, qualquer campo único pode ser usado. A anotação &lt;span style="font-weight: bold;"&gt;DocumentId &lt;/span&gt;apenas ajudará o &lt;span style="font-weight: bold;"&gt;Lucene &lt;/span&gt;a garantir a unicidade dos registros:&lt;br /&gt;    &lt;blockquote style="font-weight: bold;"&gt;@Id&lt;br /&gt;    &lt;span style="font-style: italic;"&gt;@DocumentId&lt;/span&gt;&lt;br /&gt;    @Column(name = "id_relator", unique = true, nullable = false)&lt;br /&gt;    public short getIdRelator() {&lt;br /&gt;        return this.idRelator;&lt;br /&gt;    }&lt;/blockquote&gt;&lt;br /&gt;Dentro da definição dessa entidade, agora é necessário especificar quais campos são indexados, e como eles serão indexados:&lt;br /&gt;    &lt;blockquote style="font-weight: bold;"&gt;@Column(name = "str_nome_relator", length = 500)&lt;br /&gt;    @Length(max = 500)&lt;br /&gt;    &lt;span style="font-style: italic;"&gt;@Field(index=Index.TOKENIZED,store=Store.YES,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            analyzer= @Analyzer(impl = BrazilianAnalyzer.class))&lt;/span&gt;&lt;br /&gt;    public String getStrNomeRelator() {&lt;br /&gt;        return this.strNomeRelator;&lt;br /&gt;    }&lt;/blockquote&gt;Nesse ponto, cabem algumas explicações: o parâmetro &lt;span style="font-weight: bold;"&gt;index &lt;/span&gt;permite dizer se o campo será quebrado em tokens (trechos de caracteres), ou será tratado como uma sequência única. No caso, por ser um campo String composto por nome e sobrenome do relator, é aconselhável usar a constante &lt;span style="font-weight: bold;"&gt;Index.TOKENIZED&lt;/span&gt;. O parâmetro &lt;span style="font-weight: bold;"&gt;store &lt;/span&gt;diz se o campo será armazenado em arquivo, e pode ser visualizado através da ferramenta Luke (&lt;a href="http://code.google.com/p/luke/"&gt;http://code.google.com/p/luke/&lt;/a&gt;). Essa ferramenta, por sinal, é muito útil para estudar a forma com que o Lucene gera os índices em arquivo, permitindo simular buscas usando diferentes analizadores semânticos de linguagens.&lt;br /&gt;&lt;br /&gt;O outro parâmetro (&lt;span style="font-weight: bold;"&gt;analyzer&lt;/span&gt;) permite definir um analizador semântico diferente do Inglês. No caso, existe um &lt;span style="font-weight: bold;"&gt;BrazilianAnalyzer&lt;/span&gt;, e isso é muito importante, pois o tratamento sobre caracteres acentuados, por exemplo, é viabilizado através dos analizadores. Caso um analizador adequado não seja usado, internamente o &lt;span style="font-weight: bold;"&gt;Lucene &lt;/span&gt;pode ignorar caracteres acentuados, por exemplo, como se fossem símbolos inválidos. Ademais, o analizador específico para a linguagem que você utiliza para armazenar dados permite que uma busca por "Abraão" ou "Abraao" retorne o mesmo resultado. O recurso de internacionalização dos Analyzers permite ignorar detalhes de acentuação, melhorando a qualidade da busca.&lt;br /&gt;&lt;br /&gt;Agora, já é possível fazer uma busca, usando o trecho a seguir:&lt;br /&gt;          &lt;blockquote style="font-weight: bold;"&gt;     try&lt;br /&gt;               {&lt;br /&gt;                      QueryParser parser =&lt;br /&gt;                            new MultiFieldQueryParser( new String[] {&lt;br /&gt;                                    "strNomeRelator"&lt;br /&gt;                                },&lt;br /&gt;                                  new BrazilianAnalyzer() );&lt;br /&gt;                        Query luceneQuery = parser.parse(nome_relator);&lt;br /&gt;&lt;br /&gt;                       FullTextQuery ftq = entityManager.createFullTextQuery(luceneQuery&lt;br /&gt;                            ,Relator.class);&lt;br /&gt;                 } catch (ParseException exc) {&lt;br /&gt;                 }&lt;/blockquote&gt;&lt;br /&gt;Na chamado a classe &lt;span style="font-weight: bold;"&gt;MultiFieldQueryParser&lt;/span&gt;, nós passaremos como parâmetro: o campo que foi indexado, e que será buscado agora; e o analizador utilizado (&lt;span style="font-weight: bold;"&gt;BrazilianAnalyzer&lt;/span&gt;). Normalmente, pode-se passar null para o analyzer, pois ele já foi configurado na entidade Relator. Dessa forma, nós ainda não criamos a &lt;span style="font-weight: bold;"&gt;Query &lt;/span&gt;Lucene, apenas criamos um "criador de Queries Lucene". A seguir, nós chamamos o método parse, herdado da classe ancestral QueryParser, passando como parâmetro o valor que se quer buscar (por exemplo, a variável String nome_relator poderia conter "José", pois queríamos buscar por José na base).  Com a query em mão, criaremos a &lt;span style="font-weight: bold;"&gt;FullTextQuery&lt;/span&gt;, essa sim que fará a busca propriamente dita na base de índices.&lt;br /&gt;&lt;br /&gt;Para retornar a lista de registros encontrados, devemos chamar:&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="font-weight: bold;"&gt;List&amp;lt;relator&amp;gt; resultPrimary  = ftq.getResultList();&lt;/blockquote&gt;&lt;br /&gt;No próximo post, veremos como executar outras funções, como: marcar os hits encontrados, procurar em múltiplas tabelas, etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-3159959494172127052?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/3159959494172127052/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=3159959494172127052' title='1 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/3159959494172127052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/3159959494172127052'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2010/04/lucene-search.html' title='Lucene Search'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-9203259072630927218</id><published>2008-08-16T01:20:00.001-03:00</published><updated>2008-08-16T01:27:49.749-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='ccna'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithms'/><category scheme='http://www.blogger.com/atom/ns#' term='google treasure hunt'/><category scheme='http://www.blogger.com/atom/ns#' term='network'/><category scheme='http://www.blogger.com/atom/ns#' term='depth-first search'/><title type='text'>Google Treasure Hunt 3: Busca em Profundidade (Depth-First Search)</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;"&gt;Esse é outro problema do &lt;b style=""&gt;&lt;i style=""&gt;Google &lt;span class="SpellE"&gt;Treasure&lt;/span&gt; Hunt&lt;/i&gt;&lt;/b&gt; que eu resolvi. Esse foi o mais fácil de todos, e realmente não era necessário nenhum conhecimento de programação. Tenha-se em mente apenas que o não uso de programação para resolvê-lo não é de modo algum divertido! Tente ensinar seu computador a fazê-lo por você… O problema que eu obtive no &lt;b style=""&gt;Google&lt;/b&gt; foi o seguinte:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 9pt;" lang="EN-US"&gt;“Below is a diagram of a computer network. The nodes are hosts on the network, and the lines between them are links. A packet is sent out from host P with a destination of 4.229.231.150. Which nodes does the packet pass through on its way to the destination? (&lt;span class="GramE"&gt;include&lt;/span&gt; start and final node in your answer)”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;"&gt;O diagrama para o modelo da rede acima foi fornecido na forma da tabela de &lt;span class="SpellE"&gt;roteamento&lt;/span&gt; a seguir:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;"&gt;“&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;"&gt;A&lt;span style=""&gt;                  &lt;/span&gt;26.40.28.17&lt;span class="GramE"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=""&gt;                   &lt;/span&gt;75.174.216.140 =&gt; 126.186.188.58&lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;26.40.28.17 =&gt; 17.100.195.84&lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;4.229.231.0/24 =&gt; 75.174.216.140&lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt;                    &lt;/span&gt;13.157.234.26&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;"&gt;B &lt;span style=""&gt;                 &lt;/span&gt;13.157.234.26 &lt;span style=""&gt;                &lt;/span&gt;76.246.145.72 =&gt; 53.12.68.161 &lt;span style=""&gt;         &lt;/span&gt;126.186.188.58 =&gt; 75.174.216.140 &lt;span style=""&gt;   &lt;/span&gt;53.12.68.0/24 =&gt; 26.40.28.17 &lt;span style=""&gt;                    &lt;/span&gt;17.100.195.84&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;"&gt;C &lt;span style=""&gt;                 &lt;/span&gt;53.12.68.161 &lt;span style=""&gt;                  &lt;/span&gt;75.174.216.140 =&gt; 219.88.219.35 &lt;span style=""&gt;     &lt;/span&gt;229.23.61.42 =&gt; 13.157.234.26 &lt;span style=""&gt;         &lt;/span&gt;17.100.195.0/24 =&gt; 103.19.57.145 &lt;span style=""&gt;                    &lt;/span&gt;126.186.188.58&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;"&gt;D &lt;span style=""&gt;                 &lt;/span&gt;103.19.57.145 &lt;span style=""&gt;                &lt;/span&gt;86.60.122.237 =&gt; 86.60.122.237 &lt;span style=""&gt;       &lt;/span&gt;117.146.177.141 =&gt; 53.12.68.161 &lt;span style=""&gt;     &lt;/span&gt;229.23.61.0/24 =&gt; 219.88.219.35 &lt;span style=""&gt;                    &lt;/span&gt;212.222.1.12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;"&gt;E &lt;span style=""&gt;                 &lt;/span&gt;4.229.231.150 &lt;span style=""&gt;                &lt;/span&gt;4.229.231.150 =&gt; 103.19.57.145 &lt;span style=""&gt;       &lt;/span&gt;54.35.7.207 =&gt; 54.35.7.207&lt;span style=""&gt;                &lt;/span&gt;126.186.188.0/24 =&gt; 199.223.210.72 229.23.61.42&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;"&gt;F &lt;span style=""&gt;                 &lt;/span&gt;54.35.7.207 &lt;span style=""&gt;                    &lt;/span&gt;4.229.231.150 =&gt; 229.23.61.42 &lt;span style=""&gt;         &lt;/span&gt;13.157.234.26 =&gt; 199.223.210.72 &lt;span style=""&gt;     &lt;/span&gt;26.40.28.0/24 =&gt; 4.229.231.150 &lt;span style=""&gt;                    &lt;/span&gt;86.60.122.237&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;"&gt;G &lt;span style=""&gt;                &lt;/span&gt;86.60.122.237 &lt;span style=""&gt;                &lt;/span&gt;229.23.61.42 =&gt; 54.35.7.207 &lt;span style=""&gt;             &lt;/span&gt;13.157.234.26 =&gt; 103.19.57.145 &lt;span style=""&gt;       &lt;/span&gt;103.19.57.0/24 =&gt; 212.222.1.12 &lt;span style=""&gt;                    &lt;/span&gt;219.88.219.35&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;"&gt;H &lt;span style=""&gt;                &lt;/span&gt;212.222.1.12 &lt;span style=""&gt;                  &lt;/span&gt;126.186.188.58 =&gt; 219.88.219.35 &lt;span style=""&gt;     &lt;/span&gt;75.174.216.140 =&gt; 86.60.122.237 &lt;span style=""&gt;     &lt;/span&gt;103.19.57.0/24 =&gt; 103.19.57.145 &lt;span style=""&gt;                    &lt;/span&gt;229.23.61.42&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;"&gt;I &lt;span style=""&gt;                  &lt;/span&gt;229.23.61.42 &lt;span style=""&gt;                  &lt;/span&gt;4.229.231.150 =&gt; 4.229.231.150 &lt;span style=""&gt;       &lt;/span&gt;117.146.177.141 =&gt; 54.35.7.207 &lt;span style=""&gt;       &lt;/span&gt;126.186.188.0/24 =&gt; 199.223.210.72 212.222.1.12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;"&gt;J &lt;span style=""&gt;                  &lt;/span&gt;199.223.210.72 &lt;span style=""&gt;              &lt;/span&gt;53.12.68.161 =&gt; 229.23.61.42 &lt;span style=""&gt;           &lt;/span&gt;4.229.231.150 =&gt; 54.35.7.207 &lt;span style=""&gt;           &lt;/span&gt;219.88.219.0/24 =&gt; 219.88.219.35 &lt;span style=""&gt;                    &lt;/span&gt;4.229.231.150&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;" lang="EN-US"&gt;K &lt;span style=""&gt;                 &lt;/span&gt;219.88.219.35 &lt;span style=""&gt;                &lt;/span&gt;4.229.231.150 =&gt; 199.223.210.72 &lt;span style=""&gt;     &lt;/span&gt;17.100.195.84 =&gt; 212.222.1.12 &lt;span style=""&gt;         &lt;/span&gt;126.186.188.0/24 =&gt; 86.60.122.237 &lt;span style=""&gt;                    &lt;/span&gt;103.19.57.145&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;" lang="EN-US"&gt;L &lt;span style=""&gt;                 &lt;/span&gt;117.146.177.141 &lt;span style=""&gt;            &lt;/span&gt;4.229.231.150 =&gt; 219.88.219.35 &lt;span style=""&gt;       &lt;/span&gt;117.146.177.141 =&gt; 126.186.188.58&lt;span style=""&gt;  &lt;/span&gt;26.40.28.0/24 =&gt; 76.246.145.72 &lt;span style=""&gt;                    &lt;/span&gt;75.174.216.140&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;" lang="EN-US"&gt;M &lt;span style=""&gt;                &lt;/span&gt;75.174.216.140 &lt;span style=""&gt;              &lt;/span&gt;199.223.210.72 =&gt; 13.157.234.26 &lt;span style=""&gt;     &lt;/span&gt;4.229.231.150 =&gt; 117.146.177.141 &lt;span style=""&gt;   &lt;/span&gt;126.186.188.0/24 =&gt; 17.100.195.84 &lt;span style=""&gt;                    &lt;/span&gt;26.40.28.17&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;" lang="EN-US"&gt;N &lt;span style=""&gt;                &lt;/span&gt;17.100.195.84 &lt;span style=""&gt;                &lt;/span&gt;4.229.231.150 =&gt; 26.40.28.17 &lt;span style=""&gt;           &lt;/span&gt;219.88.219.35 =&gt; 13.157.234.26 &lt;span style=""&gt;       &lt;/span&gt;17.100.195.0/24 =&gt; 75.174.216.140 &lt;span style=""&gt;                    &lt;/span&gt;76.246.145.72&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;" lang="EN-US"&gt;O &lt;span style=""&gt;                &lt;/span&gt;76.246.145.72 &lt;span style=""&gt;                &lt;/span&gt;4.229.231.150 =&gt; 17.100.195.84 &lt;span style=""&gt;       &lt;/span&gt;86.60.122.237 =&gt; 126.186.188.58 &lt;span style=""&gt;     &lt;/span&gt;13.157.234.0/24 =&gt; 53.12.68.161 &lt;span style=""&gt;                    &lt;/span&gt;117.146.177.141&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 7pt;" lang="EN-US"&gt;P &lt;span style=""&gt;                 &lt;/span&gt;126.186.188.58 &lt;span style=""&gt;              &lt;/span&gt;13.157.234.26 =&gt; 53.12.68.161 &lt;span style=""&gt;         &lt;/span&gt;4.229.231.150 =&gt; 76.246.145.72 &lt;span style=""&gt;       &lt;/span&gt;103.19.57.0/24 =&gt; 26.40.28.17 &lt;span style=""&gt;                    &lt;/span&gt;117.146.177.141&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;" lang="EN-US"&gt;”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;"&gt;Como você talvez tenha suposto, o primeiro símbolo é o ID do nó de rede, seguido por seu &lt;b style=""&gt;&lt;i style=""&gt;número IP&lt;/i&gt;&lt;/b&gt;. A seguir, você tem uma &lt;span class="SpellE"&gt;&lt;b style=""&gt;sequência&lt;/b&gt;&lt;/span&gt;&lt;b style=""&gt; de 3 regras de &lt;span class="SpellE"&gt;roteamento&lt;/span&gt;&lt;/b&gt;, o &lt;b style=""&gt;nó&lt;/b&gt; pode ver se essa regra em específico serve para &lt;b style=""&gt;&lt;i style=""&gt;o pacote entrante (&lt;span class="SpellE"&gt;incoming&lt;/span&gt; &lt;span class="SpellE"&gt;packet&lt;/span&gt;, ou pacote de rede no estágio de ingresso ao roteador)&lt;/i&gt;&lt;/b&gt;. O &lt;b style=""&gt;&lt;i style=""&gt;ultimo número IP&lt;/i&gt;&lt;/b&gt; nos dá a rota padrão (“default &lt;span class="SpellE"&gt;route&lt;/span&gt;”), apenas no caso em que esse nó não encontrou nenhuma &lt;b style=""&gt;&lt;i style=""&gt;regra de &lt;span class="SpellE"&gt;roteamento&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; que coubesse para um dado pacote (a rota padrão é como um “&lt;span class="SpellE"&gt;else&lt;/span&gt;” após uma &lt;span class="SpellE"&gt;sequência&lt;/span&gt; de “IF”s...).No caso do pacote chegar à rota padrão, esse pacote será direcionado &lt;b style=""&gt;&lt;i style=""&gt;para o host definido pelo endereço IP na última coluna da tabela acima&lt;/i&gt;&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;"&gt;Criei uma solução em &lt;b style=""&gt;C++&lt;/b&gt;, que usa um método de busca em profundidade para buscar por um caminho válido saindo de um dado nó para outro no &lt;b style=""&gt;&lt;i style=""&gt;modelo de rede&lt;/i&gt;&lt;/b&gt; do problema. Minha idéia foi fazer a função de&lt;span class="GramE"&gt; &lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;b style=""&gt;&lt;i style=""&gt;busca em profundidade (em &lt;span class="SpellE"&gt;ingles&lt;/span&gt;, “&lt;span class="SpellE"&gt;depth-first&lt;/span&gt; search”)&lt;/i&gt;&lt;/b&gt; &lt;b style=""&gt;andar de nó em nó &lt;/b&gt;(nós são rotulados como: &lt;b style=""&gt;A, B, C,&lt;/b&gt; etc.), iterando sobre cada uma das &lt;b style=""&gt;&lt;i style=""&gt;regras da tabela de &lt;span class="SpellE"&gt;roteamento&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;, e procurando por cada uma dessas regras que possa &lt;span class="SpellE"&gt;rotear&lt;/span&gt; adequadamente o pacote através da rede. &lt;/span&gt;&lt;span style="font-size: 9pt;" lang="EN-US"&gt;A &lt;span class="SpellE"&gt;função&lt;/span&gt; &lt;span class="SpellE"&gt;abaixo&lt;/span&gt; é auto-&lt;span class="SpellE"&gt;explicável&lt;/span&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;" lang="EN-US"&gt;“&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;bool&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;&lt;b&gt;RoutingTable&lt;/b&gt;&lt;/span&gt;&lt;b&gt;::&lt;span class="SpellE"&gt;routeTo&lt;/span&gt;&lt;/b&gt;( string node, string* &lt;span class="SpellE"&gt;resp&lt;/span&gt; ) &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;{&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;bool&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;do_it_again&lt;/span&gt; = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;RoutingEntry&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;rentry&lt;/span&gt; = &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;findRouteEntry&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt; node );&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( &lt;span class="SpellE"&gt;rentry.doneThis&lt;/span&gt;() )&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;return&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;resp&lt;/span&gt;&lt;/span&gt;-&gt;append( &lt;span class="SpellE"&gt;rentry.getId&lt;/span&gt;() );&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( &lt;span class="SpellE"&gt;rentry.getAddress&lt;/span&gt;().compare(&lt;span class="SpellE"&gt;getFinalDestination&lt;/span&gt;()) == 0 ) {&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;return&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span class="GramE"&gt;vector&lt;&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;RoutingRule&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&gt; &lt;span class="SpellE"&gt;routing_rules&lt;/span&gt; = &lt;span class="SpellE"&gt;rentry.getRules&lt;/span&gt;();&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span class="GramE"&gt;vector&lt;&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;RoutingRule&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&gt;::&lt;span class="SpellE"&gt;iterator&lt;/span&gt; &lt;span class="SpellE"&gt;i&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;rentry.markThis&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;// go through each of the routing rules&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;for&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( &lt;span class="SpellE"&gt;i&lt;/span&gt; = &lt;span class="SpellE"&gt;routing_rules.begin&lt;/span&gt;(); ( &lt;span class="SpellE"&gt;i&lt;/span&gt; != routing_rules.end() ) &amp;amp;&amp;amp;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;                       &lt;/span&gt;&lt;span class="SpellE"&gt;do_it_again&lt;/span&gt;; &lt;span class="SpellE"&gt;i&lt;/span&gt;+&lt;span class="GramE"&gt;+ )&lt;/span&gt; &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( (*&lt;span class="SpellE"&gt;i&lt;/span&gt;).&lt;span class="SpellE"&gt;canRoute&lt;/span&gt;(&lt;span class="SpellE"&gt;getFinalDestination&lt;/span&gt;()) ) {&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;                       &lt;/span&gt;&lt;span class="SpellE"&gt;do_it_again&lt;/span&gt; = &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;routeTo&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt; (*&lt;span class="SpellE"&gt;i&lt;/span&gt;).&lt;span class="SpellE"&gt;getRedirection&lt;/span&gt;(), &lt;span class="SpellE"&gt;resp&lt;/span&gt; );&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;               &lt;/span&gt;} &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);" lang="EN-US"&gt;// if&lt;span style=""&gt;                &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;} &lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);" lang="EN-US"&gt;// for&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;rentry.markThis&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;// no rules; asks the default gateway…&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( &lt;span class="SpellE"&gt;do_it_again&lt;/span&gt; )&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span class="SpellE"&gt;do_it_again&lt;/span&gt; = &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;routeTo&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt; &lt;span class="SpellE"&gt;rentry.getDefaultRoute&lt;/span&gt;().&lt;span class="SpellE"&gt;getRedirection&lt;/span&gt;(),&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;                              &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;resp&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt; )&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;return&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;do_it_again&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;}&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;" lang="EN-US"&gt;”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;"&gt;Nessa solução usei apenas a STL do C++, ou &lt;b style=""&gt;C++ Standard &lt;span class="SpellE"&gt;Template&lt;/span&gt; &lt;span class="SpellE"&gt;Library&lt;/span&gt; (STL)&lt;/b&gt;. Todos os nós são armazenados em estruturas como elementos de um &lt;span class="SpellE"&gt;vector&lt;/span&gt;, e são localizadas por símbolos de ID (&lt;b style=""&gt;A, B, C&lt;/b&gt;, etc.), ou por &lt;b style=""&gt;números IP&lt;/b&gt; (método &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b style=""&gt;findRouteEntry&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b style=""&gt;()).&lt;/b&gt; Cada nó tem a sua própria estrutura “&lt;span class="SpellE"&gt;Rules&lt;/span&gt;” (que você pode obter chamando &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b style=""&gt;&lt;i style=""&gt;getRules&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b style=""&gt;&lt;i style=""&gt;()&lt;/i&gt;&lt;/b&gt;). Uma vez processadas, cada uma dessas regras pode apontar para &lt;span class="GramE"&gt;um outro&lt;/span&gt; nó da tabela, e a função &lt;span class="SpellE"&gt;&lt;b style=""&gt;&lt;i style=""&gt;routeTo&lt;/i&gt;&lt;/b&gt;&lt;/span&gt; pode atuar de forma recursiva sobre uma dada regra. Se nenhuma regra suficiente para &lt;span class="SpellE"&gt;combiner&lt;/span&gt; com o pacote for encontrada, a função &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b style=""&gt;&lt;i style=""&gt;routeTo&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; é chamada sobre o nó retornado pela chamada a &lt;b style=""&gt;&lt;i style=""&gt;“&lt;span class="SpellE"&gt;getDefaultRoute&lt;/span&gt;”&lt;/i&gt;&lt;/b&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;“&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;// no rules; asks the default gateway…&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( &lt;span class="SpellE"&gt;do_it_again&lt;/span&gt; )&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span class="SpellE"&gt;do_it_again&lt;/span&gt; = &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;routeTo&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt; &lt;span class="SpellE"&gt;rentry.getDefaultRoute&lt;/span&gt;().&lt;span class="SpellE"&gt;getRedirection&lt;/span&gt;(),&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;                              &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;resp&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt; )&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;" lang="EN-US"&gt;“&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;"&gt;As chamadas para a função &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b style=""&gt;&lt;i style=""&gt;markThis&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b style=""&gt;&lt;i style=""&gt;()&lt;/i&gt;&lt;/b&gt; são para evitar recursões infinitas (iterar sobre os mesmos nós, de uma forma circular e muitas vezes irreversível, levando ao esgotamento de recursos computacionais). A semântica é simples: &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b style=""&gt;markThis&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b style=""&gt;(&lt;span class="SpellE"&gt;true&lt;/span&gt;)&lt;/b&gt;, quando o código precisar entrar numa “&lt;span class="SpellE"&gt;regão&lt;/span&gt; &lt;span class="SpellE"&gt;crítca&lt;/span&gt;”, e &lt;span class="SpellE"&gt;&lt;b style=""&gt;markThis&lt;/b&gt;&lt;/span&gt;&lt;b style=""&gt;(&lt;span class="SpellE"&gt;false&lt;/span&gt;)&lt;/b&gt; quando tiver saído da região crítica.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;"&gt;Você conseguiria encontrar a diferença entre o método de &lt;span class="SpellE"&gt;roteamento&lt;/span&gt; que eu formulei para o que é implementado por &lt;b style=""&gt;&lt;i style=""&gt;roteadores de rede&lt;/i&gt;&lt;/b&gt; de verdade (de fabricantes como &lt;b style=""&gt;Cisco&lt;/b&gt;)? Talvez meus &lt;span class="SpellE"&gt;&lt;b style=""&gt;posts&lt;/b&gt;&lt;/span&gt; anteriores com questões da certificação &lt;b style=""&gt;CCNA&lt;/b&gt; da Cisco possam ajudar...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-9203259072630927218?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/9203259072630927218/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=9203259072630927218' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/9203259072630927218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/9203259072630927218'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/08/google-treasure-hunt-3-busca-em.html' title='Google Treasure Hunt 3: Busca em Profundidade (Depth-First Search)'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-5520595232442573971</id><published>2008-06-30T22:57:00.006-03:00</published><updated>2008-07-01T20:45:42.425-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='google treasure hunt'/><category scheme='http://www.blogger.com/atom/ns#' term='qt'/><category scheme='http://www.blogger.com/atom/ns#' term='programming contest'/><category scheme='http://www.blogger.com/atom/ns#' term='programação'/><title type='text'>Google Treasure Hunt 2 - MapReduce?</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;Para resolver o &lt;b&gt;Google &lt;span class="SpellE"&gt;Treasure&lt;/span&gt; Hunt 2&lt;/b&gt;, decidi usar um velho programa para &lt;span class="GramE"&gt;busca de arquivos implementado em &lt;b&gt;&lt;i&gt;C++ usando &lt;span class="SpellE"&gt;multi-threading&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;. Eu &lt;i&gt;mudei algumas partes do código&lt;/i&gt;, só para garantir que possa fazer a busca pelos 2 padrões especificados no problema, e escolhi usar o framework &lt;span class="SpellE"&gt;&lt;b&gt;Qt&lt;/b&gt;&lt;/span&gt; (da &lt;span class="SpellE"&gt;&lt;b&gt;&lt;i&gt;Trolltech&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;) que tem algumas funções muito legais para lidar com arquivos, e isso é realmente verdade – você não precisa de mais nada, a não ser as classes &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b&gt;QFile&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; e &lt;span class="SpellE"&gt;&lt;b&gt;QDir&lt;/b&gt;&lt;/span&gt; e derivadas delas.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;Se você gosta de &lt;b&gt;&lt;i&gt;programação distribuída&lt;/i&gt;&lt;/b&gt;, talvez você já tenha ouvido falar no &lt;b style=""&gt;modelo &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style=""&gt;MapReduce&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;, desenvolvido pela &lt;b&gt;Google&lt;/b&gt; (www.google.com). &lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;De &lt;span class="SpellE"&gt;acordo&lt;/span&gt; com Jeffrey Dean e Sanjay &lt;span class="SpellE"&gt;Ghemawat&lt;/span&gt;, &lt;span class="SpellE"&gt;em&lt;/span&gt; um &lt;span class="SpellE"&gt;artigo&lt;/span&gt; &lt;b&gt;(“Distributed Programming with &lt;span class="SpellE"&gt;MapReduce&lt;/span&gt;”&lt;/b&gt;) &lt;span class="SpellE"&gt;escrito&lt;/span&gt; &lt;span class="SpellE"&gt;para&lt;/span&gt; o &lt;span class="SpellE"&gt;interessante&lt;/span&gt; &lt;span class="SpellE"&gt;livro&lt;/span&gt; &lt;b&gt;“Beautiful Code”&lt;/b&gt; (O’Reilly, 2007), &lt;b&gt;&lt;i&gt;“&lt;span class="SpellE"&gt;MapReduce&lt;/span&gt; was developed as a way of simplifying the development of large-scale computations at Google.”&lt;/i&gt;&lt;/b&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;(tradução: “O &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;MapReduce&lt;/span&gt;&lt;/span&gt; foi desenvolvido como uma forma de &lt;span class="SpellE"&gt;simplicar&lt;/span&gt; o desenvolvimento de processamento em larga-escala no Google”) Acredito que esse problema proposto no Google &lt;span class="SpellE"&gt;Treasure&lt;/span&gt; Hunt não seja realmente um &lt;i&gt;“processamento em larga-escala”&lt;/i&gt;, mas eu gostei da forma como o &lt;span class="SpellE"&gt;&lt;b&gt;MapReduce&lt;/b&gt;&lt;/span&gt; funciona, e decidi aplicar esse conceito ao meu programa.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;Aqui está o problema número 2 do &lt;span style="font-weight: bold;"&gt;Google Treasure Hunt&lt;/span&gt;:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;blockquote&gt;Here is a random zip archive for you to download:&lt;br /&gt;   GoogleTreasureHunt08_14338682343771558225.zip&lt;br /&gt;&lt;br /&gt;Unzip the archive, then process the resulting files to obtain a numeric result. You'll be taking the sum of lines from files matching a certain description, and multiplying those sums together to obtain a final result. Note that files have many different extensions, like '.pdf' and '.js', but all are plain text files containing a small number of lines of text.&lt;br /&gt;&lt;br /&gt;Sum of line 4 for all files with path or name containing BCD and ending in .js&lt;br /&gt;Sum of line 5 for all files with path or name containing foo and ending in .xml&lt;br /&gt;Hint: If the requested line does not exist, do not increment the sum.&lt;br /&gt;&lt;br /&gt;Multiply all the above sums together and enter the product below.&lt;br /&gt;(Note: Answer must be an exact, decimal representation of the number.) &lt;/blockquote&gt;&lt;br /&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;&lt;o:p&gt;&lt;/o:p&gt;Se você der uma olhada no código fonte, existem &lt;b&gt;2 threads&lt;/b&gt;; o primeiro (&lt;span class="SpellE"&gt;&lt;b&gt;Mapper&lt;/b&gt;&lt;/span&gt;) obtêm a lista de arquivos com um padrão de nomes fornecido (&lt;span class="GramE"&gt;no meu caso, nomes contendo “BCD” e com extensão “&lt;/span&gt;.&lt;span class="SpellE"&gt;js&lt;/span&gt;”, ou contendo “&lt;span class="SpellE"&gt;foo&lt;/span&gt;” e terminando com “.&lt;span class="SpellE"&gt;xml&lt;/span&gt;”); o segundo thread (&lt;span class="SpellE"&gt;&lt;b&gt;Reducer&lt;/b&gt;&lt;/span&gt;) utiliza a lista com nomes de arquivos do thread &lt;span class="SpellE"&gt;&lt;b style=""&gt;Mapper&lt;/b&gt;&lt;/span&gt; e faz uma outra busca mais profunda dentro de cada um dos arquivos pré-selecionados (para obter os valores de números nas linhas de número “4”). O principal método do &lt;span class="SpellE"&gt;&lt;b&gt;Mapper&lt;/b&gt;&lt;/span&gt; é o seguinte:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;bool&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt; &lt;span class="SpellE"&gt;&lt;b&gt;FileSearchMap&lt;/b&gt;&lt;/span&gt;&lt;b&gt;::&lt;span class="SpellE"&gt;depthFirstTraversal&lt;/span&gt;&lt;/b&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;const&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);"&gt;QString&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;&amp;amp; &lt;span class="SpellE"&gt;currentDir&lt;/span&gt;)&lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;{&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;QDir&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;dirP&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;currentDir&lt;/span&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;QString&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; temp;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;QString&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;fileName&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;QStringList&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;entryP&lt;/span&gt; = &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;dirP.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;entryList&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;QStringListIterator&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;entryL&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;entryP&lt;/span&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;while&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (&lt;span class="SpellE"&gt;entryL.hasNext&lt;/span&gt;())&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;lock&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;myFileCount&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; == 5)&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;bufferNotFull&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;wait&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&amp;amp;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            } &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);" lang="EN-US"&gt;// if - &lt;span class="SpellE"&gt;mutex&lt;/span&gt; and signal&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;unlock&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;fileName.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;clear&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;span class="GramE"&gt;temp&lt;/span&gt; = &lt;span class="SpellE"&gt;entryL.next&lt;/span&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ((temp != &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;"."&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;) &amp;amp;&amp;amp; (&lt;span class="GramE"&gt;temp !&lt;/span&gt;= &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;".."&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;))&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;fileName&lt;/span&gt;&lt;/span&gt; = &lt;span class="SpellE"&gt;currentDir&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;fileName.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;append&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;'\\'&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;fileName.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;append&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;temp);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (&lt;span class="SpellE"&gt;isDirectory&lt;/span&gt;(&lt;span class="SpellE"&gt;fileName&lt;/span&gt;))&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;depthFirstTraversal&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;fileName&lt;/span&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  }&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;else&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (&lt;span class="SpellE"&gt;isRegular&lt;/span&gt;(&lt;span class="SpellE"&gt;fileName&lt;/span&gt;))&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;unsigned&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;ftype&lt;/span&gt; = 0;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( ( &lt;span class="SpellE"&gt;fileName.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;endsWith&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;(&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;".&lt;span class="SpellE"&gt;js&lt;/span&gt;"&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;) ) &amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                               &lt;span class="GramE"&gt;( &lt;span class="SpellE"&gt;fileName.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;contains&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;(&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;"BCD"&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;) ) )&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                         &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;ftype&lt;/span&gt;&lt;/span&gt; = &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;TXT_FILE_PATTERN&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;else&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( ( &lt;span class="SpellE"&gt;fileName.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;endsWith&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;(&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;".xml"&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;) ) &amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                         &lt;span class="GramE"&gt;( &lt;span class="SpellE"&gt;fileName.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;contains&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;(&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;"&lt;span class="SpellE"&gt;foo&lt;/span&gt;"&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;) ) )&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                         &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;ftype&lt;/span&gt;&lt;/span&gt; = &lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;XML_FILE_PATTERN&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( &lt;span class="SpellE"&gt;ftype&lt;/span&gt; != 0 )&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                   &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;DirEntry&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;dentry&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt; &lt;span class="SpellE"&gt;fileName&lt;/span&gt;, &lt;span class="SpellE"&gt;ftype&lt;/span&gt; );&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                   &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;queueMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;lock&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                   &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;textFiles&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.push&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;dentry&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                   &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;queueMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;unlock&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                   &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                   &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;lock&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                   ++&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;myFileCount&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                   &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;unlock&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                   &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                                   &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;bufferNotEmpty&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;wakeAll&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              }&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        }&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  } &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);" lang="EN-US"&gt;// if - &lt;span class="SpellE"&gt;isDirectory&lt;/span&gt; / &lt;span class="SpellE"&gt;isRegular&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            } &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);" lang="EN-US"&gt;// if&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      } &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);" lang="EN-US"&gt;// while&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;return&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;O método acima &lt;span class="SpellE"&gt;sera&lt;/span&gt; chamado exatamente uma vez, a partir do método &lt;b&gt;&lt;i&gt;“&lt;span class="SpellE"&gt;run&lt;/span&gt;”&lt;/i&gt;&lt;/b&gt; da minha implementação do &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b style=""&gt;&lt;i style=""&gt;QThread&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; no &lt;span class="SpellE"&gt;&lt;b&gt;Mapper&lt;/b&gt;&lt;/span&gt;. Colocando o método &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;i&gt;depthFirstTraversal&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; para rodar, primeiramente ele obtêm todos os arquivos do &lt;span class="SpellE"&gt;diretóro&lt;/span&gt;, chamando o método &lt;span class="SpellE"&gt;&lt;b&gt;&lt;i&gt;entryList&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;, da classe &lt;span class="SpellE"&gt;&lt;b&gt;QDir&lt;/b&gt;&lt;/span&gt;. Então um &lt;span class="SpellE"&gt;&lt;b style=""&gt;iterator&lt;/b&gt;&lt;/span&gt; é instanciado sobre a lista de arquivos anteriormente obtida, e, enquanto estiver iterando sobre os arquivos, e antes que qualquer coisa eu faço uma chamada à função &lt;span class="SpellE"&gt;&lt;b style=""&gt;wait&lt;/b&gt;&lt;/span&gt; da estrutura &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b&gt;QWaitCondition&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;: a &lt;b style=""&gt;“&lt;span class="SpellE"&gt;wait&lt;/span&gt; &lt;span class="SpellE"&gt;condition&lt;/span&gt;”&lt;/b&gt; é um tipo de variável de condição usada para sincronizar threads, interrompendo-o no caso de ter obtido 5 arquivos (claro, pode ser qualquer número que você queira). &lt;i&gt;Porque obter exatamente 5 arquivos e interromper a execução, esperando para que a estrutura &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b&gt;QWaitCondition&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; seja liberada?&lt;/i&gt; Isso é usado de forma a criar um buffer com capacidade para 5 arquivos (no máximo), a partir do qual o thread &lt;span class="SpellE"&gt;&lt;b&gt;Reducer&lt;/b&gt;&lt;/span&gt; pode iterar sobre cada um dos arquivos listados pelo thread &lt;span class="SpellE"&gt;&lt;b style=""&gt;Mapper&lt;/b&gt;&lt;/span&gt;, abrir cada um desses arquivos, e procurar pelo critério de busca dado. Dessa forma, o thread &lt;span class="SpellE"&gt;&lt;b&gt;Reducer&lt;/b&gt;&lt;/span&gt; pode lidar apenas com uma lista de 5 arquivos, esgotá-la, e depois permitir que o &lt;span class="SpellE"&gt;&lt;b style=""&gt;Mapper&lt;/b&gt;&lt;/span&gt; preencha com mais alguns novos arquivos encontrados. Essa é a &lt;b&gt;&lt;i&gt;primeira regra&lt;/i&gt;&lt;/b&gt; usada para sincronizar os &lt;b style=""&gt;&lt;i style=""&gt;2 threads&lt;/i&gt;&lt;/b&gt;: &lt;i&gt;“&lt;span class="SpellE"&gt;&lt;b&gt;Mapper&lt;/b&gt;&lt;/span&gt;, comece a cobrir o buffer com os nomes dos arquivos encontrados, até que ele tenha 5 elementos. Daí, espere até que o &lt;span class="SpellE"&gt;Reducer&lt;/span&gt; consuma alguns desses arquivos, pois a partir disso você pode obter mais alguns arquivos. Faça isso até o fim dos tempos”&lt;/i&gt;. Agora, o thread &lt;span class="SpellE"&gt;&lt;b&gt;Reducer&lt;/b&gt;&lt;/span&gt;, obtendo todos os arquivos que o &lt;span class="SpellE"&gt;&lt;b&gt;Mapper&lt;/b&gt;&lt;/span&gt; consiga procurar:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;void&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;&lt;b&gt;KeySearchReduce&lt;/b&gt;&lt;/span&gt;&lt;b&gt;::run&lt;/b&gt;()&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;{&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;DirEntry&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;dirEntry&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;cnt&lt;/span&gt; = 0;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;do&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;lock&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;myFileCount&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; == 0)&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;bufferNotEmpty&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;wait&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&amp;amp;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;span class="SpellE"&gt;isSearchDown&lt;/span&gt;())&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;unlock&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;return&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  }&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            }&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;unlock&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;queueMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;lock&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;dirEntry&lt;/span&gt;&lt;/span&gt; = &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;span class="SpellE"&gt;getFirstTextFile&lt;/span&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;queueMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;unlock&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;QFile&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;infile&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;dirEntry.getFileName&lt;/span&gt;());&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (!&lt;span class="SpellE"&gt;infile.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;open&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;QIODevice&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;::&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;ReadOnly&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; | &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;QIODevice&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;::&lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;Text&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;) )&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;continue&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;QString&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; line;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;unsigned&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;i&lt;/span&gt; = 0;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;QTextStream&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="GramE"&gt;in(&lt;/span&gt;&amp;amp;infile);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( &lt;span class="SpellE"&gt;dirEntry.getFileType&lt;/span&gt;() == &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;FileSearchMap&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;::&lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;TXT_FILE_&lt;span class="GramE"&gt;PATTERN&lt;span style="color: black; font-style: normal;"&gt; )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;while&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (!&lt;span class="SpellE"&gt;in.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;atEnd&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;())&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        &lt;span class="GramE"&gt;line&lt;/span&gt; = &lt;span class="SpellE"&gt;in.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;readLine&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        ++i;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( &lt;span class="SpellE"&gt;i&lt;/span&gt; == 4 ) {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;lineP2Count&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; += &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;atol&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;line.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;toLocal8Bit&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;().&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;constData&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;());&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              ++&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;foundCount&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;break&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        }&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  } &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);" lang="EN-US"&gt;// while        &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            } &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;else&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="GramE"&gt;( &lt;span class="SpellE"&gt;dirEntry.getFileType&lt;/span&gt;&lt;/span&gt;() == &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;FileSearchMap&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;::&lt;/span&gt;&lt;i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;XML_FILE_&lt;span class="GramE"&gt;PATTERN&lt;span style="color: black; font-style: normal;"&gt; )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;while&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (!&lt;span class="SpellE"&gt;in.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;atEnd&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;())&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        &lt;span class="GramE"&gt;line&lt;/span&gt; = &lt;span class="SpellE"&gt;in.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;readLine&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        ++i;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( &lt;span class="SpellE"&gt;i&lt;/span&gt; == 5 ) {&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;lineP1Count&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; += &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;atol&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;line.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;toLocal8Bit&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;().&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;constData&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;());&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              ++&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;foundCount&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                              &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;break&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                        }&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  } &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);" lang="EN-US"&gt;// while&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            } &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);" lang="EN-US"&gt;// if - &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;getFileType&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;infile.&lt;b&gt;&lt;span style="color: rgb(100, 40, 128);"&gt;close&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;);&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;lock&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;myFileCount&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;--;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;producerMutex&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;unlock&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;-&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);" lang="EN-US"&gt;bufferNotFull&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;wakeAll&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      } &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;while&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (&lt;span class="GramE"&gt;!&lt;span style="color: rgb(0, 0, 192);"&gt;prod&lt;/span&gt;&lt;/span&gt;-&gt;&lt;span class="SpellE"&gt;isSearchDown&lt;/span&gt;());&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;}&lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;O &lt;span class="SpellE"&gt;&lt;b&gt;Reducer&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt; na primeira linha do comando “do” diz o seguinte: &lt;i&gt;“&lt;span class="SpellE"&gt;Ei&lt;/span&gt; &lt;span class="SpellE"&gt;&lt;b&gt;Mapper&lt;/b&gt;&lt;/span&gt;, você tem algum arquivo para que eu possa procurar &lt;span class="GramE"&gt;pelo informação&lt;/span&gt; numérica na linha X? Caso você não tenha arquivo algum, eu esperarei um pouco, até que você tenha algo para mim...”&lt;/i&gt; Então, para cada arquivo que o thread &lt;span class="SpellE"&gt;&lt;b&gt;Reducer&lt;/b&gt;&lt;/span&gt; processa, ele avisará ao &lt;span class="SpellE"&gt;&lt;b&gt;Mapper&lt;/b&gt;&lt;/span&gt;, de forma a que ele possa alimentar mais o buffer. No caso do &lt;span class="SpellE"&gt;&lt;b&gt;Mapper&lt;/b&gt;&lt;/span&gt; estiver dormindo em um &lt;b&gt;&lt;i&gt;buffer cheio com 5 elementos&lt;/i&gt;&lt;/b&gt;, ele será acordado e então recomeçará a cobrir o buffer com arquivos – isso é feito com uma chamada a &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);"&gt;prod&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;-&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);"&gt;bufferNotFull&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;.&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);"&gt;wakeAll&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;()&lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;, encontrado no fim do loop principal do &lt;span class="SpellE"&gt;&lt;b&gt;Reducer&lt;/b&gt;&lt;/span&gt;. A chamada a &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b style=""&gt;wakeAll&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; faz com que todos os threads que estejam dormindo sobre essa variável de condição acordem imediatamente (ou quase). Com isso, o &lt;span class="SpellE"&gt;&lt;b&gt;Mapper&lt;/b&gt;&lt;/span&gt; pode estar dormindo na linha &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);"&gt;bufferNotFull&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;.&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);"&gt;wait&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;(&amp;amp;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 0, 192);"&gt;producerMutex&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;)&lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;, no início do loop de busca, e essa chamada à função &lt;span class="SpellE"&gt;&lt;b&gt;wakeAll&lt;/b&gt;&lt;/span&gt; a partir do &lt;span class="SpellE"&gt;&lt;b&gt;Reducer&lt;/b&gt;&lt;/span&gt; pode liberar o&lt;span style=""&gt;  &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;bufferNotFull&lt;/b&gt;&lt;/span&gt; (uma instância do &lt;span class="SpellE"&gt;&lt;b&gt;QWaitCondition&lt;/b&gt;&lt;/span&gt;), permitindo ao &lt;span class="SpellE"&gt;&lt;b&gt;Mapper&lt;/b&gt;&lt;/span&gt; reiniciar o processo de completar &lt;b&gt;&lt;i&gt;o seu buffer de 5 elementos&lt;/i&gt;&lt;/b&gt; de novo. Tudo o que o &lt;span class="SpellE"&gt;Mapper&lt;/span&gt; tem que fazer é cobrir o buffer com nomes de arquivos.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;Nós estamos lidando aqui com recursos compartilhados, e os &lt;span class="SpellE"&gt;&lt;b&gt;mutexes&lt;/b&gt;&lt;/span&gt; são de uso obrigatório (veja as referências às instâncias de &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b&gt;QMutex&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; no código fonte) uma vez que essa aplicação é &lt;span class="SpellE"&gt;&lt;b&gt;&lt;i&gt;multithreaded&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;, e não queremos que ocorram condições de corrida.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;Colocando&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;tudo&lt;/span&gt; &lt;span class="SpellE"&gt;junto&lt;/span&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;FileSearchMap&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;* &lt;span class="SpellE"&gt;mapper&lt;/span&gt; = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;FileSearchMap&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(0, 80, 50);" lang="EN-US"&gt;KeySearchReduce&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;* reducer = &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;span class="SpellE"&gt;KeySearchReduce&lt;/span&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;mapper&lt;/span&gt;&lt;/span&gt;-&gt;&lt;span class="SpellE"&gt;setDirectory&lt;/span&gt;( dir );&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;span class="GramE"&gt;reducer&lt;/span&gt;-&gt;&lt;span class="SpellE"&gt;setMapper&lt;/span&gt;( &lt;span class="SpellE"&gt;mapper&lt;/span&gt; );&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;mapper&lt;/span&gt;&lt;/span&gt;-&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;start&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;span class="GramE"&gt;reducer&lt;/span&gt;-&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;start&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;mapper&lt;/span&gt;&lt;/span&gt;-&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;wait&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;span class="GramE"&gt;reducer&lt;/span&gt;-&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;wait&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;();&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; a1, a2;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;cout&lt;/span&gt;&lt;/span&gt; &lt;&lt; &lt;span class="SpellE"&gt;argv&lt;/span&gt;[1] &lt;&lt; &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;" contains "&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;&lt;&gt;&lt;span class="SpellE"&gt;getFoundCount&lt;/span&gt;()&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;&lt; &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;" files&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt; that contains "&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;&lt;&gt;&lt;span class="SpellE"&gt;getLineCount&lt;/span&gt;() &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;&lt; &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;" lines for the pattern 1 &lt;span class="GramE"&gt;( "&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;&lt; (a1 = reducer-&gt;getLineP1Count()) &lt;&lt; &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;                  &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;" )&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt; and pattern 2 ( "&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;&lt; (a2 = reducer-&gt;getLineP2Count()) &lt;&lt; &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;" )."&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;&lt; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;endl&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span class="GramE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; response = a1*a2;&lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;cout&lt;/span&gt;&lt;/span&gt; &lt;&lt; &lt;/span&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;"Response: ("&lt;/span&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;&lt;&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;")"&lt;/span&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;&lt; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;b&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;endl&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;Aqui, a chamada &lt;span class="GramE"&gt;&lt;b&gt;getLineP1Count&lt;/b&gt;&lt;/span&gt;&lt;b&gt;()&lt;/b&gt; retorna a soma de todos os &lt;span class="SpellE"&gt;numeros&lt;/span&gt; na linha 4, nos arquivos com o primeiro padrão; e &lt;b&gt;getLineP2Count()&lt;/b&gt; faz o mesmo para o padrão de busca 2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;Claro, dá pra resolver o problema todo sem usar capacidade de &lt;span class="SpellE"&gt;&lt;b&gt;&lt;i&gt;multithread&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;, mas aí não tem graça! &lt;span class="GramE"&gt;:)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size: 10pt; line-height: 115%;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-5520595232442573971?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/5520595232442573971/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=5520595232442573971' title='1 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/5520595232442573971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/5520595232442573971'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/06/google-treasure-hunt-2-mapreduce.html' title='Google Treasure Hunt 2 - MapReduce?'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-936494230557410596</id><published>2008-06-20T20:08:00.004-03:00</published><updated>2008-06-20T20:16:58.523-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='blog'/><category scheme='http://www.blogger.com/atom/ns#' term='doctor dobbs'/><category scheme='http://www.blogger.com/atom/ns#' term='desenvolvimento de software'/><title type='text'>Doctor Dobb's Code Talk</title><content type='html'>Para quem gosta de ler coisas sobre &lt;span style="font-weight: bold;"&gt;programação&lt;/span&gt;, um excelente site sempre foi o da revista &lt;a style="font-weight: bold; font-style: italic;" href="http://www.ddj.com"&gt;Doctor Dobb's Journal&lt;/a&gt; [&lt;span style="font-style: italic;"&gt;www.ddj.com&lt;/span&gt;]. Agora eles disponibilizaram um &lt;span style="font-weight: bold;"&gt;serviço de blog&lt;/span&gt; para os leitores. As discussões são sempre muito interessantes, para quem gosta de coisas como &lt;span style="font-weight: bold; font-style: italic;"&gt;otimização de código&lt;/span&gt;, &lt;span style="font-style: italic; font-weight: bold;"&gt;"thread-local heaps"&lt;/span&gt;, &lt;span style="font-style: italic; font-weight: bold;"&gt;arrays multi-dimensionais&lt;/span&gt;, &lt;span style="font-weight: bold; font-style: italic;"&gt;desenvolvimento de software distribuído&lt;/span&gt;, e qual a &lt;span style="font-weight: bold; font-style: italic;"&gt;melhor máquina para programar&lt;/span&gt;. Quem tiver a fim de participar, começa dando uma olhada no &lt;a href="http://dobbscodetalk.com/index.php?option=com_myblog&amp;amp;task=view&amp;amp;id=531&amp;amp;Itemid=29"&gt;meu blog&lt;/a&gt;:&lt;br /&gt;http://dobbscodetalk.com/index.php?option=com_myblog&amp;amp;task=view&amp;amp;id=531&amp;amp;Itemid=29&lt;br /&gt;&lt;br /&gt;Vejo vocês lá!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-936494230557410596?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/936494230557410596/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=936494230557410596' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/936494230557410596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/936494230557410596'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/06/doctor-dobbs-code-talk.html' title='Doctor Dobb&apos;s Code Talk'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-819837253725025161</id><published>2008-06-16T19:33:00.013-03:00</published><updated>2008-06-18T22:33:57.092-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithms'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><category scheme='http://www.blogger.com/atom/ns#' term='programming contest'/><title type='text'>Google Treasure Hunt 4</title><content type='html'>&lt;p class="MsoNormal" style="text-align: justify;"&gt;O &lt;b&gt;Google&lt;/b&gt; resolveu disponibilizar uma espécie de competição, onde são propostos problemas e pede-se a solução deles, cujas respostas sugerem (na verdade, praticamente obrigam) a aplicação de algum recurso computacional. Até onde eu sei, os problemas são únicos para cada candidato, o que inviabiliza qualquer tentativa de “trabalho em conjunto”. Chama-se de &lt;b&gt;&lt;i&gt;“Google Treasure Hunt 2008”&lt;/i&gt;&lt;/b&gt; [http://treasurehunt.appspot.com/]. O conjunto de problemas apresentado (atualmente, contando com apenas 4) assemelha-se aos vistos em outros campeonatos de programação, como o &lt;b&gt;International Collegiate Programming Contest&lt;/b&gt; (&lt;b&gt;ICPC&lt;/b&gt;), da &lt;b&gt;Association for Computing Machinery&lt;/b&gt; (&lt;b&gt;ACM&lt;/b&gt;) [www.acm.org]. Resolvi o último desses problemas (o quarto), e detalho aqui como cheguei à solução.&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;O problema proposto foi o seguinte:&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;“Find the smallest number that can be expressed as&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify; text-indent: 35.4pt;"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;the sum of 11 consecutive prime numbers,&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify; text-indent: 35.4pt;"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;the sum of 25 consecutive prime numbers,&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify; text-indent: 35.4pt;"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;the sum of 513 consecutive prime numbers,&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify; text-indent: 35.4pt;"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;the sum of 1001 consecutive prime numbers,&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify; text-indent: 35.4pt;"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;the sum of 1129 consecutive prime numbers,&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify; text-indent: 35.4pt;"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;and is itself a prime number.&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;For example, 41 is the smallest prime number that can be expressed as&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;the sum of 3 consecutive primes (11 + 13 + 17 = 41) and&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;the sum of 6 consecutive primes (2 + 3 + 5 + 7 + 11 + 13 = 41).”&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;Para solucionar o problema proposto, resolvi utilizar a linguagem de programação &lt;b&gt;C++&lt;/b&gt;, pelos recursos que a &lt;b&gt;STL&lt;/b&gt; oferece (estruturas como set’s&lt;i&gt;, vector’s, operações sobre conjuntos&lt;/i&gt;, etc.). Antes de tudo&lt;b&gt;&lt;i&gt;, o grande problema foi o de gerar os números primos&lt;/i&gt;&lt;/b&gt;. De modo que o problema não se refere a &lt;i&gt;um limite razoável para a quantidade de números primos&lt;/i&gt; que a solução envolva, gerar uma &lt;b&gt;&lt;i&gt;tabela com todos os números primos&lt;/i&gt;&lt;/b&gt; até o limite considerável de &lt;b&gt;&lt;i&gt;100.000&lt;/i&gt;&lt;/b&gt;, por exemplo, resolvi obter uma listagem pronta com o todos os números primos abaixo de &lt;b&gt;&lt;i&gt;100 mil&lt;/i&gt;&lt;/b&gt; [http://members.aol.com/MICRO46/primes_1.zip], um total de exatamente &lt;b&gt;78498&lt;/b&gt; primos. A razão de usar uma tabela pronta foi que o método que eu estava usando para gerar essa lista de primos demorava algo &lt;i&gt;em torno de 4 minutos&lt;/i&gt;... Posteriormente, otimizei o procedimento para durar menos de 0,5 segundos, e gerei o resultado em disco. Contudo, quem não tiver afim de gerar essa quantidade de primos, esses arquivos prontos são uma mão na roda. Com o conjunto de primos em mãos, apliquei o procedimento seguinte:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 36pt; text-align: justify; text-indent: -18pt;"&gt;1)&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;     &lt;/span&gt;Calcular as &lt;b&gt;&lt;i&gt;somas dos números primos em cada um dos intervalos&lt;/i&gt;&lt;/b&gt; (&lt;b&gt;11, 25, 513, 1001, 1129&lt;/b&gt;) – isso implica em somar os primos em todos os subintervalos de tamanho 11, por exemplo, dentro do conjunto de primos, o que gerou &lt;b&gt;&lt;i&gt;uma seqüência de 78488 intervalos de tamanho 11&lt;/i&gt;&lt;/b&gt;, até &lt;b&gt;&lt;i&gt;77.370 subintervalos de tamanho 1129&lt;/i&gt;&lt;/b&gt;;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 36pt; text-align: justify; text-indent: -18pt;"&gt;2)&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;     &lt;/span&gt;Fazer uma &lt;b&gt;&lt;i&gt;intersecção de conjuntos, 2 a 2&lt;/i&gt;&lt;/b&gt;, com os conjuntos resultantes da operação acima (por exemplo, &lt;b&gt;&lt;i&gt;as somas de todos os subintervalos de&lt;/i&gt;&lt;/b&gt; &lt;b&gt;&lt;i&gt;tamanho 11&lt;/i&gt;&lt;/b&gt; geram um conjunto) – o objetivo é obter as somas que são comuns entre esses conjuntos de somatórios de primos;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 36pt; text-align: justify; text-indent: -18pt;"&gt;3)&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;     &lt;/span&gt;&lt;b&gt;&lt;i&gt;Ordenar o conjunto intersecção resultante&lt;/i&gt;&lt;/b&gt; e &lt;b&gt;&lt;i&gt;mostrar o primeiro valor&lt;/i&gt;&lt;/b&gt; (ou seja, o menor).&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;Para as etapas 1 e 2, o método que usei foi o seguinte:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;void&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;sum_subintervals&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;const&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; vector&lt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&gt;&amp;amp; primes, &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;unsigned&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; max,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            set&lt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&gt;* pivot)&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;{&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;unsigned&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; soma = 0, j = 0, old_sum = 0;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;set&lt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;&gt; sums;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;      &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;for&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (j = 0; j &lt;&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      {&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            soma += primes.at(j);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      } &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(63, 127, 95);" lang="EN-US"&gt;// for&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      sums.insert(soma);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;while&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; ( (j &lt;&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      {&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            old_sum = soma;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            soma = old_sum - primes.at(j-max) + primes.at(j);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            ++j;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            sums.insert(soma);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      }&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      set&lt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;long&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&gt; s;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (pivot-&gt;size() != 0)&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      {&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            set_intersection(sums.begin(), sums.end(), pivot-&gt;begin(),&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt 70.8pt; text-indent: 35.4pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; pivot-&gt;end(), inserter(s, s.end()) );&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            pivot-&gt;clear();&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            copy(s.begin(), s.end(), inserter(*pivot, pivot-&gt;begin()));&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      }&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;else&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      {&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            copy( sums.begin(), sums.end(), inserter(*pivot, pivot-&gt;end()) );          &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;}&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;O código é pouco óbvio, mas eu explico: o que ele faz é pegar &lt;b&gt;intervalos de um certo tamanho&lt;/b&gt; (11, 25, 513, etc.) e somar os elementos nesse intervalo. Uma &lt;b&gt;&lt;i&gt;solução bastante elementar &lt;/i&gt;&lt;/b&gt;seria tentar somar diretamente todos os valores, e fazer isso para cada intervalo. Computacionalmente, no entanto, &lt;i&gt;esse método repete desnecessariamente operações de soma&lt;/i&gt; (a maior parte dos elementos &lt;b&gt;&lt;i&gt;seriam somados duplicados entre subintervalos consecutivos&lt;/i&gt;&lt;/b&gt;). Foi exatamente nessas somas supérfluas que o algoritmo que eu fiz gerou otimizações. Por exemplo, o &lt;b&gt;primeiro subintervalo de tamanho 11&lt;/b&gt; é o seguinte:&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;i&gt;{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;O próximo subintervalo é assim:&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;b&gt;&lt;i&gt;{3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;Qual a diferença entre os 2? No segundo, &lt;b&gt;inseriu-se o 37 e removeu-se o 2&lt;/b&gt;. De forma geral, &lt;b&gt;&lt;i&gt;cada subintervalo adiciona à seqüência anterior o próximo elemento primo, e remove o primeiro elemento da sequência anterior do resultado&lt;/i&gt;&lt;/b&gt;. Aplicando esse método iterativamente, foi possível &lt;b&gt;&lt;i&gt;reduzir a complexidade da solução de uma exponencial&lt;/i&gt;&lt;/b&gt; (em função do quadrado do conjunto de primos) para uma &lt;b&gt;&lt;i&gt;solução linear&lt;/i&gt;&lt;/b&gt;, com o esforço de execução variando apenas sobre &lt;i&gt;o tamanho da tabela de primos&lt;/i&gt;.&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;Pra finalizar, a &lt;b&gt;&lt;i&gt;parte mais simples do código&lt;/i&gt;&lt;/b&gt; apenas mostra o algoritmo acima rodando em cima de cada constante do problema:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;"&gt;      set&amp;lt;long&amp;gt; all_sums;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 35.4pt; line-height: normal;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; nums[5] = { 11, 25, 513, 1001, 1129 };&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; i;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;for&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (i = 0; i &amp;lt; 5; i++)&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      {&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            sum_subintervals(primes, nums[i], &amp;amp;all_sums);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      }&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;" lang="EN-US"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;      &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(127, 0, 85);" lang="EN-US"&gt;if&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; (all_sums.size() &amp;gt; 0)&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;            cout &amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(42, 0, 255);" lang="EN-US"&gt;"Solution: "&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; *(all_sums.begin()) &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(100, 40, 128);" lang="EN-US"&gt;endl&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black;" lang="EN-US"&gt;;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span lang="EN-US"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;Nem precisei ordenar o conjunto resultante, porque a &lt;b&gt;&lt;i&gt;classe template&lt;/i&gt;&lt;/b&gt; &lt;b&gt;“set”&lt;/b&gt; da &lt;b&gt;Standard Template Library&lt;/b&gt; já adiciona os elementos em ordem na estrutura. Quando tudo dá certo, na submissão aparece isso:&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;  Correct answer: XXXXXXXXXX&lt;br /&gt;  Your answer was: Correct&lt;br /&gt;&lt;br /&gt;  Your answer was correct! Congratulations, you're part-way there.&lt;br /&gt;  There will more questions over the coming weeks, and the first person to answer them all correctly will win a prize, so keep trying!&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;Boa sorte!&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt; &lt;/p&gt;&lt;p class="MsoNormal" style="text-align: justify;"&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-819837253725025161?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/819837253725025161/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=819837253725025161' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/819837253725025161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/819837253725025161'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/06/google-treasure-hunt-4.html' title='Google Treasure Hunt 4'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-3155249760877689236</id><published>2008-05-28T18:48:00.001-03:00</published><updated>2008-05-28T18:54:42.276-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cisco'/><category scheme='http://www.blogger.com/atom/ns#' term='ccna'/><category scheme='http://www.blogger.com/atom/ns#' term='ppp'/><category scheme='http://www.blogger.com/atom/ns#' term='wan'/><category scheme='http://www.blogger.com/atom/ns#' term='hdlc'/><title type='text'>CCNA / WANs</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;Questão &lt;b style=""&gt;CCNA&lt;/b&gt; sobre “&lt;b style=""&gt;&lt;i style=""&gt;Wide Area Networks” (WAN)&lt;/i&gt;&lt;/b&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;“Why won’t the serial link between the Corp router and the Remote router come up?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;Corp#sh int s0/0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;Serial0/0 is up, line protocol is down&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;Hardware is PowerQUICC Serial&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;Internet address is 10.0.1.1/24&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;reliability 254/255, txload 1/255, rxload 1/255&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;Encapsulation PPP, loopback not set&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;Remote#sh int s0/0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;Serial0/0 is up, line protocol is down&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;Hardware is PowerQUICC Serial&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;Internet address is 10.0.1.2/24&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;reliability 254/255, txload 1/255, rxload 1/255&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;Encapsulation HDLC, loopback not set&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;A. The serial cable is faulty.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;B. The IP addresses are not in the same subnet.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;C. The subnet masks are not correct.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;D. The keepalive settings are not correct.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;E. The layer 2 frame types are not compatible.”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Avaliando cada um dos itens, temos que a letra &lt;b style=""&gt;“A”&lt;/b&gt; não pode ser verdadeira porque, se assim o fosse, a mensagem após o comando &lt;b style=""&gt;&lt;i style=""&gt;“sh int s0/0”&lt;/i&gt;&lt;/b&gt; (ou melhor, &lt;b style=""&gt;&lt;i style=""&gt;“show interface serial0/0”&lt;/i&gt;&lt;/b&gt;) indicaria que a interface &lt;b style=""&gt;&lt;i style=""&gt;Serial0/0&lt;/i&gt;&lt;/b&gt; estaria &lt;b style=""&gt;“down”&lt;/b&gt; e não &lt;b style=""&gt;“up”&lt;/b&gt; (&lt;b style=""&gt;&lt;i style=""&gt;“Serial0/0 is up”&lt;/i&gt;&lt;/b&gt;). Tal informação indicaria uma falha física, como um cabo serial desconectado ou com defeito – contudo as coisas parecem funcionar &lt;b style=""&gt;&lt;i style=""&gt;na linha física serial&lt;/i&gt;&lt;/b&gt;. Apenas após a vírgula vemos algo mais esclarecedor; há uma mensagem indicativa dizendo &lt;b style=""&gt;&lt;i style=""&gt;“line protocol is down”&lt;/i&gt;&lt;/b&gt;. O protocolo estar não-funcional, mas &lt;i style=""&gt;a linha serial&lt;/i&gt; estar perfeita, nos faz levantar &lt;b style=""&gt;&lt;i style=""&gt;2 hipóteses possíveis&lt;/i&gt;&lt;/b&gt;: se estivéssemos trabalhando com &lt;i style=""&gt;mecanismos de roteamento dinâmico&lt;/i&gt;, divergências em parâmetros de sincronização do tipo &lt;b style=""&gt;&lt;i style=""&gt;“Dead timers”&lt;/i&gt;&lt;/b&gt; (como os encontrados no &lt;b style=""&gt;RIP&lt;/b&gt; e no &lt;b style=""&gt;EIGRP&lt;/b&gt;) que especificam o tempo em que uma mensagem permanece válida até ser automaticamente descartada dentro do tempo determinado (estratégia usada para evitar &lt;b style=""&gt;&lt;i style=""&gt;loops de roteamento&lt;/i&gt;&lt;/b&gt;), poderia causar &lt;i style=""&gt;problemas de comunicação&lt;/i&gt; e gerar mensagens de &lt;b style=""&gt;&lt;i style=""&gt;“protocol is down”&lt;/i&gt;&lt;/b&gt;; caso não estejamos lidando com &lt;i style=""&gt;algoritmos de roteamento&lt;/i&gt;, inúmeros utilitários do &lt;b style=""&gt;&lt;i style=""&gt;Cisco IOS&lt;/i&gt;&lt;/b&gt; poderiam ser úteis aqui, mas das telas podemos deduzir de forma direta o que pode estar ocorrendo de ruim...&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Acontece que os protocolos &lt;b style=""&gt;&lt;i style=""&gt;PPP&lt;/i&gt;&lt;/b&gt; e &lt;b style=""&gt;&lt;i style=""&gt;HDLC&lt;/i&gt;&lt;/b&gt; não são inteiramente compatíveis. Para não conhecedores das plataformas &lt;b style=""&gt;Cisco&lt;/b&gt;, isso pode parecer um contra-senso, porque o protocolo &lt;b style=""&gt;PPP&lt;/b&gt; prevê o uso do &lt;b style=""&gt;HDLC&lt;/b&gt; para encapsular &lt;i style=""&gt;datagramas&lt;/i&gt; sobre &lt;b style=""&gt;&lt;i style=""&gt;linhas seriais&lt;/i&gt;&lt;/b&gt;. Acontece que o &lt;b style=""&gt;HDLC&lt;/b&gt; ao qual a listagem acima se refere diz respeito a uma versão proprietária do &lt;b style=""&gt;&lt;i style=""&gt;High-Level&lt;/i&gt;&lt;/b&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;b style=""&gt;&lt;i style=""&gt;Data Link Control&lt;/i&gt;&lt;/b&gt;, que funciona com um formato diferente de frame &lt;b style=""&gt;HDLC&lt;/b&gt;, incluindo um campo a mais chamado &lt;b style=""&gt;&lt;i style=""&gt;“Proprietary”&lt;/i&gt;&lt;/b&gt;. Esse belo fruto da inovação &lt;b style=""&gt;Cisco&lt;/b&gt; é incompatível com o padrão &lt;b style=""&gt;&lt;i style=""&gt;ISO HDLC&lt;/i&gt;&lt;/b&gt;, e acaso você queira interligar roteadores de diferentes fabricantes, vai ser melhor optar por um formato &lt;i style=""&gt;padrão de encapsulamento&lt;/i&gt; como o &lt;b style=""&gt;PPP&lt;/b&gt;.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Voltando ao mostrado no enunciado, e do acima exposto, temos que os roteadores acima estão utilizando formatos diferentes e incompatíveis de &lt;i style=""&gt;roteamento&lt;/i&gt;: &lt;b style=""&gt;HDLC&lt;/b&gt; no roteador &lt;b style=""&gt;&lt;i style=""&gt;Remote&lt;/i&gt;&lt;/b&gt;, e &lt;b style=""&gt;PPP&lt;/b&gt; no roteador &lt;b style=""&gt;&lt;i style=""&gt;Corp&lt;/i&gt;&lt;/b&gt;. Trocar o formato de um ou de outro já resolveria o problema, e portanto a letra “&lt;b style=""&gt;E&lt;/b&gt;” esclarece exatamente a razão do problema, porque ambos &lt;b style=""&gt;&lt;i style=""&gt;HDLC e PPP&lt;/i&gt;&lt;/b&gt; são protocolos de enlace de dados, ou seja, de &lt;i style=""&gt;camada 2&lt;/i&gt; (&lt;b style=""&gt;&lt;i style=""&gt;layer 2&lt;/i&gt;&lt;/b&gt;).&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-3155249760877689236?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/3155249760877689236/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=3155249760877689236' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/3155249760877689236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/3155249760877689236'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/05/ccna-wans.html' title='CCNA / WANs'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-8962826754024032026</id><published>2008-05-14T18:46:00.002-03:00</published><updated>2008-05-14T18:49:03.418-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cisco'/><category scheme='http://www.blogger.com/atom/ns#' term='ccna'/><category scheme='http://www.blogger.com/atom/ns#' term='network'/><category scheme='http://www.blogger.com/atom/ns#' term='router'/><category scheme='http://www.blogger.com/atom/ns#' term='access control list'/><category scheme='http://www.blogger.com/atom/ns#' term='acl'/><title type='text'>Access Control Lists - ACLs</title><content type='html'>&lt;p class="MsoNormal"&gt;Tópicos que tem ocorrido com mais freqüência são aqueles relacionados com segurança, apesar de ser um assunto mais freqüente em exames mais avançados como o &lt;b style=""&gt;CCNP&lt;/b&gt; e o &lt;b style=""&gt;CCIE&lt;/b&gt;. Na questão abaixo, um exemplo básico com &lt;b style=""&gt;Access Control Lists (ACLs)&lt;/b&gt;, retirado do livro &lt;b style=""&gt;&lt;i style=""&gt;“CCNA Study Guide, Sixth Edition”&lt;/i&gt;&lt;/b&gt;, do &lt;b style=""&gt;Todd Lammle&lt;/b&gt;:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;“You configure the following access list:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 35.4pt;"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;access-list 110 deny tcp 10.1.1.128 0.0.0.63 any eq smtp&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 35.4pt;"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;access-list 110 deny tcp any eq 23&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 35.4pt;"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;int ethernet 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 35.4pt;"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;ip access-group 110 out&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;What will the result of this access list be?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;A. Email and Telnet will be allowed out E0.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;B. Email and Telnet will be allowed in E0.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;C. Everything but email and Telnet will be allowed out E0.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%;" lang="EN-US"&gt;D. No IP traffic will be allowed out E0.”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Na questão, uma lista de comandos do roteador é apresentada, e pede-se o resultado da execução de tal lista num &lt;i style=""&gt;roteador &lt;/i&gt;hipotético. Aqui deve-se ter sempre em mente uma interpretação recorrente nas provas da &lt;b style=""&gt;Cisco&lt;/b&gt;: que o que não constar da relação de comandos, presume-se que foi omisso. Ou melhor, a lista de comandos começa exatamente com a primeira sentença de &lt;b style=""&gt;&lt;i style=""&gt;“access-list ...”,&lt;/i&gt;&lt;/b&gt; e termina com &lt;b style=""&gt;&lt;i style=""&gt;“ip access-group 110 out”&lt;/i&gt;&lt;/b&gt;. O trecho então não é parte de uma entrada do administrador de rede, mas sim uma sequência completa e indivisível de comandos.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Os comandos de &lt;b style=""&gt;&lt;i style=""&gt;access-lists&lt;/i&gt;&lt;/b&gt; na questão acima são no formato &lt;b style=""&gt;“extended”,&lt;/b&gt; ou seja, são no formato que começa com a definição da ação &lt;b style=""&gt;(“deny”&lt;/b&gt; ou &lt;b style=""&gt;“permit”),&lt;/b&gt; o intervalo de hosts de origem, o intervalo de hosts destino e, possivelmente, condições que especificam em que porta a restrição vai se impor. As &lt;b style=""&gt;&lt;i style=""&gt;listas extended&lt;/i&gt;&lt;/b&gt; são numeradas com identificadores &lt;b style=""&gt;de 100 a 199&lt;/b&gt;, e com elas é possível filtrar pacotes por campos IP &lt;b style=""&gt;&lt;i style=""&gt;de camada 3&lt;/i&gt;&lt;/b&gt; e até alguns serviços de &lt;b style=""&gt;&lt;i style=""&gt;camada 4 ou maior&lt;/i&gt;&lt;/b&gt; (&lt;b style=""&gt;WWW, Telnet, SMTP&lt;/b&gt;&lt;i style=""&gt;, etc.),&lt;/i&gt; o que amplia o espectro de usos possíveis para as &lt;b style=""&gt;ACLs&lt;/b&gt;, como por exemplo mitigar ataques &lt;i style=""&gt;Denial-of-Service (DoS), DoS Smurfs, IP Spoofing&lt;/i&gt;, etc. É possível estabelecer regras que serão aplicadas especificamente a pacotes &lt;b style=""&gt;TCP&lt;/b&gt; com a flag &lt;b style=""&gt;SYN&lt;/b&gt; setada, por exemplo, o que serve de ajuda contra ataques de &lt;b style=""&gt;SYN flood&lt;/b&gt;. Certo, apenas “mitigar”, não necessariamente impedir tais ataques, dada a dificuldade em definir regras sobre grupos de pacotes suspeitos num universo tão grande de possibilidades de ataques. Mas a utilidade das &lt;b style=""&gt;ACLs&lt;/b&gt; ainda assim é muito bem vinda e quebra alguns galhos.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Quando é preciso definir regras que se apliquem a apenas um par de hosts, como a sentença “&lt;b style=""&gt;access-list 110 deny ip host 172.16.10.3 host 172.16.20.5&lt;/b&gt;”, por exemplo, que bloqueia &lt;b style=""&gt;&lt;i style=""&gt;pacotes IP com campo de origem 172.16.10.3 e destino para 172.16.20.5&lt;/i&gt;&lt;/b&gt;, a tarefa é imediata. Contudo, é mais comum, na definição das regras de&lt;b style=""&gt; ACLs&lt;/b&gt;, quando é necessário que sejam aplicadas regras a um intervalo de hosts numa sub-rede, pode-se recorrer aos &lt;b style=""&gt;wildcards&lt;/b&gt;. Vamos dizer que queiramos aplicar determinada regra ao conjunto de hosts nas sub-redes de &lt;b style=""&gt;192.168.113.0 até 192.168.140.0&lt;/b&gt;. Primeiro, calcule quantas sub-redes existem entre os endereços anteriores; &lt;b style=""&gt;&lt;i style=""&gt;diminuindo 113 de 140 (140 – 113)&lt;/i&gt;&lt;/b&gt;, obtemos &lt;b style=""&gt;&lt;i style=""&gt;27&lt;/i&gt;&lt;/b&gt;. Agora é preciso achar uma potência de 2 que seja maior ou igual a esse intervalo; temos que &lt;b style=""&gt;&lt;i style=""&gt;32 é maior que 27&lt;/i&gt;&lt;/b&gt; (16 é outra potência de 2, mas é menor que 27), e portanto nos serve para esse propósito. Esse valor é &lt;b style=""&gt;32&lt;/b&gt; é o tamanho do bloco, e quando diminuído de &lt;b style=""&gt;1&lt;/b&gt;, nos traz o endereço de &lt;b style=""&gt;&lt;i style=""&gt;wildcard&lt;/i&gt;&lt;/b&gt;. Nesse caso, temos que o endereço de &lt;b style=""&gt;&lt;i style=""&gt;wildcard&lt;/i&gt;&lt;/b&gt; para esse intervalo é &lt;b style=""&gt;&lt;i style=""&gt;0.0.31.255&lt;/i&gt;&lt;/b&gt;. O terceiro octeto, que guarda informações das sub-redes onde serão aplicadas a regra de &lt;b style=""&gt;ACL&lt;/b&gt;, tem valor &lt;b style=""&gt;31&lt;/b&gt;, representado um bloco de &lt;b style=""&gt;32&lt;/b&gt; &lt;b style=""&gt;&lt;i style=""&gt;(192.168.113.0 até 192.168.145.0&lt;/i&gt;&lt;/b&gt;). Esse intervalo é maior do que o que o intervalo que queremos, mas serve ao propósito. O &lt;i style=""&gt;quarto octeto contêm um valor de &lt;/i&gt;&lt;b style=""&gt;255&lt;/b&gt;, que permite a presença de qualquer valor, e nos garante que todos os hosts nessas sub-redes sejam também contemplados com a regra &lt;b style=""&gt;ACL&lt;/b&gt;.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;De volta à questão, a primeira sentença aplica a regra de que será descartado qualquer pacote &lt;b style=""&gt;SMTP (porta 25)&lt;/b&gt; com origem em quaisquer dos &lt;b style=""&gt;&lt;i style=""&gt;hosts em 10.1.1.128 até 10.1.1.192 (wildcard = 0.0.0.63, bloco igual a 64)&lt;/i&gt;&lt;/b&gt;. A segunda regra descarta todos os pacotes com destino ao serviço de &lt;b style=""&gt;&lt;i style=""&gt;Telnet (porta 23)&lt;/i&gt;&lt;/b&gt;. Logo a seguir, essas 2 regras são aplicadas à &lt;b style=""&gt;interface E0 (ethernet0)&lt;/b&gt; para &lt;b style=""&gt;saída (“out”),&lt;/b&gt; ou seja, em &lt;b style=""&gt;&lt;i style=""&gt;“post-routing”&lt;/i&gt;&lt;/b&gt;, após o pacote ter sido roteado localmente no roteador e estar prestes a ser encaminhado para a interface de saída, as regras são aplicadas. A princípio, até aí tudo bem, temos 2 regras, uma que nega totalmente serviços para a &lt;b style=""&gt;porta 23&lt;/b&gt;, e outra que nega serviço &lt;b style=""&gt;SMTP&lt;/b&gt; &lt;b style=""&gt;(porta 25)&lt;/b&gt; para um conjunto de hosts. A alternativa &lt;b style=""&gt;C&lt;/b&gt; parece convidativa, mas algo vai errado na lista de acesso: se era esse o fim almejado pelo &lt;i style=""&gt;administrador&lt;/i&gt; (negar pacotes para serviços portas &lt;b style=""&gt;23 e 25&lt;/b&gt;), ele deveria ter incluído a regra &lt;b style=""&gt;&lt;i style=""&gt;“permit ip any”&lt;/i&gt;&lt;/b&gt; no final da lista de acesso, porque a última regra é &lt;b style=""&gt;&lt;i style=""&gt;“deny ip any”&lt;/i&gt;&lt;/b&gt;, o que faria com que qualquer pacote tivesse o repasse concedido pela &lt;b style=""&gt;&lt;i style=""&gt;interface ethernet0&lt;/i&gt;&lt;/b&gt;. Devido à omissão dele, a &lt;b style=""&gt;&lt;i style=""&gt;interface E0&lt;/i&gt;&lt;/b&gt; vai perder comunicação com o mundo. Alternativa &lt;b style=""&gt;D&lt;/b&gt; é a correta.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-8962826754024032026?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/8962826754024032026/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=8962826754024032026' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/8962826754024032026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/8962826754024032026'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/05/access-control-lists-acls.html' title='Access Control Lists - ACLs'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-5984479742857257304</id><published>2008-04-28T21:35:00.004-03:00</published><updated>2008-04-28T21:38:39.397-03:00</updated><title type='text'>RIP Troubleshooting</title><content type='html'>&lt;p class="MsoNormal"&gt;Continuando na linha dos enunciados que abranjam o maior número de conceitos, temos essa questão, que apresenta pontos importantes e que costuma marcar presença nas seções da prova &lt;b style=""&gt;CCNA&lt;/b&gt; relacionadas a &lt;b style=""&gt;&lt;i style=""&gt;troubleshooting&lt;/i&gt;&lt;/b&gt; e &lt;b style=""&gt;&lt;i style=""&gt;protocolos de roteamento&lt;/i&gt;&lt;/b&gt;:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;“Which of the following is true regarding the following output? (Choose two.)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;04:06:16: RIP: received v1 update from 192.168.40.2 on Serial0/1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;04:06:16: 192.168.50.0 in 16 hops (inaccessible)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;04:06:40: RIP: sending v1 update to 255.255.255.255 via FastEthernet0/0 (192.168.30.1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;04:06:40: RIP: build update entries&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;04:06:40: network 192.168.20.0 metric 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;04:06:40: network 192.168.40.0 metric 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;04:06:40: network 192.168.50.0 metric 16&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;04:06:40: RIP: sending v1 update to 255.255.255.255 via Serial0/1 (192.168.40.1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;A. There are three interfaces on the router participating in this update.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;B. A ping to 192.168.50.1 will be successful.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;C. There are at least two routers exchanging information.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;D. A ping to 192.168.40.2 will be successful.”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Um ponto que merece destaque nessa questão é procurar listar o que ela quer que você saiba, a partir da situação exposta. Na assertiva &lt;b style=""&gt;A&lt;/b&gt;, o que ela procura saber sobre a quantidade de interfaces de rede. As assertivas &lt;b style=""&gt;B&lt;/b&gt; e &lt;b style=""&gt;D&lt;/b&gt;, sobre a conectividade com as redes &lt;b style=""&gt;192.168.40.0&lt;/b&gt; e &lt;b style=""&gt;192.168.50.0&lt;/b&gt;, ou melhor, se pacotes &lt;b style=""&gt;&lt;i style=""&gt;ICMP “ping”&lt;/i&gt;&lt;/b&gt; podem ser enviados e recebidos com sucesso para essas redes. A letra &lt;b style=""&gt;D&lt;/b&gt; pede o número mínimo de roteadores na transação acima.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Para saber exatamente quantas interfaces estão participando no cenário acima, é útil olhar cuidadosamente nos trechos do &lt;b style=""&gt;&lt;i style=""&gt;log&lt;/i&gt;&lt;/b&gt; que mencionam atualizações (&lt;b style=""&gt;updates&lt;/b&gt;) de tabelas de &lt;i style=""&gt;roteamento RIP&lt;/i&gt;, saindo do roteador atual para o mundo externo. As linhas 3 e 8, do log em negrito, anunciam envios (&lt;b style=""&gt;sending&lt;/b&gt;) para atualização de tabelas de rotas, que passam respectivamente, &lt;b style=""&gt;&lt;i style=""&gt;“via FastEthernet0/0”&lt;/i&gt;&lt;/b&gt; e &lt;b style=""&gt;&lt;i style=""&gt;“via Serial0/1”&lt;/i&gt;&lt;/b&gt;. Como não existem mais mensagens desse tipo &lt;b style=""&gt;&lt;i style=""&gt;(“sending v1 update”&lt;/i&gt;&lt;/b&gt;), do acima exposto podemos deduzir que apenas 2 interfaces de rede são apresentadas. A assertiva &lt;b style=""&gt;A&lt;/b&gt; é falsa, pois alega um mínimo de 3 (o mínimo é 2).&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dos questionamentos sobre o número de interfaces no roteador, partimos para a &lt;i style=""&gt;quantidade de roteadores&lt;/i&gt; que participam das mensagens de debug do &lt;b style=""&gt;RIP&lt;/b&gt;, anunciando e/ou recebendo rotas novas. Se mensagens do tipo &lt;b style=""&gt;&lt;i style=""&gt;“sending v1 update”&lt;/i&gt;&lt;/b&gt; nos ajudaram a encontrar as interfaces de rede, as mensagens &lt;b style=""&gt;&lt;i style=""&gt;“received...”&lt;/i&gt;&lt;/b&gt; vão nos dizer quais (e principalmente quantos) roteadores participam do &lt;b style=""&gt;&lt;i style=""&gt;handshake&lt;/i&gt;&lt;/b&gt; do &lt;b style=""&gt;RIP&lt;/b&gt; pra &lt;i style=""&gt;estabelecimento dinâmico de rotas&lt;/i&gt;, uma vez que apenas roteadores podem anunciar e atualizar rotas. Do parágrafo anterior, vemos que esse roteador anuncia (mensagens &lt;b style=""&gt;&lt;i style=""&gt;“sending...”&lt;/i&gt;&lt;/b&gt;) através de &lt;b style=""&gt;2 interfaces&lt;/b&gt; (&lt;b style=""&gt;&lt;i style=""&gt;Serial0/1 e FastEthernet0/0&lt;/i&gt;&lt;/b&gt;), e recebe uma atualização de rotas através da &lt;b style=""&gt;&lt;i style=""&gt;Serial0/1&lt;/i&gt;&lt;/b&gt; (do &lt;b style=""&gt;roteador 192.168.40.2&lt;/b&gt;). Temos&lt;b style=""&gt; 2 roteadores&lt;/b&gt;, um que é o roteador local (a partir do qual temos acesso à mensagem de &lt;b style=""&gt;&lt;i style=""&gt;log&lt;/i&gt;&lt;/b&gt;), e outro que emite uma mensagem de anúncio de rotas (&lt;b style=""&gt;&lt;i style=""&gt;192.168.40.2, via interface Serial0/1&lt;/i&gt;&lt;/b&gt;). A letra &lt;b style=""&gt;C&lt;/b&gt; está certa.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Restam-nos as letras B e D. As &lt;b style=""&gt;&lt;i style=""&gt;linhas 2 e 7&lt;/i&gt;&lt;/b&gt; nos dizem a mesma coisa, ou seja, que a rota para a &lt;b style=""&gt;rede 192.168.50.0&lt;/b&gt; é &lt;b style=""&gt;&lt;i style=""&gt;“alcançada” após 16 hops&lt;/i&gt;&lt;/b&gt;, e portanto &lt;b style=""&gt;inalcançável&lt;/b&gt; (linha 2). A linha 7 nos descreve que essa mesma rede tem métrica 16, o que significa a mesma coisa, em vista do fato de que &lt;b style=""&gt;&lt;i style=""&gt;o RIP tem métrica máxima de 15&lt;/i&gt;&lt;/b&gt;, para rotas possíveis e roteáveis. &lt;b style=""&gt;&lt;i style=""&gt;Métrica 16 é rota inacessível&lt;/i&gt;&lt;/b&gt;, desligada pelo administrador ou “envenenada” pelo próprio algoritmo do RIP, para evitar anúncios de circulares de rotas impossíveis (estratégia conhecida como &lt;b style=""&gt;&lt;i style=""&gt;“poisonous routing”&lt;/i&gt;&lt;/b&gt;, envenena a rota e anuncia ela desse jeito, para que as outras redes a enxerguem como proibida e assim evitar que outros roteadores na área administrativa anunciem essa rota inválida a outros roteadores). Como esse &lt;b style=""&gt;host 192.168.50.1&lt;/b&gt; faz parte da &lt;b style=""&gt;rede 192.168.50.0&lt;/b&gt;, e como essa rede é &lt;b style=""&gt;métrica 16&lt;/b&gt;, um &lt;b style=""&gt;ping&lt;/b&gt; para esse host retornaria uma mensagem de inalcançável. Letra “&lt;b style=""&gt;B&lt;/b&gt;” está errada.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;A &lt;b style=""&gt;letra D&lt;/b&gt; quer saber se um ping para o host 192.168.40.2 pode ser alcançável, e a resposta é sim, e temos 2 evidências para garantir isso: primeiro, que na linha 6 vemos que quando o roteador vai construir as entradas da &lt;i style=""&gt;tabela de roteamento&lt;/i&gt;, momento no qual algumas &lt;i style=""&gt;rotas dinâmicas externas são reconhecidas e acrescentadas&lt;/i&gt;, a rota para a rede &lt;b style=""&gt;&lt;i style=""&gt;192.168.40.0&lt;/i&gt;&lt;/b&gt; apresenta-se com &lt;b style=""&gt;métrica 1&lt;/b&gt; – isso quer dizer que a rota para essa rede passará primeiro pelo &lt;b style=""&gt;“next hop router”&lt;/b&gt;, ou seja, o roteador vizinho, conectado pela &lt;b style=""&gt;interface Serial0/1&lt;/b&gt;. Uma métrica ótima, que perde apenas para as métricas de rotas estáticas e para as diretamente conectadas (as com &lt;b style=""&gt;flag “S”&lt;/b&gt; e as com &lt;b style=""&gt;métrica 0&lt;/b&gt;, respectivamente). Isso serviria para garantir que a rede &lt;b style=""&gt;192.168.40.0&lt;/b&gt; é acessível, mas não que um &lt;b style=""&gt;&lt;i style=""&gt;ping&lt;/i&gt;&lt;/b&gt; para o &lt;b style=""&gt;&lt;i style=""&gt;host 192.168.40.2&lt;/i&gt;&lt;/b&gt; pode ser realizado com sucesso. Contudo, a &lt;i style=""&gt;primeira linha de log&lt;/i&gt; nos garante isso, porque o anúncio da tabela de rotas para essa rede veio exatamente &lt;b style=""&gt;&lt;i style=""&gt;do roteador de &lt;/i&gt;endereço IP 192.168.40.2&lt;/b&gt;. Uma coisa legal com &lt;i style=""&gt;roteamento dinâmico&lt;/i&gt; é que as rotas são configuradas nas 2 direções, e se recebemos uma mensagem de &lt;i style=""&gt;&lt;u&gt;192.168.40.2&lt;/u&gt;&lt;/i&gt;, certamente que poderemos enviar mensagens para lá também (a menos que uma &lt;b style=""&gt;ACL&lt;/b&gt; tenha sido colocada de barreira, impedindo tráfego &lt;b style=""&gt;ICMP&lt;/b&gt; de saída no roteador conectado à &lt;b style=""&gt;S0/1&lt;/b&gt;). A letra &lt;b style=""&gt;D&lt;/b&gt; está correta também.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;Respostas: C e D&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-5984479742857257304?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/5984479742857257304/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=5984479742857257304' title='3 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/5984479742857257304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/5984479742857257304'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/04/rip-troubleshooting.html' title='RIP Troubleshooting'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-4340620273595688964</id><published>2008-04-16T19:29:00.001-03:00</published><updated>2008-04-16T19:52:29.352-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ccna'/><category scheme='http://www.blogger.com/atom/ns#' term='tcp'/><category scheme='http://www.blogger.com/atom/ns#' term='ip'/><category scheme='http://www.blogger.com/atom/ns#' term='router'/><category scheme='http://www.blogger.com/atom/ns#' term='roteador'/><title type='text'>Sub-redes e Roteadores</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 12"&gt;&lt;meta name="Originator" content="Microsoft Word 12"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADNAMA%7E1%5CCONFIG%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"&gt;&lt;link rel="themeData" href="file:///C:%5CDOCUME%7E1%5CADNAMA%7E1%5CCONFIG%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"&gt;&lt;link rel="colorSchemeMapping" href="file:///C:%5CDOCUME%7E1%5CADNAMA%7E1%5CCONFIG%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:trackmoves/&gt;   &lt;w:trackformatting/&gt;   &lt;w:hyphenationzone&gt;21&lt;/w:HyphenationZone&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:donotpromoteqf/&gt;   &lt;w:lidthemeother&gt;PT-BR&lt;/w:LidThemeOther&gt;   &lt;w:lidthemeasian&gt;X-NONE&lt;/w:LidThemeAsian&gt;   &lt;w:lidthemecomplexscript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:splitpgbreakandparamark/&gt;    &lt;w:dontvertaligncellwithsp/&gt;    &lt;w:dontbreakconstrainedforcedtables/&gt;    &lt;w:dontvertalignintxbx/&gt;    &lt;w:word11kerningpairs/&gt;    &lt;w:cachedcolbalance/&gt;   &lt;/w:Compatibility&gt;   &lt;m:mathpr&gt;    &lt;m:mathfont val="Cambria Math"&gt;    &lt;m:brkbin val="before"&gt;    &lt;m:brkbinsub val="--"&gt;    &lt;m:smallfrac val="off"&gt;    &lt;m:dispdef/&gt;    &lt;m:lmargin val="0"&gt;    &lt;m:rmargin val="0"&gt;    &lt;m:defjc val="centerGroup"&gt;    &lt;m:wrapindent val="1440"&gt;    &lt;m:intlim val="subSup"&gt;    &lt;m:narylim val="undOvr"&gt;   &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"&gt;   &lt;w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"&gt;   &lt;w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 1"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 2"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 3"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 4"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 5"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 6"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 7"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 8"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 9"&gt;   &lt;w:lsdexception locked="false" priority="35" qformat="true" name="caption"&gt;   &lt;w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"&gt;   &lt;w:lsdexception locked="false" priority="1" name="Default Paragraph Font"&gt;   &lt;w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"&gt;   &lt;w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"&gt;   &lt;w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"&gt;   &lt;w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"&gt;   &lt;w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" unhidewhenused="false" name="Revision"&gt;   &lt;w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"&gt;   &lt;w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"&gt;   &lt;w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"&gt;   &lt;w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"&gt;   &lt;w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"&gt;   &lt;w:lsdexception locked="false" priority="37" name="Bibliography"&gt;   &lt;w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Wingdings; 	panose-1:5 0 0 0 0 0 0 0 0 0; 	mso-font-charset:2; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:1; 	mso-generic-font-family:roman; 	mso-font-format:other; 	mso-font-pitch:variable; 	mso-font-signature:0 0 0 0 0 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0cm; 	margin-right:0cm; 	margin-bottom:10.0pt; 	margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page Section1 	{size:595.3pt 841.9pt; 	margin:70.85pt 3.0cm 70.85pt 3.0cm; 	mso-header-margin:35.4pt; 	mso-footer-margin:35.4pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Tabela normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin-top:0cm; 	mso-para-margin-right:0cm; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;} &lt;/style&gt; &lt;![endif]--&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 12"&gt;&lt;meta name="Originator" content="Microsoft Word 12"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADNAMA%7E1%5CCONFIG%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"&gt;&lt;link rel="themeData" href="file:///C:%5CDOCUME%7E1%5CADNAMA%7E1%5CCONFIG%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"&gt;&lt;link rel="colorSchemeMapping" href="file:///C:%5CDOCUME%7E1%5CADNAMA%7E1%5CCONFIG%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:trackmoves/&gt;   &lt;w:trackformatting/&gt;   &lt;w:hyphenationzone&gt;21&lt;/w:HyphenationZone&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:donotpromoteqf/&gt;   &lt;w:lidthemeother&gt;PT-BR&lt;/w:LidThemeOther&gt;   &lt;w:lidthemeasian&gt;X-NONE&lt;/w:LidThemeAsian&gt;   &lt;w:lidthemecomplexscript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:splitpgbreakandparamark/&gt;    &lt;w:dontvertaligncellwithsp/&gt;    &lt;w:dontbreakconstrainedforcedtables/&gt;    &lt;w:dontvertalignintxbx/&gt;    &lt;w:word11kerningpairs/&gt;    &lt;w:cachedcolbalance/&gt;   &lt;/w:Compatibility&gt;   &lt;m:mathpr&gt;    &lt;m:mathfont val="Cambria Math"&gt;    &lt;m:brkbin val="before"&gt;    &lt;m:brkbinsub val="--"&gt;    &lt;m:smallfrac val="off"&gt;    &lt;m:dispdef/&gt;    &lt;m:lmargin val="0"&gt;    &lt;m:rmargin val="0"&gt;    &lt;m:defjc val="centerGroup"&gt;    &lt;m:wrapindent val="1440"&gt;    &lt;m:intlim val="subSup"&gt;    &lt;m:narylim val="undOvr"&gt;   &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"&gt;   &lt;w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"&gt;   &lt;w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 1"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 2"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 3"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 4"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 5"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 6"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 7"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 8"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 9"&gt;   &lt;w:lsdexception locked="false" priority="35" qformat="true" name="caption"&gt;   &lt;w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"&gt;   &lt;w:lsdexception locked="false" priority="1" name="Default Paragraph Font"&gt;   &lt;w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"&gt;   &lt;w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"&gt;   &lt;w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"&gt;   &lt;w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"&gt;   &lt;w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" unhidewhenused="false" name="Revision"&gt;   &lt;w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"&gt;   &lt;w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"&gt;   &lt;w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"&gt;   &lt;w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"&gt;   &lt;w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"&gt;   &lt;w:lsdexception locked="false" priority="37" name="Bibliography"&gt;   &lt;w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Wingdings; 	panose-1:5 0 0 0 0 0 0 0 0 0; 	mso-font-charset:2; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:1; 	mso-generic-font-family:roman; 	mso-font-format:other; 	mso-font-pitch:variable; 	mso-font-signature:0 0 0 0 0 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0cm; 	margin-right:0cm; 	margin-bottom:10.0pt; 	margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page Section1 	{size:595.3pt 841.9pt; 	margin:70.85pt 3.0cm 70.85pt 3.0cm; 	mso-header-margin:35.4pt; 	mso-footer-margin:35.4pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Tabela normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin-top:0cm; 	mso-para-margin-right:0cm; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;Uma questão do exame CCNA muito interessante, que resume muitos dos conceitos sobre as funções básicas dos dispositivos de roteamento e segmentação em sub-redes:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;" lang="EN-US"&gt;“&lt;b&gt;A router receives a packet on interface 172.16.45.66/26. The source IP of the packet is 172.16.45.127/26 and the destination is 172.16.46.191/26. How will the router handle the packet?&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;" lang="EN-US"&gt;A. The destination is a host on another subnet, so the router will not forward the packet.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;" lang="EN-US"&gt;B. The destination is a host on the same subnet, so the router will forward the packet.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;" lang="EN-US"&gt;C. The destination is a broadcast address, so the router will not forward the packet.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;i style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;" lang="EN-US"&gt;D. The destination is a network address, so the router will forward the packet.”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;span style="" lang="EN-US"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;A princípio, percebemos que &lt;b style=""&gt;todos os endereços IP&lt;/b&gt; são &lt;b style=""&gt;/26&lt;/b&gt;, ou seja, os &lt;i style=""&gt;2 bits iniciais do quarto octeto &lt;/i&gt;são usados para identificação de sub-redes (&lt;b style=""&gt;&lt;i style=""&gt;24 &lt;/i&gt;&lt;/b&gt;&lt;i style=""&gt;&amp;lt;&lt;/i&gt;&lt;b style=""&gt;&lt;i style=""&gt; 26 &lt;/i&gt;&lt;/b&gt;&lt;i style=""&gt;&amp;lt;&lt;/i&gt;&lt;b style=""&gt;&lt;i style=""&gt; 32&lt;/i&gt;&lt;/b&gt;, ou seja, quarto octeto), e os &lt;i style=""&gt;6 restantes&lt;/i&gt; são usados para host, o que nos dá um total de &lt;b style=""&gt;4 sub-redes&lt;/b&gt; (2 bits de rede, elevado a 2) e &lt;b style=""&gt;62 hosts&lt;/b&gt; (contando os endereços reservados para a base da rede, e para o broadcast da respectiva &lt;i style=""&gt;sub-rede&lt;/i&gt;, teríamos um total de &lt;b style=""&gt;64&lt;/b&gt;). Como o número de sub-redes é bastante restrito, convêm que listemos cada um desses intervalos, para averiguarmos as condições de chegada desse pacote:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;172.16.46.0 &lt;/span&gt;&lt;/b&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: Wingdings;"&gt;&lt;span style=""&gt;à&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; 172.16.46.63 (0-63)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;172.16.46.64 &lt;/span&gt;&lt;/b&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: Wingdings;"&gt;&lt;span style=""&gt;à&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; 172.16.46.127 (64-127)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;172.16.46.128 &lt;/span&gt;&lt;/b&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: Wingdings;"&gt;&lt;span style=""&gt;à&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; 172.16.46.191 (128-191)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;172.16.46.192 &lt;/span&gt;&lt;/b&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: Wingdings;"&gt;&lt;span style=""&gt;à&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=""&gt;&lt;span style="font-size: 10pt; line-height: 115%; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; 172.16.46.255 (192-255)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;A matemática básica para a enumeração desses intervalos de sub-redes é simples: basta obter &lt;b style=""&gt;o comprimento de cada intervalo&lt;/b&gt;, calculando &lt;i style=""&gt;o espaço reservado para os hosts no endereço&lt;/i&gt; base acima: ou seja, &lt;i style=""&gt;6 bits denotam um espaço de representação de&lt;/i&gt; &lt;b style=""&gt;64&lt;/b&gt;, então a primeira sub-rede iniciará no &lt;b style=""&gt;IP&lt;/b&gt; terminado em&lt;b style=""&gt; 0&lt;/b&gt;, e terminará no &lt;b style=""&gt;IP&lt;/b&gt; terminado em &lt;b style=""&gt;63 &lt;/b&gt;(&lt;i style=""&gt;63 – 0 + 1&lt;/i&gt; = total de &lt;b style=""&gt;64&lt;/b&gt;). O &lt;i style=""&gt;endereço inicial da próxima sub-rede será o último endereço válido para a sub-rede antecedente mais &lt;/i&gt;&lt;b style=""&gt;1&lt;/b&gt;, ou melhor, &lt;b style=""&gt;172.16.46.64 (63 + 1)&lt;/b&gt;, e o endereço final será 64 (endereço inicial) mais o número de hosts nesse intervalo (&lt;b style=""&gt;64&lt;/b&gt;&lt;i style=""&gt;, igual para todas as sub-redes&lt;/i&gt;), &lt;b style=""&gt;menos 1&lt;/b&gt;, porque começamos a numeração com &lt;b style=""&gt;0&lt;/b&gt;, &lt;i style=""&gt;desde o primeiro subintervalo&lt;/i&gt;. E assim, prossegue-se até que todos os intervalos tenham sido listados.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;A partir da lista de &lt;i style=""&gt;sub-redes&lt;/i&gt; que fizemos, percebemos que o endereço de destino &lt;b style=""&gt;172.16.46.191&lt;/b&gt; é um endereço de broadcast. O &lt;b style=""&gt;&lt;i style=""&gt;endereço de broadcast &lt;/i&gt;&lt;/b&gt;será sempre o último numa dada &lt;b style=""&gt;&lt;i style=""&gt;sub-rede&lt;/i&gt;&lt;/b&gt; (por isso mesmo, não contabilizamos esse endereço na atribuição de um &lt;i style=""&gt;host válido&lt;/i&gt; dentro de uma determinada sub-rede – &lt;i style=""&gt;&lt;u&gt;ele será sempre reservado para broadcast&lt;/u&gt;&lt;/i&gt;). Ora, temos que os &lt;b style=""&gt;&lt;i style=""&gt;roteadores segmentam as redes em domínios de broadcast&lt;/i&gt;&lt;/b&gt;, e por isso, não perpetuam pacotes incidentes em suas portas que tenham um &lt;i style=""&gt;endereço de broadcast&lt;/i&gt; como destino (popularmente falando, &lt;b style=""&gt;endereços de broadcast não são roteáveis&lt;/b&gt;). A letra &lt;b style=""&gt;C&lt;/b&gt; é a resposta.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Uma observação: veja que &lt;i style=""&gt;o endereço fonte do pacote direcionado pelo roteador, &lt;b style=""&gt;pertence à mesma sub-rede da interface do roteador&lt;/b&gt;&lt;/i&gt;, ou seja, a sub-rede de &lt;b style=""&gt;172.16.46.64&lt;/b&gt; até &lt;b style=""&gt;172.19.46.127&lt;/b&gt; ( &lt;i style=""&gt;64 &amp;lt; 66 &amp;lt; 127&lt;/i&gt; ). O que aconteceria se isso não fosse verdadeiro, &lt;b style=""&gt;se o endereço fonte estivesse em um segmento de rede divergente da que a interface do roteador pertença&lt;/b&gt;?&lt;/p&gt;  &lt;i style=""&gt;&lt;i style=""&gt;&lt;/i&gt;&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-4340620273595688964?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/4340620273595688964/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=4340620273595688964' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/4340620273595688964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/4340620273595688964'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/04/sub-redes-e-roteadores.html' title='Sub-redes e Roteadores'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-199064583415288505</id><published>2008-04-09T19:41:00.000-03:00</published><updated>2008-04-09T19:42:11.045-03:00</updated><title type='text'>Segmentação em Sub-redes</title><content type='html'>&lt;p class="MsoNormal"&gt;Uma matéria comum às questões do exame &lt;b style=""&gt;CCNA&lt;/b&gt;, refere-se aos &lt;b style=""&gt;&lt;i style=""&gt;cálculos de sub-rede&lt;/i&gt;&lt;/b&gt;. A maior parte das questões não obriga a realização de cálculos extensivos, mas envolvem prática com as &lt;b style=""&gt;regras de segmentações em sub-redes&lt;/b&gt;, saber discernir entre &lt;b style=""&gt;&lt;i style=""&gt;endereços de escopo privado e público&lt;/i&gt;&lt;/b&gt;, bem como ter alguma noção do sistema de &lt;b style=""&gt;numeração binário&lt;/b&gt;. Ainda, noções básicas sobre &lt;b style=""&gt;Teoria dos Números&lt;/b&gt;, principalmente no que diz respeito à &lt;b style=""&gt;divisibilidade&lt;/b&gt;, pode ser bastante útil (&lt;i style=""&gt;mas não imprescindível&lt;/i&gt;).&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Na questão abaixo, apresenta-se um endereço IP válido e pede-se qual a sub-rede que envolve o endereço dado:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;span style="" lang="EN-US"&gt;“What is the subnet address of the host with an IP address of 172.16.159.159/22?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;A. 172.16.128.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;B. 172.16.156.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;C. 172.16.159.128&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;D. 172.16.159.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;E. 172.16.192.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;F. 172.16.0.0”&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;A princípio, percebemos que só serão válidos endereços de sub-rede nas assertivas acima que se refiram à &lt;b style=""&gt;classe B&lt;/b&gt; – por ser um endereço de rede &lt;b style=""&gt;/22&lt;/b&gt;, e sendo &lt;i style=""&gt;22 maior que 16&lt;/i&gt; (segundo octeto) e &lt;i style=""&gt;menor que 24&lt;/i&gt; (que se referiria ao quarto octeto), decorre disso que foi expandido o &lt;b style=""&gt;espaço de 16 bits de rede originais da classe B&lt;/b&gt;, para &lt;b style=""&gt;22 bits de rede&lt;/b&gt;. Ou seja, com &lt;b style=""&gt;6 bits&lt;/b&gt; (22 – 16) &lt;i style=""&gt;mascarados no terceiro octeto&lt;/i&gt; destinados a identificação de sub-redes, e com &lt;b style=""&gt;10 bits&lt;/b&gt; (32 – 22) restantes &lt;i style=""&gt;para referência a host&lt;/i&gt;, deduz-se facilmente que são permitidas &lt;b style=""&gt;64 sub-redes nessa configuração&lt;/b&gt;, com &lt;b style=""&gt;1022&lt;/b&gt; &lt;i style=""&gt;(2 elevado a 10, menos 2)&lt;/i&gt; hosts possíveis em cada uma das sub-redes (elimina-se 2 do total de hosts, simplesmente porque um dos endereços é para identificar a própria sub-rede, e o outro endereço &lt;i style=""&gt;não contabilizado&lt;/i&gt; como host é o endereço de broadcast, também único para cada sub-rede).&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Voltando ao que é necessário ao enunciado, precisamos saber qual &lt;i style=""&gt;sub-rede engloba o host&lt;/i&gt; referido. &lt;span style=""&gt; &lt;/span&gt;A &lt;b style=""&gt;máscara de rede é de&lt;/b&gt; &lt;b style=""&gt;classe B&lt;/b&gt;, mas com &lt;b style=""&gt;2 bits mascarados para host&lt;/b&gt; no terceiro octeto, mais &lt;b style=""&gt;8 desses bits no quarto e último octeto&lt;/b&gt;. Esses &lt;i style=""&gt;2 bits do terceiro octeto&lt;/i&gt; são pertinentes para nossa solução, porque são exatamente eles que conferirão mobilidade para a quantidade de sub-redes, por conta do seguinte: &lt;b style=""&gt;6 bits do terceiro octeto podem variar indistintamente&lt;/b&gt;, mas os &lt;b style=""&gt;outros 2 bits são fixos&lt;/b&gt;, ou invariáveis, no que se refere à numeração de sub-redes, porque esses 2 bits se referem a hosts, e &lt;i style=""&gt;não são contabilizados na seqüência de sub-redes disponíveis&lt;/i&gt;. Isso significa dizer que, sempre que formos atribuir uma sub-rede válida a essa máscara, devemos notar que os &lt;b style=""&gt;6 bits denotam livremente uma sub-rede&lt;/b&gt;, mas os &lt;b style=""&gt;&lt;i style=""&gt;2 bits do terceiro octeto não podem ser “invadidos” pelos bits de sub-rede&lt;/i&gt;&lt;/b&gt; (pois pertencem a hosts). Essa é a lógica na criação de sub-redes: &lt;b style=""&gt;alguns bits válidos da seção original de host são desperdiçados para que possam então ser criadas mais sub-redes&lt;/b&gt;, e facilitar a segmentação dos hosts, o que traz diversas vantagens, como a departamentalização da rede e o incremento em segurança, por exemplo. No nosso caso, com uma &lt;b style=""&gt;máscara de classe B&lt;/b&gt;, teríamos &lt;i style=""&gt;16 bits&lt;/i&gt; para rede, e &lt;i style=""&gt;16 bits&lt;/i&gt; para host: em alguns casos, 16 bits para os hosts pode ser demasiado, portanto alguns desses bits poderiam ser usados para segmentação de redes (no nosso caso, expandimos para &lt;b style=""&gt;&lt;i style=""&gt;mais 6 bits de sub-redes&lt;/i&gt;&lt;/b&gt;). Por exemplo, a seqüência a seguir compõe-se de sub-redes válidas para a máscara &lt;b style=""&gt;/22&lt;/b&gt; (&lt;b style=""&gt;255.255.252.0&lt;/b&gt;): &lt;b style=""&gt;&lt;i style=""&gt;172.16.148.0, 172.16.152.0, 172.16.156&lt;/i&gt;&lt;/b&gt;, e assim por diante, sempre &lt;b style=""&gt;de 4 em 4&lt;/b&gt;, por conta dos &lt;b style=""&gt;2 bits de host&lt;/b&gt; que são invariáveis, exclusivamente no que diz respeito à numeração de &lt;i style=""&gt;sub-redes&lt;/i&gt;.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Já que o &lt;i style=""&gt;terceiro octeto&lt;/i&gt; dos endereços de &lt;i style=""&gt;sub-rede&lt;/i&gt; que fazem parte da rede &lt;b style=""&gt;&lt;i style=""&gt;172.16.0.0&lt;/i&gt;&lt;/b&gt; denota parte da &lt;i style=""&gt;sub-rede&lt;/i&gt;, com &lt;b style=""&gt;&lt;i style=""&gt;6 bits&lt;/i&gt;&lt;/b&gt;, e parte do host, com &lt;b style=""&gt;&lt;i style=""&gt;2 bits&lt;/i&gt;&lt;/b&gt;, a faixa de endereços disponíveis para &lt;i style=""&gt;sub-redes&lt;/i&gt; inicia-se em 0 no terceiro octeto, e vai saltando de 4 em 4 (por conta do total de combinações dos 2 bits reservados para hosts). A faixa de endereços válidos é então: &lt;b style=""&gt;&lt;i style=""&gt;172.16.0.0, 172.16.4.0, 172.16.8.0, 172.16.12.0, ..., 172.16.252.0&lt;/i&gt;&lt;/b&gt; (num total de &lt;b style=""&gt;64&lt;/b&gt; &lt;i style=""&gt;sub-redes&lt;/i&gt;). Dessas 64 sub-redes, apenas uma delas engloba o endereço &lt;b style=""&gt;172.16.159.159&lt;/b&gt;. Para que a encontremos, teremos que encontrar o primeiro número inteiro menor do que &lt;b style=""&gt;159&lt;/b&gt;, &lt;i style=""&gt;e que seja divisível por 4&lt;/i&gt;. Aplicando esse processo na prática, pegamos o número &lt;b style=""&gt;159&lt;/b&gt; (terceiro octeto, que nos interessa), e &lt;b style=""&gt;dividimos por 4&lt;/b&gt; – daí, vemos que dessa divisão decorre um &lt;i style=""&gt;número fracionário &lt;/i&gt;(&lt;b style=""&gt;39,75&lt;/b&gt;), ou seja, retorna resto, portanto, não divisível por 4. Passamos então para o número imediatamente anterior (&lt;b style=""&gt;158&lt;/b&gt;), dividimos por &lt;b style=""&gt;4&lt;/b&gt;, o que nos dá &lt;b style=""&gt;39,5&lt;/b&gt;, que também não é o que queremos. Continuando nesse processo, percebemos que &lt;i style=""&gt;156 divide 4&lt;/i&gt; (sem resto). E é exatamente essa a resposta: &lt;b style=""&gt;172.16.156.0&lt;/b&gt;, a &lt;b style=""&gt;&lt;i style=""&gt;sub-rede&lt;/i&gt;&lt;/b&gt; referente ao endereço de host &lt;b style=""&gt;172.16.159.159 (/22)&lt;/b&gt;. Resposta: letra &lt;b style=""&gt;“B”&lt;/b&gt;.&lt;b style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Mais um assunto típico de prova, mas que do ponto de vista do &lt;i style=""&gt;dia-a-dia do profissional&lt;/i&gt; de &lt;i style=""&gt;redes&lt;/i&gt;, implica na maior parte apenas curiosidade típica de &lt;b style=""&gt;&lt;i style=""&gt;“hackers”,&lt;/i&gt;&lt;/b&gt; que se interessem por saber &lt;i style=""&gt;a qual sub-rede pertença um dado host&lt;/i&gt; – um gerente de redes competente mantém sempre uma documento com &lt;b style=""&gt;as faixas de sub-redes configuradas&lt;/b&gt;. Mas, é lógico, automatizar mentalmente o &lt;i style=""&gt;cálculo de faixas de redes&lt;/i&gt; é sempre uma ajuda...&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-199064583415288505?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/199064583415288505/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=199064583415288505' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/199064583415288505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/199064583415288505'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/04/segmentao-em-sub-redes.html' title='Segmentação em Sub-redes'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-6055909962204967206</id><published>2008-03-18T20:17:00.001-03:00</published><updated>2008-03-18T20:20:00.492-03:00</updated><title type='text'>STP - Spanning Tree Path Cost</title><content type='html'>&lt;p class="MsoNormal"&gt;Uma questão mais simples sobre o processo de “Spanning Tree”, essencial para o entendimento de eliminação de loops de rede a nível de enlace em switchs:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;By default, which of the following factors determines the spanning-tree path cost?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;A. It is the individual link cost based on latency&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;B. It is the sum of the costs based on bandwidth&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;C. It is the total hop count&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="" lang="EN-US"&gt;D. It is dynamically determined based on load&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;O protocolo &lt;b style=""&gt;STP&lt;/b&gt; &lt;i style=""&gt;(“Spanning Tree Protocol”&lt;/i&gt;) é definido por um padrão &lt;b style=""&gt;IEEE&lt;/b&gt; chamado &lt;b style=""&gt;&lt;i style=""&gt;802.1d&lt;/i&gt;&lt;/b&gt;, e foi inicialmente desenvolvido pela &lt;b style=""&gt;Digital Equipment Corporation&lt;/b&gt; (&lt;b style=""&gt;DEC&lt;/b&gt;). Como costuma ocorrer com freqüência num mundo dominado por padrões tecnológicos, a especificação oficial da &lt;b style=""&gt;IEEE&lt;/b&gt; para o &lt;b style=""&gt;STP&lt;/b&gt; não é de todo compatível com a versão criada pela &lt;b style=""&gt;DEC&lt;/b&gt;. Contudo, há atualmente um esforço em desenvolver um protocolo &lt;b style=""&gt;STP&lt;/b&gt; que seja efetivamente compatível com a especificação inicial, que será chamado &lt;b style=""&gt;&lt;i style=""&gt;802.1w&lt;/i&gt;&lt;/b&gt;.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;De forma simples, o protocolo &lt;b style=""&gt;STP&lt;/b&gt; evita que ocorram loops a nível de rede em switches de &lt;i style=""&gt;camada 2&lt;/i&gt; (camada de Enlace, no modelo &lt;b style=""&gt;OSI&lt;/b&gt;). Atuando de forma intermitente, o algoritmo do &lt;b style=""&gt;STP&lt;/b&gt; (chamado, de forma óbvia, &lt;b style=""&gt;Spanning Tree Algorithm&lt;/b&gt;) cria uma topologia ótima (ou quase ótima) da rede,&lt;span style=""&gt;  &lt;/span&gt;na qual não ocorram rotas redundantes, e links de switches que sirvam de conexão a rotas que possam ocasionar redundância são desligados em determinados momentos (principalmente quando os switches conectando segmentos de uma rede estão em processo de convergência – uma fase necessária quando os switches negociam quais rotas eles manterão, e quais &lt;i style=""&gt;links&lt;/i&gt; precisarão ser bloqueados). Para que isso ocorra, cada porta de um switch pode estar em um dos seguintes estados: &lt;b style=""&gt;&lt;i style=""&gt;Blocking&lt;/i&gt;&lt;/b&gt; (Bloqueado), &lt;b style=""&gt;&lt;i style=""&gt;Listening&lt;/i&gt;&lt;/b&gt; (Escutando), &lt;b style=""&gt;&lt;i style=""&gt;Learning&lt;/i&gt;&lt;/b&gt; (Aprendendo), &lt;b style=""&gt;&lt;i style=""&gt;Forwarding&lt;/i&gt;&lt;/b&gt; (Repassando) e &lt;b style=""&gt;&lt;i style=""&gt;Disabled&lt;/i&gt;&lt;/b&gt; (Desabilitada). Os nomes são auto-explicativos, mas uma observação importante merece ser dada para 2 desses estados: o estado &lt;i style=""&gt;Learning&lt;/i&gt; significa que o &lt;i style=""&gt;switch&lt;/i&gt; está efetivamente preenchendo sua tabela de endereços &lt;b style=""&gt;MAC&lt;/b&gt;, usados no roteamento a nível de enlace; e o estado &lt;i style=""&gt;Listening&lt;/i&gt;, um meio termo entre &lt;i style=""&gt;Blocking&lt;/i&gt; e &lt;i style=""&gt;Forwarding&lt;/i&gt;, significa que nem a porta está bloqueada (ou seja, recebe os frames de sincronização do STP – também chamados de &lt;b style=""&gt;BPDU&lt;/b&gt;s, ou &lt;i style=""&gt;“Bridge Protocol Data Unit”&lt;/i&gt;), nem muito menos pode repassar &lt;i style=""&gt;frames&lt;/i&gt; adiante. O objetivo disso tudo é que depois do switch ter passado pelo necessário estágio de convergência (passagem da porta de &lt;i style=""&gt;Blocking&lt;/i&gt; para &lt;i style=""&gt;Forwarding&lt;/i&gt;), e assim a rede esteja sem &lt;i style=""&gt;loops de roteamento&lt;/i&gt;, ele possa enfim repassar para frente os &lt;i style=""&gt;frames&lt;/i&gt; recebidos...&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Voltando à resposta, a convergência no &lt;b style=""&gt;STP&lt;/b&gt; passa por uma etapa em que uma das portas é eleita a “porta designada”, que vem a ser a porta com a largura de banda mais alta – é particularmente importante descobrir quais das portas num &lt;b style=""&gt;&lt;i style=""&gt;switch&lt;/i&gt;&lt;/b&gt; oferece a maior vazão, porque vai ser unicamente por essa porta que o vai ser calculado o caminho mais curto para o outro switch (sim, para o &lt;b style=""&gt;STP&lt;/b&gt;, o &lt;i style=""&gt;caminho mais curto&lt;/i&gt; é aquele que passa pela porta com maior &lt;b style=""&gt;largura de banda&lt;/b&gt;... apesar de que seria possível inúmeras outras medidas, o &lt;b style=""&gt;STP&lt;/b&gt; aceita apenas essa)&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Ora, se um caminho (&lt;b style=""&gt;&lt;i style=""&gt;path&lt;/i&gt;&lt;/b&gt;) pode ser definido por uma &lt;i style=""&gt;seqüência de portas&lt;/i&gt;, e uma vez que em cada &lt;i style=""&gt;switch&lt;/i&gt; há apenas uma dessas portas que sirvam de caminho, então o custo de uma rota pode ser definido como a &lt;i style=""&gt;soma dos custos de cada uma das portas no caminho&lt;/i&gt;. Letra &lt;b style=""&gt;(B)&lt;/b&gt; a correta.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-6055909962204967206?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/6055909962204967206/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=6055909962204967206' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/6055909962204967206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/6055909962204967206'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/03/stp-spanning-tree-path-cost.html' title='STP - Spanning Tree Path Cost'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-1993795458391033917</id><published>2008-02-16T00:08:00.004-03:00</published><updated>2008-02-16T00:44:52.203-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='link state routing'/><category scheme='http://www.blogger.com/atom/ns#' term='ccna'/><category scheme='http://www.blogger.com/atom/ns#' term='router'/><category scheme='http://www.blogger.com/atom/ns#' term='ospf'/><title type='text'>OSPF - Open Shortest Path First</title><content type='html'>Mais uma questão nos moldes das que são encontradas no exame &lt;span style="font-weight: bold;"&gt;CCNA&lt;/span&gt;, só que dessa vez envolvendo algoritmos de roteamento entre roteadores:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;On the topic of the OSPF hello protocol; which of the statements below are true?&lt;br /&gt;(Select two answer choices)&lt;br /&gt;A. The OSPF Hello protocol provides dynamic neighbor discovery.&lt;br /&gt;B. The OSPF Hello protocol detects unreachable neighbors in 90 second intervals.&lt;br /&gt;C. The OSPF Hello protocol maintains neighbor relationships.&lt;br /&gt;D. The OSPF Hello protocol negotiates the correct parameters between neighboring&lt;br /&gt;interfaces.&lt;br /&gt;E. The OSPF Hello protocol uses timers to elect the router with the fastest links at the&lt;br /&gt;designated router.&lt;br /&gt;F. The OSPF Hello protocol broadcast hello packets throughout the internetwork to&lt;br /&gt;discover all routers that are running OSPF.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Resposta: A, C&lt;br /&gt;O protocolo &lt;span style="font-weight: bold; font-style: italic;"&gt;Hello &lt;/span&gt;do &lt;span style="font-weight: bold;"&gt;OSPF &lt;/span&gt;&lt;span style="font-style: italic;"&gt;(Open Shortest Path First) &lt;/span&gt;serve como um meio de estabelecer as relações de vizinhança entre roteadores. É por meio desse tipo de pacote que se torna possível reconhecer potenciais roteadores numa vizinhança, e que poderão ser reconhecidos como &lt;span style="font-weight: bold;"&gt;"Neighbor Router"&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;"Designated Router"&lt;/span&gt;, ou &lt;span style="font-weight: bold;"&gt;"Backup Designated Router"&lt;/span&gt;, e a partir dos quais serão construídas as listas de adjacências, de onde serão escolhidas as melhores rotas baseadas nos custos das interfaces de saída do roteador. O &lt;span style="font-style: italic; font-weight: bold;"&gt;Hello &lt;/span&gt;serve tanto para estabelecer as vizinhaças, como também para mantê-las ativas, sempre que possível e para que rotas que se tornaram inválidas possam ser removidas. Além do protocolo &lt;span style="font-style: italic;"&gt;Hello&lt;/span&gt;, o &lt;span style="font-weight: bold;"&gt;OSPF &lt;/span&gt;trabalha em conjunto com mais &lt;span style="font-weight: bold;"&gt;4 &lt;/span&gt;mensagens: &lt;span style="font-weight: bold;"&gt;Database Description&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;Link State Request&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;Link State Update&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;Link State Ack&lt;/span&gt;.&lt;br /&gt;A letra &lt;span style="font-weight: bold;"&gt;B &lt;/span&gt;se refere a um &lt;span style="font-style: italic;"&gt;timer &lt;/span&gt;de 90 segundos, que não é utilizado pelo &lt;span style="font-weight: bold;"&gt;OSPF&lt;/span&gt;. Apesar disso, é necessário que o &lt;span style="font-style: italic;"&gt;timing &lt;/span&gt;entre os pacotes &lt;span style="font-style: italic; font-weight: bold;"&gt;Hello &lt;/span&gt;subsequentes estejam em sincronia, caso contrário não seria possível relações de vizinhança. (o &lt;span style="font-weight: bold;"&gt;OSPF &lt;/span&gt;usa algo com uma variante do &lt;span style="font-weight: bold; font-style: italic;"&gt;"round-trip time"&lt;/span&gt;, encontrada no &lt;span style="font-weight: bold;"&gt;TCP &lt;/span&gt;para descobrir de forma ativa quando um envio de pacote não chegou ao destino, e possivelmente não vai ser retransmitido). A letra &lt;span style="font-weight: bold;"&gt;E &lt;/span&gt;é falsa, porque o &lt;span style="font-weight: bold;"&gt;Hello &lt;/span&gt;não serve para identificar quem dos roteadores vizinhos possam estar usando ou não &lt;span style="font-weight: bold;"&gt;OSPF&lt;/span&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-1993795458391033917?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/1993795458391033917/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=1993795458391033917' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/1993795458391033917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/1993795458391033917'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/02/ospf-open-shortest-path-first.html' title='OSPF - Open Shortest Path First'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-6069286420837815098</id><published>2008-01-20T12:00:00.000-03:00</published><updated>2008-02-05T22:29:35.962-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ccna'/><category scheme='http://www.blogger.com/atom/ns#' term='frame relay'/><category scheme='http://www.blogger.com/atom/ns#' term='wan'/><title type='text'>WAN com Frame-Relays no CCNA</title><content type='html'>Continuando com a explanação acerca dos objetivos e sobre a forma como as questões são cobertas na avaliação &lt;span style="font-weight: bold;"&gt;CCNA&lt;/span&gt;, irei mostrar alguns exemplos parecidos com os da prova. Pra começar, na questão abaixo, vemos um tema recorrente nos últimos exames, que são aqueles assuntos envolvendo &lt;span style="font-weight: bold;"&gt;WAN &lt;/span&gt;e redes &lt;span style="font-style: italic; font-weight: bold;"&gt;Frame-Relay&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;From the network configuration below, both the Matriz and Filial offices are configured as shown below:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Matriz# show running-config &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Filial# show running-config&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;some&gt; &lt;some&gt;&lt;/some&gt;&lt;/some&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;interface Serial0/0   interface Serial0/0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ip address 10.0.8.1 255.255.248.0   ip address 10.0.15.2 255.255.248.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;encapsulation frame-relay    encapsulation frame-relay&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;frame-relay map ip 10.0.15.2 200 frame-relay map ip 10.0.8.1 100&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;! ! &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;router rip router rip&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;network 10.0.0.0 network 10.0.0.0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;The Filial router can be successfully pinged from the Matriz office, but the Filial users can't access the server at the Matriz office.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Based on the output above, what do you suspect is the cause of this problem?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;A. The Frame Relay PVC is down.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;B. The IP addressing on the Central/Remote serial link is incorrect.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;C. RIP routing information is not being forwarded.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;D. Frame Relay inverse-ARP is not properly configured.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Como muitas das questões encontradas no exame, é comum o uso da técnica de eliminar as alternativas menos prováveis (ou absurdas) primeiro. Avaliando as alternativas na ordem, vemos as letras &lt;span style="font-weight: bold;"&gt;A&lt;/span&gt; e &lt;span style="font-weight: bold;"&gt;B &lt;/span&gt;não se configuram como causas para o problema citado na questão, uma vez que, de acordo como o enunciado, é possível obter resultados positivos com as respostas aos pacotes &lt;span style="font-weight: bold;"&gt;ICMP&lt;/span&gt; enviados pelo utilitário &lt;span style="font-weight: bold; font-style: italic;"&gt;"ping"&lt;/span&gt;.  Do suposto no enunciado, está estabelecida sim uma PVC, e as interfaces estão todas funcionando a contento (caso contrário, seriam obtidas mensagens do tipo &lt;span style="font-style: italic;"&gt;"Host Unreachable"&lt;/span&gt; na resposta ao &lt;span style="font-style: italic;"&gt;ping&lt;/span&gt;).&lt;br /&gt;A alternativa &lt;span style="font-weight: bold;"&gt;D &lt;/span&gt;refere-se a um recurso chamado &lt;a href="http://en.wikipedia.org/wiki/Address_Resolution_Protocol"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;Inverse Address Resolution Protocol&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;IARP&lt;/span&gt;)&lt;/a&gt; (, que é usado para estabelecer, dinamicamente, números &lt;span style="font-style: italic; font-weight: bold;"&gt;DLCI &lt;/span&gt;a endereços IP de interfaces no roteador que serve de ponta a &lt;span style="font-weight: bold; font-style: italic;"&gt;Permanent Virtual Connection&lt;/span&gt;s (&lt;span style="font-weight: bold;"&gt;PVCs&lt;/span&gt;). Com o &lt;span style="font-weight: bold;"&gt;IARP&lt;/span&gt;, se torna desnecessário estabelecer rotas estáticas para os canais &lt;span style="font-weight: bold;"&gt;Frame-Relay&lt;/span&gt;, mas da leitura do resultado do comando show running-config, vemos que é feito o uso de comandos &lt;span style="font-weight: bold; font-style: italic;"&gt;"frame-relay map"&lt;/span&gt;, que fazem exatamente a mesma coisa, só que de forma estática. Por não depender do &lt;span style="font-weight: bold;"&gt;IARP&lt;/span&gt;, a afirmativa contida na alternativa &lt;span style="font-weight: bold;"&gt;D&lt;/span&gt; também não explica o mal-funcionamento da rede.&lt;br /&gt;Da remoção das 3 outras alternativas, a alternativa &lt;span style="font-weight: bold;"&gt;C&lt;/span&gt; aponta como a única correta. Revendo a situação proposta, percebemos que as interfaces em questão não estão permitindo &lt;span style="font-style: italic;"&gt;broadcast/multicast&lt;/span&gt;, o que invalida a atuação do algoritmo &lt;span style="font-weight: bold;"&gt;RIP &lt;/span&gt;de roteamento, uma vez que ele usa de endereços &lt;span style="font-weight: bold;"&gt;broadcast&lt;/span&gt;, na &lt;span style="font-style: italic;"&gt;versão 1&lt;/span&gt; do protocolo, e endereços do tipo multicast, na &lt;span style="font-style: italic;"&gt;versão 2&lt;/span&gt;. O protocolo &lt;span style="font-weight: bold; font-style: italic;"&gt;RIP&lt;/span&gt; faz uso de &lt;span style="font-style: italic;"&gt;broadcast/multicast&lt;/span&gt; para gerar as relações de vizinhança com roteadores próximos, e assim criar a sua topologia de roteamento. E &lt;span style="font-weight: bold; font-style: italic;"&gt;Frame-Relay&lt;/span&gt;, por padrão, não repassa broadcasts. Bastaria acrescentar-se a opção &lt;span style="font-style: italic;"&gt;broadcast &lt;/span&gt;ao comando &lt;span style="font-style: italic; font-weight: bold;"&gt;frame-relay map&lt;/span&gt; para se corrigir o defeito de roteamento.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-6069286420837815098?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/6069286420837815098/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=6069286420837815098' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/6069286420837815098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/6069286420837815098'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2008/01/wan-com-frame-relays-no-ccna.html' title='WAN com Frame-Relays no CCNA'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-9031019592858804812</id><published>2007-12-26T14:59:00.000-03:00</published><updated>2007-12-26T15:49:43.276-03:00</updated><title type='text'>CCNA - Cisco Certified Network Associate</title><content type='html'>Semana passada, mais precisamente no dia &lt;span style="font-style: italic;"&gt;21 de dezembro&lt;/span&gt;, fui aprovado no exame de certificação da &lt;a href="http://www.cisco.com/web/learning/le3/le2/le0/le9/learning_certification_type_home.html"&gt;CCNA, &lt;/a&gt;da &lt;span style="font-weight: bold;"&gt;Cisco&lt;/span&gt;. Sobretudo em relação ao que falam sobre a prova, cabe salientar que é tudo verdade, as questões são realmente difíceis. Vale ressaltar contudo o abuso de intencionais &lt;span style="font-style: italic;"&gt;"cascas-de-banana"&lt;/span&gt; que aparecem com cada vez mais frequência à medida que esse exame, antes considerado&lt;span style="font-style: italic;"&gt; "entry-level"&lt;/span&gt; da &lt;a href="http://www.cisco.com"&gt;Cisco &lt;/a&gt;(agora a Cisco criou um mais básico, chamado &lt;span style="font-weight: bold;"&gt;CCENT&lt;/span&gt;), evolui no sentido de dificultar a trajetória de quem se habilita a seguir qualquer um dos&lt;span style="font-weight: bold; font-style: italic;"&gt; "certification path"&lt;/span&gt; que a &lt;span style="font-weight: bold;"&gt;Cisco &lt;/span&gt;disponibiliza (Wireless, Security, etc.), onde o CCNA se localiza nos degraus iniciais na escalada &lt;a href="http://www.cisco.com"&gt;&lt;span style="font-style: italic;"&gt;Cisco&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Meu exame tinha &lt;span style="font-weight: bold;"&gt;49 questões&lt;/span&gt;, e &lt;span style="font-weight: bold;"&gt;75 &lt;/span&gt;minutos pra concluir. A nota mínima é &lt;span style="font-weight: bold;"&gt;849&lt;/span&gt;, de um mínimo de &lt;span style="font-weight: bold;"&gt;300 &lt;/span&gt;até um máximo de &lt;span style="font-weight: bold;"&gt;1000&lt;/span&gt;. Não é permitido voltar à questão anteriormente respondida; uma vez que você tenha clicado no botão &lt;span style="font-style: italic;"&gt;"Next"&lt;/span&gt;, para passar para a próxima questão, não é mais possível corrigí-la. O &lt;span style="font-weight: bold;"&gt;resultado final&lt;/span&gt; é dado no exato momento em que você clica no &lt;span style="font-style: italic;"&gt;"Next"&lt;/span&gt; da última questão, o que, aliado ao fato de não poder revisar as questões marcadas na prova, torna o resultado final sempre uma surpresa, de fazer gelar qualquer coração adolescente apaixonado... :)&lt;br /&gt;&lt;br /&gt;As questões também não se limitam às de &lt;span style="font-style: italic;"&gt;múltipla escolha&lt;/span&gt;: há tipos bem exóticos de questões, onde é proposto ao candidato um &lt;span style="font-style: italic;"&gt;cenário falho de infraestrutura de rede&lt;/span&gt;, e lhe é solicitado acessar os respectivos &lt;span style="font-style: italic;"&gt;dispositivos &lt;/span&gt;danificados de rede e entrar com os comandos que possivelmente tornarão a rede novamente operacional, num simulador em &lt;span style="font-style: italic; font-weight: bold;"&gt;shell &lt;/span&gt;do &lt;span style="font-style: italic;"&gt;Internetwork Operating System&lt;/span&gt; (&lt;span style="font-weight: bold;"&gt;IOS&lt;/span&gt;), o sistema operacional proprietário da Cisco que roda em &lt;span style="font-style: italic;"&gt;switches &lt;/span&gt;e &lt;span style="font-style: italic;"&gt;roteadores&lt;/span&gt;. As questões abusam da memorização, portanto não é considerada uma precaução extrema memorizar todas as distâncias administrativas e valores de timers para os protocolos de roteamento disponíveis,  os termos técnicos para dispositivos de conexão ISDN e frame relay, nem mesmo as siglas que representam os status de rotas quando se executa comandos como &lt;span style="font-weight: bold; font-style: italic;"&gt;"show ip ospf topology"&lt;/span&gt;, por exemplo.&lt;br /&gt;&lt;br /&gt;Ter passado no exame foi uma maratona de &lt;span style="font-style: italic;"&gt;livros&lt;/span&gt; e &lt;span style="font-style: italic;"&gt;referências&lt;/span&gt;, dentre as quais se destacam:&lt;br /&gt;    1. &lt;span style="font-weight: bold; font-style: italic;"&gt;CCNA Study Guide&lt;/span&gt;, do &lt;span style="font-style: italic;"&gt;Todd Lammle&lt;/span&gt; (http://www.amazon.com/CCNA-Certified-Network-Associate-640-802/dp/0470110082/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1198692515&amp;amp;sr=8-1);&lt;br /&gt;    2. Questões selecionadas do &lt;span style="font-weight: bold;"&gt;TestKing &lt;/span&gt;- CCNA (http://www.testking.com/certs/CCNA.htm);&lt;br /&gt;    3. &lt;span style="font-weight: bold; font-style: italic;"&gt;CCNA 4.0: Guia da Certificação&lt;/span&gt;, do Marco Fillipetti (cobre bem a teoria, mas falta muito em relação ao nível das questões, que é superficial nesse livro);&lt;br /&gt;    4. &lt;span style="font-weight: bold; font-style: italic;"&gt;Boson Router Simulator&lt;/span&gt; (http://www.boson.com/) - essencial pra exercitar as questões de simulação de cenários de topologia de rede.&lt;br /&gt;&lt;br /&gt;Nos próximos &lt;span style="font-style: italic;"&gt;posts&lt;/span&gt;, colocarei aqui algumas questões bem parecidas com as que eu vi no exame. Não seria permitido colocar na íntegra, uma vez que os candidatos ao &lt;span style="font-weight: bold;"&gt;CCNA &lt;/span&gt;são obrigados a assinar um &lt;span style="font-style: italic;"&gt;contrato de confidencialidade&lt;/span&gt;...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-9031019592858804812?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/9031019592858804812/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=9031019592858804812' title='2 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/9031019592858804812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/9031019592858804812'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2007/12/ccna-cisco-certified-network-associate.html' title='CCNA - Cisco Certified Network Associate'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-2599308870710479562</id><published>2007-08-21T20:40:00.000-03:00</published><updated>2007-08-21T21:50:52.086-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gcc'/><category scheme='http://www.blogger.com/atom/ns#' term='makefile'/><category scheme='http://www.blogger.com/atom/ns#' term='autoconf'/><category scheme='http://www.blogger.com/atom/ns#' term='make'/><category scheme='http://www.blogger.com/atom/ns#' term='coverage testing'/><category scheme='http://www.blogger.com/atom/ns#' term='autogen'/><title type='text'>Mais sobre GNU Autotools (parte IV)</title><content type='html'>Continuando a superficial &lt;span style="font-weight: bold;"&gt;explanação&lt;/span&gt; acerca dos detalhes de &lt;span style="font-style: italic;"&gt;definição&lt;/span&gt; de um &lt;span style="font-weight: bold; font-style: italic;"&gt;arquivo configure.ac&lt;/span&gt;, que definirá como exatamente o &lt;span style="font-weight: bold;"&gt;build&lt;/span&gt; do nosso sistema em questão será gerado, e por quais &lt;span style="font-style: italic;"&gt;bibliotecas&lt;/span&gt; precisará gerar &lt;span style="font-style: italic;"&gt;dependências,&lt;/span&gt; veremos mais alguns exemplos de chamada de macros &lt;span style="font-weight: bold;"&gt;M4&lt;/span&gt; que são de uso mais frequente.&lt;br /&gt;&lt;br /&gt;As definições de arquivos &lt;span style="font-weight: bold;"&gt;configure.ac&lt;/span&gt; começam com chamadas de configuração ao &lt;span style="font-weight: bold;"&gt;autoconf&lt;/span&gt;.&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;Para diferenciá-las em relação às &lt;span style="font-style: italic;"&gt;macros comuns&lt;/span&gt;, remetesse à &lt;span style="font-style: italic;"&gt;notação das macros&lt;/span&gt;, que assumem o prefixo &lt;span style="font-weight: bold;"&gt;AC&lt;/span&gt;. Por exemplo, a macro &lt;span style="font-weight: bold;"&gt;AC_CHECK_FUNCS&lt;/span&gt; realiza uma busca pelos nomes de funções passadas como &lt;span style="font-style: italic;"&gt;parâmetro&lt;/span&gt; (&lt;span style="font-style: italic;"&gt;listas de parâmetro&lt;/span&gt; em &lt;span style="font-weight: bold;"&gt;M4&lt;/span&gt; são representadas não por vírgulas, mas por sequências de nomes de &lt;span style="font-style: italic;"&gt;argumentos de função&lt;/span&gt;, separados por espaço e tendo por limites os &lt;span style="font-style: italic;"&gt;símbolos especiais&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;'[' &lt;/span&gt;e &lt;span style="font-weight: bold;"&gt;']'&lt;/span&gt;). Após serem encontrados as origens dos nomes de função, o respectivo &lt;span style="font-style: italic;"&gt;arquivo de biblioteca&lt;/span&gt; e adicionado como &lt;span style="font-style: italic;"&gt;parâmetro de compilação&lt;/span&gt; dos fontes do sistema. Na chamada abaixo, as &lt;span style="font-style: italic;"&gt;funções especificadas&lt;/span&gt; são verificadas e seus respectivos &lt;span style="font-style: italic;"&gt;headers&lt;/span&gt; e &lt;span style="font-style: italic;"&gt;binários de bibliotecas&lt;/span&gt; são referenciados para serem usados depois, através de variáveis execíficas, como &lt;span style="font-weight: bold;"&gt;CFLAGS&lt;/span&gt; e &lt;span style="font-weight: bold;"&gt;LDFLAGS&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;AC_CHECK_FUNCS([memset socket stime strstr strtoul gethostname inet_ntoa localtime_r select strrchr localtime strptime])&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Essa chamada em &lt;span style="font-weight: bold;"&gt;M4&lt;/span&gt; é especialmente genérica, e pode ser usada de forma incondicional para todo &lt;span style="font-style: italic;"&gt;nome de função&lt;/span&gt; que se suspeite estar presente no &lt;span style="font-style: italic;"&gt;ambiente atual de desenvolvimento&lt;/span&gt;. Mas tem-se definidas outras chamadas mais particulares, que buscam por chamadas bem específicas de &lt;span style="font-style: italic;"&gt;funções&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# Checks for library functions.&lt;br /&gt;AC_FUNC_FORK&lt;br /&gt;AC_FUNC_STRFTIME&lt;br /&gt;AC_FUNC_MALLOC&lt;br /&gt;AC_FUNC_MKTIME&lt;br /&gt;AC_FUNC_VPRINTF&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Todas as &lt;span style="font-style: italic;"&gt;funções&lt;/span&gt; acima (&lt;span style="font-weight: bold;"&gt;fork, strftime, malloc, mktime, vprintf&lt;/span&gt;) são buscadas no &lt;span style="font-style: italic;"&gt;ambiente atual&lt;/span&gt;, e adicionadas  por padrão aos campos &lt;span style="font-weight: bold;"&gt;CFLAGS&lt;/span&gt; e &lt;span style="font-weight: bold;"&gt;LDFLAGS&lt;/span&gt; (quando necessário).&lt;br /&gt;&lt;br /&gt;Pode-se definir &lt;span style="font-style: italic;"&gt;parâmetros&lt;/span&gt; que são passados ao &lt;span style="font-weight: bold; font-style: italic;"&gt;autoconf&lt;/span&gt; para que ele instrua de forma adequada a geração dos &lt;span style="font-weight: bold;"&gt;Makefiles&lt;/span&gt;. No &lt;span style="font-style: italic;"&gt;código&lt;/span&gt; abaixo usa-se a macro &lt;span style="font-weight: bold;"&gt;AC_ARG_ENABLE&lt;/span&gt; para verificar se o parâmetro de linha de comando &lt;span style="font-weight: bold;"&gt;--enable-coverage&lt;/span&gt; foi aplicado, no caso do desenvolvedor necessitar da funcionalidade de compilação usando os recursos de &lt;span style="font-style: italic;"&gt;teste de cobertura&lt;/span&gt; (&lt;span style="font-weight: bold;"&gt;coverage&lt;/span&gt;):&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;AC_ARG_ENABLE(coverage,&lt;br /&gt;       AS_HELP_STRING([--enable-coverage],&lt;br /&gt;               [enable coverage (default = no)]),&lt;br /&gt;               [&lt;br /&gt;                       if test $enableval = no; then&lt;br /&gt;                               USE_COVERAGE=no;&lt;br /&gt;                       else&lt;br /&gt;                               USE_COVERAGE=yes;&lt;br /&gt;                       fi&lt;br /&gt;               ],[&lt;br /&gt;                       USE_COVERAGE=no;&lt;br /&gt;               ]&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;if [ test $USE_COVERAGE = yes ]; then&lt;br /&gt;       CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage -O0"&lt;br /&gt;       LDFLAGS="$LDFLAGS -lgcov"&lt;br /&gt;fi&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Caso o parâmetro &lt;span style="font-weight: bold;"&gt;--enable-coverage&lt;/span&gt; seja passado, a variável &lt;span style="font-weight: bold;"&gt;$USE_COVERAGE&lt;/span&gt; será definida com valor &lt;span style="font-weight: bold;"&gt;"yes"&lt;/span&gt;, e serão adicionados os &lt;span style="font-style: italic;"&gt;parâmetros&lt;/span&gt; necessários como &lt;span style="font-style: italic;"&gt;atributos de compilação&lt;/span&gt; do &lt;span style="font-weight: bold;"&gt;gcc&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;A chamada abaixo sinaliza ao &lt;span style="font-style: italic;"&gt;utilitário&lt;/span&gt; &lt;span style="font-weight: bold; font-style: italic;"&gt;automake&lt;/span&gt; que seja executado. Ele processará todos os &lt;span style="font-style: italic;"&gt;arquivos texto&lt;/span&gt; com terminação &lt;span style="font-weight: bold;"&gt;".am"&lt;/span&gt;, e criará a partir deles os arquivos &lt;span style="font-weight: bold;"&gt;Makefile&lt;/span&gt; apropriados:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;AM_INIT_AUTOMAKE($PACKAGE, $VERSION)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Tendo o arquivo &lt;span style="font-weight: bold;"&gt;configure.ac&lt;/span&gt; definido corretamente, além dos respectivos &lt;span style="font-weight: bold;"&gt;Makefile.am&lt;/span&gt; (que definirão os processos de &lt;span style="font-style: italic;"&gt;compilação&lt;/span&gt; e &lt;span style="font-style: italic;"&gt;geração das builds&lt;/span&gt;, rodando em cima do utilitário &lt;span style="font-style: italic; font-weight: bold;"&gt;make&lt;/span&gt;), a execução de &lt;span style="font-weight: bold; font-style: italic;"&gt;autogen.sh&lt;/span&gt; (um script de uso bastante difundido, apesar de não vir em distibuição padrão das principais &lt;span style="font-weight: bold;"&gt;GNU autotools&lt;/span&gt; - quase todo projeto autoconf usa um modelo similar de &lt;span style="font-weight: bold; font-style: italic;"&gt;autogen.sh&lt;/span&gt;, que simplesmente irá executar os comandos &lt;span style="font-weight: bold;"&gt;autoconf&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;automake&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;libtool&lt;/span&gt;, etc. numa ordem pré-estabelecida e funcional).&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# ./autogen.sh&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;O qual &lt;span style="font-style: italic;"&gt;terminada a execução&lt;/span&gt;, pode vir acompanhado da chamada ao &lt;span style="font-weight: bold;"&gt;make&lt;/span&gt; para que o &lt;span style="font-style: italic;"&gt;sistema de software&lt;/span&gt; seja compilado e instalado:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# make all install&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-2599308870710479562?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/2599308870710479562/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=2599308870710479562' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/2599308870710479562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/2599308870710479562'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2007/08/mais-sobre-gnu-autotools-parte-iv.html' title='Mais sobre GNU Autotools (parte IV)'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-148521282367053838</id><published>2007-08-16T20:37:00.000-03:00</published><updated>2007-08-16T21:27:44.302-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='software deployment'/><category scheme='http://www.blogger.com/atom/ns#' term='software development'/><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><category scheme='http://www.blogger.com/atom/ns#' term='autoconf'/><category scheme='http://www.blogger.com/atom/ns#' term='automake'/><category scheme='http://www.blogger.com/atom/ns#' term='autoscan'/><title type='text'>GNU Autotools (parte III) - Configure.ac</title><content type='html'>Chegamos à &lt;span style="font-weight: bold;"&gt;etapa&lt;/span&gt; mais interessante dessa rápida introdução aos recursos de &lt;span style="font-style: italic;"&gt;deployment&lt;/span&gt; e geração de &lt;span style="font-style: italic;"&gt;builds&lt;/span&gt; com &lt;span style="font-weight: bold; font-style: italic;"&gt;autotools&lt;/span&gt;. Iniciaremos essa exposição detalhando a &lt;span style="font-style: italic;"&gt;estrutura do arquivo de configuração &lt;span style="font-weight: bold;"&gt;configure.ac&lt;/span&gt;&lt;/span&gt; e as &lt;span style="font-weight: bold;"&gt;macros M4&lt;/span&gt; úteis na sua composição. Relembrando, o &lt;span style="font-weight: bold; font-style: italic;"&gt;configure.ac &lt;/span&gt;é um arquivo útil para se configurar as variáveis de ambiente, onde quer que o aplicativo em desenvovimento precisar ser &lt;span style="font-weight: bold;"&gt;empacotado&lt;/span&gt;. Dentro do &lt;span style="font-weight: bold;"&gt;configure.ac&lt;/span&gt;, declararemos coisas como o nome da distro, números de versão (&lt;span style="font-style: italic; font-weight: bold;"&gt;minor e major&lt;/span&gt; versions), as bibliotecas que precisam se verificadas quanto da sua existência, passagem de parâmetros de compilação para os fontes, opções de &lt;span style="font-weight: bold;"&gt;debug&lt;/span&gt; e teste automatizado, etc. Abaixo temos um trecho útil do &lt;span style="font-weight: bold; font-style: italic;"&gt;configure.ac&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#                                               -*- Autoconf -*-&lt;br /&gt;# Process this file with autoconf to produce a configure script.&lt;br /&gt;&lt;br /&gt;AC_PREREQ(2.50)&lt;br /&gt;&lt;br /&gt;AC_INIT([gmyth],[0.3])&lt;br /&gt;&lt;br /&gt;AC_CONFIG_SRCDIR([src/gmyth.h])&lt;br /&gt;AC_CONFIG_HEADER(config.h)&lt;br /&gt;&lt;br /&gt;dnl when going to/from release please set the nano (fourth number) right !&lt;br /&gt;dnl releases only do Wall, SVN and prerelease does Werror too&lt;br /&gt;AS_VERSION(gmyth, GMYTH, 0, 3, 0, 0, GMYTH_SVN="no", GMYTH_SVN="yes")&lt;br /&gt;GMYTH_MAJORMINOR=$GMYTH_MAJOR_VERSION.$GMYTH_MINOR_VERSION&lt;br /&gt;AC_SUBST(GMYTH_MAJORMINOR)&lt;br /&gt;&lt;br /&gt;(...)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Logo no início do arquivo &lt;span style="font-weight: bold;"&gt;configure.ac&lt;/span&gt;, temos uma chamada à macro &lt;span style="font-weight: bold;"&gt;M4&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;AC_PREREQ,&lt;/span&gt; que irá definir como obrigatório o uso da versão &lt;span style="font-style: italic; font-weight: bold;"&gt;2.50&lt;/span&gt; da ferramenta &lt;span style="font-weight: bold;"&gt;autoconf&lt;/span&gt; sobre esse arquivo específico de &lt;span style="font-style: italic; font-weight: bold;"&gt;distribuição&lt;/span&gt;. Caso o &lt;span style="font-style: italic;"&gt;desenvolvedor&lt;/span&gt; que baixe a versão da sua &lt;span style="font-style: italic;"&gt;biblioteca&lt;/span&gt; no &lt;span style="font-weight: bold;"&gt;SVN&lt;/span&gt; da sua empresa, por exemplo, tentar gerar os &lt;span style="font-weight: bold;"&gt;builds&lt;/span&gt; automáticos e os arquivos &lt;span style="font-weight: bold;"&gt;Makefile&lt;/span&gt;, usando uma versão anterior a &lt;span style="font-weight: bold; font-style: italic;"&gt;2.50&lt;/span&gt; do &lt;span style="font-weight: bold;"&gt;autoconf&lt;/span&gt;, o procedimento de build terminará com uma &lt;span style="font-style: italic;"&gt;mensagem de erro&lt;/span&gt; ao usuário, informando a necessidade de uso de uma &lt;span style="font-weight: bold;"&gt;versão mais atual&lt;/span&gt;. A macro &lt;span style="font-weight: bold;"&gt;AC_INIT&lt;/span&gt; atribui um nome para a &lt;span style="font-weight: bold;"&gt;distro&lt;/span&gt;, além de uma versão inicial: isso será de extrema valia quando sua &lt;span style="font-style: italic;"&gt;equipe de desenvolvimento &lt;/span&gt;estiver gerenciando o lançamento de novas &lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;releases&lt;/span&gt; do sistema&lt;/span&gt;, porque a versão presente nessa &lt;span style="font-weight: bold;"&gt;tag&lt;/span&gt; marcará a forma como funcionará o esquema de &lt;span style="font-style: italic;"&gt;versionamento&lt;/span&gt; para todos os &lt;span style="font-weight: bold;"&gt;builds&lt;/span&gt; subsequentes. Logo abaixo dessa chamada, temos a &lt;span style="font-weight: bold;"&gt;AS_VERSION&lt;/span&gt;, que detalha a versão do &lt;span style="font-weight: bold;"&gt;build&lt;/span&gt; atual em seções de &lt;span style="font-weight: bold;"&gt;MAJOR&lt;/span&gt; e &lt;span style="font-weight: bold;"&gt;MINOR&lt;/span&gt; version, o que aumenta a precisão com que as releases do seu sistema de &lt;span style="font-weight: bold;"&gt;software&lt;/span&gt; em &lt;span style="font-weight: bold; font-style: italic;"&gt;fase de deployment&lt;/span&gt; será lançado, o que costuma tornar mais fácil a comunicação com outras equipes importantes no &lt;span style="font-style: italic; font-weight: bold;"&gt;processo de software&lt;/span&gt;, porque cria uma &lt;span style="font-style: italic;"&gt;linguagem comum&lt;/span&gt;, onde uma &lt;span style="font-style: italic;"&gt;equipe de teste&lt;/span&gt;, por exemplo, poderá discernir, através da numeração de &lt;span style="font-weight: bold;"&gt;4 partes&lt;/span&gt; que compõe a &lt;span style="font-style: italic;"&gt;versão&lt;/span&gt;, se o build representa uma &lt;span style="font-weight: bold;"&gt;nightly-build&lt;/span&gt;, ou um release &lt;span style="font-weight: bold;"&gt;M1&lt;/span&gt; para usuário final, por exemplo.&lt;br /&gt;&lt;br /&gt;A macro &lt;span style="font-weight: bold;"&gt;AC_SUBST&lt;/span&gt; é bastante comum, e representa num arquivo &lt;span style="font-weight: bold;"&gt;configure.ac&lt;/span&gt; a operação de &lt;span style="font-style: italic; font-weight: bold;"&gt;declaração de variáveis&lt;/span&gt;, que poderão ser partilhadas entre &lt;span style="font-style: italic;"&gt;inúmeros&lt;/span&gt; arquivos &lt;span style="font-weight: bold;"&gt;Makefile.am&lt;/span&gt;. Como, a priori, podemos supor que exista um arquivo &lt;span style="font-weight: bold;"&gt;Makefile.am&lt;/span&gt; para cada &lt;span style="font-style: italic;"&gt;módulo&lt;/span&gt; que compôe o sistema, a importância dessa &lt;span style="font-style: italic;"&gt;funcionalidade&lt;/span&gt; atribuída por &lt;span style="font-weight: bold;"&gt;AC_SUBST&lt;/span&gt; fica clara, pois aí teremos uma forma de espalhar entre os &lt;span style="font-style: italic;"&gt;módulos&lt;/span&gt; dados que são de necessidade comum a todos eles (como nesse caso, os números de &lt;span style="font-style: italic;"&gt;versão&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;MINOR&lt;/span&gt; e &lt;span style="font-weight: bold;"&gt;MAJOR&lt;/span&gt;, que poderão ser usadas por &lt;span style="font-style: italic;"&gt;diretivas de compilação &lt;/span&gt;em código, denotando compilação condicional de determinados trechos, baseados em versão de &lt;span style="font-weight: bold;"&gt;build&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;Veremos depois mais &lt;span style="font-style: italic;"&gt;macros&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;M4&lt;/span&gt; úteis. Mas a &lt;span style="font-style: italic;"&gt;boa notícia&lt;/span&gt;, que serve sobremaneira na tarefa de gerar o arquivo &lt;span style="font-weight: bold;"&gt;configure.ac&lt;/span&gt;, e a ferramenta &lt;span style="font-weight: bold;"&gt;autoscan&lt;/span&gt;. Para usá-la, simplesmente rode-a dentro do seu &lt;span style="font-style: italic;"&gt;diretório de projeto&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# autoscan&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Essa ferramenta tem função dupla: caso você não tenha criado uma versão inicial do configure.ac, a ferramenta autoscan irá gerar automaticamente, baseado em inspeção do código da sua aplicação, um arquivo configure.ac exemplo, chamado configure.scan (basta renomeá-lo depois para configure.ac, caso ele atenda às suas necessidades). E caso contrário, você já tenha criado seu texto plenamente funcional para o configure.ac, mas deseja verificá-lo quanto à correção, e caso você não tenha esquecido de verificar alguma dependência, a autoscan poderá gerar um relatório de advertências, que poderão servir como dicas para que você melhore o seu configure.ac:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;configure.ac: warning: missing AC_CHECK_FUNCS([gethostbyname]) wanted by: src/gmyth_vlc.c:227&lt;br /&gt;configure.ac: warning: missing AC_CHECK_HEADERS([arpa/inet.h]) wanted by: gmyth_file_transfer.c:50&lt;br /&gt;configure.ac: warning: missing AC_CHECK_HEADERS([netdb.h]) wanted by: gmyth_file_transfer.c:53&lt;br /&gt;configure.ac: warning: missing AC_CHECK_HEADERS([netinet/in.h]) wanted by: src/gmyth_socket.c:52&lt;br /&gt;configure.ac: warning: missing AC_CHECK_HEADERS([sys/param.h]) wanted by: src/gmyth_socket.c:44&lt;br /&gt;configure.ac: warning: missing AC_CHECK_HEADERS([sys/time.h]) wanted by: src/gmyth_util.c:40&lt;br /&gt;configure.ac: warning: missing AC_FUNC_REALLOC wanted by: src/gmyth_http.c:965&lt;br /&gt;configure.ac: warning: missing AC_PROG_RANLIB wanted by: ltmain.sh:6817&lt;br /&gt;configure.ac: warning: missing AC_TYPE_SIZE_T wanted by: src/gmyth_http.c:960&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;No log da &lt;span style="font-weight: bold;"&gt;autoscan&lt;/span&gt; acima, ela aconselha que eu faça a verificação de &lt;span style="font-style: italic;"&gt;dependências de biblioteca&lt;/span&gt; para a minha aplicação, usando a macro &lt;span style="font-weight: bold;"&gt;AC_CHECK_FUNCS&lt;/span&gt;, que é bastante útil, e realiza uma busca nas bibliotecas (&lt;span style="font-style: italic;"&gt;.so&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;.a, shared ou static libraries, etc.&lt;/span&gt;) por um determinado &lt;span style="font-style: italic;"&gt;nome de função&lt;/span&gt;. Caso o &lt;span style="font-style: italic;"&gt;nome de função&lt;/span&gt; solicitado seja encontrado, a &lt;span style="font-style: italic;"&gt;biblioteca&lt;/span&gt; que o &lt;span style="font-weight: bold; font-style: italic;"&gt;encapsula&lt;/span&gt; será incluída como &lt;span style="font-style: italic;"&gt;parâmetro&lt;/span&gt; para que o &lt;span style="font-weight: bold;"&gt;GCC&lt;/span&gt; ou outro compilador a inclua como &lt;span style="font-style: italic;"&gt;parâmetro de biblioteca&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Mais detalhes sobre a &lt;span style="font-style: italic;"&gt;geração&lt;/span&gt; dos &lt;span style="font-weight: bold;"&gt;builds&lt;/span&gt; propriamente ditos no próximo &lt;span style="font-weight: bold;"&gt;post&lt;/span&gt;...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-148521282367053838?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/148521282367053838/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=148521282367053838' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/148521282367053838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/148521282367053838'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2007/08/gnu-autotools-parte-iii-configureac.html' title='GNU Autotools (parte III) - Configure.ac'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-1211624786175314150</id><published>2007-08-14T19:27:00.000-03:00</published><updated>2007-08-15T11:09:12.647-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gnu'/><category scheme='http://www.blogger.com/atom/ns#' term='autotools'/><category scheme='http://www.blogger.com/atom/ns#' term='autoconf'/><category scheme='http://www.blogger.com/atom/ns#' term='autoscan'/><title type='text'>GNU Autotools (parte II) - Utilitários</title><content type='html'>Na continuação da apresentação dos &lt;span style="font-style: italic;"&gt;conceitos básicos&lt;/span&gt; de funcionamento das &lt;span style="font-weight: bold;"&gt;Autotools&lt;/span&gt;, conjunto de ferramentas usadas para &lt;span style="font-weight: bold; font-style: italic;"&gt;automatização de geração de builds de software&lt;/span&gt;, veremos os arquivos fundamentais presentes numa distribuição que se aproveita da infraestrutura &lt;span style="font-weight: bold;"&gt;makefile&lt;/span&gt;. Observando um projeto típico que usa das &lt;span style="font-weight: bold;"&gt;autoconf&lt;/span&gt;s, alguns arquivos são característicos, e muitos deles são de presença &lt;span style="font-style: italic;"&gt;mandatória&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;data/&lt;br /&gt;debian/&lt;br /&gt;m4/&lt;br /&gt;samples/&lt;br /&gt;src/&lt;br /&gt;tests/&lt;br /&gt;AUTHORS&lt;br /&gt;COPYING&lt;br /&gt;ChangeLog&lt;br /&gt;INSTALL&lt;br /&gt;Makefile.am&lt;br /&gt;NEWS&lt;br /&gt;README&lt;br /&gt;aminclude.am&lt;br /&gt;autogen.sh&lt;br /&gt;configure.ac&lt;br /&gt;doxygen.cfg&lt;br /&gt;gmyth.pc.in&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;A estrutura de diretórios acima foi obtida de: &lt;a href="http://gmyth.svn.sourceforge.net/viewvc/gmyth/trunk/gmyth/"&gt;http://gmyth.svn.sourceforge.net/viewvc/gmyth/trunk/gmyth/&lt;/a&gt;. Os arquivos com nomes em maiúsculas são documentos texto, caracteres no formato &lt;span style="font-weight: bold;"&gt;ASCII&lt;/span&gt;, e são &lt;span style="font-style: italic;"&gt;descritivos do projeto&lt;/span&gt;, contém metadados com informações importantes, como o nome dos autores do projeto (&lt;span style="font-weight: bold;"&gt;AUTHORS&lt;/span&gt;) e a &lt;span style="font-style: italic;"&gt;licença de cópia e distribuição do código&lt;/span&gt; (&lt;span style="font-weight: bold;"&gt;COPYING&lt;/span&gt;). Eles são obrigatórios, e em alguns passos de processamento, é possível que ferramentas como &lt;span style="font-weight: bold;"&gt;autoconf&lt;/span&gt; retornem com erro, caso não encontrem tais arquivos, apesar da aparente função de baixa prioridade que seria a de informação sobre &lt;span style="font-weight: bold;"&gt;releases de software&lt;/span&gt; e &lt;span style="font-weight: bold;"&gt;nomes de autores&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;A seguir, por ordem de importância, temos o &lt;span style="font-weight: bold;"&gt;Makefile.am&lt;/span&gt;. Esse arquivo é uma espécie de &lt;span style="font-weight: bold;"&gt;Makefile&lt;/span&gt;, tal como visto no último &lt;span style="font-weight: bold;"&gt;post&lt;/span&gt;, porém em&lt;span style="font-style: italic;"&gt; estágio de pré-processamento&lt;/span&gt;, ou seja, contém estruturas e macros que ainda devem ser processadas, e utiliza de variáveis definidas na sequência de montagem de &lt;span style="font-weight: bold;"&gt;build&lt;/span&gt; comandada pelo arquivo &lt;span style="font-weight: bold; font-style: italic;"&gt;configure.ac&lt;/span&gt; (que por sua vez gera o &lt;span style="font-weight: bold;"&gt;configure&lt;/span&gt;). O trecho seguinte de Makefile.am apresenta algumas estruturas fundamentais:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SUBDIRS= src samples tests&lt;br /&gt;&lt;br /&gt;(...)&lt;br /&gt;&lt;br /&gt;if HAVE_INDENT&lt;br /&gt;indent:&lt;br /&gt;      cd src; \&lt;br /&gt;      make indent; \&lt;br /&gt;      cd ..&lt;br /&gt;endif&lt;br /&gt;&lt;br /&gt;include aminclude.am&lt;br /&gt;&lt;br /&gt;EXTRA_DIST =                    \&lt;br /&gt;      autogen.sh                      \&lt;br /&gt;      gmyth.pc.in                     \&lt;br /&gt;      AUTHORS                       \&lt;br /&gt;      COPYING                        \&lt;br /&gt;      README&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Esse arquivo &lt;span style="font-weight: bold;"&gt;Makefile.am&lt;/span&gt; será utilizado como entrada no &lt;span style="font-style: italic;"&gt;utilitário &lt;span style="font-weight: bold;"&gt;automake&lt;/span&gt;&lt;/span&gt;, as macros chamadas a partir dele serão processadas como devido, e o arquivo texto resultante será transformado no arquivo &lt;span style="font-weight: bold;"&gt;Makefile&lt;/span&gt;, com estruturas semelhantes àquelas vistas no post passado, porém bem mais detalhada e complexa, Por sinal, os resultados de&lt;span style="font-weight: bold; font-style: italic;"&gt; processamento das autotools&lt;/span&gt; costumam ser de leitura &lt;span style="font-style: italic;"&gt;BEM difícil&lt;/span&gt; para quem não estiver habituado a Makefiles e programação em &lt;span style="font-weight: bold;"&gt;Shell Script&lt;/span&gt;, mas depurar uma distribuição com &lt;span style="font-weight: bold;"&gt;autoconf&lt;/span&gt; algumas vezes necessita-se inspecionar arquivos &lt;span style="font-weight: bold; font-style: italic;"&gt;Makefile&lt;/span&gt; e configure auto-gerados a fim de identificar inconsistência ou erros (como um path de biblioteca inválido, ou variável de ambiente mal definida).&lt;br /&gt;&lt;br /&gt;Ao rodar em cima desse arquivo &lt;span style="font-weight: bold;"&gt;Makefile.am&lt;/span&gt;, o &lt;span style="font-weight: bold; font-style: italic;"&gt;automake&lt;/span&gt; definirá, na ordem, uma variável &lt;span style="font-weight: bold;"&gt;SUBDIRS&lt;/span&gt;, que listará os subdiretórios do projeto que contém outras definições &lt;span style="font-style: italic; font-weight: bold;"&gt;Makefile.am&lt;/span&gt;. A variável &lt;span style="font-weight: bold;"&gt;SUBDIRS&lt;/span&gt; é padrão, e deve sempre ser definida quando se lida com projetos mais complexos, com vários &lt;span style="font-weight: bold;"&gt;Makefiles&lt;/span&gt;, porque é através dele que será determinada a abrangência e a forma como o &lt;span style="font-weight: bold;"&gt;build&lt;/span&gt; vai ser gerado: um diretório faltando pode prejudicar a&lt;span style="font-style: italic; font-weight: bold;"&gt; release final&lt;/span&gt;, bem como a inclusão de um módulo em &lt;span style="font-weight: bold;"&gt;SUBDIRS&lt;/span&gt; que não seja possível de ser compilado em determinada arquitetura, pode gerar problemas na execução em alguma etapa de processamento das &lt;span style="font-weight: bold; font-style: italic;"&gt;autotools&lt;/span&gt;... Durante a execução, serão processados, respectivamente, arquivos Makefile.am nos subdiretórios &lt;span style="font-style: italic;"&gt;src&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;samples&lt;/span&gt; e &lt;span style="font-style: italic;"&gt;tests&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Pode-se, dentro de um &lt;span style="font-weight: bold;"&gt;Makefile.am&lt;/span&gt;, determinar a criação condicional de &lt;span style="font-weight: bold;"&gt;targets&lt;/span&gt;, ou adição de qualquer trecho de código, usando variáveis definidas numa etapa anterior do &lt;span style="font-weight: bold;"&gt;automake&lt;/span&gt;, como o uso de variáveis definidas no &lt;span style="font-style: italic;"&gt;configure.ac&lt;/span&gt; (&lt;span style="font-weight: bold; font-style: italic;"&gt;autoconf&lt;/span&gt;). Aqui temos que a variável &lt;span style="font-weight: bold;"&gt;HAVE_INDENT&lt;/span&gt; é verificada com relação ao seu valor verdade e, caso a avaliação seja positiva, o target &lt;span style="font-style: italic; font-weight: bold;"&gt;indent&lt;/span&gt; é criado. Essa variável será definida &lt;span style="font-weight: bold;"&gt;TRUE&lt;/span&gt; caso a opção de identação de código tenha sido informada em linha de comando (durante a chamada inicial aos &lt;span style="font-weight: bold;"&gt;autotools&lt;/span&gt;), bem como se a ferramenta &lt;span style="font-weight: bold; font-style: italic;"&gt;indent&lt;/span&gt; foi encontrada na &lt;span style="font-weight: bold; font-style: italic;"&gt;distribuição alvo&lt;/span&gt;. Abaixo, vemos o trecho de código do &lt;span style="font-weight: bold;"&gt;configure.ac&lt;/span&gt; que cria a variável &lt;span style="font-weight: bold;"&gt;HAVE_INDENT&lt;/span&gt; com o valor apropriado:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# checks if the indent tool can be found&lt;br /&gt;AC_CHECK_PROG(HAVE_INDENT, indent, [Found!])&lt;br /&gt;if test -n "$HAVE_INDENT"; then&lt;br /&gt;      AC_DEFINE(HAVE_INDENT, 1, [AutoIndent found!])&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;AM_CONDITIONAL(HAVE_INDENT, test -n "$HAVE_INDENT")&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;A macro &lt;span style="font-weight: bold;"&gt;M4&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;span style="font-weight: bold;"&gt;"A&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;C_CHECK_PROG"&lt;/span&gt; funciona da seguinte forma: a variável &lt;span style="font-weight: bold;"&gt;HAVE_INDENT&lt;/span&gt; será declarada caso o aplicativo &lt;span style="font-weight: bold;"&gt;indent&lt;/span&gt; possa ser executado com sucesso em &lt;span style="font-style: italic;"&gt;prompt de comando&lt;/span&gt;, imprimindo uma mensagem &lt;span style="font-weight: bold;"&gt;"Found!"&lt;/span&gt; em caso afirmativo. A macro &lt;span style="font-weight: bold;"&gt;AM_CONDITIONAL&lt;/span&gt; faz com que a variável &lt;span style="font-weight: bold;"&gt;HAVE_INDENT&lt;/span&gt; seja visível em escopo de arquivos de entrada &lt;span style="font-style: italic; font-weight: bold;"&gt;Automake&lt;/span&gt; (&lt;span style="font-weight: bold;"&gt;Makefile.am&lt;/span&gt;), o que a torna passível de ser usada em expressões condicionais, como o trecho de avaliação do &lt;span style="font-weight: bold; font-style: italic;"&gt;if&lt;/span&gt; no &lt;span style="font-weight: bold;"&gt;Makefile.am&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Na sequência, e voltando ao arquivo &lt;span style="font-weight: bold;"&gt;Makefile.am&lt;/span&gt;, temos a definição da macro &lt;span style="font-weight: bold;"&gt;EXTRA_DIST&lt;/span&gt;, que irá informar ao utilitário &lt;span style="font-weight: bold; font-style: italic;"&gt;automake&lt;/span&gt; quais os arquivos que devem ser disponibilizados quando da geração do &lt;span style="font-weight: bold;"&gt;build&lt;/span&gt; de distribuição (aquele que fará parte do pacote de distribuição ao usuário do &lt;span style="font-style: italic;"&gt;sistema de software&lt;/span&gt;). No caso da biblioteca &lt;span style="font-weight: bold;"&gt;GMyth&lt;/span&gt; acima, os arquivos distribuídos são aqueles que incorporam &lt;span style="font-style: italic;"&gt;meta-dados&lt;/span&gt; &lt;span style="font-style: italic;"&gt;de informação&lt;/span&gt; ao pacote (&lt;span style="font-weight: bold;"&gt;AUTHORS&lt;/span&gt;, &lt;span style="font-weight: bold;"&gt;COPYING&lt;/span&gt;), além de &lt;span style="font-style: italic;"&gt;scripts&lt;/span&gt; úteis à geração do &lt;span style="font-weight: bold;"&gt;build&lt;/span&gt; (&lt;span style="font-style: italic;"&gt;autogen.sh&lt;/span&gt;) e um arquivo de configuração para resolução de dependências (&lt;span style="font-weight: bold; font-style: italic;"&gt;gmyth.pc.in&lt;/span&gt;), que serve como &lt;span style="font-style: italic;"&gt;arquivo de entrada&lt;/span&gt; para o utilitário &lt;span style="font-weight: bold;"&gt;pkg-config&lt;/span&gt;, que procura resolver as dependências de &lt;span style="font-style: italic;"&gt;biblioteca&lt;/span&gt; no ambiente constante à distribuição. Detalharemos depois o uso dessas outras ferramentas.&lt;br /&gt;&lt;br /&gt;No próximo post, detalharei mais a respeito do processamento do &lt;span style="font-weight: bold;"&gt;configure.ac&lt;/span&gt; através do autotools...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-1211624786175314150?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/1211624786175314150/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=1211624786175314150' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/1211624786175314150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/1211624786175314150'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2007/08/gnu-autotools-parte-ii-utilitrios.html' title='GNU Autotools (parte II) - Utilitários'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-6190619792280784265</id><published>2007-08-09T20:28:00.000-03:00</published><updated>2007-08-14T19:48:33.273-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gnu'/><category scheme='http://www.blogger.com/atom/ns#' term='autotools'/><category scheme='http://www.blogger.com/atom/ns#' term='makefile'/><category scheme='http://www.blogger.com/atom/ns#' term='autoconf'/><category scheme='http://www.blogger.com/atom/ns#' term='automake'/><title type='text'>Iniciando com GNU Autotools</title><content type='html'>Muita gente procura em sites para desenvolvedores informações sobre como usar as ferramentas da &lt;span style="font-weight: bold;"&gt;GNU&lt;/span&gt; para &lt;span style="font-weight: bold; font-style: italic;"&gt;gerenciamento de compilação de código-fonte&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;library linking&lt;/span&gt; com os binários, geração de &lt;span style="font-weight: bold;"&gt;bibliotecas&lt;/span&gt; e distribuição de &lt;span style="font-weight: bold;"&gt;código executável&lt;/span&gt;. Essas ferramentas são amplamenta conhecidas como &lt;span style="font-style: italic; font-weight: bold;"&gt;"autotools"&lt;/span&gt; (&lt;span style="font-weight: bold;"&gt;automake, autoconf, libtool&lt;/span&gt;, etc.), e são usadas com frequência em projetos de &lt;span style="font-style: italic;"&gt;software livre&lt;/span&gt;. E encontrar tais informações de uso, de forma simples e resumida, é tarefa que demanda a busca em inúmeros sites, bem como experimentações em linha de comando. Pra piorar, o mecanismo de funcionamento das &lt;span style="font-weight: bold;"&gt;autotools&lt;/span&gt; não é simples. Portanto, qual a real necessidade delas? Definindo da forma mais simples possível, &lt;span style="font-weight: bold; font-style: italic;"&gt;autotools&lt;/span&gt; são &lt;span style="font-weight: bold;"&gt;aplicativos e scripts de linha de comando&lt;/span&gt; que facilitam o trabalho do &lt;span style="font-style: italic;"&gt;desenvolvedor de aplicativos&lt;/span&gt; e &lt;span style="font-style: italic;"&gt;bibliotecas&lt;/span&gt; no trabalho de gerar e linkar um &lt;span style="font-style: italic;"&gt;código binário&lt;/span&gt;, por dinamizar a forma como esse produto vai ser disponibilizado em produção. Tal recurso provê meios de, automaticamente, buscar pela versão de uma biblioteca necessária para um determinado módulo do aplicativo, por exemplo. Isso é particularmente importante quando o &lt;span style="font-style: italic;"&gt;projeto de software&lt;/span&gt; é uma atividade desenvolvida através da &lt;span style="font-weight: bold; font-style: italic;"&gt;participação de membros em ambientes heterogêneos de desenvolvimento&lt;/span&gt;, facilitando o trabalho do programador no momento em que ele se vê, por exemplo, com uma dependência recém adicionada de biblioteca.&lt;br /&gt;&lt;br /&gt;Vou tentar mostrar aqui como iniciar o uso dos &lt;span style="font-weight: bold;"&gt;Makefiles&lt;/span&gt;. A princípio, não abordarei como se cria um &lt;span style="font-weight: bold;"&gt;Makefile&lt;/span&gt;, porque esse vem sendo continuamente um trabalho menos necessária, uma vez que ferramentas como o &lt;span style="font-style: italic;"&gt;automake&lt;/span&gt;/&lt;span style="font-style: italic;"&gt;autoconf&lt;/span&gt; já facilitam muita coisa, através de inúmeras macros de automação pré-definidas em &lt;span style="font-weight: bold;"&gt;M4&lt;/span&gt;, uma espécie de meta-linguagem funcional usada para adicionar recursos de configuração e busca aos &lt;span style="font-weight: bold;"&gt;Makefiles&lt;/span&gt;, tal como a macro &lt;span style="font-weight: bold;"&gt;M4&lt;/span&gt; chamada &lt;span style="font-weight: bold;"&gt;AC_CHECK_LIB,&lt;/span&gt; que checa no sistema de execução por uma biblioteca especificada, necessária para a distribuição. Me limitarei aqui a detalhar como começar um projeto em autoconf, que abstrai muitas das demandas de projetos complexos em &lt;span style="font-weight: bold;"&gt;Makefile&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Um arquivo de configuração &lt;span style="font-weight: bold;"&gt;GNU Make&lt;/span&gt; (&lt;span style="font-style: italic;"&gt;Makefile&lt;/span&gt;) simplesmente especifica regras (tasks, ou tarefas) de &lt;span style="font-style: italic;"&gt;compilação e geração de código com bibliotecas&lt;/span&gt;. Por exemplo, no arquivo &lt;span style="font-weight: bold;"&gt;Makefile&lt;/span&gt; abaixo:&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;pre&gt;&lt;br /&gt;%.o: %.c&lt;br /&gt;  $(CXX) -c $(CFLAGS) $(INCLUDES) $&amp;lt; -o $@  &lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;OBJ_FILES = gmu_dragwin.o gmu_dragwin_module.o  &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;TARGET = gmu_dragwin.so  &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;build: $(OBJ_FILES)      &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;     $(CXX) $(LDFLAGS) $(INCLUDES) $(LIBSPATH) $(OBJ_FILES) $(LIBS) -o $(TARGET)  &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;all: build&lt;br /&gt;&lt;/p&gt;&lt;/pre&gt;&lt;br /&gt;Aí vemos alguns conceitos importantes na definição de &lt;span style="font-weight: bold;"&gt;Makefiles&lt;/span&gt;: o conceito fundamental é o de &lt;span style="font-weight: bold;"&gt;tasks&lt;/span&gt; (tarefas) &lt;span style="font-weight: bold;"&gt;de manutenção&lt;/span&gt;, que são especificadas no texto acima por identificadores alfanuméricos seguidos de dois pontos. Daí temos a definição de 2 tasks básicas: &lt;span style="font-weight: bold;"&gt;build&lt;/span&gt; e &lt;span style="font-weight: bold;"&gt;all&lt;/span&gt;. A task build é simplesmente a que define a geração do produto específico do &lt;span style="font-style: italic;"&gt;Makefile&lt;/span&gt;, a meta básica decorrente da execução deste. Tanto que é ela que vai especificar como parâmetro último na geração a variável &lt;span style="font-weight: bold; font-style: italic;"&gt;$(TARGET)&lt;/span&gt;, que está definida mais acima como sendo o nome de arquivo de &lt;span style="font-weight: bold;"&gt;biblioteca&lt;/span&gt;,&lt;span style="font-style: italic;"&gt; "gmu_dragwin.so"&lt;/span&gt;, que é o nome do nosso componente. A &lt;span style="font-weight: bold;"&gt;task&lt;/span&gt; (ou &lt;span style="font-weight: bold;"&gt;target&lt;/span&gt;) "all" é simplesmente uma conveniência do &lt;span style="font-style: italic;"&gt;Makefile&lt;/span&gt; para que, caso não seja especificada taks alguma em momento de execução do procedimento de &lt;span style="font-weight: bold;"&gt;make&lt;/span&gt;, a taks build será a chamada default. A linha seguinte ao símbolo &lt;span style="font-weight: bold;"&gt;":"&lt;/span&gt; de definição do target é chamada de pré-requisito, porque a realização dessa task depende da execução sem erros de cada um dos &lt;span style="font-weight: bold;"&gt;pré-requisitos&lt;/span&gt; determinados. Portanto, digitar em&lt;span style="font-style: italic;"&gt; linha de comando&lt;/span&gt; o comando make, no mesmo nível de diretório em que se encontra o arquivo &lt;span style="font-weight: bold;"&gt;Makefile&lt;/span&gt; acima, irá resultar na geração dos códigos objetos e o arquivo &lt;span style="font-weight: bold;"&gt;gmu_dragwin.so&lt;/span&gt;, que se refere à biblioteca:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;# cd drawin_library&lt;br /&gt;# ls&lt;br /&gt;Makefile     gmu_dragwin.c    gmu_dragwin_module.c&lt;br /&gt;# make&lt;br /&gt;# ls&lt;br /&gt;Makefile      gmu_dragwin.c    gmu_dragwin_module.c&lt;br /&gt;gmu_dragwin.o    gmu_dragwin_module.o    gmu_dragwin.so&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;A chamada a &lt;span style="font-weight: bold;"&gt;make&lt;/span&gt; sem task nenhuma, faz com que a task &lt;span style="font-weight: bold;"&gt;all&lt;/span&gt; seja buscada como a padrão, que por sua vez em nosso Makefile redireciona a tarefa para a &lt;span style="font-weight: bold;"&gt;build&lt;/span&gt;. Na chamada a &lt;span style="font-weight: bold; font-style: italic;"&gt;make&lt;/span&gt;, poderia-se ter especificado a task desejada diretamente, tal como em: &lt;span style="font-weight: bold; font-style: italic;"&gt;make build&lt;/span&gt;. O resultado seria exatamente o mesmo.&lt;br /&gt;&lt;br /&gt;A terceira task no &lt;span style="font-weight: bold;"&gt;Makefile&lt;/span&gt; exemplo do texto acima é mais aprimorada, e admite um critério dinâmico para a necessidade de recompilação dos &lt;span style="font-weight: bold;"&gt;códigos-objeto&lt;/span&gt; dos arquivos fontes em &lt;span style="font-weight: bold;"&gt;linguagem C&lt;/span&gt;. A &lt;span style="font-weight: bold;"&gt;task %.o&lt;/span&gt; diz que toda referência no texto a qualquer&lt;span style="font-weight: bold;"&gt; pré-requisito&lt;/span&gt;, em qualquer target, que tenha um nome definido por uma sequência qualquer de caracteres alfanuméricos, seguido por uma string &lt;span style="font-weight: bold;"&gt;".o"&lt;/span&gt; (por sinal, uma extensão de arquivo objeto), fará com que seja automaticamente chamada essa&lt;span style="font-weight: bold;"&gt; task&lt;/span&gt;, que por sua vez verificará a efetividade de cada um dos &lt;span style="font-style: italic;"&gt;pré-requisitos&lt;/span&gt;. O primeiro pré-requisito será encontrar um arquivo de código-fonte com o mesmo nome do target, mas com extensão ".c":&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;%.o: %.c&lt;br /&gt;  $(CXX) -c $(CFLAGS) $(INCLUDES) $&lt; -o $@  &lt;/pre&gt;&lt;br /&gt;No &lt;span style="font-weight: bold;"&gt;pré-requisito&lt;/span&gt; seguinte, será chamado o compilador &lt;span style="font-weight: bold;"&gt;GCC&lt;/span&gt; (cujo caminho no sistema de arquivos é apontado pela variável &lt;span style="font-weight: bold;"&gt;$(CXX)&lt;/span&gt;) com os parâmetros detalhados no target acima como sendo &lt;span style="font-weight: bold;"&gt;$&lt;&lt;/span&gt;, que se refere ao nome do &lt;span style="font-weight: bold;"&gt;arquivo-fonte&lt;/span&gt; (por exemplo, &lt;span style="font-weight: bold;"&gt;gmu_dragwin.c&lt;/span&gt;); e a variável &lt;span style="font-weight: bold;"&gt;$@&lt;/span&gt; aponta para o valor corrente do nome do target (p.e., &lt;span style="font-weight: bold;"&gt;gmu_dragwin.o&lt;/span&gt;). Esses &lt;span style="font-style: italic;"&gt;recursos de substituição&lt;/span&gt; são amplamente utilizados, uma vez que permitem que o Makefile defina dinamicamente suas próprias regras, e são chamados de &lt;span style="font-weight: bold;"&gt;"regras de substituição"&lt;/span&gt; (&lt;span style="font-style: italic;"&gt;pattern rules&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;Uma vez tendo fundamentado os &lt;span style="font-weight: bold;"&gt;conceitos básicos&lt;/span&gt; de &lt;span style="font-style: italic;"&gt;Makefile&lt;/span&gt;, veremos na sequência os detalhes de como as ferramentas de &lt;span style="font-weight: bold;"&gt;autotools&lt;/span&gt; criam tudo isso de forma mais prática, permitindo a definição de regras mais avançadas de configuração.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-6190619792280784265?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/6190619792280784265/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=6190619792280784265' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/6190619792280784265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/6190619792280784265'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2007/08/iniciando-com-gnu-autotools.html' title='Iniciando com GNU Autotools'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-2654415666254304024</id><published>2007-05-12T20:08:00.000-03:00</published><updated>2007-05-12T20:29:14.243-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='software development'/><category scheme='http://www.blogger.com/atom/ns#' term='digital tv'/><category scheme='http://www.blogger.com/atom/ns#' term='mythtv'/><category scheme='http://www.blogger.com/atom/ns#' term='gmyth'/><category scheme='http://www.blogger.com/atom/ns#' term='gcov'/><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><title type='text'>Real Case Application of Coverage Tests on Linux - Part 3</title><content type='html'>These special topics on&lt;span style="font-style: italic;"&gt; coverage tests &lt;/span&gt;I made are based on real case situations of tests implementation, when I used to think about a nice way to certify that the &lt;span style="font-style: italic;"&gt;user requirements &lt;/span&gt;needs related to a &lt;span style="font-weight: bold;"&gt;MythTV protocol API&lt;/span&gt; implementation I´m developing are well concerned. This API is not the official one, based on the &lt;a href="http://www.mythtv.org"&gt;MythTV server and client&lt;/a&gt; implementations, but another totally different effort based on &lt;span style="font-weight: bold; font-style: italic;"&gt;GObject/GLib frameworks and object model&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;main test architecture &lt;/span&gt;I had developed is to allow that the test script's writer could develops the &lt;span style="font-style: italic;"&gt;testing scripts&lt;/span&gt; with the minimum possible effort. So, I choose to use &lt;span style="font-weight: bold;"&gt;Python &lt;/span&gt;as the language of choice on the test scripts, because it's easier to learn, and removes the extra step of compiling code, because &lt;span style="font-weight: bold;"&gt;Python &lt;/span&gt;is interpreted. Each one of these &lt;span style="font-style: italic; font-weight: bold;"&gt;Python scripts&lt;/span&gt; do, at least, one basic task: start a process with the testing program, compiled with the gcov program line arguments. A very &lt;span style="font-style: italic;"&gt;simple strategy&lt;/span&gt; had been used to guarantee that the process testing stoped at a given known time, and the &lt;span style="font-weight: bold; font-style: italic;"&gt;Python script&lt;/span&gt; could be signalized about the program termination.&lt;br /&gt;&lt;br /&gt;You can see all these concepts, and see how to code gcov-based tests in practice, seeing my contribution on &lt;a href="http://sourceforge.net/projects/gmyth"&gt;GMyth's SourceForge&lt;/a&gt;: &lt;span style="font-style: italic;"&gt;http://sourceforge.net/projects/gmyth&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Have a lot of fun! :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-2654415666254304024?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/2654415666254304024/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=2654415666254304024' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/2654415666254304024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/2654415666254304024'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2007/05/real-case-application-of-coverage-tests.html' title='Real Case Application of Coverage Tests on Linux - Part 3'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-8474787731407623348</id><published>2007-05-10T20:01:00.000-03:00</published><updated>2007-05-12T20:30:51.169-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lcov'/><category scheme='http://www.blogger.com/atom/ns#' term='gnu'/><category scheme='http://www.blogger.com/atom/ns#' term='gcc'/><category scheme='http://www.blogger.com/atom/ns#' term='digital tv'/><category scheme='http://www.blogger.com/atom/ns#' term='coverage test'/><category scheme='http://www.blogger.com/atom/ns#' term='gcov'/><category scheme='http://www.blogger.com/atom/ns#' term='tests'/><title type='text'>More on Coverage Tests on Linux - Generating Better Reports</title><content type='html'>At the last post, I showed up some code that could be interesting for testing purposes, and to see how the &lt;span style="font-weight: bold;"&gt;gcov&lt;/span&gt; do these &lt;span style="font-style: italic;"&gt;automatic testing procedures&lt;/span&gt;. In fact, &lt;span style="font-weight: bold;"&gt;gcov&lt;/span&gt; uses a number of techniques to cover a given test code. Internally, we can say that &lt;span style="font-weight: bold;"&gt;gcov&lt;/span&gt; will insert into your program object file, some kind of &lt;span style="font-style: italic;"&gt;meta-code&lt;/span&gt;, which will try for a large number of &lt;span style="font-style: italic;"&gt;meaningful execution paths&lt;/span&gt;. So, it uses some know strategies to select what are the &lt;span style="font-style: italic;"&gt;most effective paths&lt;/span&gt; he must to cover, because is theoretically impossible just try&lt;span style="font-style: italic;"&gt; to cover all the possible situations&lt;/span&gt; when a program is running.&lt;br /&gt;&lt;br /&gt;There are &lt;span style="font-weight: bold; font-style: italic;"&gt;2 main types of coverage&lt;/span&gt;: &lt;span style="font-style: italic;"&gt;branch coverage&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;loop coverage&lt;/span&gt;. Just to give you an idea, in the &lt;span style="font-style: italic;"&gt;branch coverage&lt;/span&gt;, it is important to verify that &lt;span style="font-weight: bold;"&gt;every branch has been taken&lt;/span&gt;. When it uses the loop coverage, &lt;span style="font-weight: bold;"&gt;gcov&lt;/span&gt; try to take all the &lt;span style="font-style: italic;"&gt;execution paths&lt;/span&gt; through a loop. To see more about gcov and some information about some internal working issues, refer to &lt;span style="font-style: italic;"&gt;http://gcc.gnu.org/onlinedocs/gcc/Gcov.html&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Since our &lt;span style="font-weight: bold;"&gt;gcov&lt;/span&gt; execution at the last article produced some files that encapsulates all the information above, we'd got almost all we need. But could be better if we could put all the data collected from &lt;span style="font-weight: bold;"&gt;gcov&lt;/span&gt; in a more beautiful and useful way. That is what a tool called &lt;span style="font-weight: bold;"&gt;lcov&lt;/span&gt; do:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;lcov -d . -c -o test_gcov.info&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;This simple command will search for the files generated by &lt;span style="font-weight: bold; font-style: italic;"&gt;gcov&lt;/span&gt; (&lt;span style="font-weight: bold;"&gt;*.gcda, *.gcno&lt;/span&gt;) at the current (".") directory (&lt;span style="font-weight: bold;"&gt;-d option&lt;/span&gt;), and put this in the &lt;span style="font-weight: bold;"&gt;test_gcov.info&lt;/span&gt;. This file has the collected information about the &lt;span style="font-style: italic;"&gt;program execution&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;automatic testing&lt;/span&gt;, but is not yet in a &lt;span style="font-style: italic;"&gt;human-readable form&lt;/span&gt;. But we can put this file as an input to a very useful tool, &lt;span style="font-weight: bold;"&gt;genhtml&lt;/span&gt;:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;genhtml test_gcov.info&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;After this program script finishes execution, type "ls" on your prompt and see what it had just created: a lot of images (&lt;span style="font-weight: bold;"&gt;.png&lt;/span&gt;), &lt;span style="font-weight: bold;"&gt;CSS&lt;/span&gt; (&lt;span style="font-style: italic;"&gt;cascading style sheets&lt;/span&gt;)  and &lt;span style="font-weight: bold;"&gt;HTML&lt;/span&gt; files. Open the &lt;span style="font-weight: bold;"&gt;"index.html"&lt;/span&gt; in your preferable browser, and it will show you how powerful this tool can really be, as a valuable way to certify that your &lt;span style="font-style: italic;"&gt;test scripts are covering the software requirements&lt;/span&gt; initially specified, which test cases are important, and if you can find some dead code that you can throw off.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-8474787731407623348?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/8474787731407623348/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=8474787731407623348' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/8474787731407623348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/8474787731407623348'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2007/05/more-on-coverage-tests-on-linux.html' title='More on Coverage Tests on Linux - Generating Better Reports'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-55960617723065869</id><published>2007-05-04T11:00:00.000-03:00</published><updated>2007-05-12T20:31:58.684-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='genhtml'/><category scheme='http://www.blogger.com/atom/ns#' term='lcov'/><category scheme='http://www.blogger.com/atom/ns#' term='glib'/><category scheme='http://www.blogger.com/atom/ns#' term='gobject'/><category scheme='http://www.blogger.com/atom/ns#' term='mythtv'/><category scheme='http://www.blogger.com/atom/ns#' term='ltp'/><category scheme='http://www.blogger.com/atom/ns#' term='gmyth'/><category scheme='http://www.blogger.com/atom/ns#' term='gcov'/><title type='text'>Coverage Tests on Linux</title><content type='html'>Every time you want to add a new &lt;span style="font-style: italic;"&gt;test case&lt;/span&gt; to your &lt;span style="font-weight: bold;"&gt;software implementation&lt;/span&gt; (i.e., a &lt;span style="font-style: italic;"&gt;library,&lt;/span&gt; a &lt;span style="font-style: italic;"&gt;framework,&lt;/span&gt; a &lt;span style="font-style: italic;"&gt;network server&lt;/span&gt;), your client may want to know how these tests are being done, if the &lt;span style="font-style: italic;"&gt;test specifications &lt;/span&gt;corresponds to the &lt;span style="font-style: italic;"&gt;software requisites&lt;/span&gt;, and how much of these functionalities are being covered by the &lt;span style="font-style: italic; font-weight: bold;"&gt;test cases&lt;/span&gt;. It may be difficult to say to anyone that is not a real &lt;span style="font-style: italic;"&gt;hacker&lt;/span&gt;, or doesn't know so much about your implementation, that your tests are being effective. In order to allow that your test case script start reporting how much it has been covering from the target implentation, there is a tool that you can use: &lt;span style="font-weight: bold;"&gt;GCOV&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;LCOV&lt;/span&gt;&lt;span&gt;, a great effort from the &lt;a href="http://ltp.sourceforge.net/"&gt;&lt;span style="font-weight: bold;"&gt;LTP group&lt;/span&gt;&lt;/a&gt;.&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;These &lt;span style="font-style: italic;"&gt;coverage testing tools &lt;/span&gt;can be helpful to you that want a kind of automatic process to determine how much of the code is actually being covered by your tests, which is always an indirect measure, but it works. And its very important to know that coverage tests cannot find &lt;span style="font-style: italic;"&gt;logical errors&lt;/span&gt; in a program! The code coverage analysis is very well discussed in the &lt;span style="font-weight: bold;"&gt;software testing&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;quality assurance&lt;/span&gt; fields of software development, and I will show now how you can start using them to help you on your tests.&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;At first, you should compile the programs you want to be covered with 2 special &lt;span style="font-weight: bold;"&gt;GCC&lt;/span&gt; parameters:  &lt;span style="font-weight: bold;"&gt;-fprofile-arcs&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;-ftest-coverage.&lt;/span&gt; If you want to apply &lt;span style="font-style: italic;"&gt;coverage testing&lt;/span&gt; to an API you are developing, certainly you should add these parameters to all source code being compiled (if you are using &lt;span style="font-style: italic;"&gt;autoconf,&lt;/span&gt; add this to the &lt;span style="font-weight: bold;"&gt;CFLAGS&lt;/span&gt; variable, on &lt;span style="font-style: italic;"&gt;configure.{ac,in}&lt;/span&gt;). This will cause the &lt;span style="font-weight: bold;"&gt;GCC&lt;/span&gt; compiler to add special symbols inside the generated object files.&lt;br /&gt;&lt;br /&gt;Now let's compile some code, including in there the coverage information. Here is a code example that will certainly fall into some &lt;span style="font-weight: bold;"&gt;memory error&lt;/span&gt; and cause incomplete code execution:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/code&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main( argc, argv )&lt;br /&gt;     int argc;&lt;br /&gt;     char **argv;&lt;br /&gt;{&lt;br /&gt;     int x;&lt;br /&gt;     char **str = (char**)malloc(20 * sizeof(char*));&lt;br /&gt;     for ( x = 0; x &amp;lt; 23; x++ )&lt;br /&gt;     {&lt;br /&gt;             str[x] = malloc( 3 * sizeof (char) );&lt;br /&gt;             if ( NULL == str[x] )&lt;br /&gt;                     exit(-1);&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;stdlib.h&gt;&lt;stdio.h&gt; &lt;/stdio.h&gt;&lt;/stdlib.h&gt;Now, compile the code above with the following line:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;blockquote&gt;gcc -ftest-coverage -fprofile-arcs test_gcov.c -o test_gcov  &lt;/blockquote&gt;&lt;/span&gt;This will generate not only the &lt;span style="font-weight: bold;"&gt;test_gcov&lt;/span&gt; executable object, but another important &lt;span style="font-weight: bold;"&gt;GCOV&lt;/span&gt; object structure, which you can see as &lt;span style="font-weight: bold;"&gt;test_gcov.gcno&lt;/span&gt;. This is only part of the things you need to do before running the tests using the types of coverage GCOV do to you. After this .gcno file is generated, you should execute the application:&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="font-weight: bold;"&gt;./test_gcov&lt;/blockquote&gt;&lt;br /&gt;This will create another important file, &lt;span style="font-weight: bold;"&gt;test_gcov.gcda&lt;/span&gt;. With this &lt;span style="font-weight: bold;"&gt;test run description file&lt;/span&gt;, the &lt;span style="font-weight: bold;"&gt;"gcov"&lt;/span&gt; tool will inform you about how much percent you program could be covered by its automatic testing procedures. So you can run gcov passing the test_gcov source code to be analyzed:&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="font-weight: bold;"&gt;gcov test_gcov.c&lt;/blockquote&gt;&lt;br /&gt;And you will see something like the following:&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="font-weight: bold;"&gt;File 'test_gcov.c'&lt;br /&gt;Lines executed:85.71% of 7&lt;br /&gt;test_gcov.c:creating 'test_gcov.c.gcov'&lt;/blockquote&gt;Next, we will see how to make better reports over your &lt;span style="font-weight: bold;"&gt;coverage test scripts&lt;/span&gt;, presenting them in &lt;span style="font-weight: bold;"&gt;.HTML&lt;/span&gt;, and showing these percentages for each line of covered code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-55960617723065869?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/55960617723065869/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=55960617723065869' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/55960617723065869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/55960617723065869'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2007/05/coverage-tests-on-linux.html' title='Coverage Tests on Linux'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-113344745278588718</id><published>2005-12-01T11:01:00.000-03:00</published><updated>2005-12-01T11:30:52.876-03:00</updated><title type='text'>Nokia launched the first UPnP enabled device</title><content type='html'>&lt;span class="down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;br /&gt;   Last 29 November (tuesday), &lt;span style="font-weight: bold;"&gt;Nokia&lt;/span&gt; announced the first mobile device that is able to aply &lt;span style="font-weight: bold;"&gt;UPnP&lt;/span&gt; for doing ubiquitous (seamless) home media networking. The &lt;span style="font-weight: bold;"&gt;Nokia N80&lt;/span&gt; was released with 2 another new devices, the N71 and N92, in the beggining of november. Using N80, you will now do things like listen to music stored on your computer (or through a UPnP-enabled living room audio system), or send photos or slides from your N80 to be presented on your home TV-set. The device can send files to be wirelessly printed on a printing kiosk, or a UPnP compatible printer. Since it is using UPnP, discovering of these devices is almost automatic, users don't need to know too much about the network infrasctructure.&lt;br /&gt;   A &lt;span style="font-weight: bold;"&gt;3-MegaPixel digital camera&lt;/span&gt; is another very good feature in this mobile device. And it has the same size of a credit card. But the features that are more impressive are the ones related with &lt;span style="font-weight: bold;"&gt;UPnP.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;See below:&lt;br /&gt;&lt;a href="http://www.connecting.nokia.com/NOKIA/nns.nsf/a/66B83764C6903DE6C22570C0004928A3"&gt;http://www.connecting.nokia.com/NOKIA/nns.nsf/a/66B83764C6903DE6C22570C0004928A3&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-113344745278588718?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/113344745278588718/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=113344745278588718' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/113344745278588718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/113344745278588718'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2005/12/nokia-launched-first-upnp-enabled.html' title='Nokia launched the first UPnP enabled device'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-112933307479474633</id><published>2005-10-14T19:57:00.000-03:00</published><updated>2005-10-14T20:45:55.253-03:00</updated><title type='text'>Quine: Self-reproducing programs</title><content type='html'>Last week, I saw something that is, at least, an excentricity. There is some of &lt;span style="font-weight: bold;"&gt;Logic&lt;/span&gt; and Computer Theory inside of such things, but not necessarily you must to read a lot of Mathematics theory books to understand it. And that is the funniest thing in see this examples!&lt;br /&gt;Tell me, what the program below, written in &lt;span style="font-weight: bold;"&gt;C language&lt;/span&gt;, is wanting to do? It seems, at first, not so difficult...&lt;br /&gt;&lt;pre&gt;char a[] = "int main(){ printf(b,34,a,34,10,34,b,34,10,10,a,10); }";&lt;br /&gt;char b[] = "char a[] = %c%s%c;%cchar b[] = %c%s%c;%c%c%s%c";&lt;br /&gt;&lt;br /&gt;int main(){ printf(b,34,a,34,10,34,b,34,10,10,a,10); }&lt;br /&gt;&lt;/pre&gt; We can see &lt;span style="font-weight: bold;"&gt;two variable declarations&lt;/span&gt;. Next thing we observe is that these variables are characters arrays. And the content of the first variable (named &lt;span style="font-weight: bold;"&gt;"a"&lt;/span&gt;), seems to follow a familiar syntax, which computer hackers frequently uses for writing computer programs. So, the application above is doing only one thing: it is writing itself! It is interesting to pay attention to how these great programmers deals with the high an lows of the languages... (such as, variable scope, the time between the instant the variables starts living, and the moment the variable would not be referenced anymore). Maybe another example, only to show how it works... (coded using the Python language)&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;a = ['print "a =", a', 'for s in a: print s']&lt;br /&gt;print "a =", a&lt;br /&gt;for s in a: print s&lt;br /&gt;&lt;/pre&gt; &lt;pre&gt;(Author: Omar Antolin - omar@galois.fciencias.unam.mx)&lt;/pre&gt; Or another great quine example in C language (it is not only a self-printing, it is a palindrome too!):&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;/**/char q='"',*a="*//**/char q='%c',*a=%c%s%c*/};)b(stup;]d[b=]d-852&lt;br /&gt;[b)--d(elihw;)q,a,q,q,2+a,b(ftnirps{)(niam;031=d tni;]952[b,",b[259];&lt;br /&gt;int d=130;main(){sprintf(b,a+2,q,q,a,q);while(d--)b[258-d]=b[d];puts(&lt;br /&gt;b);}/*c%s%c%=a*,'c%'=q rahc/**//*"=a*,'"'=q rahc/**/&lt;br /&gt;&lt;/pre&gt; &lt;pre&gt;Author: Dan Hoey&lt;/pre&gt;&lt;br /&gt;Maybe you think that it is not a &lt;span style="font-weight: bold;"&gt;great problem&lt;/span&gt;. But, can you make a program that can write its own contents? We may consider a major difficulty: you will write a program, and you will try to not do it so difficulty, because you want to print all source code on the screen - as much code you write, much more work you will have to print the contents. Remembering that you must to write everything, including all commands and instruction used to print and to present results on the screen! :)&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Self-reproducing programs&lt;/span&gt; are not a so recent idea, and a very famous phylosopher and logician, called &lt;a href="http://www.wvquine.org/"&gt;&lt;span style="font-weight: bold;"&gt;Willard van Orman Quine&lt;/span&gt;&lt;/a&gt; (1908-2000). He made many contributions to the phylosophy of language and phylosophy of &lt;span style="font-weight: bold;"&gt;Logic.&lt;/span&gt; He made a lot of works, such an improved normalization methodology enabling better &lt;span style="font-weight: bold;"&gt;optimization of SQL      queries&lt;/span&gt;, for example. And was he that give his name to the concept of a program that can reproduce itself, or its own source code...&lt;br /&gt;You can see a lot of references (and source codes) in this site, illustrating "quine": &lt;a href="http://www.nyx.net/%7Egthompso/quine.htm"&gt;http://www.nyx.net/~gthompso/quine.htm&lt;span class="down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-112933307479474633?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/112933307479474633/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=112933307479474633' title='2 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/112933307479474633'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/112933307479474633'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2005/10/quine-self-reproducing-programs.html' title='Quine: Self-reproducing programs'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-112855392307237977</id><published>2005-10-05T19:24:00.000-03:00</published><updated>2005-10-05T20:16:37.026-03:00</updated><title type='text'>O Governo querendo dar armas para os bandidos???</title><content type='html'>Pois é, esse é mais um assunto que dá o que falar. E não é por menos...&lt;br /&gt;Uma coisa estranha aconteceu a poucos meses, o Governo quer que nós votemos "sim" no plebiscito. Para quê será???&lt;br /&gt;Pra começar, tal referendo nem deveria existir. Pessoalmente, sou contra essa política de querer colocar uma responsabilidade tão complexa nas mãos de pessoas como nós, que não somos especialistas em Segurança Pública. Mas, sim, é verdade, eu voto NÃO! &lt;span style="font-weight: bold;"&gt;Eu sou contra o desarmamento!!!&lt;/span&gt; Porquê?&lt;br /&gt;Existem várias razões para isso: imagine o que pensará o bandido que costuma assaltar à mão armada, depois que souber que as casas já não podem guardar armas de fogo? O que antes era permitido (ter uma arma em casa), depois que essa campanha da Globo der certo (o que, infelizmente, está acontecendo... a Globo sempre teve uma grande influência com as massas...), se tornará algo proibido. Sim, você acha inseguro ter uma arma em casa, só que o bandido acha que é SEGURO pra ele você NÃO TER!!! Ou seja, se você não tiver uma arma em casa, por opção, ou porque você resolveu doá-la ao Governo (e lógico que o bandido vai conseguir se convencer disso com mais facilidade se esse referendo for votado com inúmeros SIM), o bandido vai se sentir mais seguro de entrar nela, roubar os seus pertences, talvez te agredir gravemente (na verdade, MUITO gravemente... ou você acha que os bandidos vão passar a andar desarmados depois dessa lei?). E os bandidos vão se sentir mais seguros porque SABE que você PODE (por ser um bom cidadão...) não guardar uma arma.&lt;br /&gt;Eu acho que o governo resolveu tocar numa ferida que já demorava a cicatrizar, e que agora foi reaberta. Antes, nós simples cidadãos, poderíamos ter essa arma tão efetiva que é a dúvida: se o ladrão não sabe que você tem arma em casa, ele não vai dar tiro no escuro. Caso contrário, para eles às vezes é até vantajoso apostar nisso e ver no que dá... Talvez, para benefício da maleficência, ele leve embora o seu aparelho de DVD e a sua vida.&lt;br /&gt;Estão tirando um benefício pacífico, que é nosso, de nos defender com uma arma incólume, que é a dúvida, plantada com cuidado nas cabeças dos marginais que ficam de plantão em frente de tua casa, e que agora vão olhar com mais cuidado a quantas andam esse processo do Governo de derrubada da &lt;span style="font-weight: bold;"&gt;Segurança Pública&lt;/span&gt;...&lt;br /&gt;Sou contra as armas, mas talvez seja uma boa idéia comprar uma.&lt;br /&gt;Seria uma idéia melhor ainda que TODOS pensassem em comprar armas agora, antes que não seja mais possível (quem sabe...). Talvez você nem queira comprar mesmo uma arma, mas seria bom que pensasse, digamos, 5 minutos em comprar uma.&lt;br /&gt;Se todos pensassem nisso, a gente consiga plantar de novo na cabeça dos marginais que o nosso lar, o lugar onde você convive, com a sua família, seus pais, sua mulher e seus filhos, é sagrado e inviolável, e que, caso contrário, a vida do próprio bandido estará em risco.&lt;br /&gt;Eu prefiro esse benefício da dúvida amargando bem ácida no estômago dos marginais. É por isso que eu sou contra o desarmamento, e a favor da vida e do respeito.&lt;br /&gt;Uma bela e concisa &lt;a href="http://veja.abril.com.br/051005/p_076.html"&gt;matéria na Veja&lt;/a&gt;: http://veja.abril.com.br/051005/p_076.html&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Não confiem no Governo, o Governo não confia em vocês.&lt;/span&gt; Quem proíbe a venda de armas e impede que pessoas de bem a possuam, é porque não confia na força e na inteligência da população. Cuidem disso antes que seja tarde.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-112855392307237977?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/112855392307237977/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=112855392307237977' title='1 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/112855392307237977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/112855392307237977'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2005/10/o-governo-querendo-dar-armas-para-os.html' title='O Governo querendo dar armas para os bandidos???'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-112748743325901129</id><published>2005-09-23T11:52:00.000-03:00</published><updated>2005-10-05T20:25:37.320-03:00</updated><title type='text'>Contando de 1 a 100 (ANSI C)</title><content type='html'>É o quê, hômi?&lt;br /&gt;Contando de &lt;span style="font-weight: bold;"&gt;1 a 100&lt;/span&gt;, sem uso de condicionais (if-then), nem loops. Lembrem que os operadores lógicos também não são permitidos (&amp;&amp;amp;, ||, etc...). Mas, porque não pode usar os operadores lógicos?&lt;br /&gt;Porque dizer "sem instruções condicionais", significa "sem operadores condicionais" em &lt;span style="font-weight: bold;"&gt;C&lt;/span&gt;. Isso se justifica pelo fato que todas as expressões em C (e &lt;span style="font-weight: bold;"&gt;C++&lt;/span&gt;) são sentenças (statements), uma vez que você sempre pode ignorar o resultado de uma expressão. E todos os operadores (incluindo os binários - &amp;&amp;amp;, ||, ~, etc. - e unários) são também expressões, logo (juntando 1 com 2 na breve demonstração acima) todos os operadores são também sentenças.&lt;br /&gt;&lt;br /&gt;(código obtido de &lt;span style="font-weight: bold;"&gt;Sitikant Sahu&lt;/span&gt;/Índia)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;void func2(int lower,int upper);&lt;br /&gt;void func(int lower,int upper)&lt;br /&gt;{&lt;br /&gt;printf("%d\n",upper);&lt;br /&gt;func2(lower,--upper);&lt;br /&gt;}&lt;br /&gt;void func3(int lower,int upper)&lt;br /&gt;{&lt;br /&gt;exit(-1);&lt;br /&gt;}&lt;br /&gt;void func2(int lower,int upper)&lt;br /&gt;{&lt;br /&gt;void (*a)(int,int);&lt;br /&gt;a = ((int)(&amp;func) * !(!(upper-lower))) + ((int)(&amp;amp;func3) * (!(upper-lower))) ;&lt;br /&gt;a(lower,upper);&lt;br /&gt;}&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;int lower,upper;&lt;br /&gt;scanf("%d",&amp;lower);&lt;br /&gt;scanf("%d",&amp;upper);&lt;br /&gt;&lt;br /&gt;func2(lower-1,upper);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-112748743325901129?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/112748743325901129/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=112748743325901129' title='2 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/112748743325901129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/112748743325901129'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2005/09/contando-de-1-100-ansi-c.html' title='Contando de 1 a 100 (ANSI C)'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-112740857424842598</id><published>2005-09-22T13:38:00.000-03:00</published><updated>2005-09-23T09:52:56.076-03:00</updated><title type='text'>UPnP CyberLink</title><content type='html'>Last month (august, 1st), an &lt;span style="font-weight: bold;"&gt;UPnP library&lt;/span&gt; I suggested to the OSSO &lt;span style="font-weight: bold;"&gt;Connectivity&lt;/span&gt; group personnel, was delivered on SourceForge. The new was sent on the &lt;a href="http://www.cybergarage.org/blog/archive/2005_08_01_skonnoblog.html"&gt;Satoshi's Blog: &lt;code&gt;http://www.cybergarage.org/blog/archive/2005_08_01_skonnoblog.html&lt;/code&gt;&lt;/a&gt;&lt;br /&gt;Satoshi Konno is an engineer from Japan, and the main developer of &lt;a href="http://sourceforge.net/projects/clinkc"&gt;CyberLink for C&lt;/a&gt; library. He made 2 (two) more versions of CyberLink before: one for &lt;a href="http://sourceforge.net/projects/clinkcc"&gt;C++&lt;/a&gt; programmers, and another for &lt;a href="http://sourceforge.net/projects/cgupnpjava"&gt;Java&lt;/a&gt; developers. I made some contributions for this and the old (C++) release...&lt;br /&gt;This is a very good new; OSSO is wanting for something non-C++ related for his UPnP applications, and the very stable version of CyberLink was, until then, the C++ release. This one is a very complete implementation, with a lot of features, like most of &lt;span style="font-weight: bold;"&gt;AV&lt;/span&gt; (audio-visual) aspects of UPnP. The C version of CyberLink only needs this missing AV features, but is very stable and well optimized, and was ready for working in embedded devices, like the japanese device &lt;a href="http://www.t-engine.org/index.html"&gt;T-Engine&lt;/a&gt; (in japanese; only &lt;a href="http://leosobral.blogspot.com/"&gt;Sobral&lt;/a&gt; would be able to read this page, I guess!) :)&lt;br /&gt;This, definitely, is not the first effort to construct a stable UPnP implementation: several developers around the world invest his own time to create UPnP APIs, and some enterprises, like &lt;span style="font-weight: bold;"&gt;Intel&lt;/span&gt; made one implementation too. I had opportunity to use some of them... But I think CyberLink is the most well-designed and "developer friendly" UPnP library. And it is free (it has a &lt;span style="font-weight: bold;"&gt;BSD&lt;/span&gt; license).&lt;br /&gt;&lt;br /&gt;&lt;span class="" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;span class="" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;span class="down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-112740857424842598?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/112740857424842598/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=112740857424842598' title='1 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/112740857424842598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/112740857424842598'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2005/09/upnp-cyberlink.html' title='UPnP CyberLink'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16984085.post-112734066552774804</id><published>2005-09-21T18:59:00.000-03:00</published><updated>2005-09-21T19:11:05.530-03:00</updated><title type='text'>Primeiro Post do Garoto Hipotenusa</title><content type='html'>Depois de muito insistir em não criar esse blog, e após tanta pressão, criei agora um blog público, junto com a galera do &lt;span style="font-weight: bold;"&gt;Instituto&lt;/span&gt;.&lt;br /&gt;Devo dizer que não é meu primeiro blog. Tenho outros blogs, alguns fictícios (para extravasar minha parte criativa!), outros diários pessoais, ou de grupos do qual participo (ou participei). Apesar da grande insistência: não, não vou dizer quais os nomes desse blogs! ;) Apenas espero que vocês continuem dando uma olhada por aqui, e que encontrem sempre coisas curiosas e interessantes...&lt;br /&gt;Não vou escrever muita coisa aqui, quem quiser, pode dar uma olhada no meu perfil no &lt;a href="http://www.orkut.com/Home.aspx?xid=1511306046830256280"&gt;Orkut&lt;/a&gt;: http://www.orkut.com/Home.aspx?xid=1511306046830256280&lt;br /&gt;Voltar agora pra essa loucura de bateria de &lt;span style="font-weight: bold;"&gt;testes&lt;/span&gt; que não acaba nunca...&lt;span class="" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16984085-112734066552774804?l=garotohipotenusa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://garotohipotenusa.blogspot.com/feeds/112734066552774804/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16984085&amp;postID=112734066552774804' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/112734066552774804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16984085/posts/default/112734066552774804'/><link rel='alternate' type='text/html' href='http://garotohipotenusa.blogspot.com/2005/09/primeiro-post-do-garoto-hipotenusa.html' title='Primeiro Post do Garoto Hipotenusa'/><author><name>Rosfran Borges</name><uri>http://www.blogger.com/profile/04921510796685794819</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='18' height='32' src='http://images3.orkut.com/images/medium/704/161704.jpg'/></author><thr:total>0</thr:total></entry></feed>
