make code more readeable
git-svn-id: file:///home/jan/tmp/wetterstation/trunk@18 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
parent
55290ad359
commit
33a1feb516
|
|
@ -100,7 +100,7 @@ int read_port(){
|
|||
|
||||
temp = buffer; /* Temporärer Zeiger bekommt die Anfangsaddresse vom Puffer */
|
||||
|
||||
add_clean(clean_port, &fd);
|
||||
add_clean(clean_port, &fd); /* Callbackfunktion zum Aufräumen registrieren */
|
||||
|
||||
|
||||
DEBUGOUT1("\nWarte auf Daten\n\n");
|
||||
|
|
|
|||
|
|
@ -119,10 +119,10 @@ static int pg_connect(){
|
|||
conn_string = malloc(sizeof(char)*255);
|
||||
snprintf(conn_string, 255, "host=%s dbname=%s user=%s password=%s", global_opts.pg_host, global_opts.pg_database, global_opts.pg_user, global_opts.pg_pass);
|
||||
}
|
||||
connection = PQconnectdb(conn_string);
|
||||
add_clean(clean_write, connection);
|
||||
connection = PQconnectdb(conn_string); /* Connection aufbauen */
|
||||
add_clean(clean_write, connection); /* Callbackfunktion zum Aufräumen registrieren */
|
||||
} else {
|
||||
PQreset(connection);
|
||||
PQreset(connection); /* Connecion resetten */
|
||||
}
|
||||
if(PQstatus(connection) != CONNECTION_OK){
|
||||
DEBUGOUT2("\nFehler beim Aufbau der Datenbankverbindung\n%s\n", PQerrorMessage(connection));
|
||||
|
|
@ -137,6 +137,7 @@ static int pg_connect(){
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Ein Datum in die Datenbank schreiben */
|
||||
static void pg_insert(char *query){
|
||||
PGresult *res;
|
||||
if(pg_connect()){
|
||||
|
|
@ -154,6 +155,8 @@ static void pg_insert(char *query){
|
|||
}
|
||||
}
|
||||
|
||||
/* Callbackfunktion zum Aufräume.
|
||||
* Schliesst die Verbindung zur Datenbank */
|
||||
static void clean_write(void *data){
|
||||
PGconn *conn = data;
|
||||
PQfinish(conn);
|
||||
|
|
|
|||
Loading…
Reference in New Issue