Commit d16962bd authored by Bernhard Link's avatar Bernhard Link

More clean-up

parent 167928fb
......@@ -83,6 +83,7 @@ static void aptmethod_free(struct aptmethod *method) {
free(todo->filekey);
free(todo);
}
free(method);
}
retvalue aptmethod_shutdown(struct aptmethodrun *run) {
......@@ -95,7 +96,7 @@ retvalue aptmethod_shutdown(struct aptmethodrun *run) {
if( method->child > 0 ) {
if( verbose > 5 )
fprintf(stderr,"Still waiting for %d\n",method->child);
fprintf(stderr,"Still waiting for %d\n",(int)method->child);
lastmethod = method;
method = method->next;
continue;
......
#ifndef __MIRRORER_APTMETHOD_H
#define __MIRRORER_APTMETHOD_H
#ifndef REPREPRO_APTMETHOD_H
#define REPREPRO_APTMETHOD_H
#ifndef __MIRRORER_FILES_H
#ifndef REPREPRO_FILES_H
#include "files.h"
#endif
......
#ifndef __MIRRORER_BINARIES_H
#define __MIRRORER_BINARIES_H
#ifndef REPREPRO_BINARIES_H
#define REPREPRO_BINARIES_H
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
#ifndef __MIRRORER_TARGET_H
#ifndef REPREPRO_TARGET_H
#include "target.h"
#endif
......
......@@ -27,7 +27,6 @@
#include <string.h>
#include <malloc.h>
#include <ctype.h>
#include <db.h>
#include "error.h"
#include "strlist.h"
#include "md5sum.h"
......@@ -666,7 +665,7 @@ static retvalue changes_includefiles(filesdb filesdb,const char *filename,struct
return r;
}
static retvalue changes_includepkgs(const char *dbdir,DB *references,filesdb filesdb,struct distribution *distribution,struct changes *changes,const struct overrideinfo *srcoverride,const struct overrideinfo *binoverride,int force) {
static retvalue changes_includepkgs(const char *dbdir,references refs,filesdb filesdb,struct distribution *distribution,struct changes *changes,const struct overrideinfo *srcoverride,const struct overrideinfo *binoverride,int force) {
struct fileentry *e;
retvalue r;
bool_t somethingwasmissed = FALSE;
......@@ -680,11 +679,11 @@ static retvalue changes_includepkgs(const char *dbdir,DB *references,filesdb fil
e = e->next;
continue;
}
fullfilename = calc_dirconcat(filesdb->mirrordir,e->filekey);
fullfilename = files_calcfullfilename(filesdb,e->filekey);
if( fullfilename == NULL )
return RET_ERROR_OOM;
if( e->type == fe_DEB ) {
r = deb_add(dbdir,references,filesdb,
r = deb_add(dbdir,refs,filesdb,
e->component,e->architecture,
e->section,e->priority,
"deb",
......@@ -695,7 +694,7 @@ static retvalue changes_includepkgs(const char *dbdir,DB *references,filesdb fil
if( r == RET_NOTHING )
somethingwasmissed = TRUE;
} else if( e->type == fe_UDEB ) {
r = deb_add(dbdir,references,filesdb,
r = deb_add(dbdir,refs,filesdb,
e->component,e->architecture,
e->section,e->priority,
"udeb",
......@@ -708,7 +707,7 @@ static retvalue changes_includepkgs(const char *dbdir,DB *references,filesdb fil
} else if( e->type == fe_DSC ) {
assert(changes->srccomponent);
assert(changes->srcdirectory);
r = dsc_add(dbdir,references,filesdb,
r = dsc_add(dbdir,refs,filesdb,
changes->srccomponent,e->section,e->priority,
distribution,fullfilename,
e->filekey,e->basename,
......@@ -734,7 +733,7 @@ static retvalue changes_includepkgs(const char *dbdir,DB *references,filesdb fil
/* insert the given .changes into the mirror in the <distribution>
* if forcecomponent, forcesection or forcepriority is NULL
* get it from the files or try to guess it. */
retvalue changes_add(const char *dbdir,DB *references,filesdb filesdb,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,struct distribution *distribution,const struct overrideinfo *srcoverride,const struct overrideinfo *binoverride,const char *changesfilename,int force,int delete) {
retvalue changes_add(const char *dbdir,references refs,filesdb filesdb,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,struct distribution *distribution,const struct overrideinfo *srcoverride,const struct overrideinfo *binoverride,const char *changesfilename,int force,int delete) {
retvalue r;
struct changes *changes;
......@@ -773,7 +772,7 @@ retvalue changes_add(const char *dbdir,DB *references,filesdb filesdb,const char
}
/* add the source and binary packages in the given distribution */
r = changes_includepkgs(dbdir,references,filesdb,
r = changes_includepkgs(dbdir,refs,filesdb,
distribution,changes,srcoverride,binoverride,force);
if( RET_WAS_ERROR(r) ) {
changes_free(changes);
......
#ifndef __MIRRORER_CHECKIN_H
#define __MIRRORER_CHECKIN_H
#ifndef REPREPRO_CHECKIN_H
#define REPREPRO_CHECKIN_H
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
#ifndef __MIRRORER_DISTRIBUTION_H
#ifndef REPREPRO_DISTRIBUTION_H
#include "distribution.h"
#endif
#ifndef __MIRRORER_OVERRIDE_H
#ifndef REPREPRO_OVERRIDE_H
#include "override.h"
#endif
/* insert the given .changes into the mirror in the <distribution>
* if forcecomponent, forcesection or forcepriority is NULL
* get it from the files or try to guess it. */
retvalue changes_add(const char *dbdir,DB *references,filesdb filesdb,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,struct distribution *distribution,const struct overrideinfo *srcoverride,const struct overrideinfo *binoverride,const char *changesfilename,int force,int delete);
retvalue changes_add(const char *dbdir,references refs,filesdb filesdb,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,struct distribution *distribution,const struct overrideinfo *srcoverride,const struct overrideinfo *binoverride,const char *changesfilename,int force,int delete);
#endif
......@@ -28,7 +28,6 @@
#include <malloc.h>
#include <ctype.h>
#include <zlib.h>
#include <db.h>
#include "error.h"
#include "strlist.h"
#include "md5sum.h"
......@@ -280,7 +279,7 @@ static retvalue deb_checkfiles(filesdb filesdb,struct debpackage *pkg,const char
* causing error, if it is not one of them otherwise)
* if component is NULL, guessing it from the section. */
retvalue deb_add(const char *dbdir,DB *references,filesdb filesdb,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,const char *suffix,struct distribution *distribution,const char *debfilename,const char *givenfilekey,const char *givenmd5sum,const struct overrideinfo *binoverride,int force,int delete){
retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,const char *suffix,struct distribution *distribution,const char *debfilename,const char *givenfilekey,const char *givenmd5sum,const struct overrideinfo *binoverride,int force,int delete){
retvalue r,result;
struct debpackage *pkg;
const struct overrideinfo *oinfo;
......@@ -419,7 +418,7 @@ retvalue deb_add(const char *dbdir,DB *references,filesdb filesdb,const char *fo
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
r = target_addpackage(t,references,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE);
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......@@ -429,7 +428,7 @@ retvalue deb_add(const char *dbdir,DB *references,filesdb filesdb,const char *fo
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
r = target_addpackage(t,references,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE);
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......@@ -442,7 +441,7 @@ retvalue deb_add(const char *dbdir,DB *references,filesdb filesdb,const char *fo
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
r = target_addpackage(t,references,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE);
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......
#ifndef __MIRRORER_CHECKINDEB_H
#define __MIRRORER_CHECKINDEB_H
#ifndef REPREPRO_CHECKINDEB_H
#define REPREPRO_CHECKINDEB_H
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
#ifndef __MIRRORER_DISTRIBUTION_H
#ifndef REPREPRO_DISTRIBUTION_H
#include "distribution.h"
#endif
#ifndef __MIRRORER_FILES_H
#ifndef REPREPRO_FILES_H
#include "files.h"
#endif
#ifndef __MIRRORER_OVERRIDE_H
#ifndef REPREPRO_OVERRIDE_H
#include "override.h"
#endif
......@@ -21,5 +21,5 @@
* if overwrite is not NULL, it will be search for fields to reset for this
* package. (forcesection and forcepriority have higher priority than the
* information there) */
retvalue deb_add(const char *dbdir,DB *references,filesdb filesdb,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,const char *suffix,struct distribution *distribution,const char *debfilename,const char *givenfilekey,const char *givenmd5sum,const struct overrideinfo *override,int force,int delete);
retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,const char *suffix,struct distribution *distribution,const char *debfilename,const char *givenfilekey,const char *givenmd5sum,const struct overrideinfo *override,int force,int delete);
#endif
......@@ -29,7 +29,6 @@
#include <malloc.h>
#include <ctype.h>
#include <zlib.h>
#include <db.h>
#include "error.h"
#include "strlist.h"
#include "md5sum.h"
......@@ -375,7 +374,7 @@ static retvalue dsc_checkfiles(filesdb filesdb,
* of beeing newly calculated.
* (And all files are expected to already be in the pool). */
retvalue dsc_add(const char *dbdir,DB *references,filesdb filesdb,const char *forcecomponent,const char *forcesection,const char *forcepriority,struct distribution *distribution,const char *dscfilename,const char *filekey,const char *basename,const char *directory,const char *md5sum,const struct overrideinfo *srcoverride,int force,int delete){
retvalue dsc_add(const char *dbdir,references refs,filesdb filesdb,const char *forcecomponent,const char *forcesection,const char *forcepriority,struct distribution *distribution,const char *dscfilename,const char *filekey,const char *basename,const char *directory,const char *md5sum,const struct overrideinfo *srcoverride,int force,int delete){
retvalue r;
struct dscpackage *pkg;
const struct overrideinfo *oinfo;
......@@ -462,7 +461,7 @@ retvalue dsc_add(const char *dbdir,DB *references,filesdb filesdb,const char *fo
r = target_initpackagesdb(t,dbdir);
if( !RET_WAS_ERROR(r) ) {
retvalue r2;
r = target_addpackage(t,references,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE);
r = target_addpackage(t,refs,pkg->package,pkg->version,pkg->control,&pkg->filekeys,force,FALSE);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......
#ifndef __MIRRORER_CHECKINDSC_H
#define __MIRRORER_CHECKINDSC_H
#ifndef REPREPRO_CHECKINDSC_H
#define REPREPRO_CHECKINDSC_H
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
#ifndef __MIRRORER_DISTRIBUTION_H
#ifndef REPREPRO_DISTRIBUTION_H
#include "distribution.h"
#endif
#ifndef __MIRRORER_FILES_H
#ifndef REPREPRO_FILES_H
#include "files.h"
#endif
#ifndef __MIRRORER_OVERRIDE_H
#ifndef REPREPRO_OVERRIDE_H
#include "override.h"
#endif
......@@ -20,6 +20,6 @@
* If basename, filekey and directory are != NULL, then they are used instead
* of beeing newly calculated.
* (And all files are expected to already be in the pool). */
retvalue dsc_add(const char *dbdir,DB *references,filesdb filesdb,const char *forcecomponent,const char *forcesection,const char *forcepriority,struct distribution *distribution,const char *dscfilename,const char *filekey,const char *basename,const char *directory,const char *md5sum,const struct overrideinfo *srcoverride,int force,int delete);
retvalue dsc_add(const char *dbdir,references refs,filesdb filesdb,const char *forcecomponent,const char *forcesection,const char *forcepriority,struct distribution *distribution,const char *dscfilename,const char *filekey,const char *basename,const char *directory,const char *md5sum,const struct overrideinfo *srcoverride,int force,int delete);
#endif
......@@ -39,7 +39,7 @@ retvalue chunk_foreach(const char *filename,chunkaction action,void *data,int fo
char *chunk;
f = gzopen(filename,"r");
if( !f ) {
if( f == NULL ) {
fprintf(stderr,"Unable to open file %s: %m\n",filename);
return RET_ERRNO(errno);
}
......@@ -49,7 +49,7 @@ retvalue chunk_foreach(const char *filename,chunkaction action,void *data,int fo
free(chunk);
if( RET_WAS_ERROR(ret) && !force ) {
if( RET_WAS_ERROR(ret) && force > 0 ) {
if( verbose > 0 )
fprintf(stderr,"Stop reading further chunks from '%s' due to privious errors.\n",filename);
break;
......@@ -66,7 +66,7 @@ retvalue chunk_foreach(const char *filename,chunkaction action,void *data,int fo
/* get the next chunk from file f ( return RET_NOTHING, if there are none )*/
retvalue chunk_read(gzFile f,char **chunk) {
char *buffer,*bhead,*p;
char *buffer,*bhead;
size_t size,already,without,l;
bool_t afternewline = FALSE;
......@@ -76,8 +76,9 @@ retvalue chunk_read(gzFile f,char **chunk) {
if( buffer == NULL )
return RET_ERROR_OOM;
while( gzgets(f,bhead,size-1-already) ) {
char *p;
p = bhead;
while( *p ) {
while( *p != '\0' ) {
if( *p != '\r' && *p != '\n' )
without = 1 + p - buffer;
p++;
......@@ -97,13 +98,14 @@ retvalue chunk_read(gzFile f,char **chunk) {
already += l;
afternewline = bhead[l-1] == '\n';
if( size-already < 1024 ) {
char *n;
size *= 2;
p = realloc(buffer,size);
if( p == NULL ) {
n = realloc(buffer,size);
if( n == NULL ) {
free(buffer);
return RET_ERROR_OOM;
}
buffer = p;
buffer = n;
}
bhead = buffer + already;
}
......@@ -111,15 +113,17 @@ retvalue chunk_read(gzFile f,char **chunk) {
free(buffer);
return RET_NOTHING;
} else {
char *n;
/* we do not want to include the final newlines */
buffer[without] = '\0';
p = realloc(buffer,without+1);
if( p == NULL ) {
n = realloc(buffer,without+1);
if( n == NULL ) {
/* guess this will not happen, but... */
free(buffer);
return RET_ERROR_OOM;
}
*chunk = p;
buffer = n;
*chunk = buffer;
return RET_OK;
}
}
......@@ -297,7 +301,7 @@ retvalue chunk_getwholedata(const char *chunk,const char *name,char **value) {
f = chunk_getfield(name,chunk);
if( !f )
return RET_NOTHING;
for ( e = p = f ; *p ; p++ ) {
for ( e = p = f ; *p != '\0' ; p++ ) {
if( afternewline ) {
if( *p == ' ' || *p == '\t' )
afternewline = FALSE;
......@@ -390,12 +394,12 @@ retvalue chunk_getname(const char *chunk,const char *name,
field = chunk_getfield(name,chunk);
if( !field )
return RET_NOTHING;
while( *field && *field != '\n' && isspace(*field) )
while( *field != '\0' && *field != '\n' && isspace(*field) )
field++;
name_end = field;
names_overpkgname(&name_end);
p = name_end;
while( *p && *p != '\n' && isspace(*p) )
while( *p != '\0' && *p != '\n' && isspace(*p) )
p++;
if( name_end == field ||
( *p != '\0' && *p != '\n' &&
......@@ -417,7 +421,7 @@ retvalue chunk_getname(const char *chunk,const char *name,
}
p++;
}
while( *p && *p != '\n' && isspace(*p) )
while( *p != '\0' && *p != '\n' && isspace(*p) )
p++;
if( *p != '\0' && *p != '\n' ) {
fprintf(stderr,"Error: Field '%s' contains trailing junk starting with '%c'!\n",name,*p);
......@@ -529,8 +533,10 @@ struct fieldtoadd *addfield_new(const char *field,const char *data,struct fieldt
assert(field != NULL && data != NULL);
n = malloc(sizeof(struct fieldtoadd));
if( n == NULL )
return n;
if( n == NULL ) {
addfield_free(next);
return NULL;
}
n->field = field;
n->len_field = strlen(field);
n->data = data;
......@@ -544,8 +550,10 @@ struct fieldtoadd *deletefield_new(const char *field,struct fieldtoadd *next) {
assert(field != NULL);
n = malloc(sizeof(struct fieldtoadd));
if( n == NULL )
return n;
if( n == NULL ) {
addfield_free(next);
return NULL;
}
n->field = field;
n->len_field = strlen(field);
n->data = NULL;
......@@ -557,8 +565,10 @@ struct fieldtoadd *addfield_newn(const char *field,const char *data,size_t len,s
struct fieldtoadd *n;
n = malloc(sizeof(struct fieldtoadd));
if( n == NULL )
return n;
if( n == NULL ) {
addfield_free(next);
return NULL;
}
n->field = field;
n->len_field = strlen(field);
n->data = data;
......
#ifndef __MIRRORER_CHUNKS_H
#define __MIRRORER_CHUNKS_H
#ifndef REPREPRO_CHUNKS_H
#define REPREPRO_CHUNKS_H
#include <zlib.h>
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
#include "strlist.h"
/* get the next chunk from file f ( return RET_NOTHING, if there are none )*/
retvalue chunk_read(gzFile f,char **chunk);
retvalue chunk_read(gzFile f,/*@out@*/char **chunk);
/* look for name in chunk. returns RET_NOTHING if not found */
retvalue chunk_getvalue(const char *chunk,const char *name,char **value);
......@@ -37,11 +37,11 @@ retvalue chunk_foreach(const char *filename,chunkaction action,void *data,int fo
/* modifications of a chunk: */
struct fieldtoadd {
struct fieldtoadd *next;
/*@null@*/struct fieldtoadd *next;
/* The name of the field: */
const char *field;
/*@dependent@*/const char *field;
/* The data to include: (if NULL, delete this field) */
const char *data;
/*@null@*//*@dependent@*/const char *data;
/* how many chars in them (the *exact* len to use
* , no \0 allowed within!), */
size_t len_field,len_data;
......@@ -50,13 +50,13 @@ struct fieldtoadd {
// TODO make this return retvalue..
/* Add this the <fields to add> to <chunk> before <beforethis> field,
* replacing older fields of this name, if they are already there. */
char *chunk_replacefields(const char *chunk,const struct fieldtoadd *toadd,const char *beforethis);
struct fieldtoadd *deletefield_new(const char *field,struct fieldtoadd *next);
struct fieldtoadd *addfield_new(const char *field,const char *data,struct fieldtoadd *next);
struct fieldtoadd *addfield_newn(const char *field,const char *data,size_t len,struct fieldtoadd *next);
void addfield_free(struct fieldtoadd *f);
/*@null@*/ char *chunk_replacefields(const char *chunk,const struct fieldtoadd *toadd,const char *beforethis);
/*@null@*/struct fieldtoadd *deletefield_new(/*@dependent@*/const char *field,/*@only@*//*@null@*/struct fieldtoadd *next);
/*@null@*/struct fieldtoadd *addfield_new(/*@dependent@*/const char *field,/*@dependent@*//*@null@*/const char *data,/*@only@*/struct fieldtoadd *next);
/*@null@*/struct fieldtoadd *addfield_newn(/*@dependent@*/const char *field,/*@dependent@*//*@null@*/const char *data,size_t len,/*@only@*/struct fieldtoadd *next);
void addfield_free(/*@only@*//*@null@*/struct fieldtoadd *f);
/* that is chunk_replacefields(chunk,{fieldname,strlen,data,strlen},fieldname); */
char *chunk_replacefield(const char *chunk,const char *fieldname,const char *data);
/*@null@*/char *chunk_replacefield(const char *chunk,const char *fieldname,const char *data);
#endif
#ifndef __MIRRORER_COPYFILE_H
#define __MIRRORER_COPYFILE_H
#ifndef REPREPRO_COPYFILE_H
#define REPREPRO_COPYFILE_H
retvalue copyfile_copy(const char *mirrordir,const char *filekey,const char *origfile,const char *md5expected,char **md5sum);
retvalue copyfile_move(const char *mirrordir,const char *filekey,const char *origfile,const char *md5expected,char **md5sum);
......
#ifndef __MIRRORER_DIRS_H
#define __MIRRORER_DIRS_H
#ifndef REPREPRO_DIRS_H
#define REPREPRO_DIRS_H
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#warning "What is happening here?"
#include "error.h"
#endif
#ifndef __MIRRORER_STRLIST_H
#ifndef REPREPRO_STRLIST_H
#warning "What is happening here?"
#include "strlist.h"
#endif
......
......@@ -27,7 +27,6 @@
#include <ctype.h>
#include <time.h>
#include <zlib.h>
#include <db.h>
#include "error.h"
#include "chunks.h"
#include "sources.h"
......
#ifndef __MIRRORER_DISTRIBUTION_H
#define __MIRRORER_DISTRIBUTION_H
#ifndef REPREPRO_DISTRIBUTION_H
#define REPREPRO_DISTRIBUTION_H
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
#ifndef __MIRRORER_STRLIST_H
#ifndef REPREPRO_STRLIST_H
#include "strlist.h"
#endif
#ifndef __MIRRORER_TARGET_H
#ifndef REPREPRO_TARGET_H
#include "target.h"
#endif
......@@ -19,16 +19,16 @@ struct distribution {
/* additional information for the Release-file to be
* generated, may be NULL. only suite is sometimes used
* (and only for sanity checks) */
char *suite,*version;
char *origin,*label,*description;
/*@null@*/char *suite,*version;
/*@null@*/char *origin,*label,*description;
/* What architectures and components are there */
struct strlist architectures,components;
/* which update rules to use */
struct strlist updates;
/* the key to sign with, may be NULL: */
char *signwith;
/*@null@*/char *signwith;
/* the override file to use by default */
char *override,*srcoverride;
/*@null@*/char *override,*srcoverride;
/* the list of components containing a debian-installer dir, normaly only "main" */
struct strlist udebcomponents;
/* A list of all targets contained in the distribution*/
......
......@@ -117,7 +117,7 @@ retvalue downloadcache_add(struct downloadcache *cache,filesdb filesdb,struct ap
if( item == NULL )
return RET_ERROR_OOM;
fullfilename = calc_dirconcat(filesdb->mirrordir,filekey);
fullfilename = files_calcfullfilename(filesdb,filekey);
if( fullfilename == NULL ) {
free(item);
return RET_ERROR_OOM;
......
#ifndef __MIRRORER_DOWNLOADLIST_H
#define __MIRRORER_DOWNLOADLIST_H
#ifndef REPREPRO_DOWNLOADLIST_H
#define REPREPRO_DOWNLOADLIST_H
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
#ifndef __MIRRORER_STRLIST_H
#ifndef REPREPRO_STRLIST_H
#include "strlist.h"
#warning "What's hapening here?"
#endif
#ifndef __MIRRORER_FILES_H
#ifndef REPREPRO_FILES_H
#include "files.h"
#endif
#ifndef __MIRRORER_APTMETHOD_H
#ifndef REPREPRO_APTMETHOD_H
#include "aptmethod.h"
#endif
......
#ifndef __MIRRORER_DPKGVERSIONS_H
#define __MIRRORER_DPKGVERSIONS_H
#ifndef REPREPRO_DPKGVERSIONS_H
#define REPREPRO_DPKGVERSIONS_H
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning wth?
#endif
......
#ifndef __MIRRORER_ERROR_H
#define __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#define REPREPRO_ERROR_H
/* retvalue is simply an int.
* just named to show it follows the given semantics */
typedef int retvalue;
#define RET_OK 1
#define RET_NOTHING 0
#define RET_ERROR -1
#define RET_ERROR_WRONG_MD5 -2
#define RET_ERROR_OOM -3
#define RET_ERROR_EXIST -4
#define RET_ERROR_GPGME -5
#define RET_ERROR_BADSIG -6
#define RET_ERROR_MISSING -7
#define RET_OK (retvalue)1
#define RET_NOTHING (retvalue)0
#define RET_ERROR (retvalue)-1
#define RET_ERROR_WRONG_MD5 (retvalue)-2
#define RET_ERROR_OOM (retvalue)-3
#define RET_ERROR_EXIST (retvalue)-4
#define RET_ERROR_GPGME (retvalue)-5
#define RET_ERROR_BADSIG (retvalue)-6
#define RET_ERROR_MISSING (retvalue)-7
#define RET_IS_OK(r) ((r) == RET_OK)
#define RET_WAS_NO_ERROR(r) ((r) >= 0)
#define RET_WAS_ERROR(r) ((r) < 0)
#define RET_WAS_NO_ERROR(r) ((r) >= (retvalue)0)
#define RET_WAS_ERROR(r) ((r) < (retvalue)0)
/* update a return value, so that it contains the first error-code
* and otherwise is RET_OK, if anything was RET_OK */
......@@ -27,16 +27,16 @@ typedef int retvalue;
#define RET_ENDUPDATE(ret,update) {if(RET_WAS_ERROR(update)&&RET_WAS_NO_ERROR(ret)) ret=update;}
/* code a errno in a error */
#define RET_ERRNO(err) ((err>0)?(-err):RET_ERROR)
#define RET_ERRNO(err) ((err>0)?((retvalue)-err):RET_ERROR)
/* code a zlib-error in a error */
#define RET_ZERRNO(zerr) ((zerr>=Z_OK)?RET_OK:((zerr==Z_ERRNO)?RET_ERRNO(errno):(-5000+zerr)))
#define RET_ZERRNO(zerr) ((zerr>=Z_OK)?RET_OK:((zerr==Z_ERRNO)?RET_ERRNO(errno):((retvalue)(-5000+zerr))))
/* code a db-error in a error */
// TODO: to be implemented...
#define RET_DBERR(e) RET_ERROR
#define EXIT_RET(ret) (RET_WAS_NO_ERROR(ret)?((nothingiserror&&ret==RET_NOTHING)?EXIT_FAILURE:EXIT_SUCCESS):ret)
#define EXIT_RET(ret) (RET_WAS_NO_ERROR(ret)?((nothingiserror&&ret==RET_NOTHING)?EXIT_FAILURE:EXIT_SUCCESS):(int)ret)
typedef int bool_t;
#define TRUE (1==1)
......
......@@ -34,11 +34,11 @@
extern int verbose;
//**********************************************************************
//* This is simply a ugly prototype until I have time to get something
//* correct (perhaps borrowing code from dpkg2.0). Until then its just
//* a quick and dirty hack to make it running.
//**********************************************************************
// **********************************************************************
// * This is simply a ugly prototype until I have time to get something
// * correct (perhaps borrowing code from dpkg2.0). Until then its just
// * a quick and dirty hack to make it running.
// **********************************************************************
//TODO: write this properly.
......
#ifndef __MIRRORER_EXTRACTCONTROL_H
#define __MIRRORER_EXTRACTCONTROL_H
#ifndef REPREPRO_EXTRACTCONTROL_H
#define REPREPRO_EXTRACTCONTROL_H
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
......@@ -9,7 +9,7 @@
/* Read the control information of <debfile< and save it's only chunk
* into <control> */
retvalue extractcontrol(char **control,const char *debfile);
retvalue extractcontrol(/*@out@*/ char **control,const char *debfile);
#endif
......@@ -36,6 +36,11 @@
#include "files.h"
#include "copyfile.h"
struct s_filesdb {
DB *database;
char *mirrordir;
};
#define CLEARDBT(dbt) {memset(&dbt,0,sizeof(dbt));}
#define SETDBT(dbt,datastr) {const char *my = datastr;memset(&dbt,0,sizeof(dbt));dbt.data=(void *)my;dbt.size=strlen(my)+1;}
......@@ -550,3 +555,8 @@ retvalue files_includefiles(filesdb db,const char *sourcedir,const struct strlis
}
return result;
}
/* concat mirrordir. return NULL if OutOfMemory */
char *files_calcfullfilename(const filesdb filesdb,const char *filekey) {
return calc_dirconcat(filesdb->mirrordir,filekey);
}
#ifndef __MIRRORER_FILES_H
#define __MIRRORER_FILES_H
#ifndef REPREPRO_FILES_H
#define REPREPRO_FILES_H
#include <db.h>
#ifndef __MIRRORER_ERROR_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
typedef struct s_filesdb {
DB *database;
char *mirrordir;
} *filesdb;
typedef struct s_filesdb *filesdb;
/* initalize "md5sum and size"-database */
retvalue files_initialize(filesdb *filesdb,const char *dbpath,const char *mirrordir);
retvalue files_initialize(/*@out@*/ filesdb *filesdb,const char *dbpath,const char *mirrordir);
/* release the files-database initialized got be files_initialize */
retvalue files_done(filesdb db);
retvalue files_done(/*@only@*/filesdb db);
/* Add file's md5sum to database */
retvalue files_add(filesdb filesdb,const char *filekey,const char *md5sum);
......@@ -78,4 +74,7 @@ retvalue files_checkpool(filesdb filesdb,bool_t fast);
/* dump out all information */