distroquery: correctly finalize sqlite3 prepared statements
This commit is contained in:
parent
ec0c093578
commit
868ec46738
@ -315,15 +315,14 @@ void printQueryData() {
|
||||
if (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[ARCHS_MAX], sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
sqlite3_step(stmt1);
|
||||
get_favicon_from_url(sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX);
|
||||
} else buffer[0]='\0';
|
||||
|
||||
printf("<div style='position:relative'><hr><br>");
|
||||
printTagsLine(query_repositories[i]->arch[a],
|
||||
query_repositories[i]->tag,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
||||
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license")));
|
||||
printf("<br><img src=\"%s\" width\"16\" height=\"16\"> ", buffer);
|
||||
|
||||
sqlite3_finalize(stmt1);
|
||||
}
|
||||
printf("<b>%s</b> %s-%s<br>%s",
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
||||
@ -364,6 +363,7 @@ void printQueryData() {
|
||||
printf("</div></div><br>");
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
localprovidesresults = 0;
|
||||
snprintf(sql, PATH_MAX,
|
||||
"SELECT * FROM packages,provides,provided WHERE "
|
||||
@ -394,6 +394,7 @@ void printQueryData() {
|
||||
}
|
||||
if (localprovidesresults > 0) printf("</div>");
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -442,6 +443,7 @@ void printQueryData() {
|
||||
query_repositories[i]->tag,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")));
|
||||
}
|
||||
sqlite3_finalize(statement);
|
||||
} else {
|
||||
fprintf(stderr, "ERROR: SQLite: %s (%s)\n", sqlite3_errmsg(query_repositories[i]->db[ARCHS_MAX]), sql);
|
||||
}
|
||||
@ -493,15 +495,21 @@ void printPackageData() {
|
||||
if (db &&
|
||||
(sqlite3_prepare_v2(db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
|
||||
if (sqlite3_step(statement) == SQLITE_ROW) {
|
||||
|
||||
snprintf(dbname, PATH_MAX, "%s%s-sources.db", ct->repository_dir, ct->tag);
|
||||
if (!sqlite3_open_v2(dbname, &dbs, SQLITE_OPEN_READONLY, NULL)) {
|
||||
|
||||
if (sqlite3_open_v2(dbname, &dbs, SQLITE_OPEN_READONLY, NULL)) {
|
||||
if (dbs) sqlite3_close(dbs);
|
||||
dbs = NULL;
|
||||
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; aborting.\n", dbname);
|
||||
return;
|
||||
}
|
||||
snprintf(sql, PATH_MAX,
|
||||
"SELECT * FROM sources,packagers WHERE sources.id=%d AND sources.id_packager=packagers.id",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id_source")));
|
||||
if (sqlite3_prepare_v2(dbs, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) sqlite3_step(stmt1);
|
||||
if (!sqlite3_prepare_v2(dbs, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
fprintf(stderr, "ERROR: unable to prepare statement for %s; aborting.\n", sql);
|
||||
return;
|
||||
}
|
||||
sqlite3_step(stmt1);
|
||||
|
||||
printf("<hr><br>");
|
||||
printTagsLine(query_arch,
|
||||
@ -529,7 +537,7 @@ void printPackageData() {
|
||||
snprintf(sql, PATH_MAX, "SELECT * FROM packages WHERE id_source=%d AND NOT id=%d",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id_source")),
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt2, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt2, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt2) == SQLITE_ROW)
|
||||
printf(" <a href='javascript:distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s(%s)</a>",
|
||||
ct->tag,
|
||||
@ -537,7 +545,8 @@ void printPackageData() {
|
||||
query_arch,
|
||||
sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "name")),
|
||||
query_arch);
|
||||
|
||||
sqlite3_finalize(stmt2);
|
||||
}
|
||||
printf("<br><br><div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div><br>",
|
||||
htmlclean(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
|
||||
|
||||
@ -568,7 +577,8 @@ void printPackageData() {
|
||||
printf("<br><br>%s:", _("Obsoletes"));
|
||||
snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK)
|
||||
sqlite3_finalize(stmt1);
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
||||
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoletename")));
|
||||
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteversion"))) {
|
||||
@ -576,13 +586,14 @@ void printPackageData() {
|
||||
printf("%s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteversion")));
|
||||
}
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt1);
|
||||
}
|
||||
printf("<br><br>%s:",_("Provides"));
|
||||
snprintf(sql, PATH_MAX, "SELECT * FROM provides,provided "
|
||||
"WHERE provides.id_package=%d AND provided.id=provides.id_provided "
|
||||
"ORDER BY provided.name",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
||||
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
|
||||
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideversion"))) {
|
||||
@ -590,13 +601,14 @@ void printPackageData() {
|
||||
printf("%s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideversion")));
|
||||
}
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt1);
|
||||
}
|
||||
printf("<br><br>%s:", _("Requires"));
|
||||
snprintf(sql, PATH_MAX, "SELECT * FROM requires,provided "
|
||||
"WHERE requires.id_package=%d AND provided.id=requires.id_provided "
|
||||
"ORDER BY provided.name",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
||||
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
|
||||
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "requireversion"))) {
|
||||
@ -604,14 +616,18 @@ void printPackageData() {
|
||||
printf("%s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "requireversion")));
|
||||
}
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt1);
|
||||
}
|
||||
sqlite3_close(dbs);
|
||||
}
|
||||
snprintf(buffer, PATH_MAX, "%s - %s",
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")));
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
printf("]]></queryreply>");
|
||||
printf("<title><![CDATA[%s - %s :: %s]]></title>",
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
|
||||
printf("<title><![CDATA[%s :: %s]]></title>",
|
||||
buffer,
|
||||
firstconfigtag->configdefaults->distribution_name);
|
||||
|
||||
sqlite3_close(db);
|
||||
@ -673,7 +689,7 @@ void printSourcePackageData() {
|
||||
if (!sqlite3_open_v2(dbname, &dba, SQLITE_OPEN_READONLY, NULL)) {
|
||||
snprintf(sql, PATH_MAX, "SELECT * FROM packages WHERE id_source=%d",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||
if (sqlite3_prepare_v2(dba, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare_v2(dba, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt1) == SQLITE_ROW)
|
||||
printf(" <a href='javascript:distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s(%s)</a>",
|
||||
ct->tag,
|
||||
@ -681,6 +697,8 @@ void printSourcePackageData() {
|
||||
ct->arch[a],
|
||||
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
|
||||
ct->arch[a]);
|
||||
sqlite3_finalize(stmt1);
|
||||
}
|
||||
sqlite3_close(dba);
|
||||
}
|
||||
}
|
||||
@ -707,25 +725,27 @@ void printSourcePackageData() {
|
||||
snprintf(sql, PATH_MAX,
|
||||
"SELECT * FROM sources_source WHERE id_source=%d",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
||||
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "source")));
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt1);
|
||||
}
|
||||
printf("<br><br>%s:", _("Patches"));
|
||||
snprintf(sql, PATH_MAX,
|
||||
"SELECT * FROM sources_patch WHERE id_source=%d",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
||||
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "patch")));
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt1);
|
||||
}
|
||||
|
||||
printf("<br><br>%s:", _("Build requirements"));
|
||||
snprintf(sql, PATH_MAX, "SELECT * FROM buildrequires WHERE id_source=%d",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
||||
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequirename")));
|
||||
if (strcmp("", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireversion")))) {
|
||||
@ -733,12 +753,14 @@ void printSourcePackageData() {
|
||||
printf("%s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireversion")));
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(stmt1);
|
||||
}
|
||||
|
||||
printf("<br><br>%s:<br>", _("Changelog"));
|
||||
snprintf(sql, PATH_MAX,
|
||||
"SELECT * FROM changelog,packagers WHERE id_source=%d AND changelog.id_packager=packagers.id",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(stmt1) == SQLITE_ROW) {
|
||||
printf("%s - %s (%s)<br><pre>%s</pre>",
|
||||
simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "time")), (humanDate *) & strdate),
|
||||
@ -746,14 +768,17 @@ void printSourcePackageData() {
|
||||
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "release")),
|
||||
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "text")));
|
||||
}
|
||||
|
||||
|
||||
sqlite3_finalize(stmt1);
|
||||
}
|
||||
}
|
||||
snprintf(buffer, PATH_MAX, "%s - %s",
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")));
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
printf("]]></queryreply>");
|
||||
printf("<title><![CDATA[%s - %s :: %s]]></title>",
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
|
||||
printf("<title><![CDATA[%s :: %s]]></title>",
|
||||
buffer,
|
||||
firstconfigtag->configdefaults->distribution_name);
|
||||
|
||||
sqlite3_close(db);
|
||||
|
Loading…
Reference in New Issue
Block a user