Last active
August 29, 2015 14:01
-
-
Save Aenigma/eed110761cca2177ab8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Reads from a file and reads out a field in a hardcoded position | |
* | |
* By Kevin Raoofi | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define LINE_SEEK_AMOUNT (0x770) | |
#define TIME_OFFSET (61) | |
#define TIME_SIZE (10) | |
int main(int argc, char **argv) | |
{ | |
if(argc < 2) { | |
fprintf(stderr, "You must enter exactly one argument to the file to read\n"); | |
return 1; | |
} | |
char time[TIME_SIZE]; | |
FILE *in; | |
in = fopen(argv[1], "r"); | |
fseek(in, LINE_SEEK_AMOUNT + TIME_OFFSET, SEEK_SET); | |
int result = fread(&time, 1, TIME_SIZE, in); | |
fclose(in); | |
if (result != TIME_SIZE) { | |
fprintf(stderr,"Result size is %d instead of %d!\n", result, TIME_SIZE); | |
return 2; | |
} | |
puts(time); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a GNU Make file which describes how to build the application's | |
# DLL/SO for both x86 Windows and Linux systems. | |
# | |
# | |
# To do a full compile, invoke 'make all' | |
# To build just the test executable, invoke 'make bins' | |
# | |
CC:=$(shell which cc) | |
CFLAGS=-Wall -pedantic -O3 -std=c99 | |
CFILES=./main.c | |
OUT_DIR=build | |
BIN_DIR=$(OUT_DIR)/bin | |
.PHONY: all bins clean fresh not_do assembly | |
VPATH =lib | |
all: bins | |
do: all | |
not_do: | |
$(error 'make do because not do is not an option') | |
bins: | |
@mkdir -p $(BIN_DIR) | |
$(CC) $(CFLAGS) $(LIBS) $(CFILES) -o $(BIN_DIR)/reader | |
$(OUT_DIR): | |
@mkdir -p $(OUT_DIR) | |
clean: | |
@rm -r $(OUT_DIR) | |
@rm -f *.o | |
%.o: %.c $(DEPS) | |
$(CC) -c -o $@ $< $(CFLAGS) | |
%.s: %.c | |
$(CC) $(CFLAGS) $(LIBS) $(CFILES) -S $< | |
fresh: | clean all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment