quarta-feira, 12 de novembro de 2008

Apenas alguns links que estava olhando na tentativa de rodar várias interfáces gráficas diferentes no servidor x, mas pelo jeito não tem jeito ...!

http://www.debian.org/doc/manuals/reference/ch-tune.pt-br.html

http://www.scribd.com/doc/259439/Guia-do-Linux-Desktop-06-Ambientes-Graficos

http://www.docstoc.com/docs/712762/Portuguese-HOWTO

http://www.google.com.br/search?hl=pt-BR&client=firefox-a&rls=com.ubuntu:pt-BR:unofficial&q=comandos+para+o+servidor+x+do+linux+%2Bxinit&start=90&sa=N

Como estou com o icewm, o fluxox, o gnome e o kde instalado no debian queria poder trocar de interface com o ctr + alt +F7 ...

Só que acho que não funciona, o primeiro passo é decobrir como parar o servidor x

Só que não acho nenhum manual em português sobre isso ...!


http://www.google.com.br/search?hl=pt-BR&client=firefox-a&rls=com.ubuntu:pt-BR:unofficial&q=comandos+para+o+servidor+x+do+linux+%2Bxinit&start=90&sa=N

http://www.guiadohardware.net/tutoriais/configurando-servidor-xdmcp/pagina2.html




http://www.vivaolinux.com.br/dica/Iniciando-uma-segunda-interface-grafica-no-Linux


http://www.magnux.org/doc/howto/pt_BR/Portuguese-HOWTO/Portuguese-HOWTO.pt_BR-197.php


http://www.gdhpress.com.br/redeseservidores/leia/index.php?p=cap8-24

http://www.mclink.it/personal/MG2508/nbsdbra/netbsd.html


http://www.mclink.it/personal/MG2508/nbsdbra/preface.html


http://www.mclink.it/personal/MG2508/nbsdbra/chap-misc.html

http://www.mclink.it/personal/MG2508/nbsdbra/chap-x.html

http://focalinux.cipsga.org.br/guia/inic_interm/ch-run.html#s-run-fechando


http://focalinux.cipsga.org.br/guia/inic_interm/ch-x11.html

http://www.mtm.ufsc.br/~krukoski/pub/linux/focalinux1/ch-x11.htm

http://www.gdhpress.com.br/etdl/leia/index.php?p=cap5-2

http://www.freebsd.org/doc/pt_BR.ISO8859-1/books/faq/x.html

http://www.gentoo.org/doc/pt_br/xorg-config.xml

http://www.vivaolinux.com.br/dica/Instalando-e-rodando-multiplas-interfaces-graficas-em-Linux-tipo-Debian

http://wiki.forumdebian.com.br/index.php/X-Window-System

link para baixar o iso do dvd do debian

http://cdimage.debian.org/debian-cd/4.0_r5/i386/iso-dvd/

Dica importante se você
não tem uma placa vídeo decente não invente de querer instalar o xgl, pois quase que tive que reinstalar todo o debian devido a isso, o x simplesmente não funcionava mais e muito menos o xgl, já que a placa nao tem o recurso de aceleração gráfica ...!


Para baixar os dvds do debian stable:

wget -c http://cdimage.debian.org/debian-cd/4.0_r5/i386/iso-dvd/debian-40r5-i386-DVD-1.iso ;
wget -c http://cdimage.debian.org/debian-cd/4.0_r5/i386/iso-dvd/debian-40r5-i386-DVD-2.iso ;
wget -c http://cdimage.debian.org/debian-cd/4.0_r5/i386/iso-dvd/debian-40r5-i386-DVD-3.iso ;
wget -c ;
wget -c http://cdimage.debian.org/debian-cd/4.0_r5/i386/iso-dvd/debian-update-4.0r5-i386-DVD-1.iso

sexta-feira, 7 de novembro de 2008

Fiquei pasmado ao ver o windows inializar mais rápido que o debian linux com o gnome instalado ..!

Fiquei pasmado ao ver o windows inializar mais rápido que o debian linux com o gnome instalado ..!

Fiquei pasmado ao ver o windows inializar mais rápido que o debian linux com o gnome instalado ..!

No modesto desktop aqui em casa o windows xp pro sp2 iniciou em 1 minuto e 24 segundos
já o debian em 1 minuto e 32 segundos, entretanto devido a maneira como o sistema operacional windows foi construido, para eu efetivamente conseguir usar um programa nele demoro uns 4 minutos, já no debian esse tempo cai para menos de 3, em fim, pra quem defende o linux com unhas e dentes, vale a pena uma ressalva, o windows atende muito bem ao propósito que ele foi criado, um sistema operacional intuitivo, que certamente é bem mais tranquilo de aprender a utilizar que os linux da vida, em linux se esqueceu o nome do comando já era, não tem muito jeito a não ser buscar na internet, entretanto existe um fator, que para mim é a seção crítica para preferir usar o debian GNU/Linux ao Windows, embora tenha voltado a utilizar o dual boot, essa seção, ou fator crítico é o fato de ter que se preocupar com os vírus, e não conseguir proteger adequadamente algumas pastas ...!

Mas do jeito que o mercado anda, muito provavelmente a utilização das distribuições baseadas em GNU/Linux tende a aumentar significativamente ...!

Outra grade vantagem do debian é que você pode escolher que interface deseja ter no seu sistema operacional, já em windows não ..., mas pelo menos na minha opinião, o que dificulta e muito a difusão das distribuições é a idéia dos poucos provilegiados, que conhecem bem a língua inglesa e se lembram dos comandos, para realizar alguma tarefa na Shell, enquanto tivermos gente pensando que fazer interface gráfica não compensa já que pela shell é mais rápido, o que é verdade, os novos usuários não se sentirão muito atraídos a utilizarem esse sistema operacional tão fantástico.
Da vontade de dizerm gente ACORDEM NEM TODO MUNDO TEM QUE FICAR LENDO TUTORIAIS OU MANUAIS APENAS PARA REALIZAREM ALGUMAS TAREFAS SIMPLES !
Tudo o que todos queremos é que tenhamos que interagir o mínimo possível com os softwares, e ele meio que adivinhe o que desejamos e retorne as respostas que esperamos, se desenvolvermos softwares assim, as chances de popularização dele são bem maiores, pena que muitos acabam esquecendo que o normal no mundo é ser ignorante, não ter o conhecimento, uma criança nasce totalmente ignorante ..., fato que inclusive se extende a educação, a educação aqui é ruim a beça, por vários motivos e um deles é os mestres não considerarem que o aluno está ali justamente para aprender, se é pré requisito algum conhecimento e ele não tem, de esse conhecimento e continue ensinando, pois para que irmos as escolas se consideram que os alunos sabem quase tudo ?
Outro detalhe importante, linguagem coloquial é feio, só que quase todos entendem, faça um teste pegue uma obra de José de alencar e pegue uma obra menos preocupada com a forma que as coisas serão ditas, umas obra preocupada com o entendimento do autor, por exemplo uma obra no que na minha opinião é o maior escritor, o Machado de Assis, achei o livro do José de Alencar chato por que simplesmente era dificil de entender a linguagem, o do Machado fantástico por que ele se preocupava com a idéia, e que ela fosse entendida ...!

Então em tudo na vida, principalmente no desenvolvimento de software façamos coisas simples, e intuitivas que as chances de sucesso são bem maiores ...!

quarta-feira, 29 de outubro de 2008

Apenas imprimindo em várias páginas em um arquivo .ps

Usei apenas os comandos abaixo:

sudo apt-get install mpage pstops psnup pdf2ps pdftops a2ps xpdf groff psselect


kurumin@negao1986:~/PDF/ pdftops 3.pdf
kurumin@negao1986:~/PDF/naunha$ ls
1.pdf 3.pdf exerc-gerencia-proc.pdf SOP_02_Exerc-GES.pdf
2.pdf 3.ps exerc-ipc.pdf SOP_05_Exerc-GM.pdf

kurumin@negao1986:~/PDF/naunha$ mpage -2 3.ps > 31.ps
O comando acima é o comando que efetivamente imprime 2 páginas por folha do arquivo 3.ps no arquivo 31.ps

kurumin@negao1986:~/PDF/naunha$ pstodf 31.ps
bash: pstodf: command not found
kurumin@negao1986:~/PDF/naunha$ sudo apt-get install pstopdf ps2pdf
Lendo lista de pacotes... Pronto
Construindo árvore de dependências... Pronto
E: Impossível achar pacote pstopdf
kurumin@negao1986:~/PDF/naunha$ ls
1.pdf 3.pdf exerc-ipc.pdf
2.pdf 3.ps SOP_02_Exerc-GES.pdf
31.ps exerc-gerencia-proc.pdf SOP_05_Exerc-GM.pdf
kurumin@negao1986:~/PDF/naunha$ pstopdf 31.ps

kurumin@negao1986:~/PDF/naunha$ mpage -4 3.ps > 41.ps
O comando acima é o comando que efetivamente imprime 4 páginas por folha do arquivo 3.ps no arquivo 41.ps
kurumin@negao1986:~/PDF/naunha$ ps2pdf 41.ps
o comando acima criará um arquivo 41.pdf para o arquivo 41.ps

domingo, 7 de setembro de 2008

Não é possível atualizar mais a página http://br.geocities.com/danilomatias17/

Não é possível atualizar mais a página:
http://br.geocities.com/danilomatias17/

Devido a já possuir os 15 MB que o servidor http: (geocities) disponibiliza aos usuários não posso mais atualizar minha página homepage - hp

Devo colocar alguma coisa apartir da minha página inicial em:

http://br.geocities.com/danilomatias@ymail.com/

Essa é a minha página inicial, só tem o que acesso lá!

Colocando códigos (code2HTML) ; Ada, Awk, C, C++, HTML, Java, JavaScript, m4, Makefile, Pascal, Perl, SQL, ruby e povray em HTML com CODE2HTML



Teve um Autríaco que desenvolveu um código em Pearl capaz de formatar as linguagens de programação; Ada, Awk, C, C++, HTML, Java, JavaScript, m4, Makefile, Pascal, Perl, SQL, ruby e povray em HTML

Coloquei essas informações de maneira melhor organizada em:
http://br.geocities.com/danilomatias@ymail.com/code/code2html/index/123456.html
Ainda é possível conferir o resultado desse script de maneira online no link:

http://www.palfrader.org/code2html/code2html.html

A documentação oficial se encontra em:

http://www.palfrader.org/code2html/manual.html

A página oficial do projeto é:
http://www.palfrader.org/code2html/


Na página:
http://gnu.fyxm.net/directory/devel/conversion/code2html.html

Achei o link para baixar o código fonte e executar em:
http://www.palfrader.org/code2html/all/code2html-0.9.1.tar.gz

Descompatei entrei na pasta que estava o código fonte e testei o programa.

De uma maneira geral:

A sintaxe geral é:

./code2html -nvL lingagem_de_programaçao arquivo.lingagem_de_programaçao arquivo_destino.html

Teste com o exemplo abaixo:
./code2html -nvL c 3.c 3_c.html
Onde:

c é a linguagem [c, java, paskal, pearl, php, ...]
3.c o nome do Arquivo.c
3_c.html o nome do arquivo .html


A página do cara que desenvolveu o código é (Peter Palfrader):

http://www.palfrader.org/

o Resultado (código convertido) foi:


1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #define LEITURA 0
5 #define ESCRITA 1
6 #define LEITURAESCRITA 2
7 #define TAMNOME 500
8 #define NR_MAX_OF_CHR_ARQ 20000
9 /*=============================================================*/
10 /*=============================================================*/
11 /*
12 *
13 * ordem das chamadas
14 de funções que estão me
15 dando dor de cabeça:
16 *
17 * prog();
18 ==>>getLinhaISomenteleitura(arq, &i, t7, 3); ==>>
19 gettextoarq1Somenteleitura1(arq); ==>> ==>> ==>>
20 ==>> ==>> ==>> ==>> ==>> ==>>
21 ==>>
22 *
23 * -> prog();
24 ==>>mostraLinhas(arq, 10); ==>>getLinhaISomenteleitura1(arq,
25 3); ==>> t1=gettextoarq1Somenteleitura1(arq); ==>> ==>>
26 ==>> ==>> ==>> ==>> ==>> ==>>
27 ==>> ==>>
28 -> prog();
29 ==>>mostraRespricoes() ==>>[mostraLinhas4(arq);==>>
30 (vet1=get_vetor_string_arq(arq);==>>)==>>nl=getNumeroLinhaStringArquivo(arq);==>>]==>>
31 ==>> ==>> ==>> ==>> ==>> ==>>
32 ==>> ==>> ==>>* */

33 /*=============================================================*/
34 /* 528 - 541*/char *alocarStringA(int tam);
35 /* 542 - 550 */char *alocarStringB(char *str);
36 /* 156 - 184 */char ***alocar_vetor_string_arq(char *arq);
37 /* 309 - 319 */int contachar(char string[], char letra);
38 /* 186 - 200 */int getimaiorStringemArq(char *arq);
39 /* 343 - 386 */char *getLinhaISomenteleitura(char *arq, int *j, char *linha,int I);
40 /* 156 - 184 */char *getLinhaISomenteleitura1(char *arq, int I);
41 /* 156 - 184 */char *gettextoarq(int fd, char *buf, int buf_size, char *texto);
42 /* 518 - 529 */char *gettextoarq1Somenteleitura1A( char *arq, int Numero_de_caracteres_do_nome_do_arquivo, int Numero_de_caracteres_do_arquivo);
43 /* 156 - 184 */char *gettextoarq1Somenteleitura( char *arq, char *texto);
44 /* 156 - 184 */char *gettextoarq1Somenteleitura1( char *arq);
45 /* 156 - 184 */char ***getLinhasSomenteleitura(char *arq, int *j, char ***texto4);
46 /* 156 - 184 */int getNumeroLinhaString(char *str);
47 /* 156 - 184 */int getNumeroLinhaStringArquivo(char *arq);
48 /* 156 - 184 */int get_Strlen_da_maior_String_em_Arq(char *arq);
49 /* 156 - 184 */char ***get_vetor_string_arq(char *arq);
50 /* 156 - 184 */char **getvetorLinhasArg(char *arq);
51 /* 156 - 184 */char **getvetorLinhasArg1(char *arq);
52 /* 156 - 184 */char **getvetorLinhasArg1(char *arq);
53 /* 156 - 184 */void limpaStr(char *Str);
54 /* 156 - 184 */void mostraRespricoes();
55 /* 156 - 184 */void mostraLinhas(char *arq, int j);
56 /* 156 - 184 */void mostraLinhas1(char *arq);
57 /* 156 - 184 */void mostraLinhas2(char *arq);
58 /* 156 - 184 */void mostraLinhas3(char *arq);
59 /* 156 - 184 */void mostraLinhas4(char *arq);
60 /* 156 - 184 */int open1(char *file,int oflag );
61 /* 156 - 184 */void prog();
62 /* 156 - 184 */char *strpdftk(char *arq);
63 /* 156 - 184 */char *substituiEspacoPor_(char *str);
64 /* 156 - 184 */char *subs_str(char *string, char *substring, char *nova);
65
66 /*=============================================================*/
67 /*=============================================================*/
68 /*=============================================================*/
69 char ***get_vetor_string_arq(char *arq)
70 {
71 int l, i, j, k, m, n,o, num_linhas;
72 char ***vet1, **vet;
73
74 vet1=NULL; vet=NULL;
75 vet1=alocar_vetor_string_arq(arq);
76 vet=*vet1;/* tenho o vetor de strings alocadinha basta preenchê-lo*/
77 num_linhas=getNumeroLinhaStringArquivo(arq);
78 for(i=0;i<num_linhas; i++)
79 {
80 sprintf(vet[i] ,"%s", getLinhaISomenteleitura1(arq, i) );
81 }
82 return vet1;
83 }
84 /*=============================================================*/
85 /*=============================================================*/
86 void mostraLinhas4(char *arq)
87 {
88 int l, i, nl;
89 char **vet, ***vet1;
90
91 vet=NULL; vet1=NULL;
92 vet1=get_vetor_string_arq(arq);
93 vet=*vet1;
94 nl=getNumeroLinhaStringArquivo(arq);
95 for(i=0; i <nl;i++)
96 {
97 printf("\n vet[%i]: %s", i, vet[i]);
98 }
99 printf("\n\n ************************************\n\n");
100 }
101 /*=============================================================*/
102 void mostraLinhas3(char *arq)
103 {
104 int l, i;
105 char **vet;
106
107 vet=NULL;
108 vet=getvetorLinhasArg1(arq);
109 if(vet==NULL){printf("\n Deu problema no mostra linha3 ver e nulo !\n");}
110 //t8=getLinhaISomenteleitura1(arq,9);
111 /*printf("\n
112 Passemos a i=getNumeroLinhaStringArquivo(arq);\n");*/

113 i=getNumeroLinhaStringArquivo(arq);
114 //printf("********* Mostrando as %i linhas do arquivo %s ****\n\n", i,arq);
115 printf("Linhas(vet)[%i ]{%i}: %s \n", 0, strlen(vet[0]), vet[0]);
116 printf("Linhas(vet)[%i ]{%i}: %s \n", 1, strlen(vet[1]), vet[1]);
117 /*
118 for(l=0; l < i;l++)
119 {
120 printf("Linhas(vet)[
121 %i ]{%i}: %s \n", l, strlen(vet[l]), vet[l]);
122 }*/

123 printf("\n\n************************************\n\n");
124 }
125 /*===================================================================*/
126 /*===================================================================*/
127 void mostraLinhas2(char *arq)
128 {
129 int l, i;
130 char **vet;
131
132 vet=getvetorLinhasArg(arq);
133 //t8=getLinhaISomenteleitura1(arq,9);
134 i=getNumeroLinhaStringArquivo(arq);
135 //printf("********* Mostrando as %i linhas do arquivo %s ****\n\n", i,arq);
136 for(l=0; l < i;l++)
137 {
138 printf("Linhas(vet)[%i ]{%i}: %s \n", l, strlen(vet[i]), vet[i]);
139 }
140 printf("\n\n************************************\n\n");
141 }
142 /*=============================================================*/
143 int get_Strlen_da_maior_String_em_Arq(char *arq)
144 {
145 int l, i, k, la, bb, maior, idomaior;
146 char **vet, str[TAMNOME];
147
148 k=0;maior=0;
149 for(i=0; i<getNumeroLinhaStringArquivo(arq);i++)
150 {
151 k = strlen(getLinhaISomenteleitura1(arq, i));
152 if(k>=maior){maior=k;idomaior=i;}
153 }
154 return maior;
155 }
156 /*=============================================================*/
157 char ***alocar_vetor_string_arq(char *arq)
158 {
159 int tam1, tam2, i,j;
160 char **vetor, ***vet;
161
162 tam2 =get_Strlen_da_maior_String_em_Arq(arq);
163 tam2=tam2*sizeof(char);
164 tam1=getNumeroLinhaStringArquivo(arq);
165 if((vetor=(char**)malloc(tam1*sizeof(char*)))==NULL)
166 {
167 printf("\n Naofoi possivel alocar as linhas do de vetor de strings para do arquivo\n");
168 return NULL;
169 }
170 for(i=0;i<tam1;i++)
171 {
172 if((vetor[i]=(char*)malloc(tam2))==NULL)
173 {
174 printf("\nNao foi possivel alocar as colunas do vetor de strings para doarquivo \n");
175 for(--i;i>=0;i--)
176 {
177 free(vetor[i]);
178 }
179 free(vetor);
180 return NULL;
181 }
182 }
183 vet=&vetor;
184 return vet;
185 }
186 /*=============================================================*/
187 int getimaiorStringemArq(char *arq)
188 {
189 int l, i, k, la, bb, maior, idomaior;
190 char **vet, str[TAMNOME];
191 k=0;maior=0;
192 for(i=0; i<getNumeroLinhaStringArquivo(arq);i++)
193 {
194 k =strlen(getLinhaISomenteleitura1(arq, i));
195 if(k>=maior){maior=k;idomaior=i;}
196 }
197 return idomaior;
198 }
199 /*=============================================================*/
200 char **getvetorLinhasArg1(char *arq)
201 {
202 int l, i, k, la, bb;
203 char **vet,str[TAMNOME];
204 /* o probela e alocar
205 o vetor para armazenar*/

206 i=getNumeroLinhaStringArquivo(arq);
207 vet=(char**)malloc(i*sizeof(char*));
208 if(vet==NULL)
209 {
210 printf("\nNao foi possivel alocar as linhas do vetor de linhas \n");
211 return NULL;
212 }
213 for(la=0; la < i;la++)
214 {
215 strcpy(str,getLinhaISomenteleitura1(arq, la));
216 k = strlen(str);
217 /*printf("\n k
218 = strlen(str);: %i\n st: %s\n", k, str);*/

219 vet[la]=(char*)malloc(k*sizeof(char));
220 if(vet[la]==NULL)
221 {
222 printf("\n Nao foi possivel alocar as colunas do vetor de linhas \n");
223 free(vet);return NULL;
224 }
225 sprintf(vet[la],"%s", str);
226 for(bb=0; bb<=la;bb++)
227 printf("%s \n", vet[bb]);
228 //strcpy(vet[l],str);
229 // if((l%2)!=0){
230 //printf("%i%%3=%i\nLinhas(vet[%i])[ %i ]: %s \n str : %s \n\n",l, l%3, l,l, vet[l], str);
231 //}
232 }
233 //printf("vet[1-4]: %s %S %s %S \n\n", vet[0], vet[1], vet[2], vet[4]);
234 printf(" Agora vema montagem do vetor vet : %s \n\n", vet);
235 /* for(la=0; la <i; la++)
236 {
237 printf("\nvet[%i]: %s\n ", la, vet[la]);
238 }*/

239 return vet;
240 }
241
242 /*=============================================================*/
243 void mostraLinhas1(char *arq)
244 {
245 int l, i;
246 //t8=getLinhaISomenteleitura1(arq,9);
247 i=getNumeroLinhaStringArquivo(arq);
248 printf("Mostrando as %i linhas do arquivo \n\n", i);
249 for(l=0; l < i;l++)
250 {
251 printf("Linhas[%i ]: %s \n", l, getLinhaISomenteleitura1(arq, l));
252 }
253 printf("\n\n************************************\n\n");
254 }
255 /*=============================================================*/
256 char**getvetorLinhasArg(char *arq)
257 {
258 int l, i, k;
259 char **vet, *str;
260 l=getNumeroLinhaStringArquivo(arq);
261 //printf("Mostrando as %i linhas do arquivo \n\n", l);
262 vet=(char**)malloc(l*sizeof(char));
263 if(vet==NULL)
264 {
265 printf("\nNao foi possivel alocar as linhas do vetor de linhas \n");
266 return NULL;
267 }
268 for(i=0; i < l;i++)
269 {
270 strcpy(str,getLinhaISomenteleitura1(arq, i));
271 k = strlen(str);
272 vet[i]=(char*)malloc(k*sizeof(char));
273 if(vet[i]==NULL)
274 {
275 printf("\nNao foi possivel alocar as colunas do vetor de linhas \n");
276 return NULL;
277 }
278 strcpy(vet[i] ,str);
279 printf("vet[ %i]: %s \n", l, vet[i]);
280 }
281 //printf("\n\n************************************\n\n");
282 return vet;
283 }
284 /*=============================================================*/
285 /*=============================================================*/
286 void mostraLinhas(char *arq, int j)
287 {
288 int l;
289 //t8=getLinhaISomenteleitura1(arq,9);
290 printf("\n\nMostrando as %i linhas do arquivo \n\n", j);
291 for(l=0; l < j;l++)
292 {
293 printf("Linhas[%i ]: %s \n", l, getLinhaISomenteleitura1(arq, l));
294 }
295 printf("\n\n************************************\n\n");
296 printf(" %s \n O Arquivo tem %i linhas", gettextoarq1Somenteleitura1(arq), getNumeroLinhaString(gettextoarq1Somenteleitura1(arq)));/**//**/
297 printf("\n\n************************************\n\n");
298 }
299 /*=============================================================*/
300 void mostraRespricoes()
301 {
302 printf(" 1 - O arquivo arqpdf.txt tem que estar no mesmo diretorio \n ");
303 printf(" 2 - Os arquivos a serem convertidos devem estar no mesmo diretorio \n");
304 printf(" 3 - O arquivo gerado tera o nome de \'PDFTK921_ ...pdf\'\n");
305 printf(" 4 - Os nomes dos arquivos (arquivo ... .pdf) a serem unidos nao podem possuir espacos em branco\n");
306 printf(" 5 - Para o programa funcionar você deve ter a ferramenta pdftk instalada no seu computador, para mais informacoes acesse: \'http://www.vivaolinux.com.br/dica/Manipulando-arquivos-PDF-com-pdftk\'\n");
307 }
308 /*=============================================================*/
309 /*=============================================================*/
310 int contachar(char string[], char letra)
311 {
312 int contador,tamanho, ocorrencia = 0;
313 tamanho =strlen(string);
314 for(contador=1;contador <= tamanho;contador++)
315 if(string[contador] == letra)
316 ocorrencia++;
317 return(ocorrencia);
318 }
319
320 /*=============================================================*/
321 int getNumeroLinhaString(char *str)
322 {
323 /*onde str é a string com várias linhas*/
324 return contachar(str, '\n');
325 }
326
327 /*=============================================================*/
328 int getNumeroLinhaStringArquivo(char *arq)
329 {
330 /*onde str é a string com várias linhas*/
331 int i;
332 char *s1;
333 s1=gettextoarq1Somenteleitura1(arq);
334 i=getNumeroLinhaString(s1);
335 i=i-1;
336 return i;
337 }
338 /*=============================================================*/
339 /* fazer uma função
340 que retorne somente a string da linha,
341
342 * deve-se passar a
343 linha e um ponteiro onde string estara*/

344 char *getLinhaISomenteleitura1(char *arq, int I)
345 {
346 int i;
347 char text[10000],*t1, *t2, charater[500], *ta1;
348 t1=gettextoarq1Somenteleitura1(arq);
349 //t1=gettextoarq1Somenteleitura1A(arq, strlen(arq),/* strlen()*//**/NR_MAX_OF_CHR_ARQ/**/);
350 sprintf(text, "%s",t1);
351 /* agora com a string t1 tendo uma copia em "text"
352 * da pra ficar
353 mais aliviado, pois nao perderemos o
354 * conteudo do
355 arquivo, os nomes dos documentos*/

356 //res = strtok(s,delim);
357 t2=strtok(text,"\n");
358 //sprintf(texto[0],"%s", t2);
359 //printf(" \n O conteudo da variaveis text (antes de retornar a linha) e %s \n Ja o conteudo de t2 e %s \n \n", text, t2);
360 if(I==0)
361 {
362 return t2;
363 }
364 for(i=1;(i<=I)&&(t2 != NULL); i++)
365 {
366 //res =strtok(NULL, delim);
367 t2=strtok(NULL,"\n");
368 sprintf(charater,"%s", t2);
369 //printf("\n O conteudo do arquivo na linha %i e %s \n Ja o conteudo de t2 e %s \n Ja o conteudo de charater e %s \n", i, text, t2,charater);
370 if(i==I)
371 {
372 strcpy(ta1,charater);
373 return t2;
374 }
375 if(t2==NULL)
376 {
377 printf("\n A linha pedida para a funcao e maior que a quanidade de linhas no arquivo! \n Entre com um valor de linha menor que o numero de linhas do arquivo!\n ");
378 return NULL;
379 }
380 }
381 if(i==I)
382 {
383 strcpy(ta1,charater);
384 return t2;
385 }
386 return NULL;
387 }
388 /*=============================================================*/
389 void limpaStr(char *Str)
390 {
391 int i, j;
392 i=strlen(Str);
393 for(j=i-1;j>=0;j--)
394 {
395 Str[j]=' ';
396 /*Str[j]=NULL*//* ;*///strcpy(*(Str+j)," ");
397 }
398 }
399 /*=============================================================*/
400 /* fazer uma função
401 que retorne somente a string da linha,
402
403 * deve-se passar a
404 linha e um ponteiro onde string estara*/

405 char *getLinhaISomenteleitura(char *arq, int *j, char *linha, int I)
406 {
407 int i;
408 char texto[500][500],text[10000], *t1, *t2, charater[500];
409 printf("\n Agora entrarei na funcao t1=gettextoarq1Somenteleitura(arq, t1);\n");
410 t1=gettextoarq1Somenteleitura1(arq);
411 sprintf(text, "%s",t1);
412 /* agora com a string t1 tendo uma copia em "text"
413 * da pra ficar mais aliviado, pois nao perderemos o
414 * conteudo do arquivo, os nomes dos documentos*/

415 t2=strtok(text,"\n");
416 sprintf(texto[0], "%s", t2);
417 *j=i;
418 if(I==0)
419 {
420 if(/**linha==NULL */strcmp(linha,NULL)==0)
421 {/* se estiver passando somente um * ponteiro sem nada , NULL*/
422 linha=texto[0];
423 }
424 sprintf(linha, "%s", texto[0]);
425 return linha;
426 }
427 //printf("*j= %i \t", *j);
428 for(i=1;(i<500)||(t2!=NULL);i++)
429 {
430 t2=strtok('\0',"\n");
431 sprintf(charater,"%s", t2);
432 strcpy(texto[i],charater);
433 *j=i;
434 // printf("*j=%i \t", *j);
435 if(t2==NULL ||strlen(charater)<3)
436 {
437 *j=i;
438 printf("\n A linha pedida para a funcao e maior que a quanidade de linhas no arquivo! \n Retornarei a ultima linha do arquivo\n ");
439 if(/**linha==NULL */strcmp(linha,NULL)==0)
440 { /* se estiver passando somente um
441 * ponteiro sem nada , NULL*/

442 linha=texto[i-1];
443 /*linha = *//*strcpy(linha, texto[i-1]);*/
444 return linha;
445 }
446 sprintf(linha,"%s", texto[i-1]);
447 return linha;
448 }
449 if(i==I)
450 {
451 if(/**linha==NULL */strcmp(linha,NULL)==0)
452 { /* se estiver passando somente um
453 * ponteiro sem nada , NULL*/

454 linha=texto[i];
455 return linha;
456 }
457 sprintf(linha,"%s", texto[i]);
458 return linha;
459 }
460 }
461 return NULL;
462 }
463 /*=============================================================*/
464 char ***getLinhasSomenteleitura(char *arq, int *j, char ***texto4)
465 {
466 int i;
467 char texto[500][500], text[10000], *t1, *t2, charater[500], **texto5;
468 t1=gettextoarq1Somenteleitura(arq,t1);
469 printf("\n entrou em char ***getLinhasSomenteleitura(char *arq, int *j, char ***texto4) \n gettextoarq1Somenteleitura(arq, t1); = %s \n ", t1);
470 sprintf(text, "%s", t1);
471 /* agora com a string t1 tendo uma copia em "text"
472 * da pra ficar mais aliviado, pois nao perderemos o
473 * conteudo do arquivo, os nomes dos documentos*/

474 t2=strtok(text,"\n");
475 sprintf(texto[0], "%s", t2);
476 *j=i;
477 //printf("*j=%i \t", *j);
478 for(i=1;(i<500)||(t2!=NULL);i++)
479 {
480 t2=strtok('\0',"\n");
481 sprintf(charater,"%s", t2);
482 strcpy(texto[i],charater);
483 *j=i;
484 // printf("*j=%i \t", *j);
485 if(t2==NULL ||strlen(charater)<3)
486 {
487 *j=i;
488 /**texto4=&texto[0][0];
489 *texto4= =strdup(texto[0]);*/

490 // strcpy(texto5,texto);
491 *texto4=texto5;
492 return texto4;
493 }
494 }
495 /*
496 *texto4=&texto[0][0];
497 *texto4= =strdup(texto[0]);*/

498 // strcpy(texto5,texto);
499 *texto4=texto5;
500 // return &texto5;
501 return texto4;
502 }
503 /*=============================================================*/
504 char *gettextoarq1Somenteleitura1( char *arq)
505 {
506 int fd, buf_size;
507 char buf[500],buf2[10000], *buf3;
508
509 buf_size=499;
510 fd=open1(arq,LEITURA);
511 buf3=gettextoarq(fd,buf, buf_size,buf2);
512 close(fd);
513 return buf3;
514 }
515 /*=============================================================*/
516
517 char *gettextoarq1Somenteleitura1A( char *arq, int Numero_de_caracteres_do_nome_do_arquivo, int Numero_de_caracteres_do_arquivo)
518 {
519 int fd;
520 char *buf, *buf2, *buf3;
521
522 buf2=alocarStringA(Numero_de_caracteres_do_arquivo);
523 buf=alocarStringA(Numero_de_caracteres_do_nome_do_arquivo);
524 fd=open1(arq,LEITURA);
525 buf3=gettextoarq(fd,buf, Numero_de_caracteres_do_nome_do_arquivo,buf2);
526 close(fd);
527 return buf3;
528 }
529 /*=============================================================*/
530 char *alocarStringA(int tam)
531 {
532 int tam2;
533 char *vetor;
534
535 tam2=tam*sizeof(char);
536 if((vetor=(char*)malloc(tam2))==NULL)
537 {
538 printf("\n Nao foi possivel alocar a string de tamanho %i \n", tam);
539 return NULL;
540 }
541 return vetor;
542 }
543 /*=============================================================*/
544 char *alocarStringB(char *str)
545 { /* str e a string ao qual se desejara copiar em B*/
546 int tam2, tam;
547 char *str2;
548 tam=strlen(str);
549 tam=tam+30;
550 str2=alocarStringA(tam);
551 return str2;
552 }
553 /*=============================================================*/
554 /*=============================================================*/
555 /*=============================================================*/
556 /*=============================================================*/
557 /*=============================================================*/
558 /*=============================================================*/
559 /*=============================================================*/
560 char *strpdftk(char *arq)
561 {
562 int i, j, k, l, m, n,n1;
563 char *arq1, *arq2, *arqout, *out, *ext, *meio;
564 l=getNumeroLinhaStringArquivo(arq);
565 n1=strlen("pdftk");
566 n1=n1+800;
567 out=(char*)malloc(n1*sizeof(char));
568 arq1=(char*)malloc((n1-120)*sizeof(char));
569 arq2=(char*)malloc((n1-120)*sizeof(char));
570 ext=(char*)malloc((n1-500)*sizeof(char));
571 k=0;
572 i=0;
573 m=1;
574 //printf("\nString0: %s\n", out);
575 //limpaStr(out);
576 //printf("\nString1depois: %s\n", out);
577 /*printf("\n\n\n\ngetLinhaISomenteleitura1(arq, 2) : %s \n\n\n",getLinhaISomenteleitura1(arq, 2));*/
578 /*printf("\n\n\n\narquivos0 e arquivo1 arquivo2 respectivamente %s %s %s \n\n\n",getLinhaISomenteleitura1(arq, 0), getLinhaISomenteleitura1(arq, 1),getLinhaISomenteleitura1(arq, 2));*/
579 arq1=getLinhaISomenteleitura1(arq,0);
580 arq2=getLinhaISomenteleitura1(arq,1);
581 sprintf(ext, "pdftk %s %s cat output PDFTK921_%i.pdf ;", arq1, arq2, 0);
582 //printf("\n %s\n", ext);
583 strcat(out, ext);
584 k++;
585 sprintf(ext, "pdftk PDFTK921_%i.pdf %s cat output PDFTK921_%i.pdf ;", k-1,getLinhaISomenteleitura1(arq, 2), k);
586 strcat(out, ext);
587 //printf("\n %s\n\n ", ext);
588 k++;
589 sprintf(ext, "pdftk PDFTK921_%i.pdf %s cat output PDFTK921_%i.pdf ;", k-1,getLinhaISomenteleitura1(arq, 3), k);
590 strcat(out, ext);
591 //printf("\n %s\n\n ", ext);
592 k++;
593 for(i=4; i<l; i++)
594 {
595 sprintf(ext, "pdftk PDFTK921_%i.pdf %s cat output PDFTK921_%i.pdf ;", k-1,getLinhaISomenteleitura1(arq, i), k);
596 strcat(out, ext);
597 //printf("\n\n %s\n\n ", ext);
598 k++;
599 }
600 //printf("\n out= %s\n", out);
601 --k;
602 for(--k;k>=0;k--)
603 {
604 sprintf(ext, "rm pdftk PDFTK921_%i.pdf ; ", k);
605 strcat(out, ext);
606 // printf("\n\n %s\n\n ", ext);
607 }
608 strcat(out, " ls -la ");
609 //printf("\n out = %s\n", out);
610 return out;
611 }
612 /*=============================================================*/
613 /*=============================================================*/
614 /*=============================================================*/
615 /*=============================================================*/
616 /*=============================================================*/
617 /*=============================================================*/
618 /*=============================================================*/
619 /*=============================================================*/
620
621 char *gettextoarq1Somenteleitura( char *arq, char *texto)
622 {
623 int fd, buf_size;
624 char buf[500],buf2[10000], *buf3;
625
626 buf_size=499;
627 fd=open1(arq,LEITURA);
628 printf("\n Agora entrarei na funcao buf3=gettextoarq(fd, buf,buf_size,buf2);\n");
629 buf3=gettextoarq(fd,buf, buf_size,buf2);
630 printf("\n Antes de entrar no If do texto \nO conteudo do arquivo %s e :\n %s \n", arq, buf3);
631 if(/**texto==NULL */strcmp(texto,NULL)==0)
632 {/* se estiver passando somente um * ponteiro sem nada , NULL*/
633 texto=buf3;
634 }
635 sprintf(texto,"%s", buf3);
636 //printf("\n Agora entrarei na funcao close(fd);\n");
637 close(fd);
638 //printf("\n O conteudo do arquivo %s e :\n %s \n", arq, buf3);
639 return buf3;
640 }
641 /*=============================================================*/
642 char *gettextoarq(int fd, char *buf, int buf_size, char *texto)
643 {
644 for(;;)
645 {
646 if(read(fd, buf,buf_size)==0)
647 {
648 sprintf(texto, "%s \n", buf);
649 return texto;
650 }
651 sprintf(texto, "%s \n", buf);
652 }
653 }
654
655 /*=============================================================*/
656
657 int open1(char *file, int oflag )
658 {
659 int fd;
660
661 if((fd=open(file,oflag))==-1)
662 {
663 printf("\n Nao e possivel abrir o arquivo %s \n", file);
664 return fd;
665 }
666 return fd;
667 }
668 /*=============================================================*/
669
670 char *substituiEspacoPor_(char *str)
671 {
672 return subs_str(str," ", "_");
673 }
674 /*=============================================================*/
675 char *subs_str(char *string, char *substring, char *nova)
676 {
677 char *extrai;
678 int tamanho1,tamanho2,contador, a4;
679
680 tamanho1 = strlen(substring);
681 tamanho2 = strlen(nova);
682 a4=strlen(string);
683 if((tamanho1 > tamanho2) || (tamanho2 > tamanho1))
684 return(" ");
685 else
686 {
687 extrai = strstr(string,substring);
688 if(extrai)
689 {
690 for(contador = 0;contador < a4; contador++)
691 string[(extrai - string) + contador] = nova[contador];
692 return(string);
693 }
694 else
695 return(" ");
696 }
697 }
698 /*=============================================================*/
699
700 void prog()
701 {
702 char cmd[400], arq[200], texto[600], **t1, ***t6, *t7, *t10, *t8, tr[200];
703 int i;
704
705 strcpy(tr,"O joao e bacana pra caramba");
706 t7=NULL,t8=NULL;
707 sprintf(arq, "%s","arqpdf.txt");
708 //sprintf(stdout,"%s", "imprimindo na tela, stdout com sprintf");
709 /* printf("************************************");
710 printf("\n\n a string %s sem espacos e : %s \n\n", tr, substituiEspacoPor_(tr));*/

711 printf("************************************");
712 printf("\n Programa que concatenara todos os arquivos .pdf em um \n\n\n ");
713 printf(" Para esse programa funcionar direito e Necessario que: \n ");
714 mostraRespricoes();
715 sprintf(cmd, "for x in *.pdf; do echo %s ", "\"$x\"; done > arqpdf.txt");
716 system(cmd);
717 printf(" \n cmd:\n %s \n ", cmd);
718 t10=strpdftk(arq);
719 printf(" \n cmd:\n %s \n ", t10);
720 system(t10);
721 printf("\n\n");
722 }
723
724 /*=============================================================*/
725 int main()
726
727 {
728 prog();
729 return 1;
730 }