/*
 * NOSTR Core Library - Version Test Example
 * Simple version display using VERSION file
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nostr_core.h"

// Simple function to read VERSION file if it exists
static const char* get_version_from_file(void) {
    static char version_buf[64] = {0};
    FILE* f = fopen("VERSION", "r");
    if (f) {
        if (fgets(version_buf, sizeof(version_buf), f)) {
            // Remove trailing newline
            size_t len = strlen(version_buf);
            if (len > 0 && version_buf[len-1] == '\n') {
                version_buf[len-1] = '\0';
            }
        }
        fclose(f);
        return version_buf;
    }
    return "unknown";
}

int main() {
    printf("NOSTR Core Library Version Test\n");
    printf("===============================\n\n");
    
    // Initialize the library
    if (nostr_init() != NOSTR_SUCCESS) {
        printf("Failed to initialize NOSTR library\n");
        return 1;
    }
    
    // Display basic version information
    const char* version = get_version_from_file();
    printf("Library Version: %s\n", version);
    printf("Library Status: Initialized successfully\n");
    
    // Test basic functionality
    printf("\nLibrary Functionality Test:\n");
    unsigned char private_key[32];
    unsigned char public_key[32];
    
    if (nostr_generate_keypair(private_key, public_key) == NOSTR_SUCCESS) {
        printf("✓ Key generation works\n");
    } else {
        printf("✗ Key generation failed\n");
    }
    
    // Cleanup
    nostr_cleanup();
    
    printf("\nVersion test completed successfully.\n");
    printf("Note: This library no longer includes runtime version functions\n");
    printf("      to avoid build issues when used as a submodule.\n");
    
    return 0;
}
