fileiopp

File IO ++ or fileiopp serves as a utility that interprets files in ways that I deem useful
Log | Files | Refs | README | LICENSE

commit ac0fbfc74760623fd7d3f5d55a9502f7baf6576e
parent 15358da14443624050aed83dc0779ebfeffc6ef3
Author: M. Yamanaka <myamanaka@live.com>
Date:   Mon,  9 Nov 2020 19:30:44 -0500

make file and main tester file

Diffstat:
AMakefile | 32++++++++++++++++++++++++++++++++
Atester.c | 39+++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,32 @@ +# File IO ++ +# "fileiopp" +# M. Yamanaka +# email: myamanaka@live.com +# website: http://www.csmyamanaka.com +# license: MIT (See included "LICENSE" file for details) + +FILES=varbyterw.c bmpfileiopp.c +OBJS=varbyterw.o bmpfileiopp.o +TESTER=tester.c +CC=gcc +LK=ld +SOFILE=libfileiopp.so +OFILE=fileiopp.o +OUT=Tester + +tester: tester.c fileiopp.o + $(CC) -o $(OUT) $^ + +sofile: $(OBJS) + $(CC) -o $(SOFILE) -shared $(OBJS) + rm $(OBJS) + +fileiopp.o: $(OBJS) + $(LK) -o $(OFILE) -i $(OBJS) + rm $(OBJS) + +objects: $(FILES) + $(CC) -c $(FILES) + +clean: + rm -f *.o *.so *.a *.out $(OUT) example* diff --git a/tester.c b/tester.c @@ -0,0 +1,39 @@ +/* + File IO ++ teser/example file + "tester.c" + M. Yamanaka + email: myamanaka@live.com + website: csmyamanaka.com + license: MIT (See included "LICENSE" file for details) +*/ + +#include "bmpfileiopp.h" + +int main(){ + + /* + This example creates a simple bitmap file with a very generic pattern and writes it to a file. + This file is then read, and its dimensions and number of channels are printed to stdout. + */ + + //write + int n = 3; //number of channels + BMPIS e1 = {400, 600, n, "example1.bmp"}; //example 1 + char* dE1 = (char*)malloc(sizeof(char)*400*600*n); //data for e1 + + for(int i = 0; i < 400*600*n; i++){ + if(i < 200*600*n) dE1[i] = (char)255; + else dE1[i] = (char)0; + } + writeBMP(e1, dE1); + + //read + BMPIS e2 = {0, 0, 0, "example1.bmp"}; + char* dE2; + readBMP(&e2, &dE2); + printf("width: %d, height: %d, number of channels: %d\n", e2.w, e2.h, e2.c); + + free(dE1); + free(dE2); + return 0; +}

Generated using stagit (https://codemadness.org/stagit.html)