diff --git a/src/distroquery.c b/src/distroquery.c
index 2dee90f..6c48519 100644
--- a/src/distroquery.c
+++ b/src/distroquery.c
@@ -75,16 +75,16 @@
const char* ARCHS[ARCHS_MAX] = { "i586" , "x86_64" , "arm" , "", ""};
static struct configTag *firstconfigtag = NULL, *configtag = NULL;
-char *query;
+char *query = "";
char *query_package;
char *query_repository;
char *query_arch = NULL;
-int query_archs[ARCHS_MAX];
+int query_archs[ARCHS_MAX] = { 1, 0, 0, 0, 0 };
struct configTag *query_repositories[100];
int search_milestone1 = 0, search_milestone2 = 1, search_devel = 1;
-int search_sources = 0;
+int search_sources = 0, searchbox = 0;
/* Converts a hex character to its integer value */
char from_hex(char ch) {
@@ -153,7 +153,6 @@ int sqlite3_find_column_id(sqlite3_stmt *stmt, const char* table, const char* na
return -1;
}
-
int find_query_arch(char* arch) {
int i;
@@ -196,7 +195,7 @@ void printInputForm() {
")";
printf("", ajax_call);
+ printf("", ajax_call, query);
printf("", ajax_call);
/* printf(" Repository: ");*/
- printf("devel ", ajax_call);
- printf("milestone2 ", ajax_call);
- printf("milestone1 ", ajax_call);
- printf(" i586 ", ajax_call);
- printf("x86_64 ", ajax_call);
- printf("arm ", ajax_call);
- printf("sources ", ajax_call);
+
+ printf("devel ", ajax_call);
+
+ printf("milestone2 ", ajax_call);
+
+ printf("milestone1 ", ajax_call);
+
+ printf(" i586 ", ajax_call);
+
+ printf("x86_64 ", ajax_call);
+
+ printf("arm ", ajax_call);
+
+ printf("sources ", ajax_call);
+
printf("
");
/* ct = firstconfigtag;
while (ct) {
@@ -218,6 +239,9 @@ void printInputForm() {
ct = ct->next;
}*/
printf("]]>");
+
+ printf("
",
+ ct->configdefaults->distribution_name);
}
void printQueryData() {
@@ -227,10 +251,12 @@ void printQueryData() {
sqlite3_stmt *statement, *stmt1;
char sql[PATH_MAX];
char buffer[PATH_MAX];
+ char queryenc[PATH_MAX];
printf("db[a], sql, strlen(sql), &statement, NULL) == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
numresults++;
@@ -338,7 +364,7 @@ void printQueryData() {
snprintf(sql, PATH_MAX,
"SELECT * FROM sources WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%' OR version LIKE '%%%s%%'"
"ORDER BY name = '%s' DESC, name LIKE '%s%%' DESC, name LIKE '%%%s%%' DESC LIMIT 100",
- query, query, query, query, query, query);
+ queryenc, queryenc, queryenc, queryenc, queryenc);
for (i = 0; query_repositories[i] != NULL; i++) {
if (!query_repositories[i]->db[ARCHS_MAX]) {
snprintf(dbname, PATH_MAX, "%s%s-sources.db", query_repositories[i]->repository_dir, query_repositories[i]->tag);
@@ -386,6 +412,10 @@ void printQueryData() {
printf("]]>");
printf("", numresults);
+
+ printf("",
+ query,
+ firstconfigtag->configdefaults->distribution_name);
for (i = 0; query_repositories[i] != NULL; i++) {
for (a = 0; a <= ARCHS_MAX && query_repositories[i]->arch[a]; a++) {
@@ -422,7 +452,7 @@ void printPackageData() {
snprintf(sql, PATH_MAX, "SELECT * FROM packages WHERE name = '%s'", query_package);
if (db &&
(sqlite3_prepare_v2(db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
- while (sqlite3_step(statement) == SQLITE_ROW) {
+ 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)) {
@@ -536,6 +566,10 @@ void printPackageData() {
}
}
printf("]]>");
+ printf("",
+ sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
+ sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
+ firstconfigtag->configdefaults->distribution_name);
sqlite3_close(db);
db = NULL;
@@ -567,7 +601,7 @@ void printSourcePackageData() {
"SELECT * FROM sources,packagers WHERE sources.name = '%s' AND sources.id_packager=packagers.id", query_package);
if (db &&
(sqlite3_prepare_v2(db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
- while (sqlite3_step(statement) == SQLITE_ROW) {
+ if (sqlite3_step(statement) == SQLITE_ROW) {
printf("
");
printTagsLine(NULL,
@@ -672,6 +706,10 @@ void printSourcePackageData() {
}
}
printf("]]>");
+ printf("",
+ sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
+ sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
+ firstconfigtag->configdefaults->distribution_name);
sqlite3_close(db);
db = NULL;
@@ -696,11 +734,11 @@ void parse_request_variables(char *data) {
} else if (!strcmp(vartok, "query")) {
query = url_decode(valuetok);
} else if (!strcmp(vartok, "search_milestone2")) {
- search_milestone2 = (strstr(valuetok, "false") != valuetok);
+ search_milestone2 = strstr(valuetok, "false") != valuetok;
} else if (!strcmp(vartok, "search_milestone1")) {
- search_milestone1 = (strstr(valuetok, "false") != valuetok);
+ search_milestone1 = strstr(valuetok, "false") != valuetok;
} else if (!strcmp(vartok, "search_devel")) {
- search_devel = (strstr(valuetok, "false") != valuetok);
+ search_devel = strstr(valuetok, "false") != valuetok;
} else if (!strcmp(vartok, "search_i586")) {
query_archs[0] = strstr(valuetok, "false") != valuetok;
} else if (!strcmp(vartok, "search_x86_64")) {
@@ -708,7 +746,9 @@ void parse_request_variables(char *data) {
} else if (!strcmp(vartok, "search_arm")) {
query_archs[2] = strstr(valuetok, "false") != valuetok;
} else if (!strcmp(vartok, "search_sources")) {
- search_sources = (strstr(valuetok, "false") != valuetok);
+ search_sources = strstr(valuetok, "false") != valuetok;
+ } else if (!strcmp(vartok, "searchbox")) {
+ searchbox = strstr(valuetok, "false") != valuetok;
}
}
@@ -759,8 +799,10 @@ main(int argc, char *argv[])
printPackageData();
else
printSourcePackageData();
+ if (searchbox) printInputForm();
} else if (query && strlen(query)) {
printQueryData();
+ if (searchbox) printInputForm();
} else {
printInputForm();
}