I deleted everything lol

This commit is contained in:
Fijxu 2023-12-26 01:58:36 -03:00
parent 7b5846e432
commit 3cb47059aa
5 changed files with 69 additions and 66 deletions

View File

@ -1,9 +1,19 @@
INCLUDES = include
SOURCES = src
OUTPUT = main
CFLAGS=-g -o main -Wall -I$(INCLUDES)
CC=gcc
CFLAGS=-g -Wall
SRC=src
OBJ=obj
SRCS=$(wildcard $(SRC)/*.c)
OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS))
CFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.c))
BIN=./main
all:
gcc main.c $(CFILES) $(CFLAGS)
all:$(BIN)
$(BIN): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $@
$(OBJ)/%.o: $(SRC)/%.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
$(RM) -r $(OBJ)/*

BIN
blank16sectorcard Normal file

Binary file not shown.

59
main.c
View File

@ -1,59 +0,0 @@
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include "readFile.h"
#include "getSize.h"
int main(int argc, char *argv[]) {
short c;
/* if (argc <= 1) {
printf("Usage:\n %s [OPTION]... [FILE]\n\n", argv[0]);
puts("Tool to modify Mifare Classic dump files");
puts("\nOptions:");
puts("\t-s display the size of the file in bytes\n");
exit(EXIT_SUCCESS);
}
*/
FILE *file;
char *binfile = malloc(64 * sizeof(char));
if (binfile == NULL) {
puts("Failed to allocate memory");
exit(EXIT_FAILURE);
}
file = fopen(argv[argc - 1], "rb");
if (file == NULL) {
perror("Error while opening the file");
exit(EXIT_FAILURE);
}
static const struct option long_opts[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
while ((c = getopt_long(argc, argv, "hVs",
long_opts, NULL)) != -1) {
switch (c) {
case 'h':
case 'V':
case 's':
getSize(file, argc, argv);
exit(EXIT_SUCCESS);
default:
printf("Try '%s --help' for more information.\n", argv[0]);
exit(EXIT_FAILURE);
}
}
readFile(file);
fclose(file);
free(binfile);
exit(EXIT_SUCCESS);
}

19
makefile Normal file
View File

@ -0,0 +1,19 @@
CC = gcc
CFLAGS = -Wall -I$(INCLUDE)
INCLUDE = include
SRC_DIR = src
OBJ_DIR = obj
SRC = $(wildcard $(SRC_DIR)/*.c)
OBJ = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC))
BIN = ./main
all: $(BIN)
$(BIN): $(OBJ)
$(CC) -o $@ $^
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c MKOBJ
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJ_DIR)/*.o $(BIN)

33
src/main.c Normal file
View File

@ -0,0 +1,33 @@
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include "getSize.h"
#include "readFile.h"
int main(int argc, char *argv[]) {
if (argv[argc] == 1) {
FILE *file;
char *binfile = malloc(64 * sizeof(char));
if (binfile == NULL) {
puts("Failed to allocate memory");
exit(EXIT_FAILURE);
}
file = fopen(argv[argc - 1], "rb");
if (file == NULL) {
perror("Error while opening the file");
exit(EXIT_FAILURE);
}
readFile(file);
fclose(file);
free(binfile);
exit(EXIT_SUCCESS);
}