amiga-sha/sha_io.c

62 lines
1.9 KiB
C

/*
* Copyright (c) 2015 Carsten Larsen
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "platform.h"
uint8_t *buffer = NULL;
void *alloced_buffer = NULL;
struct RDArgs *rdargs = NULL;
void args_error(char *program) {
fprintf(stderr, "%s: %s\n", program, "Wrong arguments");
}
void alloc_buffer(void) {
long offs;
if (!(buffer = AllocVec(SHA_BUFFER_SIZE + 7, MEMF_ANY | MEMF_CLEAR))) {
exit(1);
}
alloced_buffer = buffer;
if ((offs = (long) buffer & 7L))
buffer += 8 - offs;
}
void clean_exit()
{
if (alloced_buffer != NULL) {
memset(buffer, 0, SHA_BUFFER_SIZE);
FreeVec(alloced_buffer);
}
if (rdargs) {
FreeArgs(rdargs);
rdargs = NULL;
}
}