/*
 * WebSocket SSH Library - Shared utilities
 *
 * Copyright (C) 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef WSSH_LIB_H
#define WSSH_LIB_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <getopt.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/select.h>

#define BUFFER_SIZE 1048576
#define DEFAULT_PORT 22

// Config structures
typedef struct {
    char *local_port;
    int wssshd_port;  // wssshd server port
    int debug;
    int interval;  // Reconnection interval in seconds
} wsssh_config_t;

typedef struct {
    char *local_port;
    int wssshd_port;  // wssshd server port
    int debug;
    int interval;  // Connection retry interval in seconds
} wsscp_config_t;

// Thread arguments
typedef struct {
    SSL *ssl;
    int debug;
} thread_args_t;

// Function declarations
char *read_config_value(const char *key);
void print_trans_flag(void);
void print_palestinian_flag(void);
int find_available_port(void);
void generate_request_id(char *request_id, size_t size);

#endif // WSSH_LIB_H