From d24c1d37677233c32ef54240b0055ab5a58fe85c Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Sun, 11 Feb 2024 23:23:50 +0100 Subject: [PATCH] big refactor of pretty much everything I still need to make the Makefile better as it's pretty shit right now but it's alright for now I think --- Makefile | 16 ++++++++++------ config.h => include/config.h | 2 +- mod.h => include/mod.h | 3 ++- semver.h => include/semver.h | 0 util.h => include/util.h | 0 modules/desktop.c | 3 ++- modules/os.c | 3 ++- modules/sep.c | 3 ++- config.c => src/config.c | 8 +++++--- src/config.o | Bin 0 -> 4072 bytes modfetch.c => src/modfetch.c | 8 ++++---- src/modfetch.o | Bin 0 -> 4488 bytes semver.c => src/semver.c | 3 ++- src/semver.o | Bin 0 -> 1984 bytes util.c => src/util.c | 3 ++- src/util.o | Bin 0 -> 3144 bytes 16 files changed, 32 insertions(+), 20 deletions(-) rename config.h => include/config.h (92%) rename mod.h => include/mod.h (94%) rename semver.h => include/semver.h (100%) rename util.h => include/util.h (100%) rename config.c => src/config.c (97%) create mode 100644 src/config.o rename modfetch.c => src/modfetch.c (97%) create mode 100644 src/modfetch.o rename semver.c => src/semver.c (96%) create mode 100644 src/semver.o rename util.c => src/util.c (98%) create mode 100644 src/util.o diff --git a/Makefile b/Makefile index 92aa9b2..c1b6b0b 100644 --- a/Makefile +++ b/Makefile @@ -6,16 +6,20 @@ CFLAGS += -Wcast-qual -Wswitch-default -Wswitch-enum CFLAGS += -Wconversion -Wunreachable-code # for asprintf() and getline() CFLAGS += -D_GNU_SOURCE +CFLAGS += -Iinclude LDFLAGS = NAME = modfetch -PROG = modfetch.c -LIB = config.c semver.c util.c -OBJ = $(PROG:.c=.o) $(LIB:.c=.o) +SRC = src +_PROG = modfetch.c +PROG = $(addprefix $(SRC)/, $(_PROG)) +_LIB = config.c semver.c util.c +LIB = $(addprefix $(SRC)/, $(_LIB)) +OBJ = $(_PROG:.c=.o) $(_LIB:.c=.o) BIN = target -TEMPMOD = $(wildcard modules/*.c) -MOD = $(TEMPMOD:modules/%=%) +_MOD = $(wildcard modules/*.c) +MOD = $(_MOD:modules/%=%) .PHONY: all clean @@ -32,7 +36,7 @@ $(NAME): $(OBJ) %.so: modules/%.c $(LIB) $(CC) $^ -shared -fPIC $(CFLAGS) $(LDFLAGS) -o $(BIN)/$@ -%.o: %.c +%.o: src/%.c $(CC) -c $< $(CFLAGS) -o $(BIN)/$@ clean: clean_modules diff --git a/config.h b/include/config.h similarity index 92% rename from config.h rename to include/config.h index a6ba16c..5dcc01e 100644 --- a/config.h +++ b/include/config.h @@ -16,7 +16,7 @@ typedef struct { Module *modules; } Config; -char *default_config_path(); +char *default_config_path(void); void parsing_error(size_t line); diff --git a/mod.h b/include/mod.h similarity index 94% rename from mod.h rename to include/mod.h index c05d356..f46a749 100644 --- a/mod.h +++ b/include/mod.h @@ -1,7 +1,8 @@ #ifndef _MODFETCH_MOD_H #define _MODFETCH_MOD_H -#include "semver.h" +#include + #include static const semver API_VERSION = { diff --git a/semver.h b/include/semver.h similarity index 100% rename from semver.h rename to include/semver.h diff --git a/util.h b/include/util.h similarity index 100% rename from util.h rename to include/util.h diff --git a/modules/desktop.c b/modules/desktop.c index 6e63924..88be1b4 100644 --- a/modules/desktop.c +++ b/modules/desktop.c @@ -4,7 +4,8 @@ * 09 Feb 2024 */ -#include "../mod.h" +#include + #include #include diff --git a/modules/os.c b/modules/os.c index e27cf97..d32c610 100644 --- a/modules/os.c +++ b/modules/os.c @@ -4,7 +4,8 @@ * 09 Feb 2024 */ -#include "../mod.h" +#include + #include #include #include diff --git a/modules/sep.c b/modules/sep.c index 9dfafd6..f8e5d56 100644 --- a/modules/sep.c +++ b/modules/sep.c @@ -8,7 +8,8 @@ * 09 Feb 2024 */ -#include "../mod.h" +#include + #include #include diff --git a/config.c b/src/config.c similarity index 97% rename from config.c rename to src/config.c index 13ebecd..ee7644d 100644 --- a/config.c +++ b/src/config.c @@ -1,5 +1,7 @@ -#include "config.h" -#include "util.h" +#include + +#include + #include #include #include @@ -7,7 +9,7 @@ #include #include -char *default_config_path() { +char *default_config_path(void) { char *config_path = NULL; char *config_dir = getenv("XDG_CONFIG_HOME"); diff --git a/src/config.o b/src/config.o new file mode 100644 index 0000000000000000000000000000000000000000..67de75dfd50d5d5935833ec1dcaf14bf218d1d73 GIT binary patch literal 4072 zcmb_fUu+ab7@unk9Ef`r&@@40O%6R0Tzi0|BAUDQj!xkORFFo*%W}8dJGp<^+iF`- zi&r$uS!tpVB);%s{PUuTi7}0#hXtDO<_kXfAP*$klqMxH5sm5jeX}#^u-u^!e#zX- z{Py?#zHh&sncaIQp4i>u^ATY_@*G*336zk~>ZNgn4I?B#6hbREJEm|>XWD|;|HdXx zEa<1s5A<}+-Vm-`aIs(6wbQksZM51Jq?Jn@(-X{>;VxDdHz2dMF;Aj~#coHUk+3@gX^C0b#n=4rmu3@M;)lED~=VWPRrc8 z<^;N)P60FFT*2_2)JX*W(eE)?PKG(VawWD}<7JOvEax&$b$WJ3ylU_=t zJd$v3)2bb8@2kxCpmvaA+n$-WIZz=`PwHEsPKY}F{@MA(dY#v0hN(~a7A(8nY=#oW&D7cs_8q+c|kVkhlX> zA8Ix|`z6Z|ZVw)0m7J~(ZomcGPETFJg#g(cIU0R6dNlf4G&vpE2t4sf=YC2!f3V=; zI_vsly~&>a`*!#BCh7j?<0Qy_H1n!Jq(yg)- zT({L+wqU56Mg|G#?djR6hI;oM+N_4RXRaw!eEcjYiwyaXR0E;T2Zbj`@I>4t}@y8%U zQ^UO5$gO%KLTkg5mXKCfjk`Ts$@05EJS)~nI_%y7djuNZx7RiS&;7>Kd@gQ!b z69pXesX>p%>J9yVXpQ)X0Z0A<^l0o^K%a)zh=05ZezFPveiQtoCio{!@bgXZ&zs=H z-G5q&qzzLa%-Km7NaBVf1BPuB-XMCpWMvDsNy>H_HWD%4w6eBAjG?Se_*P1?4Mt2( zMAYC?B(LXk#S}>*r%+77Shusq0sx?&HgefKDOtsoQ7$LTwgo|~LaH=OOv^BcWw_2} zDpxEU?*4;YA-JAealma2?{QD!>iZiGNVLZ|F8Gh~Ij$o#Zv6=;ILO~L~bj-LQ%$j4_T z_%#WCK*HxG9M_EC`>-%zs3Y?g377N9Nw~}(mT;N>nS`%}7$WYpgyTCy;J-J)cko4z zdCEEw34c)1>6LIi|AoE^V>ArIL$NuYmuLd7u^Ax;crWk;J||jvIB)C6ptmiz&xny_ zZ)B3DrRU*j_+Lx~65>phnK~og5jE%P56nvA1;cq%sa{bWemq&ZU!(sujM^~yixA& z%}eBu9JEnrsOk0pn){!FYqEL$@jZalh)ja<0siquIgaZG&rRWv-<4>MVk1tM;V-OL ro*4csMab)q?-=je0f_WtQNYA|!JXY*KRgQ?`JdzYpAn9{_tyU(xYXuB literal 0 HcmV?d00001 diff --git a/modfetch.c b/src/modfetch.c similarity index 97% rename from modfetch.c rename to src/modfetch.c index 1051e0f..3da1693 100644 --- a/modfetch.c +++ b/src/modfetch.c @@ -1,7 +1,7 @@ -#include "config.h" -#include "mod.h" -#include "semver.h" -#include "util.h" +#include +#include +#include +#include #include #include diff --git a/src/modfetch.o b/src/modfetch.o new file mode 100644 index 0000000000000000000000000000000000000000..4213e3df7980718ffc9228e076ad2f6cc0edd306 GIT binary patch literal 4488 zcmbtXZ)_Ar6rXDgy(_p^5b+Y!uCdiNq1PTtD7E5k+oOAW(1ubZK)Eb;d%X+y&)q$w zBnWyfVRKd?7~@A1zvwrNi9t+g6_CW3D2W#4twzpsOC3`dP z_kQm;Z)ay`_KrnjTkAX?!puXqkgCT}Lgag@{jk*ylU1adbao~R`BY|tsG3&Ldc}M} zv;ncG7-{&?bv4-pw6vNnl3XE~QjJ8KwCTMfIHjzji54R6ZPUk_$neO{=MO)S9^CdHSF{@1KqLI$%A`T@Q>S3da5MO5k zd9WblJWykyi2(s(x3=DXowL9aT)KDW#M(#P-(RgG2Fw;q6V!vQk0|R^x986S>mYS`EnNMR|J8KlKodB%4#SA~ik2^V zY(-%nDbUjO($x8Y6WBFKeGe|S@=>~_y+2;tJwTg=_R>*D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?d00001 diff --git a/util.c b/src/util.c similarity index 98% rename from util.c rename to src/util.c index 2ff20b6..dc4d86d 100644 --- a/util.c +++ b/src/util.c @@ -1,4 +1,5 @@ -#include "util.h" +#include + #include #include #include diff --git a/src/util.o b/src/util.o new file mode 100644 index 0000000000000000000000000000000000000000..5412c5b3c355137ccfa5c6026f12e9c5843d9b10 GIT binary patch literal 3144 zcmbtUZ%kWN6u+-6P$%r+pASn$LZi4q;$G?)5sb-J0;7D^m@FYWG|r8b_$Nlj5==eky?f#EEQyIHxxMH7 z&fj~^={uu^I$e@PI7#FMvMF(tkOl81AF$W}*-7e1H#Kjo-RhB`x&AuMta$IDPL-z` znrNmV)6CNEv}G=6-p(!>hNYu9Z!q7{Bx(Mi<;DP^^0jYQI}S^}v<41R`}naZNH8-e z$y0BZvy17aka@>)3zaBW@s&A;>LGy3*2-e(eg}hGc38Ch!UF6vn6u&A%D}v@6g@V1*)Tbdo zEqa5X{_=g3o<#G(&T{$k_dl zjgGPVO~!sLyPCe*K3>}fd4idu#O%^H59U2>>O92C>o-H@lGQ2oxEk((wgiZJ4X0fC z;yPAoRRo=;P?V{$0&}A_6O@XjPoQ|azce>G&CP>oKF_3kkl$j#9?GAlMT`uM7~AMl zZgi4n?yS+4HF&bWaCQcJJhSY^#<6}`kHgpCQSi2v$tlcWCg|K;#!@O^W%oRJbc?%ZA zX7f6%D{nNm8RosYkNMJ7wvU(T!7h!E1MTh4`y6TR+d%{CARj%|7 zFn#4gP(2BUq76_119RKX3-0rteAUYn)tMUCZ)mTfJ;ok}gLDIbHtf&4^PY*Sj!d=d zGqmnR>&k>_JmimZC9S*S7l;tI)s?LtUJxG^?5(!~wi^y?*T3koZE$RUCHwu`;4cD> zc_-mUvib)1Avl%d9Nh*#4midcbO8fo^%L%Q;Z%x4(#ENn5+zA}ATgweKj=SY=&8X- zR8NtVk&Nka5)Ma=kwHD&8;&KSWFQj53v}`5;0U;-5;5@8<3r)0NHRrE>IU$rk46kK zm`p&VR2W3km(+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