read_pg_conf
Publicado por Perfil removido 06/08/2007
[ Hits: 4.049 ]
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;
}
}
}
ListDir - Um listador de diretórios
Justificador de texto em 80 colunas
Contando a quantidade de palavras de um arquivo texto
Nenhum comentário foi encontrado.
Como atualizar sua versão estável do Debian
Cirurgia para acelerar o openSUSE em HD externo via USB
Void Server como Domain Control
Script de montagem de chroot automatica
Atualizar Linux Mint 22.2 para 22.3 beta
Jogar games da Battle.net no Linux com Faugus Launcher
Como fazer a Instalação de aplicativos para acesso remoto ao Linux
Instalar Dual Boot, Linux+Windows. (6)
Conky, alerta de temperatura alta (17)
De volta para o futuro - ou melhor, para o presente (parte 2) (3)









