/*
 * Minimal test version of main.c to debug startup issues
 */

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

// Copy just the essential parts for testing
char g_db_path[4096] = "db/ginxsom.db";
char g_storage_dir[4096] = ".";
char g_admin_pubkey[65] = "";
char g_relay_seckey[65] = "";
int g_generate_keys = 0;

int main(int argc, char *argv[]) {
  printf("DEBUG: main() started\n");
  fflush(stdout);

  // Parse minimal args
  for (int i = 1; i < argc; i++) {
    printf("DEBUG: arg %d: %s\n", i, argv[i]);
    fflush(stdout);
    if (strcmp(argv[i], "--generate-keys") == 0) {
      g_generate_keys = 1;
      printf("DEBUG: generate-keys flag set\n");
      fflush(stdout);
    } else if (strcmp(argv[i], "--help") == 0) {
      printf("Usage: test_main [options]\n");
      printf("  --generate-keys    Generate keys\n");
      printf("  --help             Show help\n");
      return 0;
    }
  }

  printf("DEBUG: g_generate_keys = %d\n", g_generate_keys);
  fflush(stdout);

  if (g_generate_keys) {
    printf("DEBUG: Would generate keys here\n");
    fflush(stdout);
    return 0;
  }

  printf("DEBUG: Normal startup would continue here\n");
  fflush(stdout);

  return 0;
}