distroquery: improved results style

This commit is contained in:
Silvan Calarco 2013-10-07 16:25:43 +02:00
parent aaf59faaf7
commit f50ba2ab52

View File

@ -107,8 +107,8 @@ void printQueryData(char* repository_tag, char* query) {
snprintf(dbname, PATH_MAX, "%sdistromatic.db", configtag->repository[i]->repository_dir); snprintf(dbname, PATH_MAX, "%sdistromatic.db", configtag->repository[i]->repository_dir);
if (sqlite3_open_v2(dbname, (sqlite3**)&configtag->repository[i]->db, SQLITE_OPEN_READONLY, NULL)) { if (sqlite3_open_v2(dbname, (sqlite3**)&configtag->repository[i]->db, SQLITE_OPEN_READONLY, NULL)) {
if (configtag->repository[i]->db) sqlite3_close(configtag->repository[i]->db); if (configtag->repository[i]->db) sqlite3_close(configtag->repository[i]->db);
configtag->repository[i]->db = NULL;
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; aborting.\n", dbname); fprintf(stderr, "ERROR: unable to open sqlite3 db %s; aborting.\n", dbname);
return;
} }
} }
@ -117,16 +117,20 @@ void printQueryData(char* repository_tag, char* query) {
int j; int j;
printf("<queryreply><![CDATA["); printf("<queryreply><![CDATA[");
printf("<h2>Binaries:</h2>");
int a; int a;
for (a = 0; a < ARCHS_MAX && configtag->arch[a]; a++) { for (a = 0; a < ARCHS_MAX && configtag->arch[a]; a++) {
snprintf(sql, PATH_MAX, "SELECT * FROM packages_%s WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%'", configtag->arch[a], query, query, query); snprintf(sql, PATH_MAX, "SELECT * FROM packages_%s WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%'", configtag->arch[a], query, query, query);
for (i = 0; i <= configtag->repository_level; i++) { for (i = 0; i <= configtag->repository_level; i++) {
if (sqlite3_prepare_v2((sqlite3*)configtag->repository[i]->db, sql, strlen(sql), &statement, NULL) == SQLITE_OK) { if (configtag->repository[i]->db &&
(sqlite3_prepare_v2((sqlite3*)configtag->repository[i]->db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
while (sqlite3_step(statement) == SQLITE_ROW) { while (sqlite3_step(statement) == SQLITE_ROW) {
printf("<b>%s</b> %s:%s-%s<br>%s<br>Group: %s<br><br><i>%s</i><br><hr>", printf("<hr><br><div style='display:inline;color:white;background-color:green'> %s </div>&nbsp;"
"<div style='display:inline;color:black;background-color:yellow'> %s </div><br>"
"<b>%s</b> %s-%s<br>%s<br>Group: %s<br><br>"
"<div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div><br>",
configtag->arch[a],
configtag->repository[i]->tag,
sqlite3_column_text(statement,1), sqlite3_column_text(statement,1),
sqlite3_column_text(statement,3),
sqlite3_column_text(statement,4), sqlite3_column_text(statement,4),
sqlite3_column_text(statement,5), sqlite3_column_text(statement,5),
sqlite3_column_text(statement,6), sqlite3_column_text(statement,6),
@ -138,14 +142,17 @@ void printQueryData(char* repository_tag, char* query) {
} }
} }
printf("<h2>Sources:</h2>");
snprintf(sql, PATH_MAX, "SELECT * FROM sources WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%'", query, query, query); snprintf(sql, PATH_MAX, "SELECT * FROM sources WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%'", query, query, query);
for (i = 0; i <= configtag->repository_level; i++) { for (i = 0; i <= configtag->repository_level; i++) {
if (sqlite3_prepare_v2((sqlite3*)configtag->repository[i]->db, sql, strlen(sql), &statement, NULL) == SQLITE_OK) { if (configtag->repository[i]->db &&
(sqlite3_prepare_v2((sqlite3*)configtag->repository[i]->db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
while (sqlite3_step(statement) == SQLITE_ROW) { while (sqlite3_step(statement) == SQLITE_ROW) {
printf("<b>%s</b> %s:%s-%s<br>%s<br>Group: %s<br>License: %s</br>URL: %s<br><br><i>%s</i><br><hr>", printf("<hr><br><div style='display:inline;color:black;background-color:red'> Source </div>&nbsp;"
"<div style='display:inline;color:black;background-color:yellow'> %s </div><br>"
"<b>%s</b> %s-%s<br>%s<br>Group: %s<br>License: %s</br>URL: %s<br><br>"
"<div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div><br>",
configtag->repository[i]->tag,
sqlite3_column_text(statement,1), sqlite3_column_text(statement,1),
sqlite3_column_text(statement,3),
sqlite3_column_text(statement,4), sqlite3_column_text(statement,4),
sqlite3_column_text(statement,5), sqlite3_column_text(statement,5),
sqlite3_column_text(statement,6), sqlite3_column_text(statement,6),