Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 84e2ee5639 | |||
| 0f3af174b0 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -3,7 +3,4 @@ pads/
|
||||
Gemini.md
|
||||
TropicOfCancer-HenryMiller.txt
|
||||
|
||||
# Auto-generated version files
|
||||
src/version.h
|
||||
src/version.c
|
||||
VERSION
|
||||
# Auto-generated files (none currently)
|
||||
|
||||
@@ -151,10 +151,7 @@ git tag v1.0.0 # Next build: v1.0.1
|
||||
- Full version display with metadata
|
||||
|
||||
### Generated Files
|
||||
The build system automatically generates:
|
||||
- `src/version.h` - Version constants and macros
|
||||
- `src/version.c` - Version API functions
|
||||
- `VERSION` - Plain text version number
|
||||
The build system automatically manages Git versioning by incrementing tags.
|
||||
|
||||
These files are excluded from git (.gitignore) and regenerated on each build.
|
||||
|
||||
@@ -176,9 +173,6 @@ otp/
|
||||
├── otp.c # Main source code
|
||||
├── README.md # This file
|
||||
├── .gitignore # Git ignore rules
|
||||
├── src/ # Generated version files (auto-created)
|
||||
│ ├── version.h # Version header (generated)
|
||||
│ └── version.c # Version implementation (generated)
|
||||
├── pads/ # OTP pad storage directory (created at runtime)
|
||||
└── VERSION # Plain text version (generated)
|
||||
```
|
||||
|
||||
77
build.sh
77
build.sh
@@ -100,13 +100,13 @@ increment_version() {
|
||||
print_success "Created new version tag: $NEW_VERSION"
|
||||
|
||||
# Push changes and tags to remote repository
|
||||
if git push ssh://ubuntu@laantungir.net:/home/ubuntu/git_repos/otp 2>/dev/null; then
|
||||
if git push 2>/dev/null; then
|
||||
print_success "Pushed changes to remote repository"
|
||||
else
|
||||
print_warning "Failed to push changes to remote repository"
|
||||
fi
|
||||
|
||||
if git push ssh://ubuntu@laantungir.net:/home/ubuntu/git_repos/otp --tags 2>/dev/null; then
|
||||
if git push --tags 2>/dev/null; then
|
||||
print_success "Pushed tags to remote repository"
|
||||
else
|
||||
print_warning "Failed to push tags to remote repository"
|
||||
@@ -123,71 +123,7 @@ increment_version() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update VERSION file for compatibility
|
||||
echo "${NEW_VERSION#v}" > VERSION
|
||||
print_success "Updated VERSION file to ${NEW_VERSION#v}"
|
||||
|
||||
# Generate version.h header file
|
||||
mkdir -p src
|
||||
cat > src/version.h << EOF
|
||||
/*
|
||||
* Auto-Generated Version Header
|
||||
* DO NOT EDIT THIS FILE MANUALLY - Generated by build script
|
||||
*/
|
||||
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define VERSION_MAJOR ${MAJOR}
|
||||
#define VERSION_MINOR ${MINOR}
|
||||
#define VERSION_PATCH ${NEW_PATCH}
|
||||
#define VERSION_STRING "${MAJOR}.${MINOR}.${NEW_PATCH}"
|
||||
#define VERSION_TAG "${NEW_VERSION}"
|
||||
|
||||
/* 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 "${NEW_VERSION}"
|
||||
#define VERSION_FULL_DISPLAY "${NEW_VERSION} ($(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 /* VERSION_H */
|
||||
EOF
|
||||
|
||||
# Generate version.c implementation file
|
||||
cat > src/version.c << EOF
|
||||
/*
|
||||
* 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 "Generated version header files"
|
||||
print_success "Version updated to ${NEW_VERSION}"
|
||||
}
|
||||
|
||||
# Build functions
|
||||
@@ -222,7 +158,6 @@ build_static() {
|
||||
clean_project() {
|
||||
print_status "Cleaning build artifacts..."
|
||||
make clean
|
||||
rm -f VERSION src/version.h src/version.c
|
||||
print_success "Clean completed"
|
||||
}
|
||||
|
||||
@@ -267,7 +202,7 @@ case "${1:-build}" in
|
||||
;;
|
||||
version)
|
||||
increment_version
|
||||
print_status "Version information generated"
|
||||
print_status "Version tag updated"
|
||||
;;
|
||||
*)
|
||||
echo "OTP Cipher Build Script"
|
||||
@@ -279,10 +214,10 @@ case "${1:-build}" in
|
||||
echo "Commands:"
|
||||
echo " build - Build project with automatic version increment (default)"
|
||||
echo " static - Build with static linking"
|
||||
echo " clean - Clean build artifacts and generated files"
|
||||
echo " clean - Clean build artifacts"
|
||||
echo " install - Install to system (requires build first)"
|
||||
echo " uninstall - Remove from system"
|
||||
echo " version - Generate version files only"
|
||||
echo " version - Update version tag only"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 build"
|
||||
|
||||
54
otp.c
54
otp.c
@@ -4215,7 +4215,7 @@ int handle_pads_menu(void) {
|
||||
printf(" \033[4mA\033[0mdd entropy to pad\n");
|
||||
printf(" \033[4mS\033[0met default pad\n");
|
||||
printf(" E\033[4mx\033[0mit\n");
|
||||
printf("\nSelect pad (by prefix): ");
|
||||
printf("\nSelect action: ");
|
||||
|
||||
char input[MAX_HASH_LENGTH];
|
||||
if (!fgets(input, sizeof(input), stdin)) {
|
||||
@@ -4224,7 +4224,7 @@ int handle_pads_menu(void) {
|
||||
}
|
||||
input[strcspn(input, "\n")] = 0;
|
||||
|
||||
// Handle actions first
|
||||
// Handle actions
|
||||
if (toupper(input[0]) == 'G') {
|
||||
int result = handle_generate_menu();
|
||||
if (result == 0) {
|
||||
@@ -4306,54 +4306,10 @@ int handle_pads_menu(void) {
|
||||
return handle_pads_menu();
|
||||
} else if (toupper(input[0]) == 'X') {
|
||||
return 0; // Exit to main menu
|
||||
} else {
|
||||
printf("Invalid action. Please select G, A, S, or X.\n");
|
||||
return handle_pads_menu();
|
||||
}
|
||||
|
||||
// Find matching pad by prefix
|
||||
int selected_pad = -1;
|
||||
for (int i = 0; i < pad_count; i++) {
|
||||
if (strncmp(input, pads[i].chksum, strlen(input)) == 0) {
|
||||
if (selected_pad == -1) {
|
||||
selected_pad = i;
|
||||
} else {
|
||||
// Multiple matches - ambiguous
|
||||
printf("Ambiguous prefix. Multiple matches found.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selected_pad == -1) {
|
||||
printf("No pad found matching prefix '%s'\n", input);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Show selected pad actions
|
||||
printf("\n=== Pad: %.16s... ===\n", pads[selected_pad].chksum);
|
||||
printf("Size: %s\n", pads[selected_pad].size_str);
|
||||
printf("Used: %s (%.1f%%)\n", pads[selected_pad].used_str, pads[selected_pad].percentage);
|
||||
|
||||
printf("\nPad Actions:\n");
|
||||
printf(" \033[4mI\033[0mnfo - Show detailed pad information\n");
|
||||
printf(" \033[4mA\033[0mdd entropy - Enhance pad randomness\n");
|
||||
printf(" \033[4mB\033[0mack to pad list\n");
|
||||
printf("\nSelect action: ");
|
||||
|
||||
char action[10];
|
||||
if (!fgets(action, sizeof(action), stdin)) {
|
||||
printf("Error: Failed to read input\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char action_choice = toupper(action[0]);
|
||||
if (action_choice == 'I') {
|
||||
return show_pad_info(pads[selected_pad].chksum);
|
||||
} else if (action_choice == 'A') {
|
||||
// Handle entropy addition
|
||||
return handle_add_entropy_to_pad(pads[selected_pad].chksum);
|
||||
}
|
||||
|
||||
// Default: back to pad list (recursive call)
|
||||
return handle_pads_menu();
|
||||
}
|
||||
|
||||
void get_directory_display(const char* file_path, char* result, size_t result_size) {
|
||||
|
||||
Reference in New Issue
Block a user