2016-10-30 20:18:15 +01:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* _____ _ */
|
|
|
|
/* libg1m.h |_ _|__ _ _| |__ ___ _ _ */
|
2016-10-31 13:19:12 +01:00
|
|
|
/* | Project: libg1m | |/ _ \| | | | '_ \ / _ \ | | | */
|
2016-10-30 20:18:15 +01:00
|
|
|
/* | | (_) | |_| | | | | __/ |_| | */
|
|
|
|
/* By: thomas <thomas@touhey.fr> |_|\___/ \__,_|_| |_|\___|\__, |.fr */
|
2016-10-31 13:19:12 +01:00
|
|
|
/* Last updated: 2016/10/31 00:14:27 |___/ */
|
2016-10-30 20:18:15 +01:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
#ifndef LIBG1M_H
|
|
|
|
# define LIBG1M_H
|
2016-11-21 10:26:52 +01:00
|
|
|
# include <libg1m/bcd.h>
|
|
|
|
# include <libg1m/fontcharacter.h>
|
|
|
|
# include <libg1m/color.h>
|
2016-10-30 20:18:15 +01:00
|
|
|
# include <stdio.h>
|
2016-11-03 01:16:21 +01:00
|
|
|
# include <stdint.h>
|
|
|
|
# include <time.h>
|
2016-10-30 20:18:15 +01:00
|
|
|
# ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
# endif
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
/* Errors */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
/* main enumeration */
|
|
|
|
typedef enum {
|
|
|
|
g1m_noerror,
|
|
|
|
|
2016-11-01 06:10:47 +01:00
|
|
|
/* no stream sent -- if lib made the libc calls, check errno */
|
2016-10-30 20:18:15 +01:00
|
|
|
g1m_error_nostream,
|
|
|
|
/* could not read from stream */
|
|
|
|
g1m_error_noread,
|
|
|
|
/* could not seek in stream */
|
|
|
|
g1m_error_noseek,
|
2016-11-19 02:47:36 +01:00
|
|
|
|
2016-10-30 20:18:15 +01:00
|
|
|
/* magic or control problem */
|
|
|
|
g1m_error_magic,
|
2016-11-01 12:03:38 +01:00
|
|
|
/* unexpected EOF */
|
|
|
|
g1m_error_eof,
|
2016-10-30 20:18:15 +01:00
|
|
|
/* memory allocation problem */
|
|
|
|
g1m_error_alloc,
|
2016-11-19 02:47:36 +01:00
|
|
|
|
|
|
|
/* operation not supported for this type */
|
|
|
|
g1m_error_op,
|
2016-10-30 20:18:15 +01:00
|
|
|
} g1m_error_t;
|
|
|
|
|
|
|
|
/* Message getting macro */
|
|
|
|
extern const char *g1m_error_strings[];
|
2016-11-20 02:13:36 +01:00
|
|
|
# define g1m_strerror(N) g1m_error_strings[N]
|
|
|
|
# define g1m_geterror(N) g1m_error_strings[N]
|
2016-10-30 20:18:15 +01:00
|
|
|
|
2016-11-03 01:16:21 +01:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* MCS-Related types */
|
|
|
|
/* ************************************************************************** */
|
2016-12-13 12:31:53 +01:00
|
|
|
/* BCD matrix - real and complex */
|
|
|
|
typedef struct {
|
|
|
|
struct bcd real;
|
|
|
|
struct bcd imgn;
|
|
|
|
int used;
|
|
|
|
} g1m_mcs_cell_t;
|
|
|
|
|
2016-11-03 01:16:21 +01:00
|
|
|
/* MCS file type */
|
2016-11-20 02:13:36 +01:00
|
|
|
# define g1m_mcstype_picture g1m_mcstype_pict
|
|
|
|
# define g1m_mcstype_capture g1m_mcstype_capt
|
2016-11-03 01:16:21 +01:00
|
|
|
typedef enum {
|
2016-11-19 02:47:36 +01:00
|
|
|
g1m_mcstype_program = 0x01,
|
|
|
|
g1m_mcstype_list = 0x02,
|
|
|
|
g1m_mcstype_mat = 0x04,
|
|
|
|
g1m_mcstype_pict = 0x08,
|
|
|
|
g1m_mcstype_capt = 0x10,
|
2016-12-16 18:01:28 +01:00
|
|
|
g1m_mcstype_spreadsheet = 0x20,
|
|
|
|
g1m_mcstype_string = 0x40,
|
|
|
|
g1m_mcstype_setup = 0x80,
|
|
|
|
g1m_mcstype_alphamem = 0x100
|
2016-11-03 01:16:21 +01:00
|
|
|
} g1m_mcsfile_type_t;
|
|
|
|
|
2016-12-16 18:01:28 +01:00
|
|
|
/* uses id */
|
|
|
|
# define g1m_mcstype_uses_id(T) ((T) & (\
|
|
|
|
g1m_mcstype_list | g1m_mcstype_mat | g1m_mcstype_pict | g1m_mcstype_capt | \
|
|
|
|
g1m_mcstype_string))
|
|
|
|
|
2016-11-03 01:16:21 +01:00
|
|
|
/* mcs file */
|
2016-11-20 02:17:14 +01:00
|
|
|
# define g1m_has_password(F) (F)->password[0]
|
2016-12-15 14:29:51 +01:00
|
|
|
# define g1m_remove_password(F) (F)->password[0] = 0
|
2016-11-03 01:16:21 +01:00
|
|
|
typedef struct {
|
|
|
|
/* file type */
|
2016-12-13 12:31:53 +01:00
|
|
|
unsigned int type;
|
2016-11-03 01:16:21 +01:00
|
|
|
|
2016-12-16 18:01:28 +01:00
|
|
|
/* file name or id */
|
|
|
|
char name[9];
|
|
|
|
int id;
|
|
|
|
|
2016-11-30 16:45:59 +01:00
|
|
|
/* for programs: the password and content */
|
2016-11-03 01:16:21 +01:00
|
|
|
char password[9];
|
2016-11-30 16:45:59 +01:00
|
|
|
char *content;
|
2016-11-03 01:16:21 +01:00
|
|
|
|
|
|
|
/* for spreadsheets, lists and matrixes */
|
|
|
|
unsigned int columns, rows;
|
2016-11-19 13:44:44 +01:00
|
|
|
g1m_mcs_cell_t **cells;
|
2016-11-03 01:16:21 +01:00
|
|
|
|
|
|
|
/* for pictures and captures */
|
|
|
|
unsigned int width, height;
|
2016-11-19 02:47:36 +01:00
|
|
|
uint32_t **image; /* 0x0RGB */
|
|
|
|
uint32_t **second_image; /* 0x0RGB */
|
2016-11-03 01:16:21 +01:00
|
|
|
} g1m_mcsfile_t;
|
|
|
|
|
|
|
|
/* version */
|
|
|
|
typedef struct {
|
|
|
|
int major;
|
|
|
|
int minor;
|
|
|
|
int revision;
|
|
|
|
} g1m_version_t;
|
|
|
|
|
2016-12-13 03:28:28 +01:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* E-activities related types */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
/* line type */
|
2016-12-13 12:31:53 +01:00
|
|
|
# define g1m_linetype_pict g1m_linetype_picture
|
|
|
|
# define g1m_linetype_heading g1m_linetype_title
|
|
|
|
# define g1m_linetype_standard_heading g1m_linetype_title
|
2016-12-13 03:28:28 +01:00
|
|
|
typedef enum {
|
|
|
|
g1m_linetype_title = 0x01,
|
|
|
|
g1m_linetype_text = 0x02,
|
|
|
|
g1m_linetype_picture = 0x04,
|
|
|
|
g1m_linetype_eact = 0x08
|
|
|
|
} g1m_eact_line_type_t;
|
|
|
|
|
|
|
|
/* line */
|
|
|
|
typedef struct g1m_line_s {
|
|
|
|
int type;
|
|
|
|
|
|
|
|
/* for subcontents */
|
|
|
|
char name[17];
|
|
|
|
|
|
|
|
/* content */
|
|
|
|
char *content;
|
|
|
|
|
|
|
|
/* subcontents */
|
|
|
|
int count;
|
|
|
|
int _size;
|
|
|
|
struct g1m_line_s **lines;
|
|
|
|
} g1m_line_t;
|
|
|
|
|
2016-11-03 01:16:21 +01:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* General types */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
/* type */
|
2016-11-23 06:44:27 +01:00
|
|
|
# define g1m_type_pict g1m_type_picture
|
|
|
|
# define g1m_type_eactivity g1m_type_eact
|
|
|
|
# define g1m_type_add_in g1m_type_addin
|
2016-11-03 01:16:21 +01:00
|
|
|
typedef enum {
|
|
|
|
g1m_type_addin = 0x01,
|
|
|
|
g1m_type_mcs = 0x02,
|
|
|
|
g1m_type_eact = 0x04,
|
2016-11-24 18:03:55 +01:00
|
|
|
g1m_type_pict = 0x08,
|
|
|
|
g1m_type_lang = 0x10
|
2016-11-03 01:16:21 +01:00
|
|
|
} g1m_type_t;
|
|
|
|
|
2016-10-30 20:18:15 +01:00
|
|
|
/* handle */
|
2016-11-03 01:16:21 +01:00
|
|
|
typedef struct {
|
|
|
|
/* g1m type */
|
|
|
|
g1m_type_t type;
|
|
|
|
/* is it a format adapted for fx-CG? */
|
|
|
|
int is_cg;
|
|
|
|
|
2016-12-15 09:58:16 +01:00
|
|
|
/* Add-in related data */
|
|
|
|
char title[17];
|
2016-11-03 01:16:21 +01:00
|
|
|
char internal_name[12];
|
|
|
|
g1m_version_t version;
|
|
|
|
time_t creation_date;
|
2016-10-30 20:18:15 +01:00
|
|
|
|
2016-12-15 09:58:16 +01:00
|
|
|
/* Tab-related properties */
|
2016-12-12 16:12:11 +01:00
|
|
|
int count;
|
|
|
|
int _size;
|
|
|
|
|
2016-12-15 09:58:16 +01:00
|
|
|
/* MCS list */
|
2016-12-16 18:01:28 +01:00
|
|
|
g1m_mcsfile_t **files;
|
2016-11-03 01:16:21 +01:00
|
|
|
|
2016-12-15 09:58:16 +01:00
|
|
|
/* Messages list */
|
2016-12-12 16:12:11 +01:00
|
|
|
char **messages;
|
|
|
|
|
2016-12-15 09:58:16 +01:00
|
|
|
/* Picture-related data (also used for add-in icons */
|
2016-11-23 06:44:27 +01:00
|
|
|
int width, height;
|
|
|
|
uint32_t **pixels; /* 0x0RGB */
|
|
|
|
|
2016-12-15 09:58:16 +01:00
|
|
|
/* E-activities related data */
|
2016-12-13 03:28:28 +01:00
|
|
|
g1m_line_t *line;
|
|
|
|
g1m_line_t _linedata;
|
2016-11-03 01:16:21 +01:00
|
|
|
} g1m_t;
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
/* Main functions */
|
|
|
|
/* ************************************************************************** */
|
2016-11-19 12:05:54 +01:00
|
|
|
/* open handles */
|
2016-10-30 20:18:15 +01:00
|
|
|
int g1m_open(g1m_t **handle, const char *path);
|
|
|
|
int g1m_fopen(g1m_t **handle, FILE *stream);
|
2016-11-19 12:05:54 +01:00
|
|
|
|
2016-12-16 18:01:28 +01:00
|
|
|
/* open MCS handle (this one is mainly for `libp7`) */
|
2016-11-19 02:47:36 +01:00
|
|
|
int g1m_parse_mcsfile_content(g1m_mcsfile_t **handle, FILE *stream,
|
2016-12-16 18:01:28 +01:00
|
|
|
int raw_type, const unsigned char *groupname, const unsigned char *filename,
|
2016-11-19 02:47:36 +01:00
|
|
|
uint_fast32_t filesize);
|
2016-10-30 20:18:15 +01:00
|
|
|
|
2016-11-19 12:05:54 +01:00
|
|
|
/* free handles */
|
|
|
|
void g1m_free(g1m_t *handle);
|
|
|
|
void g1m_free_mcsfile(g1m_mcsfile_t *handle);
|
|
|
|
|
2016-10-30 20:18:15 +01:00
|
|
|
# ifdef __cplusplus
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
#endif /* LIBG1M_H */
|