cake
/
libg1m
Archived
1
0
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libg1m/include/libg1m.h

135 lines
5.0 KiB
C

/* *****************************************************************************
* libg1m.h -- libg1m main public header.
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
*
* This file is part of libg1m.
* libg1m is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version.
*
* libg1m 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libg1m; if not, see <http://www.gnu.org/licenses/>.
*
* WARNING: Do NOT include this header using <libg1m-(version)/libg1m.h>!
*
* Compile using one of these:
* libg1m-config --cflags
* pkg-config libg1m --cflags
*
* and include using <libg1m.h>.
* ************************************************************************** */
#ifndef LIBG1M_H
# define LIBG1M_H
# include <libg1m/config.h>
# include <libg1m/buffer.h>
# include <libg1m/handle.h>
# include <libfontcharacter.h>
# include <stdio.h>
# include <stdint.h>
# include <time.h>
# ifdef __cplusplus
extern "C" {
# endif
/* ************************************************************************** */
/* Errors */
/* ************************************************************************** */
/* WARNING: Whenever you add/remove errors, think about updating core/strerror!
* ---
* First, the none error. */
# define g1m_noerror 0x00
/* Then, the miscallenous errors */
# define g1m_error_unknown 0x01
# define g1m_error_alloc 0x02
# define g1m_error_op 0x03
/* Then, the stream errors */
# define g1m_error_nostream 0x10
# define g1m_error_noread 0x11
# define g1m_error_noseek 0x12
/* Then, the decoding errors */
# define g1m_error_unrecognized 0x20
# define g1m_error_magic 0x21
# define g1m_error_checksum 0x22
# define g1m_error_eof 0x23
# define g1m_error_wrong_type 0x24
/* Error type -- for compatibility with old programs using enum */
typedef int g1m_error_t;
/* Message getting macro */
extern const char *g1m_error_strings[];
# define g1m_strerror(N) g1m_error_strings[N]
# define g1m_geterror(N) g1m_error_strings[N]
/* ************************************************************************** */
/* Main functions */
/* ************************************************************************** */
/* open a handle */
int g1m_decode(g1m_t *handle, const char *path, g1m_buffer_t *buffer,
g1m_type_t expected_type);
/* open a handle using FILEs */
#ifndef G1M_DISABLED_FILE
int g1m_open(g1m_t **handle, const char *path,
g1m_type_t expected_type);
int g1m_fopen(g1m_t **handle, const char *path, FILE *stream,
g1m_type_t expected_type);
#endif
/* open MCS head for decoding, correct it for encoding */
int g1m_decode_mcsfile_head(g1m_mcshead_t *head,
int raw_type, const unsigned char *groupname,
const unsigned char *dirname, const unsigned char *filename,
uint_fast32_t filesize);
int g1m_mcstype_correct(g1m_mcshead_t *head);
/* open and decode MCS file */
int g1m_decode_mcsfile(g1m_mcsfile_t **handle,
const g1m_mcshead_t *head, g1m_buffer_t *buffer);
int g1m_decode_mcsfile_data(g1m_mcsfile_t **handle,
const g1m_mcshead_t *head, const unsigned char *data, size_t size);
/* open CAS head for decoding (TODO: correct it for encoding) */
int g1m_decode_casfile_head(g1m_mcshead_t *head,
const char *datatype, const char *filename, const char *specific);
/* open and decode CAS file */
int g1m_decode_casfile(g1m_mcsfile_t **handle,
const g1m_mcshead_t *head, g1m_buffer_t *buffer);
int g1m_decode_casfile_data(g1m_mcsfile_t **handle,
const g1m_mcshead_t *head, const unsigned char *data, size_t size);
/* open CAS protocol file head and content */
int g1m_decode_caspro_head(g1m_mcshead_t *head, g1m_buffer_t *buffer);
int g1m_decode_caspro_part(g1m_mcsfile_t **file,
const g1m_mcshead_t *head, g1m_buffer_t *buffer);
/* free handles */
void g1m_free(g1m_t *handle);
void g1m_free_mcsfile(g1m_mcsfile_t *handle);
/* ************************************************************************** */
/* MCS file manipulation */
/* ************************************************************************** */
/* add MCS files */
int g1m_putmcs_program(g1m_t *handle, g1m_mcsfile_t **pfile,
char *name, char *password, char *content);
int g1m_putmcs_capture(g1m_t *handle, g1m_mcsfile_t **pfile,
int id, int width, int height, uint32_t **pixels);
int g1m_putmcs_picture(g1m_t *handle, g1m_mcsfile_t **pfile,
int id, uint32_t **pixels_one, uint32_t **pixels_two);
# ifdef __cplusplus
}
# endif
#endif /* LIBG1M_H */