From f97528f2f07d4285897527dfd8575155aba56a81 Mon Sep 17 00:00:00 2001 From: Spencer Jones Date: Thu, 18 Dec 2025 17:01:21 -0700 Subject: [PATCH] Add initial project structure and files --- .gitignore | 55 +++++++++++++++++++++++++++++++++++++++++++++ LICENSE | 21 +++++++++++++++++ Makefile | 43 +++++++++++++++++++++++++++++++++++ README.md | 3 +++ bin/kvstore | Bin 0 -> 33656 bytes include/cli.h | 33 +++++++++++++++++++++++++++ include/kv_store.h | 0 include/string.h | 49 ++++++++++++++++++++++++++++++++++++++++ src/cli.c | 0 src/kv_store.c | 0 src/main.c | 14 ++++++++++++ src/string.c | 11 +++++++++ 12 files changed, 229 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100755 bin/kvstore create mode 100644 include/cli.h create mode 100644 include/kv_store.h create mode 100644 include/string.h create mode 100644 src/cli.c create mode 100644 src/kv_store.c create mode 100644 src/main.c create mode 100644 src/string.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..845cda6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,55 @@ +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +# debug information files +*.dwo diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2b53484 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Spencer Jones + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4819974 --- /dev/null +++ b/Makefile @@ -0,0 +1,43 @@ +# kvstore - A simple key-value store CLI application +# Build with: make +# Run with: make run +# Clean with: make clean + +# ===== PROJECT CONFIGURATION ===== +TARGET = kvstore +CC = clang +CPPFLAGS = -I include +CFLAGS = -Wall -Wextra + +# ===== LINKER ===== +LDFLAGS = +LIBS = + +# ===== DIRECTORIES ===== +SRC_DIR = src +BUILD_DIR = build +BIN_DIR = bin + +# ===== SOURCE AND OBJECT FILES ===== +SRCS = $(wildcard $(SRC_DIR)/*.c) +OBJS = $(SRCS:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o) +TARGET_PATH = $(BIN_DIR)/$(TARGET) + +# ===== COMPILATION PATTERN RULE ===== +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR) + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + +# ===== LINKING RULES ===== +$(TARGET_PATH): $(OBJS) | $(BIN_DIR) + $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + +# ===== CONVENIENCE TARGETS ===== +.PHONY: all clean run + +all: $(TARGET_PATH) + +run: $(TARGET_PATH) + ./$(TARGET_PATH) + +clean: + rm -f $(BUILD_DIR)/*.o $(TARGET_PATH) diff --git a/README.md b/README.md new file mode 100644 index 0000000..e230b85 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# C Learning Project: Key-Value store + +The purpose of this project is to learn c development from first principles using clang and make with the loose goal of creating an RDBMS. diff --git a/bin/kvstore b/bin/kvstore new file mode 100755 index 0000000000000000000000000000000000000000..dc5ef07795808979a8377591c06e7b43cf35e971 GIT binary patch literal 33656 zcmeI5U2IfE6vt=xZed$MXsuBBuvZea5GVwVK_qc&ser|{X$xu8INOiA?OJxX+})L~ zkhnlF7$2lil_vv!L<*9q!MG$E8%qo?DkX|W4X%ksP%vVA0Aj7@%$-}dD`*Tn{!eo5 z%sJ=If6x5xWMAjA%jf@^EQCjpdC7~(O`i}ugh?|YZY5t$E@ea2s+vb?8tXYb-qhmp zseeSQvy)zwvbmUUn8Io0gcM?MuU>< z%wih3l%27h&u~pWKfS9g;H=k?m_QT#iB#&!Ia|A?uC`|78uyH(^ZKHgt(Ti2V~t#$ zyM;(|fBcn$G~A`*AjQ2DGn+Eg&+OY?p4o4dU!(=Q#IEUm z4+_zLV7tut3&h65KG95)r5w)}>Bh6O#L*(kpEX3^8KdZ6g-2Xc>;9bHM|WTsnKdNoSn#P(zfiW+cFoKwN`4;`qm9e%T$>nQJ0LgS+*GqnXPtbGGav&@#W^cjv`T|LkcJn zFX9hG`w_EwLY6!7`QY;tppl*bhKmY_l z00ck)1V8`;KmY_l00ck)1V8`;KmY_l00ck)1V8`;KmY_l00ck)1V8`;KmY_l00ck) z1V8`;KmY_l00ck)1V8`;KmY_l00ck)1a1I<^bOE}1PFit2!H?xfB*=900@8p2!H?x zfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=9 z00@8p2!H?xfB*=900@8p2!H?xfWUPSFllWAIbXTXcSN(hmV2!@-zDyvng{3>_kf$x zYxyQ<*<**JiIA#zq-f*`=M9nd)8kkXJ>H@#slAb&R@)LKJt;B65IZMP`Zun9OEq76 zOw111mL=xLtya6eOH?N8aD*;&H)NzsTD?|#GGWOstF^fUSjUhJtfS*dPG7h<8VFVXS6I^L;cy0@J4=1`3HAXfkf70Oi6L;_~UqgVaVp zHR1MBN;$&eNeeH1U9b8wL8`ZqvlR-lHEVj+)%8y1U!R_3y6owGGS2sui?S7KZjTP$ z(vm7mm2CWd_c@tex92|ZouB;BaD1ftRP9TLpMLY5me|KPJM{kt!IdFH|kA!Gl-3HSWbULLwIWm4wzUtc}>=(g;SyS+!wU$6du rt$%xNRmsE8Z$1>Od-vuQ_g{$5-SW-0rNyt str2. + */ +int string_compare(const char *str1, const char *str2); + +/* + * string_trim - Allocate and return a trimmed copy of a string + * @str: String to trim + * + * Returns: Newly allocated copy of str with leading and trailing whitespace + * removed, or NULL on failure. Caller must free the returned pointer. + */ +char *string_trim(const char *str); + +/* + * string_search - Search if a string contains a different string. + * @src: Source string to search + * @search: String to search for + * + * Returns: -1 if not found, zero-based index of the searched string if found. + * Returns -1 if search string is empty or NULL. + */ +int string_search(const char *src, const char *search); + +/* + * string_free - Free a string allocated by string functions + * @str: String to free (NULL-safe) + * + * Safe to call with NULL; does nothing in that case. + */ +void string_free(const char *str); + +#endif diff --git a/src/cli.c b/src/cli.c new file mode 100644 index 0000000..e69de29 diff --git a/src/kv_store.c b/src/kv_store.c new file mode 100644 index 0000000..e69de29 diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..26d0efe --- /dev/null +++ b/src/main.c @@ -0,0 +1,14 @@ +#include + +int main(int argc, char *argv[]) { + printf("KVStore - Key-Value Store\n"); + + if (argc > 1) { + printf("Number of arguments: %d\n", argc - 1); + for (int i = 1; i < argc; i++) { + printf("Argument %d: %s\n", i, argv[i]); + } + } + + return 0; +} diff --git a/src/string.c b/src/string.c new file mode 100644 index 0000000..ae6230e --- /dev/null +++ b/src/string.c @@ -0,0 +1,11 @@ +#include + +char *string_copy(const char *src) { return NULL; } + +int string_compare(const char *str1, const char *str2) { return -1; } + +char *string_trim(const char *str) { return NULL; } + +int string_search(const char *src, const char *search) { return -1; } + +void string_free(const char *str) {}