1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
/* This file is part of "reprepro"
* Copyright (C) 2003,2004,2005,2007 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include <config.h>
#include <errno.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "error.h"
#include "names.h"
#include "chunks.h"
#include "readtextfile.h"
#include "readrelease.h"
/* get a strlist with the md5sums of a Release-file */
retvalue release_getchecksums(const char *releasefile, const bool ignore[cs_hashCOUNT], struct checksumsarray *out) {
retvalue r;
char *chunk;
struct strlist files[cs_hashCOUNT];
enum checksumtype cs;
bool foundchecksums = false;
bool havemd5 = true;
r = readtextfile(releasefile, releasefile, &chunk, NULL);
assert( r != RET_NOTHING );
if( !RET_IS_OK(r) )
return r;
for( cs = cs_md5sum ; cs < cs_hashCOUNT ; cs++ ) {
if( ignore[cs] ) {
strlist_init(&files[cs]);
continue;
}
assert( release_checksum_names[cs] != NULL );
r = chunk_getextralinelist(chunk, release_checksum_names[cs],
&files[cs]);
if( r == RET_NOTHING ) {
if( cs == cs_md5sum ) {
havemd5 = false;
}
strlist_init(&files[cs]);
} else if( RET_WAS_ERROR(r) ) {
while( cs-- > cs_md5sum ) {
strlist_done(&files[cs]);
}
free(chunk);
return r;
} else
foundchecksums = true;
}
free(chunk);
if( !foundchecksums ) {
fprintf(stderr,
"Missing 'MD5Sum' field in Release file '%s'!\n", releasefile);
return RET_ERROR;
}
r = checksumsarray_parse(out, files, releasefile, havemd5);
for( cs = cs_md5sum ; cs < cs_hashCOUNT ; cs++ ) {
strlist_done(&files[cs]);
}
return r;
}
|