\input cwebmac
% Z� Augusto 8/98

\documentclass[language=brazil,structure=flat]{cweb}

%% Escrevendo em portugu�s:
\usepackage[brazil]{babel}
\usepackage[T1]{fontenc}
%----------------------------

\setlength{\topmargin}{-0.5in}
\setlength{\textheight}{9in}
\setlength{\oddsidemargin}{-.125in}
\setlength{\evensidemargin}{-.125in}
\setlength{\textwidth}{6.75in}

\begin{document}




\title{Grava��o e Recupera��o de Grafos com nomes contendo caracters
  acentuados}
\author{Z� Augusto}

\maketitle

\tableofcontents


\N{3}{1}Descri��o.
Este programa em \texttt{CWEB} permite a grava��o e recupera��o de
grafos com nomes onde aparecem caracteres acentuados.

Se tentarmos a grava��o usando diretamente o \PB{\\{save\_graph}}, a mensagem
abaixo � acrescentada no final do arquivo em disco.
\begin{verbatim}
> WARNING: I had trouble making this file from the given graph!
>> At least one string character had to be changed to '?'.
> You should be able to read this file with restore_graph,
> but the graph you get won't be exactly like the original.
\end{verbatim}

Para evitar que isso n�o aconte�a, temos que codificar os caracteres
acentuados antes de grava��o e decodific�-los na hora da restaura��o.

\fi

\M{2}Em linhas gerais, este m�dulo tem a seguinte organiza��o. As
defini��es de tamanhos de strings vem de \PB{\\{gb\_save}}.

\Y\B\4\D$\.{MAX\_SV\_STRING}$ \5
\T{4095}\C{ longest strings supported }\par
\B\4\D$\.{MAX\_SV\_ID}$ \5
\T{154}\C{ longest \PB{\\{id}} supported, is less than \PB{\.{ID\_FIELD\_SIZE}}
}\par
\Y\B\8\#\&{include} \.{"gb\_graph.h"}\C{ A estrutura de dados para criar o
grafo }\6
\8\#\&{include} \.{"gb\_save.h"}\C{ e para salvar e recuperar o grafo }\6
\X11:Fun��es Privadas\X\6
\X3:Fun��es Externas\X\par
\fi

\M{3}Este arquivo gera duas fun��es externas.

\Y\B\4\X3:Fun��es Externas\X${}\E{}$\6
\X5:Grava��o de um Grafo em Arquivo\X\6
\X6:Recupera��o de um Grafo de um Arquivo\X\par
\U2.\fi

\M{4}Essas rotinas devem ser usadas por outros programas. Para tanto,
vamos gerar um arquivo de \PB{\\{header}}.

\Y\B\4\X4:\.{gb\_salva.h }\X${}\E{}$\6
\&{extern} \&{long} \\{salva\_grafo}(\,);\C{ similar ao \PB{\\{save\_graph}} }\6
\&{extern} \&{Graph} ${}{*}\\{restaura\_grafo}(\,){}$;\C{ similar ao \PB{%
\\{restore\_graph}} }\par
\fi

\N{3}{5}Grava��o de um Grafo em Arquivo.

\Y\B\4\X5:Grava��o de um Grafo em Arquivo\X${}\E{}$\6
\&{long} ${}\\{salva\_grafo}(\|g,\39\|f){}$\1\1\6
\&{Graph} ${}{*}\|g{}$;\C{ grafo a ser salvo }\6
\&{char} ${}{*}\|f{}$;\C{ nome do arquivo a ser criado }\2\2\6
${}\{{}$\5
\1\X7:Codifica caracteres do nome do grafo\X\6
\X8:Codifica caracteres dos nomes dos v�rtices\X\6
\&{return} ${}(\\{save\_graph}(\|g,\39\|f));{}$\6
\4${}\}{}$\2\par
\U3.\fi

\N{3}{6}Recupera��o de um Grafo de um Arquivo.

\Y\B\4\X6:Recupera��o de um Grafo de um Arquivo\X${}\E{}$\6
\&{Graph} ${}{*}\\{restaura\_grafo}(\|f){}$\1\1\6
\&{char} ${}{*}\|f{}$;\C{ o nome do arquivo }\2\2\6
${}\{{}$\5
\1\&{Graph} ${}{*}\|g;{}$\7
${}\|g\K\\{restore\_graph}(\|f);{}$\6
\X9:Decodifica caracteres do nome do grafo\X\6
\X10:Decodifica caracteres dos nomes dos v�rtices\X\6
\&{return} (\|g);\6
\4${}\}{}$\2\par
\U3.\fi

\M{7}\B\X7:Codifica caracteres do nome do grafo\X${}\E{}$\6
${}\{{}$\5
\1\&{char} \\{nome}[\.{MAX\_SV\_ID}];\7
${}\\{strcpy}(\\{nome},\39\|g\MG\\{id});{}$\6
\\{codifica}(\\{nome});\6
${}\\{strcpy}(\|g\MG\\{id},\39\\{nome});{}$\6
\4${}\}{}$\2\par
\U5.\fi

\M{8}\B\X8:Codifica caracteres dos nomes dos v�rtices\X${}\E{}$\6
${}\{{}$\5
\1\&{char} \\{nome}[\.{MAX\_SV\_STRING}];\6
\&{Vertex} ${}{*}\|v;{}$\7
\&{for} ${}(\|v\K\|g\MG\\{vertices};{}$ ${}\|v<\|g\MG\\{vertices}+\|g\MG\|n;{}$
${}\|v\PP){}$\5
${}\{{}$\1\6
${}\\{strcpy}(\\{nome},\39\|v\MG\\{name});{}$\6
\\{codifica}(\\{nome});\6
${}\|v\MG\\{name}\K\\{gb\_save\_string}(\\{nome});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U5.\fi

\M{9}\B\X9:Decodifica caracteres do nome do grafo\X${}\E{}$\6
${}\{{}$\5
\1\&{char} \\{nome}[\.{MAX\_SV\_ID}];\7
${}\\{strcpy}(\\{nome},\39\|g\MG\\{id});{}$\6
\&{if} ${}(\\{decodifica}(\\{nome})\I\T{0}){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"Deu\ caca\ na\ decodif}\)\.{ica��o\ de\
caracteres}\)\.{\ acentuados!\\n"});{}$\6
${}\\{fprintf}(\\{stderr},\39\.{"Mande\ o\ arquivo\ com}\)\.{\ o\ grafo\ para\
o\ Z�\ A}\)\.{ugusto.\\n"});{}$\6
${}\|g\K\NULL;{}$\6
\4${}\}{}$\2\6
\&{else}\1\5
${}\\{strcpy}(\|g\MG\\{id},\39\\{nome});{}$\2\6
\4${}\}{}$\2\par
\U6.\fi

\M{10}\B\X10:Decodifica caracteres dos nomes dos v�rtices\X${}\E{}$\6
${}\{{}$\5
\1\&{char} \\{nome}[\.{MAX\_SV\_STRING}];\6
\&{Vertex} ${}{*}\|v;{}$\7
\&{for} ${}(\|v\K\|g\MG\\{vertices};{}$ ${}\|v<\|g\MG\\{vertices}+\|g\MG\|n;{}$
${}\|v\PP){}$\5
${}\{{}$\1\6
${}\\{strcpy}(\\{nome},\39\|v\MG\\{name});{}$\6
\\{decodifica}(\\{nome});\6
${}\|v\MG\\{name}\K\\{gb\_save\_string}(\\{nome});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U6.\fi

\M{11}Aqui v�o as fun��es de codifica��o e decodifica��o. Precisamos
transformar os caracteres acentuados em \textit{outra coisa}. A
\textit{outra coisa} tem que estar no que � definido no \PB{\\{gb\_io}} como
\PB{\\{imap}}:
\begin{verbatim}
static char *imap="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz_^~&@,;.:?!%#$+-*/\\<=>()[]{}`'\" \n";
\end{verbatim}
(falta uma `barra vertical' nessa lista: parece dif�cil represent�-la no
texto!)
Al�m disso, \textit{outra coisa} n�o pode ser '"', '?n', '?',
conforme consta na fun��o \PB{\\{prepare\_string}} do \PB{\\{gb\_save}}.

As defini��es do arquivo \PB{$\\{portug}.\\{el}$} do emacs, baseado no \PB{$%
\\{iso}-\\{acc}.\\{el}$}
de Johan Vromans, consideram (hoje � 18/8/98) o seguinte conjungo de
caracteres acentuados:
\begin{verbatim}
��������������  (agudo + caractere)
����������      (grave + caractere)
����������      (circunflexo + caractere)
������������    (aspas + caractere (� � o "+s e o � � o "+y))
������������    (til + caractere)
\end{verbatim}

Vamos fazer assim ent�o: transformamos os caracteres acentuados
mostrados acima em seq��ncias de caracteres come�ando com '?',
seguidos pelos caracteres que, quando digitados, geram esses
caracteres na nossa instala��o do emacs.
Se o caractere '?' aparece no nome, ele � codificado por '??'.

\Y\B\4\X11:Fun��es Privadas\X${}\E{}$\6
\X12:Fun��o Codifica\X\6
\X13:Fun��o Decodifica\X\par
\U2.\fi

\M{12}\B\X12:Fun��o Codifica\X${}\E{}$\6
\&{void} \\{codifica}(\&{char} ${}{*}\\{nome}){}$\1\1\2\2\6
${}\{{}$\1\6
\&{char} \\{saida}[\.{MAX\_SV\_STRING}];\6
\&{int} \|i${},{}$ \|j;\7
${}\|j\K\T{0};{}$\6
\&{for} ${}(\|i\K\T{0};{}$ ${}\\{nome}[\|i]\I\.{'\\0'};{}$ ${}\|i\PP){}$\5
${}\{{}$\1\6
\&{switch} (\\{nome}[\|i])\5
${}\{{}$\1\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'A'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'C'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'E'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'I'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'O'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'U'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'Y'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'a'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'c'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'e'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'i'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'o'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'u'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\\''};{}$\6
${}\\{saida}[\|j\PP]\K\.{'y'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'`'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'A'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'`'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'E'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'`'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'I'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'`'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'O'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'`'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'U'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'`'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'a'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'`'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'e'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'`'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'i'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'`'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'o'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'`'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'u'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\^'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'A'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\^'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'E'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\^'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'I'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\^'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'O'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\^'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'U'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\^'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'a'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\^'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'e'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\^'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'i'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\^'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'o'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\^'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'u'};{}$\6
\&{break};\3{-1}\C{ As aspas tamb�m s�o proibidas. Ser�o substituidas por dois
pontos }\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'A'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'E'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'I'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'O'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'U'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'a'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'e'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'i'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'o'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'s'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'u'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{':'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'y'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\~'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'A'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\~'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'D'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\~'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'N'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\~'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'O'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\~'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'a'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\~'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'d'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\~'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'n'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\~'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'o'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\~'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'>'};{}$\6
\&{break};\6
\4\&{case} \.{'�'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'\~'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'<'};{}$\6
\&{break};\6
\4\&{case} \.{'?'}:\5
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
\&{break};\6
\4\&{default}:\5
${}\\{saida}[\|j\PP]\K\\{nome}[\|i];{}$\6
\&{break};\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
${}\\{saida}[\|j]\K\.{'\\0'};{}$\6
${}\\{strcpy}(\\{nome},\39\\{saida});{}$\6
\4${}\}{}$\2\par
\U11.\fi

\M{13}\B\X13:Fun��o Decodifica\X${}\E{}$\6
\&{int} \\{decodifica}(\&{char} ${}{*}\\{nome}){}$\1\1\2\2\6
${}\{{}$\1\6
\&{char} \\{saida}[\.{MAX\_SV\_STRING}];\6
\&{int} \|i${},{}$ \|j;\7
${}\|j\K\T{0};{}$\6
\&{for} ${}(\|i\K\T{0};{}$ ${}\\{nome}[\|i]\I\.{'\\0'};{}$ ${}\|i\PP){}$\5
${}\{{}$\1\6
\&{if} ${}(\\{nome}[\|i]\E\.{'?'}\W\\{nome}[\|i+\T{1}]\E\.{'?'}){}$\5
${}\{{}$\1\6
${}\\{saida}[\|j\PP]\K\.{'?'};{}$\6
${}\|i\PP;{}$\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\\{nome}[\|i]\E\.{'?'}){}$\5
${}\{{}$\1\6
${}\|i\MRL{+{\K}}\T{2};{}$\6
\&{switch} ${}(\\{nome}[\|i-\T{1}]){}$\5
${}\{{}$\1\6
\4\&{case} \.{'\\''}:\6
\&{switch} (\\{nome}[\|i])\5
${}\{{}$\1\6
\4\&{case} \.{'A'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'C'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'E'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'I'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'O'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'U'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'Y'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'a'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'c'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'e'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'i'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'o'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'u'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'y'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{default}:\5
\&{return} \T{1};\6
\4${}\}{}$\2\6
\&{break};\6
\4\&{case} \.{'`'}:\6
\&{switch} (\\{nome}[\|i])\5
${}\{{}$\1\6
\4\&{case} \.{'A'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'E'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'I'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'O'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'U'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'a'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'e'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'i'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'o'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'u'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{default}:\5
\&{return} \T{1};\6
\4${}\}{}$\2\6
\&{break};\6
\4\&{case} \.{'\^'}:\6
\&{switch} (\\{nome}[\|i])\5
${}\{{}$\1\6
\4\&{case} \.{'A'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'E'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'I'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'O'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'U'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'a'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'e'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'i'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'o'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'u'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{default}:\5
\&{return} \T{1};\6
\4${}\}{}$\2\6
\&{break};\6
\4\&{case} \.{':'}:\6
\&{switch} (\\{nome}[\|i])\5
${}\{{}$\1\6
\4\&{case} \.{'A'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'E'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'I'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'O'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'U'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'a'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'e'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'i'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'o'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'s'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'u'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'y'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{default}:\5
\&{return} \T{1};\6
\4${}\}{}$\2\6
\&{break};\6
\4\&{case} \.{'\~'}:\6
\&{switch} (\\{nome}[\|i])\5
${}\{{}$\1\6
\4\&{case} \.{'A'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'D'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'N'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'O'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'a'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'d'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'n'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'o'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'>'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{case} \.{'<'}:\5
${}\\{saida}[\|j\PP]\K\.{'�'};{}$\6
\&{break};\6
\4\&{default}:\5
\&{return} \T{1};\6
\4${}\}{}$\2\6
\&{break};\6
\4\&{default}:\5
\&{return} \T{1};\6
\&{break};\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\&{else}\1\5
${}\\{saida}[\|j\PP]\K\\{nome}[\|i];{}$\2\6
\4${}\}{}$\2\6
${}\\{saida}[\|j]\K\.{'\\0'};{}$\6
${}\\{strcpy}(\\{nome},\39\\{saida});{}$\6
\&{return} \T{0};\6
\4${}\}{}$\2\par
\U11.\fi

\M{14}

\end{document}

\fi


\inx
\fin
\con
