summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/sha1.c
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-03-04 10:08:54 +0100
committerAaron Griffin <aaron@archlinux.org>2007-03-04 10:08:54 +0100
commitcdb46ef3fa6d2bea95ae45b8b807497982b18fd5 (patch)
tree0f2340ed62be9f99f1e4bf0764c65aad1e701964 /lib/libalpm/sha1.c
parenta7d7c963579176dfefe424931a57e86bc8b51924 (diff)
downloadpacman-cdb46ef3fa6d2bea95ae45b8b807497982b18fd5.tar.gz
pacman-cdb46ef3fa6d2bea95ae45b8b807497982b18fd5.tar.xz
* Fixed a whole mess of extra '/' pathing issues when a different root is
specified * Use db->path when appropriate * Commented out the FAKEROOT checks in libalpm. This should never ever be done. TODO test this quite a bit, as this will never cause the transactions to fail if RW operations are requested... right now it is totally up to the front end to decide when to fail * Use realpath() to canonicalize the root path when specified, so _alpm_makepath() doesn't freak out * Fixed some output/indent of MDFile and SHAFile algorithms * More efficient sprintf() usage in MDFile/SHAFile * Added real error output to _alpm_makepath
Diffstat (limited to 'lib/libalpm/sha1.c')
-rw-r--r--lib/libalpm/sha1.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/lib/libalpm/sha1.c b/lib/libalpm/sha1.c
index cf1831ea..956e87a9 100644
--- a/lib/libalpm/sha1.c
+++ b/lib/libalpm/sha1.c
@@ -386,35 +386,34 @@ documentation and/or software.
char* _alpm_SHAFile(char *filename) {
- FILE *file;
- struct sha_ctx context;
- int len, i;
- unsigned char buffer[1024], digest[20];
- char *ret;
-
- ALPM_LOG_FUNC;
-
- if((file = fopen(filename, "rb")) == NULL) {
- fprintf(stderr, _("%s can't be opened\n"), filename);
- } else {
- sha_init_ctx(&context);
- while((len = fread(buffer, 1, 1024, file))) {
- sha_process_bytes(buffer, len, &context);
+ FILE *file;
+ struct sha_ctx context;
+ int len, i;
+ unsigned char buffer[1024], digest[20];
+ char *ret;
+
+ ALPM_LOG_FUNC;
+
+ if((file = fopen(filename, "rb")) == NULL) {
+ _alpm_log(PM_LOG_ERROR, _("sha1: %s can't be opened\n"), filename);
+ } else {
+ sha_init_ctx(&context);
+ while((len = fread(buffer, 1, 1024, file))) {
+ sha_process_bytes(buffer, len, &context);
+ }
+ sha_finish_ctx(&context, digest);
+ fclose(file);
+
+ ret = (char*)malloc(41);
+ ret[0] = '\0';
+ for(i = 0; i < 20; i++) {
+ sprintf(ret+(i*2), "%02x", digest[i]);
+ }
+ _alpm_log(PM_LOG_DEBUG, _("sha1(%s) = %s"), filename, ret);
+ return(ret);
}
- sha_finish_ctx(&context, digest);
- fclose(file);
-#ifdef DEBUG
- SHAPrint(digest);
-#endif
- ret = (char*)malloc(41);
- ret[0] = '\0';
- for(i = 0; i < 20; i++) {
- sprintf(ret, "%s%02x", ret, digest[i]);
- }
- return(ret);
- }
- return(NULL);
+ return(NULL);
}
/* vim: set ts=2 sw=2 noet: */