Code :
void publishkw(const char *addr, const char *targetid, int srcid, const char *fileid, int sybilid) { PGresult* result1; PGresult* resultp1; PGresult* resultkw1; char commande_sql1[128]; char publish1[128]; char kw1[128]; sprintf(commande_sql1,"select verify_replicat('%s', '%s', current_timestamp);", addr, targetid); result1 = PQexec(connect_database, commande_sql1); char *val1 = PQgetvalue(result1,0,0); if ((PQresultStatus(result1) != PGRES_TUPLES_OK )) { fprintf(stderr, "couldn't execute query publish\n" ); PQclear(result1); } else { printf ("commande publish exécutée\n" ); } if ((strcmp(val1,"1" ) == 0)) {sprintf(publish1,"select mape_publish (date_trunc('minute',current_timestamp), %d, '%s', '%s', %d);", srcid, fileid, targetid, sybilid); resultp1 = PQexec(connect_database, publish1); char *pub1 = PQgetvalue(resultp1,0,0); if ((PQresultStatus(resultp1) != PGRES_TUPLES_OK)) { fprintf(stderr, "couldn't execute query pub\n" ); PQclear(resultp1); } else { printf ("commande pub exécutée\n" ); sprintf(kw1,"select kw_files('%s', '%s', %d);", fileid, targetid, srcid); resultkw1 = PQexec(connect_database, kw1); char *key1 = PQgetvalue(resultkw1,0,0); if ((PQresultStatus(resultkw1) != PGRES_TUPLES_OK)) { fprintf(stderr, "couldn't execute query key_pub\n" ); PQclear(resultkw1); } else { printf ("commande key_pub exécutée\n" ); } } PQclear(result1); PQclear(resultp1); PQclear(resultkw1); }
|