Compile with -Wall and fix all new warnings

This commit is contained in:
Silvan Calarco 2013-10-20 13:42:55 +02:00
parent f899e8907e
commit c80e43497e
7 changed files with 166 additions and 153 deletions

View File

@ -15,7 +15,7 @@
# this program; if not, write to the Free Software Foundation, Inc., # this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include -rdynamic AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include -rdynamic -Wall
LDFLAGS += $(SQLITE_LIBS) -lpthread -rdynamic $(LTLIBINTL) LDFLAGS += $(SQLITE_LIBS) -lpthread -rdynamic $(LTLIBINTL)
cgidir := $(localstatedir)/www/cgi-bin cgidir := $(localstatedir)/www/cgi-bin
wwwdir := $(localstatedir)/www/html wwwdir := $(localstatedir)/www/html

View File

@ -69,7 +69,7 @@ int SQLite_print_contents_subtree(sqlite3 *db,
int arch) { int arch) {
while (ft) { while (ft) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO files VALUES(%d,?,%d,%d,%d,%d);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO files VALUES(%ld,?,%ld,%ld,%ld,%d);",
ft->id, ft->id,
(ft->firstchild?ft->firstchild->id:-1), (ft->firstchild?ft->firstchild->id:-1),
(ft->next?ft->next->id:-1), (ft->next?ft->next->id:-1),
@ -127,7 +127,7 @@ int generateSQLite_files(struct configTag* ct, sqlite3 *db, int arch) {
SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_filegroups); SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_filegroups);
while (fileUser) { while (fileUser) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO fileusers VALUES(%d,?);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO fileusers VALUES(%ld,?);",
fileUser->id); fileUser->id);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query); fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
@ -143,7 +143,7 @@ int generateSQLite_files(struct configTag* ct, sqlite3 *db, int arch) {
} }
while (fileGroup) { while (fileGroup) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO filegroups VALUES(%d,?);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO filegroups VALUES(%ld,?);",
fileGroup->id); fileGroup->id);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query); fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
@ -165,7 +165,7 @@ int generateSQLite_files(struct configTag* ct, sqlite3 *db, int arch) {
while (currpackage) { while (currpackage) {
/* packages <-> files relations */ /* packages <-> files relations */
for (i = 0; i < currpackage->filenamecount; i++) { for (i = 0; i < currpackage->filenamecount; i++) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages_files_rel VALUES(NULL,%d,%d,%d,%d,%d,?,?,?);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages_files_rel VALUES(NULL,%ld,%ld,%ld,%ld,%d,?,?,?);",
currpackage->id, currpackage->id,
currpackage->file[i]->id, currpackage->file[i]->id,
currpackage->fileuser[i]->id, currpackage->fileuser[i]->id,
@ -201,7 +201,6 @@ int generateSQLite_files(struct configTag* ct, sqlite3 *db, int arch) {
int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) { int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) {
int i;
struct providedList* provided; struct providedList* provided;
snprintf(sqlite3_query, PATH_MAX, "provided"); snprintf(sqlite3_query, PATH_MAX, "provided");
@ -210,7 +209,7 @@ int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) {
provided = ct->providedlist_idx[arch][0]; provided = ct->providedlist_idx[arch][0];
while (provided) { while (provided) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%d,?,%d,%d);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%ld,?,%ld,%d);",
provided->id, provided->id,
provided->flags, provided->flags,
provided->numproviders); provided->numproviders);
@ -259,6 +258,7 @@ int generateSQLite_packagers(sqlite3 *db) {
packager = packager->next; packager = packager->next;
} }
SQLite_commit_transaction(db); SQLite_commit_transaction(db);
return 0;
} }
long generateSQLite_add_changelog(sqlite3 *db, struct changeLog* firstchangelog, long id_source) { long generateSQLite_add_changelog(sqlite3 *db, struct changeLog* firstchangelog, long id_source) {
@ -267,7 +267,7 @@ long generateSQLite_add_changelog(sqlite3 *db, struct changeLog* firstchangelog,
long lastchangelogid = 0; long lastchangelogid = 0;
while (changelog) { while (changelog) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO changelog VALUES(NULL,%d,%d,%d,?,?);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO changelog VALUES(NULL,%ld,%ld,%ld,?,?);",
id_source, id_source,
changelog->time, changelog->time,
changelog->pkg->id); changelog->pkg->id);
@ -317,7 +317,7 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
currpackage = ct->headerlist[arch]; currpackage = ct->headerlist[arch];
while (currpackage) { while (currpackage) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages VALUES(NULL,?,%d,%d,?,?,?,?,?,%d,%d);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages VALUES(NULL,?,%d,%ld,?,?,?,?,?,%ld,%ld);",
currpackage->altrepository, currpackage->altrepository,
currpackage->epoch, currpackage->epoch,
currpackage->size, currpackage->size,
@ -343,7 +343,7 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
/* obsoletes */ /* obsoletes */
for (i = 0; i < currpackage->obsoletecount; i++) { for (i = 0; i < currpackage->obsoletecount; i++) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO obsoletes VALUES(NULL,%d,?,%d,?);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO obsoletes VALUES(NULL,%ld,?,%d,?);",
currpackage->id, currpackage->id,
currpackage->obsoleteflags[i]); currpackage->obsoleteflags[i]);
@ -361,7 +361,7 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
/* provides */ /* provides */
for (i = 0; i < currpackage->providecount; i++) { for (i = 0; i < currpackage->providecount; i++) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provides VALUES(NULL,%d,%d,%d,?);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provides VALUES(NULL,%ld,%ld,%d,?);",
currpackage->id, currpackage->id,
currpackage->provided[i]->id, currpackage->provided[i]->id,
currpackage->provideflags[i]); currpackage->provideflags[i]);
@ -380,7 +380,7 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
/* requires */ /* requires */
for (i = 0; i < currpackage->requirecount; i++) { for (i = 0; i < currpackage->requirecount; i++) {
if (currpackage->require[i]->resolved) { if (currpackage->require[i]->resolved) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO requires VALUES(NULL,%d,%d,%d,?);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO requires VALUES(NULL,%ld,%ld,%ld,?);",
currpackage->id, currpackage->id,
currpackage->require[i]->resolved->id, currpackage->require[i]->resolved->id,
currpackage->require[i]->flags); currpackage->require[i]->flags);
@ -400,8 +400,8 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
} }
currpackage = currpackage->next; currpackage = currpackage->next;
} }
SQLite_commit_transaction(db); SQLite_commit_transaction(db);
return 0;
} }
#define SQLITE_TABLE_sources_source "id INTEGER PRIMARY KEY, id_source INTEGER, source STRING" #define SQLITE_TABLE_sources_source "id INTEGER PRIMARY KEY, id_source INTEGER, source STRING"
@ -436,7 +436,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
currsource = ct->headersourcelist; currsource = ct->headersourcelist;
while (currsource != NULL) { while (currsource != NULL) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources VALUES(%d,?,%d,%d,?,?,?,%d,?,?,?,?,?,?,?,%d,%d,%d);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources VALUES(%ld,?,%d,%ld,?,?,?,%ld,?,?,?,?,?,?,?,%ld,%ld,%ld);",
currsource->id, currsource->id,
currsource->altrepository, currsource->altrepository,
currsource->epoch, currsource->epoch,
@ -471,7 +471,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
if (currsource->source) { if (currsource->source) {
i=0; i=0;
while (currsource->source[i]) { while (currsource->source[i]) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_source VALUES(NULL,%d,?);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_source VALUES(NULL,%ld,?);",
currsource->id); currsource->id);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
@ -491,7 +491,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
if (currsource->patch) { if (currsource->patch) {
i=0; i=0;
while (currsource->patch[i]) { while (currsource->patch[i]) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_patch VALUES(NULL,%d,?);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_patch VALUES(NULL,%ld,?);",
currsource->id); currsource->id);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) { if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
@ -509,7 +509,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
/* buildrequires */ /* buildrequires */
for (i = 0; i < currsource->requirecount; i++) { for (i = 0; i < currsource->requirecount; i++) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO buildrequires VALUES(NULL,%d,?,%d,?);", snprintf(sqlite3_query, PATH_MAX, "INSERT INTO buildrequires VALUES(NULL,%ld,?,%ld,?);",
currsource->id, currsource->id,
currsource->require[i]->flags); currsource->require[i]->flags);
@ -546,8 +546,8 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
} }
currsource = currsource->next; currsource = currsource->next;
} }
SQLite_commit_transaction(db); SQLite_commit_transaction(db);
return 0;
} }
int int

View File

@ -20,6 +20,15 @@
#include "config.h" #include "config.h"
/* Tell glibc's <time.h> to provide a prototype for strptime() */
#ifndef __USE_XOPEN
# define __USE_XOPEN
#endif
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#include <getopt.h> #include <getopt.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
@ -48,10 +57,6 @@
# include <strings.h> # include <strings.h>
#endif #endif
/* Tell glibc's <time.h> to provide a prototype for strptime() */
#ifndef __USE_XOPEN
# define __USE_XOPEN
#endif
#if TIME_WITH_SYS_TIME #if TIME_WITH_SYS_TIME
# include <sys/time.h> # include <sys/time.h>
@ -917,7 +922,7 @@ void *threadArchScan(void* arg) {
/* currheaderlist = headerlist; */ /* currheaderlist = headerlist; */
generatePkgList(configtag, arch); generatePkgList(configtag, arch);
} }
return NULL;
} }
int int
@ -930,7 +935,7 @@ main(int argc, char *argv[])
struct headerList *currheaderlist; struct headerList *currheaderlist;
struct headerSourceList *currheadersourcelist = NULL; struct headerSourceList *currheadersourcelist = NULL;
int i,hasbuilds[ARCHS_MAX],ptharg[ARCHS_MAX]; int i = 0,hasbuilds[ARCHS_MAX],ptharg[ARCHS_MAX];
pthread_t pth[ARCHS_MAX]; pthread_t pth[ARCHS_MAX];
char warning[PATH_MAX]; char warning[PATH_MAX];

View File

@ -78,7 +78,7 @@
// must be as big as ARCHS_MAX (5) // must be as big as ARCHS_MAX (5)
const char* ARCHS[ARCHS_MAX] = { "i586", "x86_64", "arm", "", "" }; const char* ARCHS[ARCHS_MAX] = { "i586", "x86_64", "arm", "", "" };
static struct configTag *firstconfigtag = NULL, *configtag = NULL; static struct configTag *firstconfigtag = NULL;
char *query = ""; char *query = "";
char *query_package; char *query_package;
char *query_repository; char *query_repository;
@ -91,6 +91,7 @@ char *reply_xmltag = "queryreply";
int reply_plain = 0; int reply_plain = 0;
char *lang = ""; char *lang = "";
int query_archs[ARCHS_MAX] = { 1, 0, 0, 0, 0 }; int query_archs[ARCHS_MAX] = { 1, 0, 0, 0, 0 };
char *file_browser = NULL;
struct configTag *query_repositories[100]; struct configTag *query_repositories[100];
@ -149,10 +150,9 @@ char *url_decode(char *str) {
int sqlite3_find_column_id(sqlite3_stmt *stmt, const char* table, const char* name) { int sqlite3_find_column_id(sqlite3_stmt *stmt, const char* table, const char* name) {
const char* colname; const char* colname;
const char* tablename;
int id = 0; int id = 0;
while (colname = sqlite3_column_name(stmt, id)) { while ((colname = sqlite3_column_name(stmt, id))) {
if (!strcmp(colname, name)) { if (!strcmp(colname, name)) {
if (table) { if (table) {
if (!strcmp(sqlite3_column_table_name(stmt, id), table)) return id; if (!strcmp(sqlite3_column_table_name(stmt, id), table)) return id;
@ -219,7 +219,7 @@ char* resolveFilePath(sqlite3 *db, long id, char *buffer) {
buffer[0]='\0'; buffer[0]='\0';
do { do {
snprintf(sql, PATH_MAX, "SELECT * FROM files WHERE id=%d", currid); snprintf(sql, PATH_MAX, "SELECT * FROM files WHERE id=%ld", currid);
if (!sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL) == SQLITE_OK) return NULL; if (!sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL) == SQLITE_OK) return NULL;
if (sqlite3_step(stmt) != SQLITE_ROW) return NULL; if (sqlite3_step(stmt) != SQLITE_ROW) return NULL;
snprintf(sql, PATH_MAX, "/%s%s", sqlite3_column_text(stmt,1), buffer); snprintf(sql, PATH_MAX, "/%s%s", sqlite3_column_text(stmt,1), buffer);
@ -302,9 +302,17 @@ void printInputForm() {
} }
} }
void printQueryData() { void printFileBrowser() {
int a, i, j, k, numresults = 0, otherresults = 0, localresults, localprovidesresults, localsourceresults; if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
if (!reply_plain) printf("]]></%s>", reply_xmltag);
}
void printQueryResponse() {
int a, i, j, k, numresults = 0, otherresults = 0, localresults = 0, localprovidesresults = 0, localsourceresults = 0;
char dbname[PATH_MAX]; char dbname[PATH_MAX];
sqlite3 *dbf; sqlite3 *dbf;
sqlite3_stmt *statement, *stmt1; sqlite3_stmt *statement, *stmt1;
@ -317,17 +325,7 @@ void printQueryData() {
for (i = 0; i < strlen(queryenc); i++) { for (i = 0; i < strlen(queryenc); i++) {
if (queryenc[i] == ' ') queryenc[i] = '%'; if (queryenc[i] == ' ') queryenc[i] = '%';
} }
/* for (i = 0; query_repositories[i] != NULL; i++) {
for (a = 0; a < ARCHS_MAX && query_repositories[i]->arch[a]; a++) {
if (find_query_arch(query_repositories[i]->arch[a]) >= 0) {
snprintf(dbname, PATH_MAX, "%sdistromatic.db", query_repositories[i]->repository_dir);
if (sqlite3_open_v2(dbname, (sqlite3**)&query_repositories[i]->db, SQLITE_OPEN_READONLY, NULL)) {
if (query_repositories[i]->db) sqlite3_close(query_repositories[i]->db);
query_repositories[i]->db = NULL;
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; aborting.\n", dbname);
}
}*/
for (i = 0; query_repositories[i] != NULL; i++) { for (i = 0; query_repositories[i] != NULL; i++) {
for (a = 0; a < ARCHS_MAX && query_repositories[i]->arch[a]; a++) { for (a = 0; a < ARCHS_MAX && query_repositories[i]->arch[a]; a++) {
if (find_query_arch(query_repositories[i]->arch[a]) >= 0) { if (find_query_arch(query_repositories[i]->arch[a]) >= 0) {
@ -367,15 +365,15 @@ void printQueryData() {
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id_source"))); sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id_source")));
if (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[ARCHS_MAX], sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) { if (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[ARCHS_MAX], sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
sqlite3_step(stmt1); sqlite3_step(stmt1);
get_favicon_from_url(sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX); get_favicon_from_url((const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX);
if (query_compact) if (query_compact)
printf("<div style='position:relative'>"); printf("<div style='position:relative'>");
else else
printf("<div style='position:relative'><hr><br>"); printf("<div style='position:relative'><hr><br>");
printTagsLine(query_repositories[i]->arch[a], printTagsLine(query_repositories[i]->arch[a],
query_repositories[i]->tag, query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license"))); (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license")));
printf("<br><img src=\"%s\" width\"16\" height=\"16\">&nbsp;", buffer); printf("<br><img src=\"%s\" width\"16\" height=\"16\">&nbsp;", buffer);
sqlite3_finalize(stmt1); sqlite3_finalize(stmt1);
} }
@ -384,21 +382,21 @@ void printQueryData() {
"repository=%s&package=%s&arch=%s&searchbox=true' style=\"color:black\" target='distroquery'>" "repository=%s&package=%s&arch=%s&searchbox=true' style=\"color:black\" target='distroquery'>"
"%s</a></b> %s-%s - %s<br>", "%s</a></b> %s-%s - %s<br>",
query_repositories[i]->tag, query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
query_repositories[i]->arch[a], query_repositories[i]->arch[a],
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), (const char*)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)); htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
} else { } else {
printf("<b>%s</b> %s-%s<br>%s", printf("<b>%s</b> %s-%s<br>%s",
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), (const char*)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)); htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
printf("<br><br><div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div>", printf("<br><br><div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div>",
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX)); htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
/* install */ /* install */
/* printf("<div align=right style='position:absolute;top:5px;right:0;padding:5px;'>" /* printf("<div align=right style='position:absolute;top:5px;right:0;padding:5px;'>"
@ -534,7 +532,7 @@ void printQueryData() {
if (!query_repositories[i]->db[ARCHS_MAX]) { if (!query_repositories[i]->db[ARCHS_MAX]) {
snprintf(dbname, PATH_MAX, "%s%s-sources.db", query_repositories[i]->repository_dir, query_repositories[i]->tag); snprintf(dbname, PATH_MAX, "%s%s-sources.db", query_repositories[i]->repository_dir, query_repositories[i]->tag);
if (sqlite3_open_v2(dbname, (sqlite3**)&query_repositories[i]->db[ARCHS_MAX], SQLITE_OPEN_READONLY, NULL)) { if (sqlite3_open_v2(dbname, (sqlite3**)&query_repositories[i]->db[ARCHS_MAX], SQLITE_OPEN_READONLY, NULL)) {
if (query_repositories[i]->db) sqlite3_close(query_repositories[i]->db[a]); if (query_repositories[i]->db[ARCHS_MAX]) sqlite3_close(query_repositories[i]->db[ARCHS_MAX]);
query_repositories[i]->db[ARCHS_MAX] = NULL; query_repositories[i]->db[ARCHS_MAX] = NULL;
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; ignoring.\n", dbname); fprintf(stderr, "ERROR: unable to open sqlite3 db %s; ignoring.\n", dbname);
} }
@ -546,14 +544,14 @@ void printQueryData() {
numresults++; numresults++;
localsourceresults++; localsourceresults++;
get_favicon_from_url(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX); get_favicon_from_url((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX);
if (!query_compact) printf("<hr><br>"); if (!query_compact) printf("<hr><br>");
printTagsLine(NULL, printTagsLine(NULL,
query_repositories[i]->tag, query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license"))); (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license")));
printf("<br><img src=\"%s\" width\"16\" height=\"16\">&nbsp;", buffer); printf("<br><img src=\"%s\" width\"16\" height=\"16\">&nbsp;", buffer);
if (query_compact) { if (query_compact) {
@ -561,26 +559,26 @@ void printQueryData() {
"repository=%s&package=%s&searchbox=true' style=\"color:black\" target='distroquery'>" "repository=%s&package=%s&searchbox=true' style=\"color:black\" target='distroquery'>"
"%s</a></b> %s-%s - %s<br>", "%s</a></b> %s-%s - %s<br>",
query_repositories[i]->tag, query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), (const char*)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)); htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
} else { } else {
printf("<b>%s</b> %s-%s<br>%s<br><br>", printf("<b>%s</b> %s-%s<br>%s<br><br>",
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), (const char*)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)); htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
printf("<div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div>", printf("<div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div>",
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX)); htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
/* source details */ /* source details */
printf("<div style='display:inline;background-color:lightblue;font-weight:strong'>" printf("<div style='display:inline;background-color:lightblue;font-weight:strong'>"
"&nbsp;<a href=#reply onclick='distroquery_request(" "&nbsp;<a href=#reply onclick='distroquery_request("
"\"repository=%s&package=%s\")' style=\"color:black\">Details</a>&nbsp;</div>", "\"repository=%s&package=%s\")' style=\"color:black\">Details</a>&nbsp;</div>",
query_repositories[i]->tag, query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name"))); (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")));
} }
} }
sqlite3_finalize(statement); sqlite3_finalize(statement);
@ -633,30 +631,12 @@ void printQueryData() {
} }
} }
void printPackageData() { void attachCtDatabases(struct configTag* ct, sqlite3 *db) {
int a, i, j, k;
char dbname[PATH_MAX]; char dbname[PATH_MAX];
sqlite3 *db, *dbs, *dbf; int i=0;
sqlite3_stmt *statement, *stmt1, *stmt2;
char sql[PATH_MAX]; char sql[PATH_MAX];
char buffer[PATH_MAX];
char *errmsg; char *errmsg;
struct configTag* ct = findRepositoryByTag(query_repository);
humanDate strdate;
sizeString strsize;
FILE *file;
int query_arch_num = find_query_arch(query_arch);
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository_dir, ct->tag, query_arch);
if (sqlite3_open_v2(dbname, (sqlite3**)&db, SQLITE_OPEN_READONLY, NULL)) {
if (db) sqlite3_close(db);
fprintf(stderr, "ERROR: unable to open sqlite3 db %s\n", dbname);
return;
}
i=0;
while (ct->repository[i]) { while (ct->repository[i]) {
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository[i]->repository_dir, ct->repository[i]->tag, query_arch); snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository[i]->repository_dir, ct->repository[i]->tag, query_arch);
snprintf(sql, PATH_MAX, "ATTACH DATABASE '%s' as '%s'", dbname, ct->repository[i]->tag); snprintf(sql, PATH_MAX, "ATTACH DATABASE '%s' as '%s'", dbname, ct->repository[i]->tag);
@ -665,6 +645,29 @@ void printPackageData() {
} }
i++; i++;
} }
}
void printPackageData() {
int i, j;
char dbname[PATH_MAX];
sqlite3 *db, *dbs, *dbf;
sqlite3_stmt *statement, *stmt1, *stmt2;
char sql[PATH_MAX];
char buffer[PATH_MAX];
struct configTag* ct = findRepositoryByTag(query_repository);
humanDate strdate;
sizeString strsize;
FILE *file;
snprintf(dbname, PATH_MAX, "%s%s-%s.db", ct->repository_dir, ct->tag, query_arch);
if (sqlite3_open_v2(dbname, (sqlite3**)&db, SQLITE_OPEN_READONLY, NULL)) {
if (db) sqlite3_close(db);
fprintf(stderr, "ERROR: unable to open sqlite3 db %s\n", dbname);
return;
}
attachCtDatabases(ct, db);
if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag); if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
@ -691,22 +694,22 @@ void printPackageData() {
printf("<hr><br>"); printf("<hr><br>");
printTagsLine(query_arch, printTagsLine(query_arch,
ct->tag, ct->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license"))); (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license")));
get_favicon_from_url(sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX); get_favicon_from_url((const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX);
printf("<br><br>" printf("<br><br>"
"<h1><img src=\"%s\" width\"16\" height=\"16\">&nbsp;" "<h1><img src=\"%s\" width\"16\" height=\"16\">&nbsp;"
"%s - %s</h1>%s: %s-%s<br>URL: <a href=\"%s\" target=_new>%s</a><br>%s: %s", "%s - %s</h1>%s: %s-%s<br>URL: <a href=\"%s\" target=_new>%s</a><br>%s: %s",
buffer, buffer,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
_("Version"), _("Version"),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")), (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")), (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),
_("Size"), _("Size"),
humanSize(sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "size")), &strsize)); humanSize(sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "size")), &strsize));
@ -718,14 +721,14 @@ void printPackageData() {
while (sqlite3_step(stmt2) == SQLITE_ROW) while (sqlite3_step(stmt2) == SQLITE_ROW)
printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s(%s)</a>", printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s(%s)</a>",
ct->tag, ct->tag,
sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "name")), (const char*)sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "name")),
query_arch, query_arch,
sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "name")), (const char*)sqlite3_column_text(stmt2,sqlite3_find_column_id(stmt2, NULL, "name")),
query_arch); query_arch);
sqlite3_finalize(stmt2); sqlite3_finalize(stmt2);
} }
printf("<br><br><div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div><br>", 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)); htmlclean((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
/* download */ /* download */
printf("<div style='display:inline;background-color:green'>" printf("<div style='display:inline;background-color:green'>"
@ -733,9 +736,9 @@ void printPackageData() {
ct->download_prefix, ct->download_prefix,
ct->download_dir, ct->download_dir,
query_arch, query_arch,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), (const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
query_arch, query_arch,
_("Download")); _("Download"));
@ -744,11 +747,11 @@ void printPackageData() {
printf("<br>%s:", _("Source package")); printf("<br>%s:", _("Source package"));
printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s\")'>%s</a>", printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s\")'>%s</a>",
ct->tag, ct->tag,
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")), (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name"))); (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
snprintf(buffer, PATH_MAX, "%s/specs/%s.spec", ct->repository_dir, query_package); snprintf(buffer, PATH_MAX, "%s/specs/%s.spec", ct->repository_dir, query_package);
if (file = fopen(buffer, "r")) { if ((file = fopen(buffer, "r"))) {
fclose(file); fclose(file);
snprintf(buffer, PATH_MAX, "%s%s/specs/%s.spec", ct->showfile_prefix, ct->download_dir, query_package); snprintf(buffer, PATH_MAX, "%s%s/specs/%s.spec", ct->showfile_prefix, ct->download_dir, query_package);
printf("<br>%s: <a href=\"%s\" target=_blank>%s.spec</a>", _("Specfile"), buffer, query_package); printf("<br>%s: <a href=\"%s\" target=_blank>%s.spec</a>", _("Specfile"), buffer, query_package);
@ -756,9 +759,9 @@ void printPackageData() {
printf("<br>%s: %s.spec", _("Specfile"), query_package); printf("<br>%s: %s.spec", _("Specfile"), query_package);
} }
printf("<br>%s: %s", _("Maintainer"), sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packagers", "name"))); printf("<br>%s: %s", _("Maintainer"), (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packagers", "name")));
printf("<br>%s: %s", _("Build date"), printf("<br>%s: %s", _("Build date"),
simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildtime")), (humanDate *) & strdate)); (char *)simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildtime")), (humanDate *) & strdate));
/* obsoletes */ /* obsoletes */
snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d", snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d",
@ -768,10 +771,10 @@ void printPackageData() {
j=0; j=0;
while (sqlite3_step(stmt1) == SQLITE_ROW) { while (sqlite3_step(stmt1) == SQLITE_ROW) {
if (j++ == 0) printf("<br><br>%s:", _("Obsoletes")); if (j++ == 0) printf("<br><br>%s:", _("Obsoletes"));
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoletename"))); printf(" %s", (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoletename")));
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteversion"))) { if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteversion"))) {
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteflags"))); printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteflags")));
printf("%s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteversion"))); printf("%s", (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteversion")));
} }
} }
sqlite3_finalize(stmt1); sqlite3_finalize(stmt1);
@ -786,10 +789,10 @@ void printPackageData() {
j=0; j=0;
while (sqlite3_step(stmt1) == SQLITE_ROW) { while (sqlite3_step(stmt1) == SQLITE_ROW) {
if (j++ == 0) printf("<br><br>%s:",_("Provides")); if (j++ == 0) printf("<br><br>%s:",_("Provides"));
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name"))); printf(" %s", (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideversion"))) { if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideversion"))) {
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideflags"))); printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideflags")));
printf("%s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideversion"))); printf("%s", (const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideversion")));
} }
} }
sqlite3_finalize(stmt1); sqlite3_finalize(stmt1);
@ -883,7 +886,7 @@ void printPackageData() {
void printSourcePackageData() { void printSourcePackageData() {
int a, i, j, k; int a;
char dbname[PATH_MAX]; char dbname[PATH_MAX];
sqlite3 *db, *dba; sqlite3 *db, *dba;
sqlite3_stmt *statement, *stmt1; sqlite3_stmt *statement, *stmt1;
@ -892,7 +895,6 @@ void printSourcePackageData() {
struct configTag* ct = findRepositoryByTag(query_repository); struct configTag* ct = findRepositoryByTag(query_repository);
humanDate strdate; humanDate strdate;
sizeString strsize; sizeString strsize;
FILE *file;
if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag); if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
@ -913,22 +915,22 @@ void printSourcePackageData() {
printf("<hr><br>"); printf("<hr><br>");
printTagsLine(NULL, printTagsLine(NULL,
ct->tag, ct->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license"))); (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license")));
get_favicon_from_url(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX); get_favicon_from_url((char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX);
printf("<br><br>" printf("<br><br>"
"<h1><img src=\"%s\" width\"16\" height=\"16\">&nbsp;" "<h1><img src=\"%s\" width\"16\" height=\"16\">&nbsp;"
"%s - %s</h1>%s: %s-%s<br>URL: <a href=\"%s\" target=_new>%s</a><br>Size: %s", "%s - %s</h1>%s: %s-%s<br>URL: <a href=\"%s\" target=_new>%s</a><br>Size: %s",
buffer, buffer,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
_("Version"), _("Version"),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),
humanSize(sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "size")), &strsize)); humanSize(sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "size")), &strsize));
printf("<br>%s:", _("Built packages")); printf("<br>%s:", _("Built packages"));
@ -941,9 +943,9 @@ void printSourcePackageData() {
while (sqlite3_step(stmt1) == SQLITE_ROW) while (sqlite3_step(stmt1) == SQLITE_ROW)
printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s(%s)</a>", printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s(%s)</a>",
ct->tag, ct->tag,
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")), (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
ct->arch[a], ct->arch[a],
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")), (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
ct->arch[a]); ct->arch[a]);
sqlite3_finalize(stmt1); sqlite3_finalize(stmt1);
} }
@ -952,23 +954,23 @@ void printSourcePackageData() {
} }
printf("<br><br><div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div><br>", 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)); htmlclean((char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
/* download */ /* download */
printf("<div style='display:inline;background-color:red'>" printf("<div style='display:inline;background-color:red'>"
"&nbsp;<a href=\"%s%s/SRPMS.base/%s-%s-%s.src.rpm\" style=\"color:white\">%s</a>&nbsp;</div>", "&nbsp;<a href=\"%s%s/SRPMS.base/%s-%s-%s.src.rpm\" style=\"color:white\">%s</a>&nbsp;</div>",
ct->download_prefix, ct->download_prefix,
ct->download_dir, ct->download_dir,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
_("Download")); _("Download"));
printf("<hr><br><b>%s:</b>", _("Developers details")); printf("<hr><br><b>%s:</b>", _("Developers details"));
printf("<br>%s: %s", _("Maintainer"), sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packagers", "name"))); printf("<br>%s: %s", _("Maintainer"), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packagers", "name")));
printf("<br>%s: %s", _("Build date"), printf("<br>%s: %s", _("Build date"),
simpleTimeToHuman(sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "buildtime")), (humanDate *) & strdate)); (char *)simpleTimeToHuman(sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "buildtime")), (humanDate *) & strdate));
printf("<br><br>%s:", _("Source files")); printf("<br><br>%s:", _("Source files"));
snprintf(sql, PATH_MAX, snprintf(sql, PATH_MAX,
@ -976,7 +978,7 @@ void printSourcePackageData() {
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "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) { while (sqlite3_step(stmt1) == SQLITE_ROW) {
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "source"))); printf(" %s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "source")));
} }
sqlite3_finalize(stmt1); sqlite3_finalize(stmt1);
} }
@ -986,7 +988,7 @@ void printSourcePackageData() {
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "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) { while (sqlite3_step(stmt1) == SQLITE_ROW) {
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "patch"))); printf(" %s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "patch")));
} }
sqlite3_finalize(stmt1); sqlite3_finalize(stmt1);
} }
@ -996,10 +998,10 @@ void printSourcePackageData() {
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "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) { while (sqlite3_step(stmt1) == SQLITE_ROW) {
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequirename"))); printf(" %s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequirename")));
if (strcmp("", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireversion")))) { if (strcmp("", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireversion")))) {
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireflags"))); printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireflags")));
printf("%s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireversion"))); printf("%s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequireversion")));
} }
} }
sqlite3_finalize(stmt1); sqlite3_finalize(stmt1);
@ -1012,17 +1014,17 @@ void printSourcePackageData() {
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) { while (sqlite3_step(stmt1) == SQLITE_ROW) {
printf("%s - %s (%s)<br><pre>%s</pre>", printf("%s - %s (%s)<br><pre>%s</pre>",
simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "time")), (humanDate *) & strdate), (char *)simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "time")), (humanDate *) & strdate),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packagers", "name")), (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packagers", "name")),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "release")), (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "release")),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "text"))); (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "text")));
} }
sqlite3_finalize(stmt1); sqlite3_finalize(stmt1);
} }
} }
snprintf(buffer, PATH_MAX, "%s - %s", snprintf(buffer, PATH_MAX, "%s - %s",
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary"))); (char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")));
sqlite3_finalize(statement); sqlite3_finalize(statement);
} }
if (!reply_plain) printf("]]></%s>", reply_xmltag); if (!reply_plain) printf("]]></%s>", reply_xmltag);
@ -1068,6 +1070,8 @@ void parse_request_variables(char *data) {
reply_plain = strstr(valuetok, "true") == valuetok; reply_plain = strstr(valuetok, "true") == valuetok;
} else if (!strcmp(vartok, "query_compact")) { } else if (!strcmp(vartok, "query_compact")) {
query_compact = strstr(valuetok, "true") == valuetok; query_compact = strstr(valuetok, "true") == valuetok;
} else if (!strcmp(vartok, "file_browser")) {
file_browser = valuetok;
} else { } else {
/* fields to make reusable query string for next pages */ /* fields to make reusable query string for next pages */
if (!strcmp(vartok, "query")) { if (!strcmp(vartok, "query")) {
@ -1121,9 +1125,8 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
char *repository_dir = NULL;
// char *configfile = NULL;
char *data; char *data;
int responsed = 0;
// install backtrace handler // install backtrace handler
signal(SIGSEGV, backtraceHandler); signal(SIGSEGV, backtraceHandler);
@ -1154,13 +1157,16 @@ main(int argc, char *argv[])
printPackageData(); printPackageData();
else else
printSourcePackageData(); printSourcePackageData();
if (searchbox) printInputForm(); responsed = 1;
} else if (query && strlen(query)) { } else if (query && strlen(query)) {
printQueryData(); printQueryResponse();
if (searchbox) printInputForm(); responsed = 1;
} else { } else if (file_browser) {
printInputForm(); printFileBrowser();
responsed = 1;
} }
if (!responsed || (responsed && searchbox)) printInputForm();
if (!reply_plain) printf("</distroquery>\n"); if (!reply_plain) printf("</distroquery>\n");
exit(0); exit(0);

View File

@ -73,6 +73,8 @@
#include "distromatic.h" #include "distromatic.h"
#include "changelog.h" #include "changelog.h"
#include <execinfo.h>
static int debug_log = 0; static int debug_log = 0;
static struct configDefaults configdefaults; static struct configDefaults configdefaults;
static struct configTag *firstconfigtag = NULL; static struct configTag *firstconfigtag = NULL;
@ -113,7 +115,7 @@ struct configTag* read_configuration(const char *confFile)
char *vartok, *valuetok; char *vartok, *valuetok;
char input[PATH_MAX]; char input[PATH_MAX];
char buf[PATH_MAX]; char buf[PATH_MAX];
int i, j, curraltrep = 0; int i, curraltrep = 0;
struct configTag *newconfigtag, *currconfigtag = NULL; struct configTag *newconfigtag, *currconfigtag = NULL;
struct Packager *currmaintainer; struct Packager *currmaintainer;

View File

@ -10,5 +10,6 @@
#include "distromatic.h" #include "distromatic.h"
int generateSQLite(struct configTag *); int generateSQLite(struct configTag *);
int generateSQLiteFiles(struct configTag *ct);
#endif // BACKENDSQLITE3_H #endif // BACKENDSQLITE3_H

View File

@ -62,7 +62,6 @@
* static int getPackageInfo( * static int getPackageInfo(
* Header h, char **name, char **version, char **release, * Header h, char **name, char **version, char **release,
* char **summary); */ * char **summary); */
static rpmts ts;
unsigned int checkVersionWithFlags(const char* cmp1, uint_32 flags, const char* cmp2) { unsigned int checkVersionWithFlags(const char* cmp1, uint_32 flags, const char* cmp2) {
@ -94,7 +93,7 @@ int
getHeader(rpmts* ts, char *headerFile, Header * h) getHeader(rpmts* ts, char *headerFile, Header * h)
{ {
char buffer[HEADERS_BUFFER_SIZE]; char buffer[HEADERS_BUFFER_SIZE];
int len,lock=0; int len;
/* check if file is a compressed header or a RPM/SRPM */ /* check if file is a compressed header or a RPM/SRPM */
if (!strcmp(&headerFile[strlen(headerFile) - 4], ".hdr")) { if (!strcmp(&headerFile[strlen(headerFile) - 4], ".hdr")) {