Commit e54b1967 authored by Bernhard Link's avatar Bernhard Link

enough for testing the rest

parent 62063462
......@@ -22,7 +22,7 @@
#include "error.h"
#include "strlist.h"
retvalue strlist_in(const struct strlist *strlist,const char *element) {
int strlist_in(const struct strlist *strlist,const char *element) {
int c;
char **t;
......@@ -32,9 +32,9 @@ retvalue strlist_in(const struct strlist *strlist,const char *element) {
t = strlist->values;
while( c-- ) {
if( strcmp(*(t++),element) == 0 )
return RET_OK;
return 1;
}
return RET_NOTHING;
return 0;
}
retvalue strlist_new(struct strlist *strlist) {
......
......@@ -17,6 +17,6 @@ void strlist_free(struct strlist *strlist);
/* add a string, will get property of the strlist and free'd by it */
retvalue strlist_add(struct strlist *strlist,char *element);
retvalue strlist_in(const struct strlist *strlist,const char *element);
int strlist_in(const struct strlist *strlist,const char *element);
#endif
......@@ -29,8 +29,72 @@
#include "error.h"
#include "mprintf.h"
#include "dirs.h"
#include "names.h"
#include "chunks.h"
#include "strlist.h"
#include "updates.h"
extern int verbose;
// typedef retvalue updatesaction(void *data,const char *chunk,const struct release *release,const char *name);
struct mydata {
const struct release *release;
const struct strlist *updates;
void *data;
updatesaction *action;
};
static retvalue processupdates(void *data,const char *chunk) {
struct mydata *d = data;
retvalue r;
char *name;
r = chunk_getvalue(chunk,"Name",&name);
if( r == RET_NOTHING ) {
fprintf(stderr,"Unexpected chunk in updates-file: '%s'.\n",chunk);
return r;
}
if( !RET_IS_OK(r) )
return r;
if( strlist_in(d->updates,name) ) {
if( verbose > 2 ) {
fprintf(stderr,"processing '%s' for '%s'\n",name,d->release->codename);
}
// TODO: generate more information...
// (like which distributions, architectures and components to update)
d->action(d->data,chunk,d->release,name);
free(name);
return RET_OK;
} else if( verbose > 5 ) {
fprintf(stderr,"skipping '%s' in this run\n",name);
}
free(name);
return RET_NOTHING;
}
retvalue updates_foreach_matching(const char *conf,const struct release *release,const struct strlist *updates,updatesaction action,void *data,int force) {
retvalue result;
char *fn;
struct mydata mydata;
mydata.release = release;
mydata.updates = updates;
mydata.data = data;
mydata.action = action;
fn = calc_dirconcat(conf,"updates");
if( !fn )
return RET_ERROR_OOM;
result = chunk_foreach(fn,processupdates,&mydata,force);
free(fn);
return result;
}
......@@ -6,5 +6,13 @@
#warning "What's hapening here?"
#endif
#include "release.h"
#include "strlist.h"
typedef retvalue updatesaction(void *data,const char *chunk,const struct release *release,const char *name);
retvalue updates_foreach_matching(const char *conf,const struct release *release,const struct strlist *updates,updatesaction action,void *data,int force);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment