This commit is contained in:
Clinv committed 2026-10-24 12:01:52 -03:00
1 parent 7f7fcd545d
commit 4d9a339421
114 files changed
+11383 -1837

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
/* Cabecera INTERNA (no es API pública). Utilidades comunes y estructuras
* compartidas entre módulos. */
#ifndef TAHGIBU_INTERNAL_H
#define TAHGIBU_INTERNAL_H
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "tahgibu/tahgibu.h"
#if defined(__GNUC__)
#define TGB_PRINTF(a, b) __attribute__((format(printf, a, b)))
#else
#define TGB_PRINTF(a, b)
#endif
/* Registra el mensaje del último error (por hilo) y devuelve 'status'. */
tgb_status tgb_fail(tgb_status status, const char *fmt, ...) TGB_PRINTF(2, 3);
/* Operaciones aritméticas con detección de desbordamiento. */
static inline bool tgb_mul_ok(size_t a, size_t b, size_t *out) {
if (a != 0 && b > SIZE_MAX / a) return false;
*out = a * b;
return true;
}
static inline bool tgb_add_ok(size_t a, size_t b, size_t *out) {
if (b > SIZE_MAX - a) return false;
*out = a + b;
return true;
}
char *tgb_strdup(const char *s);
/* Acceso de escritura a los píxeles (solo para módulos internos; NO marca zona modificada). */
uint8_t *tgb_canvas_pixels_mut(tgb_canvas *c);
/* Copia segura a un buffer fijo (siempre termina en NUL). */
void tgb_strlcpy(char *dst, const char *src, size_t cap);
/* true si s[0..len) es UTF-8 válido. */
bool tgb_utf8_valid(const char *s, size_t len);
#define TGB_MAX_SUBSCRIBERS 64
struct tgb_context {
char config_dir[512], data_dir[512], cache_dir[512], state_dir[512];
struct {
uint32_t id;
tgb_event_fn fn;
void *user;
} subs[TGB_MAX_SUBSCRIBERS];
size_t nsubs;
uint32_t next_sub_id;
/* portapapeles de fotogramas */
struct {
bool valid;
int w, h;
uint32_t duration_ms;
size_t nlayers;
tgb_canvas **cels;
} clip;
};
void tgb_emit(tgb_context *ctx, const tgb_event *ev);
void tgb_emit_simple(tgb_document *doc, tgb_event_type type);
void tgb_context_clear_clipboard(tgb_context *ctx);
#endif