read_pg_conf
Publicado por Perfil removido 06/08/2007
[ Hits: 4.043 ]
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;
}
}
}
Leitura de arquivo texto separando as colunas
Cadastro de arquivo usando ncurses como menu
Contando a quantidade de palavras de um arquivo texto
Nenhum comentário foi encontrado.
Cirurgia para acelerar o openSUSE em HD externo via USB
Void Server como Domain Control
Modo Simples de Baixar e Usar o bash-completion
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
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
Conky, alerta de temperatura alta (10)
Assisti Avatar 3: Fogo e Cinzas (3)
Duas Pasta Pessoal Aparecendo no Ubuntu 24.04.3 LTS (42)









