56 lines
1.0 KiB
C
56 lines
1.0 KiB
C
//
|
|
// Created by Ajurna on 28/07/2025.
|
|
//
|
|
|
|
#ifndef SERVER02_H
|
|
#define SERVER02_H
|
|
#include <stdint.h>
|
|
|
|
#endif //SERVER02_H
|
|
|
|
#include <winsock2.h>
|
|
typedef struct handleArgs {
|
|
int connection;
|
|
SOCKET client;
|
|
} handle_args_t;
|
|
|
|
typedef enum MessageType {
|
|
QUERY = 'Q',
|
|
INSERT = 'I'
|
|
} message_type_t;
|
|
|
|
typedef struct Insert {
|
|
char type;
|
|
int32_t timestamp;
|
|
int32_t price;
|
|
} insert_t;
|
|
|
|
typedef struct Query {
|
|
char type;
|
|
int32_t mintime;
|
|
int32_t maxtime;
|
|
} query_t;
|
|
|
|
typedef union QueryOrInsert {
|
|
query_t query;
|
|
insert_t insert;
|
|
} query_or_insert_t;
|
|
|
|
typedef struct Price {
|
|
int32_t timestamp;
|
|
int32_t price;
|
|
} price_t;
|
|
|
|
typedef struct PriceArray {
|
|
size_t size;
|
|
size_t capacity;
|
|
price_t *data;
|
|
} price_array_t;
|
|
|
|
void *handle_connection(void *args);
|
|
query_or_insert_t *fix_message(char *message);
|
|
|
|
price_array_t *price_array_create(int capacity);
|
|
void price_array_free(price_array_t *array);
|
|
void price_array_append(price_array_t *array, insert_t *value);
|
|
int price_array_query(price_array_t *array, query_t *query); |