read_pg_conf
Publicado por Perfil removido 06/08/2007
[ Hits: 4.062 ]
Esta função lê um arquivo com configurações para conexão com bando de dados PostgreSQL.
O formato deste arquivo é do tipo:
[pgsql]
PGhost=
PGdbname=
PGuser=
PGpassword=
#include <stdio.h>
void read_pg_conf(char host[128],char dbname[128],char user[128],char password[128],char file[512]) {
FILE *conf;
char linha[256],*arg;
conf=fopen(file,"r");
if(!conf) {
fprintf(stderr,"Erro ao abrir arquivo de configuração: %s!",file);
exit(1);
}
while(fgets(linha,256,conf)) {
if(strstr(linha,"[pgsql]"))
break;
}
while(fgets(linha,256,conf)) {
if((arg=strstr(linha,"]\n")))
break;
if((arg=strstr(linha,"PGhost="))) {
arg=strchr(linha,'=');
strcpy(host,arg+1);
continue;
}
if((arg=strstr(linha,"PGdbname="))) {
arg=strchr(linha,'=');
strcpy(dbname,arg+1);
continue;
}
if((arg=strstr(linha,"PGuser="))) {
arg=strchr(linha,'=');
strcpy(user,arg+1);
continue;
}
if((arg=strstr(linha,"PGpassword="))) {
arg=strchr(linha,'=');
strcpy(password,arg+1);
continue;
}
}
}
Programa CONSULTA/ PESQUISA/ ADICIONA/ EXCLUI registros em arquivos
MakeInt - gerador de wordlist numérica
Barra de progresso em forma de “roda”
Nenhum comentário foi encontrado.
Jogando Daikatana (Steam) com Patch 1.3 via Luxtorpeda no Linux
LazyDocker – Interface de Usuário em Tempo Real para o Docker
Instalando COSMIC no Linux Mint
Turbinando o Linux Mint: o poder das Nemo Actions
Inteligência Artificial no desenvolvimento de software: quando começar a usar?
O widget do Plasma 6 Área de Notificação
[Resolvido] Algo deu errado ao abrir seu perfil
Instalar Dual Boot, Linux+Windows. (12)
Problemas com o "startx&... no Slackware (10)
Conselho distribuiçao brasileira (8)
Atalho no Linux Mint não aparece menu de troca de monitores (0)









