diff --git a/src/distroquery.c b/src/distroquery.c index cba17ba..c61177d 100644 --- a/src/distroquery.c +++ b/src/distroquery.c @@ -83,6 +83,7 @@ char *query = ""; char *query_package; char *query_repository; char *query_arch = NULL; +int query_compact = 0; int query_limit = 10; int query_offset = 0; char query_next[PATH_MAX] = ""; @@ -367,7 +368,10 @@ 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); - printf("


"); + if (query_compact) + printf("
"); + else + printf("


"); printTagsLine(query_repositories[i]->arch[a], query_repositories[i]->tag, sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")), @@ -375,44 +379,57 @@ void printQueryData() { printf("
 ", buffer); sqlite3_finalize(stmt1); } - printf("%s %s-%s
%s", + if (query_compact) { + printf("" + "%s %s-%s - %s
", + query_repositories[i]->tag, + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), + query_repositories[i]->arch[a], + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), + htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX)); + } else { + printf("%s %s-%s
%s", + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), + htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX)); + + printf("

%s
", + htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX)); + + /* install */ +/* printf("
" + "
" + "" + "
", + sqlite3_column_text(statement,1), + sqlite3_column_text(statement,6), + sqlite3_column_text(statement,1));*/ + + /* download */ + printf("
" + " %s 
", + query_repositories[i]->download_prefix, + query_repositories[i]->download_dir, sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), - htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX)); + _("Download")); - printf("

%s
", - htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX)); + /* details */ + printf(" 
" + " %s 
", + query_repositories[i]->tag, + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), + query_repositories[i]->arch[a], + _("Details")); + printf("

"); + } - /* install */ -/* printf("
" - "
" - "" - "
", - sqlite3_column_text(statement,1), - sqlite3_column_text(statement,6), - sqlite3_column_text(statement,1));*/ - - /* download */ - printf("
" - " %s 
", - query_repositories[i]->download_prefix, - query_repositories[i]->download_dir, - sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), - sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), - sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), - _("Download")); - - /* details */ - printf(" 
" - " %s 
", - query_repositories[i]->tag, - sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), - query_repositories[i]->arch[a], - _("Details")); - - printf("

"); } } sqlite3_finalize(statement); @@ -435,7 +452,20 @@ void printQueryData() { _("for arch "), query_repositories[i]->arch[a]); } - printf("" + "%s %s %s
", + query_repositories[i]->tag, + sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")), + query_repositories[i]->arch[a], + sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")), + _("provides"), + sqlite3_column_text(statement,sqlite3_find_column_id(statement, "provided", "name"))); + } else { + printf("%s %s %s
", query_repositories[i]->tag, sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")), @@ -443,6 +473,7 @@ void printQueryData() { sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")), _("provides"), sqlite3_column_text(statement,sqlite3_find_column_id(statement, "provided", "name"))); + } } } @@ -485,7 +516,7 @@ void printQueryData() { sqlite3_close(dbf); } } - if (localprovidesresults > 0) printf("
"); + if (localprovidesresults > 0) printf("

"); sqlite3_finalize(statement); } @@ -517,7 +548,7 @@ void printQueryData() { get_favicon_from_url(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX); - printf("

"); + if (!query_compact) printf("

"); printTagsLine(NULL, query_repositories[i]->tag, @@ -525,19 +556,32 @@ void printQueryData() { sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license"))); printf("
 ", buffer); - printf("%s %s-%s
%s

", - sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), - sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), - sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), - htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX)); + if (query_compact) { + printf("" + "%s %s-%s - %s
", + query_repositories[i]->tag, + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), + htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX)); + } else { + printf("%s %s-%s
%s

", + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), + htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX)); - printf("
%s
", - htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX)); - printf("
" - " Details 
", - query_repositories[i]->tag, - sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name"))); + printf("
%s
", + htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX)); + /* source details */ + printf("
" + " Details 
", + query_repositories[i]->tag, + sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name"))); + } } sqlite3_finalize(statement); } else { @@ -554,26 +598,26 @@ void printQueryData() { printf("%d %s.", numresults, _("result(s) shown")); else printf("%d %s.", numresults, _("result(s) found")); - if (k < 7) j=1; else j=k-5; /* j = start pages list from */ - if (!otherresults) { - /* current page is last available */ - a=k; - j=a-10; - if (j <= 0) j=1; - } else a=j+9; /* a = number of page links displayed */ - if (a > 1) { - printf(" [ "); - for (i = j; i <= a; i++) { - if (i != k) printf("", - query_next, query_limit, query_limit * (i-1)); - printf("%d", i); - printf(" "); - } - printf("]"); - } - if (!reply_plain) printf("]]>"); - if (!reply_plain) { + if (k < 7) j=1; else j=k-5; /* j = start pages list from */ + if (!otherresults) { + /* current page is last available */ + a=k; + j=a-10; + if (j <= 0) j=1; + } else a=j+9; /* a = number of page links displayed */ + if (a > 1) { + printf(" [ "); + for (i = j; i <= a; i++) { + if (i != k) printf("", + query_next, query_limit, query_limit * (i-1)); + printf("%d", i); + printf(" "); + } + printf("]"); + } + printf("]]>"); + printf("<![CDATA["); printf("%s '%s' :: %s", _("Search results for"), query, firstconfigtag->configdefaults->distribution_name); printf("]]>"); @@ -717,12 +761,13 @@ void printPackageData() { simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildtime")), (humanDate *) & strdate)); /* obsoletes */ - printf("

%s:", _("Obsoletes")); snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d", sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id"))); sqlite3_finalize(stmt1); if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) { + j=0; while (sqlite3_step(stmt1) == SQLITE_ROW) { + if (j++ == 0) printf("

%s:", _("Obsoletes")); 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"))) { printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteflags"))); @@ -733,13 +778,14 @@ void printPackageData() { } /* provides */ - printf("

%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) { + j=0; while (sqlite3_step(stmt1) == SQLITE_ROW) { + if (j++ == 0) printf("

%s:",_("Provides")); 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"))) { printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideflags"))); @@ -750,13 +796,14 @@ void printPackageData() { } /* requires */ - printf("

%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) { + j=0; while (sqlite3_step(stmt1) == SQLITE_ROW) { + if (j++ == 0) printf("

%s:", _("Requires")); 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"))) { printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "requireflags"))); @@ -1019,6 +1066,8 @@ void parse_request_variables(char *data) { reply_xmltag = valuetok; } else if (!strcmp(vartok, "replyplain")) { reply_plain = strstr(valuetok, "true") == valuetok; + } else if (!strcmp(vartok, "query_compact")) { + query_compact = strstr(valuetok, "true") == valuetok; } else { /* fields to make reusable query string for next pages */ if (!strcmp(vartok, "query")) {