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.,
# 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)
cgidir := $(localstatedir)/www/cgi-bin
wwwdir := $(localstatedir)/www/html

View File

@ -69,7 +69,7 @@ int SQLite_print_contents_subtree(sqlite3 *db,
int arch) {
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->firstchild?ft->firstchild->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);
while (fileUser) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO fileusers VALUES(%d,?);",
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO fileusers VALUES(%ld,?);",
fileUser->id);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
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) {
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO filegroups VALUES(%d,?);",
snprintf(sqlite3_query, PATH_MAX, "INSERT INTO filegroups VALUES(%ld,?);",
fileGroup->id);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
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) {
/* packages <-> files relations */
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->file[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 i;
struct providedList* 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];
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->flags,
provided->numproviders);
@ -259,6 +258,7 @@ int generateSQLite_packagers(sqlite3 *db) {
packager = packager->next;
}
SQLite_commit_transaction(db);
return 0;
}
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;
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,
changelog->time,
changelog->pkg->id);
@ -317,7 +317,7 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
currpackage = ct->headerlist[arch];
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->epoch,
currpackage->size,
@ -343,7 +343,7 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
/* obsoletes */
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->obsoleteflags[i]);
@ -361,7 +361,7 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
/* provides */
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->provided[i]->id,
currpackage->provideflags[i]);
@ -380,7 +380,7 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
/* requires */
for (i = 0; i < currpackage->requirecount; i++) {
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->require[i]->resolved->id,
currpackage->require[i]->flags);
@ -400,8 +400,8 @@ generateSQLite_packages(struct configTag *ct, sqlite3 *db, int arch) {
}
currpackage = currpackage->next;
}
SQLite_commit_transaction(db);
return 0;
}
#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;
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->altrepository,
currsource->epoch,
@ -471,7 +471,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
if (currsource->source) {
i=0;
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);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
@ -491,7 +491,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
if (currsource->patch) {
i=0;
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);
if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
@ -509,7 +509,7 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
/* buildrequires */
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->require[i]->flags);
@ -546,8 +546,8 @@ generateSQLite_sources(struct configTag *ct, sqlite3 *db) {
}
currsource = currsource->next;
}
SQLite_commit_transaction(db);
return 0;
}
int

View File

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

View File

@ -78,7 +78,7 @@
// must be as big as ARCHS_MAX (5)
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_package;
char *query_repository;
@ -91,6 +91,7 @@ char *reply_xmltag = "queryreply";
int reply_plain = 0;
char *lang = "";
int query_archs[ARCHS_MAX] = { 1, 0, 0, 0, 0 };
char *file_browser = NULL;
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) {
const char* colname;
const char* tablename;
int id = 0;
while (colname = sqlite3_column_name(stmt, id)) {
while ((colname = sqlite3_column_name(stmt, id))) {
if (!strcmp(colname, name)) {
if (table) {
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';
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_step(stmt) != SQLITE_ROW) return NULL;
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];
sqlite3 *dbf;
sqlite3_stmt *statement, *stmt1;
@ -317,17 +325,7 @@ void printQueryData() {
for (i = 0; i < strlen(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 (a = 0; a < ARCHS_MAX && query_repositories[i]->arch[a]; a++) {
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")));
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);
get_favicon_from_url((const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX);
if (query_compact)
printf("<div style='position:relative'>");
else
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")));
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
(const char*)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license")));
printf("<br><img src=\"%s\" width\"16\" height=\"16\">&nbsp;", buffer);
sqlite3_finalize(stmt1);
}
@ -384,21 +382,21 @@ void printQueryData() {
"repository=%s&package=%s&arch=%s&searchbox=true' style=\"color:black\" target='distroquery'>"
"%s</a></b> %s-%s - %s<br>",
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],
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));
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
} else {
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")),
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));
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
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>",
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 */
/* 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]) {
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 (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;
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; ignoring.\n", dbname);
}
@ -546,14 +544,14 @@ void printQueryData() {
numresults++;
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>");
printTagsLine(NULL,
query_repositories[i]->tag,
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, "groupdescr")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license")));
printf("<br><img src=\"%s\" width\"16\" height=\"16\">&nbsp;", buffer);
if (query_compact) {
@ -561,26 +559,26 @@ void printQueryData() {
"repository=%s&package=%s&searchbox=true' style=\"color:black\" target='distroquery'>"
"%s</a></b> %s-%s - %s<br>",
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));
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
htmlcleanNoBr((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
} else {
printf("<b>%s</b> %s-%s<br>%s<br><br>",
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));
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
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>",
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 */
printf("<div style='display:inline;background-color:lightblue;font-weight:strong'>"
"&nbsp;<a href=#reply onclick='distroquery_request("
"\"repository=%s&package=%s\")' style=\"color:black\">Details</a>&nbsp;</div>",
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);
@ -633,30 +631,12 @@ void printQueryData() {
}
}
void printPackageData() {
int a, i, j, k;
void attachCtDatabases(struct configTag* ct, sqlite3 *db) {
char dbname[PATH_MAX];
sqlite3 *db, *dbs, *dbf;
sqlite3_stmt *statement, *stmt1, *stmt2;
int i=0;
char sql[PATH_MAX];
char buffer[PATH_MAX];
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]) {
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);
@ -665,6 +645,29 @@ void printPackageData() {
}
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);
@ -691,22 +694,22 @@ void printPackageData() {
printf("<hr><br>");
printTagsLine(query_arch,
ct->tag,
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(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
(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>"
"<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",
buffer,
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, "name")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
_("Version"),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
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(statement,sqlite3_find_column_id(statement, NULL, "version")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
(const char*)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"),
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)
printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s(%s)</a>",
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,
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);
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));
htmlclean((const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
/* download */
printf("<div style='display:inline;background-color:green'>"
@ -733,9 +736,9 @@ void printPackageData() {
ct->download_prefix,
ct->download_dir,
query_arch,
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")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
(const char*)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
query_arch,
_("Download"));
@ -744,11 +747,11 @@ void printPackageData() {
printf("<br>%s:", _("Source package"));
printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s\")'>%s</a>",
ct->tag,
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")),
(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);
if (file = fopen(buffer, "r")) {
if ((file = fopen(buffer, "r"))) {
fclose(file);
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);
@ -756,9 +759,9 @@ void printPackageData() {
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"),
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 */
snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d",
@ -768,10 +771,10 @@ void printPackageData() {
j=0;
while (sqlite3_step(stmt1) == SQLITE_ROW) {
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"))) {
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);
@ -786,10 +789,10 @@ void printPackageData() {
j=0;
while (sqlite3_step(stmt1) == SQLITE_ROW) {
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"))) {
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);
@ -883,7 +886,7 @@ void printPackageData() {
void printSourcePackageData() {
int a, i, j, k;
int a;
char dbname[PATH_MAX];
sqlite3 *db, *dba;
sqlite3_stmt *statement, *stmt1;
@ -892,7 +895,6 @@ void printSourcePackageData() {
struct configTag* ct = findRepositoryByTag(query_repository);
humanDate strdate;
sizeString strsize;
FILE *file;
if (!reply_plain) printf("<%s><![CDATA[", reply_xmltag);
@ -913,22 +915,22 @@ void printSourcePackageData() {
printf("<hr><br>");
printTagsLine(NULL,
ct->tag,
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, "groupdescr")),
(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>"
"<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",
buffer,
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, "name")),
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
_("Version"),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
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, "version")),
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
(char *)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));
printf("<br>%s:", _("Built packages"));
@ -941,9 +943,9 @@ void printSourcePackageData() {
while (sqlite3_step(stmt1) == SQLITE_ROW)
printf(" <a href=#reply onclick='distroquery_request(\"repository=%s&package=%s&arch=%s\")'>%s(%s)</a>",
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],
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]);
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>",
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 */
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>",
ct->download_prefix,
ct->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")),
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
_("Download"));
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"),
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"));
snprintf(sql, PATH_MAX,
@ -976,7 +978,7 @@ void printSourcePackageData() {
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
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")));
printf(" %s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "source")));
}
sqlite3_finalize(stmt1);
}
@ -986,7 +988,7 @@ void printSourcePackageData() {
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
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")));
printf(" %s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "patch")));
}
sqlite3_finalize(stmt1);
}
@ -996,10 +998,10 @@ void printSourcePackageData() {
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
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")))) {
printf(" %s", (char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildrequirename")));
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")));
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);
@ -1012,17 +1014,17 @@ void printSourcePackageData() {
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),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packagers", "name")),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "release")),
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "text")));
(char *)simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "time")), (humanDate *) & strdate),
(char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packagers", "name")),
(char *)sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "release")),
(char *)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")));
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
(char *)sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")));
sqlite3_finalize(statement);
}
if (!reply_plain) printf("]]></%s>", reply_xmltag);
@ -1068,6 +1070,8 @@ void parse_request_variables(char *data) {
reply_plain = strstr(valuetok, "true") == valuetok;
} else if (!strcmp(vartok, "query_compact")) {
query_compact = strstr(valuetok, "true") == valuetok;
} else if (!strcmp(vartok, "file_browser")) {
file_browser = valuetok;
} else {
/* fields to make reusable query string for next pages */
if (!strcmp(vartok, "query")) {
@ -1121,9 +1125,8 @@ int
main(int argc, char *argv[])
{
char *repository_dir = NULL;
// char *configfile = NULL;
char *data;
int responsed = 0;
// install backtrace handler
signal(SIGSEGV, backtraceHandler);
@ -1154,13 +1157,16 @@ main(int argc, char *argv[])
printPackageData();
else
printSourcePackageData();
if (searchbox) printInputForm();
responsed = 1;
} else if (query && strlen(query)) {
printQueryData();
if (searchbox) printInputForm();
} else {
printInputForm();
printQueryResponse();
responsed = 1;
} else if (file_browser) {
printFileBrowser();
responsed = 1;
}
if (!responsed || (responsed && searchbox)) printInputForm();
if (!reply_plain) printf("</distroquery>\n");
exit(0);

View File

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

View File

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

View File

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