Skip to content

Commit

Permalink
Merge pull request #27 from Sjord/change-proto
Browse files Browse the repository at this point in the history
Change proto from K&R to ANSI
  • Loading branch information
Sjord committed Nov 24, 2017
2 parents c876755 + 36397fb commit 8e497d8
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 169 deletions.
25 changes: 6 additions & 19 deletions mpck/checkarguments.c
Expand Up @@ -69,10 +69,7 @@
#endif

static errno_t
checkargument(filename, total, file)
char * filename;
total_info * total;
file_info * file;
checkargument(char * filename, total_info * total, file_info * file)
{
errno_t res = 0;
if (extension_match(filename)) {
Expand Down Expand Up @@ -106,9 +103,7 @@ fisdirectory(FindFileData)
* only if _WIN32 is defined
*/
int
wildcard_checkfile(wildcardpath, total)
char * wildcardpath;
total_info * total;
wildcard_checkfile(char * wildcardpath, total_info * total)
{
WIN32_FIND_DATA FindFileData; /* struct to store the found file */
HANDLE hFind;
Expand Down Expand Up @@ -163,9 +158,7 @@ wildcard_checkfile(wildcardpath, total)
* only if _WIN32 is defined
*/
int
checkarguments(argv, total)
char **argv;
total_info * total;
checkarguments(char **argv, total_info * total)
{
int res=TRUE;

Expand All @@ -181,9 +174,7 @@ checkarguments(argv, total)
/* only if _WIN32 is defined
*/
int
recursivecheck(dirname, total)
const char *dirname;
total_info * total;
recursivecheck(const char *dirname, total_info * total)
{
char * wildcarddir;
int dirlen;
Expand All @@ -207,9 +198,7 @@ recursivecheck(dirname, total)

/* recursively scans all the files in dirname */
int
recursivecheck(dirname, total)
const char *dirname;
total_info * total;
recursivecheck(const char *dirname, total_info * total)
{
DIR * dir;
struct dirent * ent;
Expand Down Expand Up @@ -252,9 +241,7 @@ recursivecheck(dirname, total)

/* checkarguments opens each file and calls checkfile */
errno_t
checkarguments(argv, total)
char **argv;
total_info * total;
checkarguments(char **argv, total_info * total)
{
errno_t _errno, last_error=0;
char * filename;
Expand Down
20 changes: 6 additions & 14 deletions mpck/checkfile.c
Expand Up @@ -28,6 +28,7 @@
#include "checkframe.h"
#include "print.h"
#include "filename.h"
#include "checkfile.h"

#ifdef HAVE_ERRNO_H
#include <errno.h>
Expand All @@ -41,18 +42,14 @@
#include <strings.h>
#endif

static void skipframe(file, frame)
file_info * file;
frame_info * frame;
static void skipframe(file_info * file, frame_info * frame)
{
int newpos = MIN(frame->offset + frame->length, file->length);
cfseek(file->fp, newpos, SEEK_SET);
}

static size_t
lastframelength(file, frame)
file_info * file;
frame_info * frame;
lastframelength(file_info * file, frame_info * frame)
{
char buf[4 + sizeof(int)];
char * ptr;
Expand Down Expand Up @@ -93,8 +90,7 @@ lastframelength(file, frame)
return frame->length;
}

static int findlastframe(file)
file_info * file;
static int findlastframe(file_info * file)
{
int oldpos;
frame_info * frame;
Expand All @@ -118,9 +114,7 @@ static int findlastframe(file)
return TRUE;
}

static errno_t openfile(filename, file)
char * filename;
file_info * file;
static errno_t openfile(char * filename, file_info * file)
{
errno_t errno_keep;

Expand All @@ -135,9 +129,7 @@ static errno_t openfile(filename, file)
return 0;
}

errno_t checkfile(filename, file)
char * filename;
file_info * file;
errno_t checkfile(char * filename, file_info * file)
{
frame_info * frame;
errno_t _errno;
Expand Down
49 changes: 13 additions & 36 deletions mpck/checkframe.c
Expand Up @@ -32,6 +32,7 @@
#include "options.h"
#include "matrices.h"
#include "layer2.h"
#include "checkframe.h"

#ifdef HAVE_ERRNO_H
#include <errno.h>
Expand All @@ -50,9 +51,7 @@
#define layer(h) (4-(h))

/* framelength(fi) calculates the length (in bytes) of a frame */
static int framelength(file, fi)
const file_info * file;
const frame_info * fi;
static int framelength(const file_info * file, const frame_info * fi)
{
/* if this is the last frame, it has a different length */
if ((file->lastframe_offset == fi->offset) && (file->lastframe_offset)) {
Expand All @@ -68,9 +67,7 @@ static int framelength(file, fi)
}

static void
alienbytes(file, num)
file_info * file;
int num;
alienbytes(file_info * file, int num)
{
if (file->frames == 0)
file->alien_before += num;
Expand All @@ -80,9 +77,7 @@ alienbytes(file, num)

/* checks for consistency */
static int
checkconsistency(file, frame)
const file_info * file;
const frame_info * frame;
checkconsistency(const file_info * file, const frame_info * frame)
{
int verbose = options_get_verbose();

Expand All @@ -104,25 +99,20 @@ checkconsistency(file, frame)

/* sets consistency data to current frame */
static void
setconsistent(file, frame)
file_info * file;
const frame_info * frame;
setconsistent(file_info * file, const frame_info * frame)
{
file->version = frame->version;
file->layer = frame->layer;
}

/* returns bitrate in bps */
static int bitrate(headervalue, fi)
int headervalue; /* value of the bitrate as in the header */
frame_info * fi; /* this function uses version and layer */
static int bitrate(int headervalue, frame_info * fi)
{
return 1000*bitrate_matrix[3*fi->version+fi->layer-1][headervalue];
}

static int
mpegver(headervalue)
int headervalue;
mpegver(int headervalue)
{
if (headervalue == 3) return MPEG_VER_10;
if (headervalue == 2) return MPEG_VER_20;
Expand All @@ -131,10 +121,7 @@ mpegver(headervalue)
}

static void
parseframe(file, fr, buf)
const file_info * file;
frame_info * fr;
char * buf;
parseframe(const file_info * file, frame_info * fr, char * buf)
{
int res;

Expand Down Expand Up @@ -169,9 +156,7 @@ parseframe(file, fr, buf)

/* checks the validity of struct frame_info fi */
int
checkvalidity(file, frame)
const file_info * file;
const frame_info * frame;
checkvalidity(const file_info * file, const frame_info * frame)
{
int verbose = options_get_verbose();

Expand Down Expand Up @@ -200,9 +185,7 @@ checkvalidity(file, frame)
* FIXME: return the number of bytes which could not be interpreted.
*/
int
findframe(file, frame)
file_info * file;
frame_info * frame;
findframe(file_info * file, frame_info * frame)
{
int res;
char buf[8];
Expand Down Expand Up @@ -263,9 +246,7 @@ findframe(file, frame)
return FALSE;
}

static int crcdatalength(file, frame)
const file_info * file;
frame_info * frame;
static int crcdatalength(const file_info * file, frame_info * frame)
{
if (frame->layer == 2) {
return crcdatalength2(file, frame);
Expand All @@ -283,9 +264,7 @@ static int crcdatalength(file, frame)
return 0; // never reached, but supress warning
}

static int checkcrc16(file, frame)
const file_info * file;
frame_info * frame;
static int checkcrc16(const file_info * file, frame_info * frame)
{
// This buffer needs to hold the header and all other CRC bytes.
// header is 2 bytes, crcdatalength2 returns max. 39 bytes.
Expand Down Expand Up @@ -322,9 +301,7 @@ static int checkcrc16(file, frame)
}

int
checkframe(file, frame)
file_info * file;
frame_info * frame;
checkframe(file_info * file, frame_info * frame)
{
if (!checkvalidity(file, frame)) {
file->errors |= ERR_INVALID;
Expand Down
8 changes: 2 additions & 6 deletions mpck/crc.c
Expand Up @@ -42,9 +42,7 @@ crc_update(int value, int crc)
}

int
crc16(data, length)
unsigned char * data;
int length;
crc16(unsigned char * data, int length)
{
int i;
int crc=0xffff;
Expand All @@ -71,9 +69,7 @@ crc_update_bits(int value, int crc, int nbits)
}


int crc16bits(data, nbits)
unsigned char * data;
int nbits;
int crc16bits(unsigned char * data, int nbits)
{
int i;
int crc=0xffff;
Expand Down

0 comments on commit 8e497d8

Please sign in to comment.