-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompressor.h
More file actions
executable file
·85 lines (55 loc) · 2.06 KB
/
Copy pathcompressor.h
File metadata and controls
executable file
·85 lines (55 loc) · 2.06 KB
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
#ifndef COMPRESSOR_H
#define COMPRESSOR_H
#include <stdio.h>
#include <stdlib.h>
/* defines */
#define MIN_LINE 1024 /* minimum line chars*/
#define FILE_MODE_READ "r" /* file mode for reading */
#define FILE_MODE_APPEND "a" /* file mode for appending */
#define MAX_ARGS 4 /* maximum amount of args in cmd*/
#define SIZE_BYTE 8 /* amount of bits in a byte */
#define SIZE_DOUBLE_BYTE 16 /* amount of bits in a uncompressed char with flag */
#define SIZE_COMPRESSED 5 /* amount of bits of a compressed char */
#define BASE_BINARY_CHAR '0' /* character used as base binary*/
#define ALPHA_SPACE 32 /* decimal value of space character */
#define ALPHA_LOWER_BOUND 96 /* decimal value of lower character to compress */
#define ALPHA_UPPER_BOUND 128 /* decimal value of higher character to compress */
#define FLAG_STR "11111111" /* not compressed character flag str*/
#define FLAG_INT 255 /* not compressed character flag int*/
#define REDUNDANT_BITS "011" /* removed bits */
#define PAD_STR "0"
#define NULL_EXEPTION "00000000"
#
/* enumerators and constants */
enum error {NO_ERRORS, ERROR};
static const char * FILE_INPUT = "input.txt"; /* default input file */
static const char * FILE_OUTPUT = "output.dog"; /*default output file */
/* typedefs */
typedef enum bool {FALSE, TRUE} Boolean;
typedef struct array{
char * data;
size_t arraySize;
}Array;
typedef struct arguments {
const char * inputFile;
const char * outputFile;
Boolean decompress;
int Error;
} Arguments;
/* function prototypes compressLib*/
Array StrToComrpessedBin(Array *);
Array BinStreamTocharStr(Array * );
char * decToBinCompressed(int);
char * getWord(char * , int , int );
void padding(Array *);
Array readFile(FILE *);
void writeFile(Array * , FILE *);
int binToDec(char *);
void trimSpaces(char * , const char * );
/* function prototypes DecompressLib.c */
Array StrToDecomrpessedBin(Array * );
Array binToDecompressedContent(Array * );
char * decToBin(int);
/* function prototypes arguments*/
void argumentsGet(const int, const char **, Arguments *);
#endif