first commit

This commit is contained in:
Your Name 2025-08-14 15:33:41 -04:00
parent ce51c9d431
commit 5d13dd2df3
2 changed files with 99 additions and 0 deletions

View File

@ -9,3 +9,33 @@ When making TUI menus, try to use the first leter of the command and the key to
When deleting, everything gets moved to the Trash folder. When deleting, everything gets moved to the Trash folder.
MAKEFILE POLICY: There should be only ONE Makefile in the entire project. All build logic (library, tests, examples, websocket) must be consolidated into the root Makefile. Do not create separate Makefiles in subdirectories as this creates testing inconsistencies where you test with one Makefile but run with another. MAKEFILE POLICY: There should be only ONE Makefile in the entire project. All build logic (library, tests, examples, websocket) must be consolidated into the root Makefile. Do not create separate Makefiles in subdirectories as this creates testing inconsistencies where you test with one Makefile but run with another.
### Sinple Text User Interfaces (TUI)
When making TUI menus, try to use the first leter of the command and the key to press to execute that command. For example, if the command is "Open file" try to use a keypress of "o" upper or lower case to signal to open the file. Use this instead of number keyed menus when possible. In the command, the letter should be underlined that signifies the command.
q and x should be reserved for the quit command.
## Buffer Size Guidelines to Prevent Compilation Warnings.
### Path Handling
- Always use buffers of size 1024 or PATH_MAX (4096) for file paths
- When concatenating paths with snprintf, ensure buffer is at least 2x the expected maximum input
- Use safer path construction patterns that check lengths before concatenation
### String Formatting Safety
- Before using snprintf with dynamic strings, validate that buffer size >= sum of all input string lengths + format characters + 1
- Use strnlen() to check actual string lengths before formatting
- Consider using asprintf() for dynamic allocation when exact size is unknown
- Add length validation before snprintf calls
### Compiler Warning Prevention
- Always size string buffers generously (minimum 1024 for paths, 512 for general strings)
- Use buffer size calculations: `size >= strlen(str1) + strlen(str2) + format_overhead + 1`
- Add runtime length checks before snprintf operations
- Consider using safer alternatives like strlcpy/strlcat if available
### Code Patterns to Avoid
- Fixed-size buffers (512 bytes) for path operations where inputs could be 255+ bytes each
- Concatenating unchecked strings with snprintf
- Assuming maximum path component sizes without validation

View File

@ -250,6 +250,75 @@ case "$TARGET" in
if [[ -f "Makefile" ]]; then if [[ -f "Makefile" ]]; then
make clean make clean
# Regenerate version files after clean (since clean removes them)
if git rev-parse --git-dir > /dev/null 2>&1; then
LATEST_TAG=$(git tag -l 'v*.*.*' | sort -V | tail -n 1 || echo "v0.1.0")
VERSION=${LATEST_TAG#v}
if [[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
# Regenerate version files
cat > "${SRC_DIR}/version.h" << EOF
/*
* ${PROJECT_NAME_UPPER} - Auto-Generated Version Header
* DO NOT EDIT THIS FILE MANUALLY - Generated by build script
*/
#ifndef ${PROJECT_NAME_UPPER}_VERSION_H
#define ${PROJECT_NAME_UPPER}_VERSION_H
#define VERSION_MAJOR ${MAJOR}
#define VERSION_MINOR ${MINOR}
#define VERSION_PATCH ${PATCH}
#define VERSION_STRING "${MAJOR}.${MINOR}.${PATCH}"
#define VERSION_TAG "${LATEST_TAG}"
/* Build information */
#define BUILD_DATE "$(date +%Y-%m-%d)"
#define BUILD_TIME "$(date +%H:%M:%S)"
#define BUILD_TIMESTAMP "$(date '+%Y-%m-%d %H:%M:%S')"
/* Git information */
#define GIT_HASH "$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')"
#define GIT_BRANCH "$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'unknown')"
/* Display versions */
#define VERSION_DISPLAY "${LATEST_TAG}"
#define VERSION_FULL_DISPLAY "${LATEST_TAG} ($(date '+%Y-%m-%d %H:%M:%S'), $(git rev-parse --short HEAD 2>/dev/null || echo 'unknown'))"
/* Version API functions */
const char* get_version(void);
const char* get_version_full(void);
const char* get_build_info(void);
#endif /* ${PROJECT_NAME_UPPER}_VERSION_H */
EOF
cat > "${SRC_DIR}/version.c" << EOF
/*
* ${PROJECT_NAME_UPPER} - Auto-Generated Version Implementation
* DO NOT EDIT THIS FILE MANUALLY - Generated by build script
*/
#include "version.h"
const char* get_version(void) {
return VERSION_TAG;
}
const char* get_version_full(void) {
return VERSION_FULL_DISPLAY;
}
const char* get_build_info(void) {
return "Built on " BUILD_DATE " at " BUILD_TIME " from commit " GIT_HASH " on branch " GIT_BRANCH;
}
EOF
print_success "Regenerated version files after clean"
fi
fi
make make
else else
print_error "No Makefile found. Please create a Makefile for your project." print_error "No Makefile found. Please create a Makefile for your project."