Overview
Comment: | Add utils/ofhash |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
2c629663eaa16b96a9288f3fa0227208 |
User & Date: | js on 2014-09-08 01:14:19 |
Other Links: | manifest | tags |
Context
2014-09-10
| ||
10:51 | OFZIP: Handle all exceptions check-in: 8b7fd2fdd8 user: js tags: trunk | |
2014-09-08
| ||
01:14 | Add utils/ofhash check-in: 2c629663ea user: js tags: trunk | |
2014-09-06
| ||
22:25 | Add missing #include "config.h" check-in: f73023946a user: js tags: trunk | |
Changes
Modified .gitignore from [ead1623fef] to [69b5130dd6].
︙ | ︙ | |||
36 37 38 39 40 41 42 43 44 | tests/tests.arm9 tests/tests.exe tests/tests.nds tests/EBOOT.PBP tests/PARAM.SFO tests/objc_sync/objc_sync utils/objfw-config utils/ofzip/ofzip utils/ofzip/ofzip.exe | > > | 36 37 38 39 40 41 42 43 44 45 46 | tests/tests.arm9 tests/tests.exe tests/tests.nds tests/EBOOT.PBP tests/PARAM.SFO tests/objc_sync/objc_sync utils/objfw-config utils/ofhash/ofhash utils/ofhash/ofhash.exe utils/ofzip/ofzip utils/ofzip/ofzip.exe |
Modified configure.ac from [438d911fad] to [eec1183ff7].
︙ | ︙ | |||
689 690 691 692 693 694 695 696 697 698 699 700 701 702 | AC_MSG_RESULT($atomic_ops) AC_ARG_ENABLE(files, AS_HELP_STRING([--disable-files], [disable file support])) AS_IF([test x"$enable_files" != x"no"], [ AC_DEFINE(OF_HAVE_FILES, 1, [Whether we have files]) AC_SUBST(USE_SRCS_FILES, '${SRCS_FILES}') AC_SUBST(OFZIP, "ofzip") AC_CHECK_FUNCS(readdir_r) ]) AC_CHECK_FUNCS([sysconf gmtime_r localtime_r nanosleep lstat]) | > | 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 | AC_MSG_RESULT($atomic_ops) AC_ARG_ENABLE(files, AS_HELP_STRING([--disable-files], [disable file support])) AS_IF([test x"$enable_files" != x"no"], [ AC_DEFINE(OF_HAVE_FILES, 1, [Whether we have files]) AC_SUBST(USE_SRCS_FILES, '${SRCS_FILES}') AC_SUBST(OFHASH, "ofhash") AC_SUBST(OFZIP, "ofzip") AC_CHECK_FUNCS(readdir_r) ]) AC_CHECK_FUNCS([sysconf gmtime_r localtime_r nanosleep lstat]) |
︙ | ︙ |
Modified extra.mk.in from [0dba5fb818] to [d9e9453b4a].
︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@ LOOKUP_ASM_A = @LOOKUP_ASM_A@ LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@ LOOKUP_ASM_LOOKUP_ASM_A = @LOOKUP_ASM_LOOKUP_ASM_A@ LOOKUP_ASM_LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LOOKUP_ASM_LIB_A@ MAP_LDFLAGS = @MAP_LDFLAGS@ OFBLOCKTESTS_M = @OFBLOCKTESTS_M@ OFHTTPCLIENTTESTS_M = @OFHTTPCLIENTTESTS_M@ OFPROCESS_M = @OFPROCESS_M@ OFKERNELEVENTOBSERVER_KQUEUE_M = @OFKERNELEVENTOBSERVER_KQUEUE_M@ OFKERNELEVENTOBSERVER_POLL_M = @OFKERNELEVENTOBSERVER_POLL_M@ OFKERNELEVENTOBSERVER_SELECT_M = @OFKERNELEVENTOBSERVER_SELECT_M@ OFZIP = @OFZIP@ PROPERTIESTESTS_M = @PROPERTIESTESTS_M@ | > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@ LOOKUP_ASM_A = @LOOKUP_ASM_A@ LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@ LOOKUP_ASM_LOOKUP_ASM_A = @LOOKUP_ASM_LOOKUP_ASM_A@ LOOKUP_ASM_LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LOOKUP_ASM_LIB_A@ MAP_LDFLAGS = @MAP_LDFLAGS@ OFBLOCKTESTS_M = @OFBLOCKTESTS_M@ OFHASH = @OFHASH@ OFHTTPCLIENTTESTS_M = @OFHTTPCLIENTTESTS_M@ OFPROCESS_M = @OFPROCESS_M@ OFKERNELEVENTOBSERVER_KQUEUE_M = @OFKERNELEVENTOBSERVER_KQUEUE_M@ OFKERNELEVENTOBSERVER_POLL_M = @OFKERNELEVENTOBSERVER_POLL_M@ OFKERNELEVENTOBSERVER_SELECT_M = @OFKERNELEVENTOBSERVER_SELECT_M@ OFZIP = @OFZIP@ PROPERTIESTESTS_M = @PROPERTIESTESTS_M@ |
︙ | ︙ |
Modified utils/Makefile from [2b48c029ae] to [b16a509b18].
1 2 | include ../extra.mk | | > | 1 2 3 4 5 6 7 8 9 10 11 | include ../extra.mk SUBDIRS += ${OFHASH} \ ${OFZIP} include ../buildsys.mk DISTCLEAN = objfw-config install-extra: objfw-config objfw-compile for i in objfw-config objfw-compile; do \ |
︙ | ︙ |
Added utils/ofhash/Makefile version [f80d36df3e].
> > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | include ../../extra.mk PROG = ofhash${PROG_SUFFIX} SRCS = OFHash.m include ../../buildsys.mk ${PROG}: ${LIBOBJFW_DEP_LVL2} CPPFLAGS += -I../../src -I../../src/runtime -I../../src/exceptions -I../.. LIBS := -L../../src -lobjfw ${LIBS} LD = ${OBJC} LDFLAGS += ${LDFLAGS_RPATH} |
Added utils/ofhash/OFHash.m version [dd4b0c75d6].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFApplication.h" #import "OFArray.h" #import "OFFile.h" #import "OFMD5Hash.h" #import "OFRIPEMD160Hash.h" #import "OFSHA1Hash.h" #import "OFSHA224Hash.h" #import "OFSHA256Hash.h" #import "OFSHA384Hash.h" #import "OFSHA512Hash.h" #import "OFStdIOStream.h" #import "OFOpenFileFailedException.h" #import "OFReadFailedException.h" @interface OFHash: OFObject @end OF_APPLICATION_DELEGATE(OFHash) static void help(void) { [of_stderr writeFormat: @"Usage: %@ [md5|rmd160|sha1|sha224|sha256|sha384|sha512] " @"file1 [file2 ...]\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } static Class hashClassForName(OFString *name) { if ([name isEqual: @"md5"]) return [OFMD5Hash class]; else if ([name isEqual: @"rmd160"] || [name isEqual: @"ripemd160"]) return [OFRIPEMD160Hash class]; else if ([name isEqual: @"sha1"]) return [OFSHA1Hash class]; else if ([name isEqual: @"sha224"]) return [OFSHA224Hash class]; else if ([name isEqual: @"sha256"]) return [OFSHA256Hash class]; else if ([name isEqual: @"sha384"]) return [OFSHA384Hash class]; else if ([name isEqual: @"sha512"]) return [OFSHA512Hash class]; return nil; } @implementation OFHash - (void)applicationDidFinishLaunching { OFArray *arguments = [OFApplication arguments]; Class <OFHash> hashClass; OFEnumerator *enumerator; OFString *path; int exitStatus = 0; if ([arguments count] < 2) help(); if ((hashClass = hashClassForName([arguments objectAtIndex: 0])) == Nil) help(); enumerator = [[arguments objectsInRange: of_range(1, [arguments count] - 1)] objectEnumerator]; while ((path = [enumerator nextObject]) != nil) { void *pool = objc_autoreleasePoolPush(); id <OFHash> hash = [hashClass hash]; OFStream *file; const uint8_t *digest; size_t i, digestSize; if ([path isEqual: @"-"]) file = of_stdin; else { @try { file = [OFFile fileWithPath: path mode: @"rb"]; } @catch (OFOpenFileFailedException *e) { [of_stderr writeFormat: @"Failed to open file %@: %s\n", [e path], strerror([e errNo])]; exitStatus = 1; goto outer_loop_end; } } while (![file isAtEndOfStream]) { uint8_t buffer[1024]; size_t length; @try { length = [file readIntoBuffer: buffer length: 1024]; } @catch (OFReadFailedException *e) { [of_stderr writeFormat: @"Failed to read %@: %s\n", path, strerror([e errNo])]; exitStatus = 1; goto outer_loop_end; } [hash updateWithBuffer: buffer length: length]; } [file close]; digest = [hash digest]; digestSize = [hashClass digestSize]; for (i = 0; i < digestSize; i++) [of_stdout writeFormat: @"%02x", digest[i]]; [of_stdout writeFormat: @" %@\n", path]; outer_loop_end: objc_autoreleasePoolPop(pool); } [OFApplication terminateWithStatus: exitStatus]; } @end |