Skip to content

Commit b7e12fd

Browse files
committed
hii
hi
1 parent 202f0f7 commit b7e12fd

32 files changed

Lines changed: 2213 additions & 0 deletions

.vscode/c_cpp_properties.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Win32",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"C:/msys64/ucrt64/include/glib-2.0",
8+
"C:/msys64/ucrt64/lib/glib-2.0/include",
9+
"C:/msys64/ucrt64/include"
10+
],
11+
"defines": [
12+
"_DEBUG",
13+
"UNICODE",
14+
"_UNICODE"
15+
],
16+
"compilerPath": "C:/msys64/ucrt64/bin/gcc.exe",
17+
"cStandard": "c11",
18+
"cppStandard": "c++17",
19+
"intelliSenseMode": "windows-gcc-x64"
20+
}
21+
],
22+
"version": 4
23+
}

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"C_Cpp.default.includePath": [
3+
"${workspaceFolder}/**",
4+
"C:/msys64/ucrt64/include/glib-2.0",
5+
"C:/msys64/ucrt64/lib/glib-2.0/include",
6+
"C:/msys64/ucrt64/include"
7+
],
8+
"C_Cpp.default.compilerPath": "C:/msys64/ucrt64/bin/gcc.exe",
9+
"C_Cpp.default.cStandard": "c11",
10+
"C_Cpp.default.intelliSenseMode": "windows-gcc-x64"
11+
}

LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
MIT License
3+
4+
Copyright (c) 2024 Auto Decoder Team
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
24+
text
25+
26+
---

Makefile

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Auto Decoder Pro - Production Makefile
2+
VERSION := 2.0.0
3+
PREFIX ?= /usr/local
4+
5+
CC := gcc
6+
PKG_CONFIG := pkg-config
7+
8+
# Build type: release, debug, profile
9+
BUILD ?= release
10+
11+
# Flags
12+
CFLAGS_BASE := -Wall -Wextra -pthread -DVERSION=\"$(VERSION)\" -D_GNU_SOURCE
13+
CFLAGS_OPT := -O3 -march=native -flto -fomit-frame-pointer -fstack-protector-strong
14+
CFLAGS_DEBUG := -g -O0 -DDEBUG -fsanitize=address,undefined
15+
16+
ifeq ($(BUILD),debug)
17+
CFLAGS := $(CFLAGS_BASE) $(CFLAGS_DEBUG)
18+
LDFLAGS := -fsanitize=address,undefined
19+
SUFFIX := -debug
20+
else
21+
CFLAGS := $(CFLAGS_BASE) $(CFLAGS_OPT) -DNDEBUG
22+
LDFLAGS := -flto -Wl,-O2
23+
SUFFIX :=
24+
endif
25+
26+
# Dependencies
27+
GTK_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-3.0 glib-2.0 2>/dev/null)
28+
GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-3.0 glib-2.0 gmodule-2.0 2>/dev/null)
29+
30+
CFLAGS += $(GTK_CFLAGS)
31+
LDFLAGS += $(GTK_LIBS) -lm
32+
33+
# Directories
34+
SRCDIR := src
35+
INCDIR := include
36+
UIDIR := ui
37+
OBJDIR := build/obj
38+
BINDIR := build/bin
39+
40+
# Source files
41+
CORE_SRC := $(SRCDIR)/core.c $(SRCDIR)/decoder.c $(SRCDIR)/encoder.c \
42+
$(SRCDIR)/plugin.c $(SRCDIR)/lru_cache.c $(SRCDIR)/logging.c \
43+
$(SRCDIR)/errors.c $(SRCDIR)/crash_handler.c
44+
45+
UI_SRC := $(UIDIR)/gui.c
46+
GUI_SRC := $(SRCDIR)/main.c
47+
CLI_SRC := $(SRCDIR)/cli.c
48+
49+
# Objects
50+
CORE_OBJ := $(CORE_SRC:%.c=$(OBJDIR)/%.o)
51+
UI_OBJ := $(UI_SRC:%.c=$(OBJDIR)/%.o)
52+
GUI_OBJ := $(GUI_SRC:%.c=$(OBJDIR)/%.o) $(CORE_OBJ) $(UI_OBJ)
53+
CLI_OBJ := $(CLI_SRC:%.c=$(OBJDIR)/%.o) $(CORE_OBJ)
54+
55+
# Targets
56+
.PHONY: all clean install uninstall gui cli help
57+
58+
all: gui cli
59+
60+
gui: $(BINDIR)/auto_decoder_pro$(SUFFIX)
61+
62+
cli: $(BINDIR)/auto_decoder$(SUFFIX)
63+
64+
$(BINDIR)/auto_decoder_pro$(SUFFIX): $(GUI_OBJ)
65+
@mkdir -p $(BINDIR)
66+
@echo "Building GUI ($(BUILD) mode)..."
67+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
68+
@echo "✅ GUI built: $@"
69+
70+
$(BINDIR)/auto_decoder$(SUFFIX): $(CLI_OBJ)
71+
@mkdir -p $(BINDIR)
72+
@echo "Building CLI ($(BUILD) mode)..."
73+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
74+
@echo "✅ CLI built: $@"
75+
76+
$(OBJDIR)/%.o: %.c
77+
@mkdir -p $(dir $@)
78+
@echo "Compiling: $<"
79+
$(CC) $(CFLAGS) -I$(INCDIR) -I$(UIDIR) -c $< -o $@
80+
81+
clean:
82+
@echo "Cleaning..."
83+
rm -rf $(OBJDIR) $(BINDIR)
84+
@echo "✅ Clean complete"
85+
86+
install: all
87+
@echo "Installing to $(PREFIX)..."
88+
install -Dm755 $(BINDIR)/auto_decoder_pro$(SUFFIX) $(PREFIX)/bin/auto_decoder_pro
89+
install -Dm755 $(BINDIR)/auto_decoder$(SUFFIX) $(PREFIX)/bin/auto_decoder
90+
@echo "✅ Installation complete"
91+
92+
uninstall:
93+
@echo "Uninstalling..."
94+
rm -f $(PREFIX)/bin/auto_decoder_pro
95+
rm -f $(PREFIX)/bin/auto_decoder
96+
@echo "✅ Uninstall complete"
97+
98+
help:
99+
@echo "Auto Decoder Pro Build System v$(VERSION)"
100+
@echo ""
101+
@echo "Targets:"
102+
@echo " all - Build GUI and CLI (default)"
103+
@echo " gui - Build GUI only"
104+
@echo " cli - Build CLI only"
105+
@echo " clean - Remove build artifacts"
106+
@echo " install - Install to system"
107+
@echo " uninstall - Remove from system"

include/constants.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#ifndef CONSTANTS_H
2+
#define CONSTANTS_H
3+
4+
/* Performance settings */
5+
#define CACHE_SIZE_DEFAULT 1000
6+
#define THREAD_POOL_SIZE 4
7+
#define MAX_DECODE_DEPTH 5
8+
#define STREAM_BUFFER_SIZE 8192
9+
10+
/* Limits */
11+
#define MAX_INPUT_SIZE (1024 * 1024) /* 1MB */
12+
#define MAX_OUTPUT_SIZE (1024 * 1024 * 2) /* 2MB */
13+
#define MAX_HISTORY_ITEMS 1000
14+
#define MAX_PLUGINS 50
15+
16+
/* Timeouts (milliseconds) */
17+
#define TASK_TIMEOUT_MS 30000
18+
#define ANIMATION_INTERVAL_MS 50
19+
20+
/* UI defaults */
21+
#define DEFAULT_WINDOW_WIDTH 900
22+
#define DEFAULT_WINDOW_HEIGHT 700
23+
#define DEFAULT_FONT_SIZE 11
24+
25+
/* Paths */
26+
#ifdef _WIN32
27+
#define CONFIG_DIR ".\\config\\auto_decoder"
28+
#define DATA_DIR ".\\data\\auto_decoder"
29+
#define CACHE_DIR ".\\cache\\auto_decoder"
30+
#define PLUGINS_DIR ".\\plugins"
31+
#else
32+
#define CONFIG_DIR "~/.config/auto_decoder"
33+
#define DATA_DIR "~/.local/share/auto_decoder"
34+
#define CACHE_DIR "~/.cache/auto_decoder"
35+
#define PLUGINS_DIR "/usr/lib/auto_decoder/plugins"
36+
#endif
37+
38+
#endif /* CONSTANTS_H */

include/core.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#ifndef CORE_H
2+
#define CORE_H
3+
4+
#include <glib.h>
5+
#include "errors.h"
6+
7+
typedef enum {
8+
CORE_MODE_AUTO,
9+
CORE_MODE_MORSE,
10+
CORE_MODE_BASE64,
11+
CORE_MODE_HEX,
12+
CORE_MODE_BINARY
13+
} CoreMode;
14+
15+
typedef struct {
16+
char *output;
17+
char *format;
18+
char *input;
19+
CoreMode mode;
20+
ErrorCode error_code;
21+
char *error_message;
22+
double processing_time_ms;
23+
size_t input_size;
24+
size_t output_size;
25+
gboolean from_cache;
26+
int decode_depth;
27+
} DecodeResult;
28+
29+
typedef struct {
30+
char *output;
31+
char *format;
32+
ErrorCode error_code;
33+
size_t input_size;
34+
size_t output_size;
35+
} EncodeResult;
36+
37+
gboolean core_init(void);
38+
void core_cleanup(void);
39+
40+
DecodeResult* core_decode(const char *input);
41+
DecodeResult* core_decode_recursive(const char *input, int max_depth);
42+
43+
EncodeResult* core_encode(const char *input, CoreMode mode);
44+
45+
void core_cache_clear(void);
46+
void core_cache_set_max_size(size_t size);
47+
48+
typedef struct {
49+
guint64 total_decodes;
50+
guint64 cache_hits;
51+
guint64 cache_misses;
52+
double avg_decode_time_ms;
53+
size_t total_input_bytes;
54+
size_t total_output_bytes;
55+
guint64 active_plugins;
56+
} CoreStats;
57+
58+
CoreStats core_get_stats(void);
59+
void core_reset_stats(void);
60+
61+
void decode_result_free(DecodeResult *result);
62+
void encode_result_free(EncodeResult *result);
63+
64+
#endif /* CORE_H */

include/crash_handler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef CRASH_HANDLER_H
2+
#define CRASH_HANDLER_H
3+
4+
void install_crash_handler(void);
5+
6+
#endif /* CRASH_HANDLER_H */

include/decoder.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef DECODER_H
2+
#define DECODER_H
3+
4+
#include <glib.h>
5+
6+
gboolean is_morse(const char *text, size_t len);
7+
gboolean is_base64(const char *text, size_t len);
8+
gboolean is_hex(const char *text, size_t len);
9+
gboolean is_binary(const char *text, size_t len);
10+
11+
char* decode_morse(const char *morse);
12+
char* decode_base64(const char *input);
13+
char* decode_hex(const char *input);
14+
char* decode_binary(const char *input);
15+
16+
#endif /* DECODER_H */

include/encoder.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef ENCODER_H
2+
#define ENCODER_H
3+
4+
typedef enum {
5+
ENCODE_MORSE,
6+
ENCODE_BASE64,
7+
ENCODE_HEX,
8+
ENCODE_BINARY
9+
} EncodeType;
10+
11+
char* encode_morse(const char *text);
12+
char* encode_base64(const char *text);
13+
char* encode_hex(const char *text);
14+
char* encode_binary(const char *text);
15+
char* encode_text(const char *text, EncodeType type);
16+
17+
#endif /* ENCODER_H */

include/errors.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef ERRORS_H
2+
#define ERRORS_H
3+
4+
#include <glib.h>
5+
6+
typedef enum {
7+
ERROR_OK = 0,
8+
ERROR_GENERIC = 1,
9+
ERROR_INVALID_INPUT = 100,
10+
ERROR_UNKNOWN_FORMAT = 101,
11+
ERROR_INVALID_ENCODING = 102,
12+
ERROR_DECODE_FAILED = 200,
13+
ERROR_ENCODE_FAILED = 201,
14+
ERROR_FILE_NOT_FOUND = 300,
15+
ERROR_FILE_READ = 301,
16+
ERROR_FILE_WRITE = 302,
17+
ERROR_OUT_OF_MEMORY = 400,
18+
ERROR_THREAD_CREATE = 500,
19+
ERROR_TIMEOUT = 600,
20+
ERROR_CANCELLED = 601,
21+
ERROR_PLUGIN_LOAD = 700,
22+
ERROR_PLUGIN_INIT = 701
23+
} ErrorCode;
24+
25+
typedef struct Error {
26+
ErrorCode code;
27+
char *message;
28+
char *file;
29+
int line;
30+
char *function;
31+
} Error;
32+
33+
Error* error_new(ErrorCode code, const char *format, ...) G_GNUC_PRINTF(2, 3);
34+
void error_free(Error *error);
35+
const char* error_get_message(ErrorCode code);
36+
37+
#endif /* ERRORS_H */

0 commit comments

Comments
 (0)