read_pg_conf
Publicado por Perfil removido 06/08/2007
[ Hits: 3.932 ]
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; } } }
ORDENACAO PELO METODO SHELLSORT
Copia uma linha selecionada para um arquivo secundário
Transformando uma sequencia de binário em executável
Nenhum coment�rio foi encontrado.
Servidor de Backup com Ubuntu Server 24.04 LTS, RAID e Duplicati (Dell PowerEdge T420)
Visualizar câmeras IP ONVIF no Linux sem necessidade de instalar aplicativos
Atualizar Debian Online de uma Versão para outra
Proteja seu Linux Mint com o Timeshift: Restaure o sistema mesmo que ele não inicie!
Instalando Google Chrome no Debian 13
Alguém pode me recomendar um editor de textos? [RESOLVIDO] (9)
Erro de interface de Rede no Virt Manager dentro Debian 13 KDE (0)
meus dois pen drives não são mais reconhecidos pelo meu PC apos tentar... (3)