204 lines
6.2 KiB
C
204 lines
6.2 KiB
C
/* ****************************************************************************
|
|
* libcasio/file.h -- file handle.
|
|
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
*
|
|
* This file is part of libcasio.
|
|
* libcasio 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.
|
|
*
|
|
* libcasio 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 libcasio; if not, see <http://www.gnu.org/licenses/>.
|
|
* ************************************************************************* */
|
|
#ifndef LIBCASIO_FILE_H
|
|
# define LIBCASIO_FILE_H
|
|
# include "cdefs.h"
|
|
# include "mcs.h"
|
|
# include "version.h"
|
|
# include "date.h"
|
|
|
|
CASIO_BEGIN_NAMESPACE
|
|
CASIO_STRUCT(casio_file, casio_file_t)
|
|
|
|
/* ---
|
|
* Description.
|
|
* --- */
|
|
|
|
/* This header is about files that are adapted for most filesystems out there,
|
|
* such as G1M, G1A, G3E, et caetera.
|
|
*
|
|
* Here are the managed file types: */
|
|
|
|
typedef unsigned int casio_filetype_t;
|
|
|
|
# define casio_filetype_addin 0x0001
|
|
# define casio_filetype_mcs 0x0002
|
|
# define casio_filetype_eact 0x0004
|
|
# define casio_filetype_picture 0x0008
|
|
# define casio_filetype_lang 0x0010
|
|
# define casio_filetype_fkey 0x0020
|
|
# define casio_filetype_storage 0x0040
|
|
|
|
/* (with aliases) */
|
|
|
|
# define casio_filetype_pict casio_filetype_picture
|
|
# define casio_filetype_eactivity casio_filetype_eact
|
|
# define casio_filetype_e_activity casio_filetype_eact
|
|
# define casio_filetype_add_in casio_filetype_addin
|
|
|
|
/* Those types can exist for each of the platformes.
|
|
* For example, G1E is e-activities for the fx platform, and C2P are
|
|
* pictures for the fx-CP platform. */
|
|
|
|
typedef unsigned int casio_filefor_t;
|
|
|
|
# define casio_filefor_none 0x0000
|
|
# define casio_filefor_fx 0x0001
|
|
# define casio_filefor_cp 0x0002
|
|
# define casio_filefor_cg 0x0004
|
|
# define casio_filefor_cas 0x0008
|
|
# define casio_filefor_casemul 0x0010
|
|
|
|
/* And here is the file structure.
|
|
* The elements can be initialized or uninitialized depending on the
|
|
* file type. */
|
|
|
|
struct casio_file {
|
|
/* file type, destination platform */
|
|
|
|
casio_filetype_t casio_file_type;
|
|
casio_filefor_t casio_file_for;
|
|
|
|
/* Add-in related data */
|
|
|
|
time_t casio_file_creation_date;
|
|
unsigned char *casio_file_content;
|
|
size_t casio_file_size;
|
|
|
|
/* Lists for various purposes */
|
|
|
|
int casio_file_count;
|
|
int casio_file__size;
|
|
char **casio_file_messages;
|
|
casio_pixel_t ***casio_file_fkeys;
|
|
|
|
/* Main memory */
|
|
|
|
casio_mcs_t *casio_file_mcs;
|
|
|
|
/* Picture-related data (also used for add-in icons) */
|
|
|
|
int casio_file_width;
|
|
int casio_file_height;
|
|
casio_pixel_t **casio_file_pixels; /* 0x0RGB */
|
|
casio_pixel_t **casio_file_icon_unsel; /* 0x0RGB */
|
|
casio_pixel_t **casio_file_icon_sel; /* 0x0RGB */
|
|
|
|
/* Other string data */
|
|
|
|
char casio_file_title[17];
|
|
char casio_file_intname[12];
|
|
casio_version_t casio_file_version;
|
|
};
|
|
|
|
/* ---
|
|
* Methods.
|
|
* --- */
|
|
|
|
CASIO_BEGIN_DECLS
|
|
|
|
/* Make a file. */
|
|
|
|
CASIO_EXTERN(int) casio_make_picture
|
|
OF((casio_file_t **casio__handle,
|
|
unsigned int casio__width, unsigned int casio__height));
|
|
|
|
CASIO_EXTERN(int) casio_make_mcs
|
|
OF((casio_file_t **casio__handle));
|
|
|
|
CASIO_EXTERN(int) casio_make_fkey
|
|
OF((casio_file_t **casio__handle,
|
|
casio_filefor_t casio__for, int casio__count));
|
|
|
|
CASIO_EXTERN(int) casio_make_lang
|
|
OF((casio_file_t **casio__handle,
|
|
casio_filefor_t casio__for, int casio__count));
|
|
|
|
CASIO_EXTERN(int) casio_make_addin
|
|
OF((casio_file_t **casio__handle,
|
|
casio_filefor_t casio__for, size_t casio__size,
|
|
char const *casio__name, char const *casio__internal,
|
|
casio_version_t const *casio__version, time_t const *casio__created));
|
|
|
|
/* Free a file. */
|
|
|
|
CASIO_EXTERN(void) casio_free_file
|
|
OF((casio_file_t *casio__handle));
|
|
|
|
/* Decode a file. */
|
|
|
|
CASIO_EXTERN(int) casio_decode
|
|
OF((casio_file_t **casio__handle,
|
|
char const *casio__filename, tio_stream_t *casio__buffer,
|
|
casio_filetype_t casio__expected_types));
|
|
|
|
/* General management functions for files */
|
|
|
|
CASIO_EXTERN(int) casio_get_file_type
|
|
OF((casio_file_t *casio__handle, casio_filetype_t *casio__type));
|
|
CASIO_EXTERN(int) casio_get_file_for
|
|
OF((casio_file_t *casio__handle, casio_filefor_t *casio__for));
|
|
|
|
/* Management functions for add-in functions. */
|
|
|
|
CASIO_EXTERN(int) casio_get_addin_code
|
|
OF((casio_file_t *casio__handle, void **casio__codep,
|
|
size_t *casio__sizep));
|
|
CASIO_EXTERN(int) casio_set_addin_code
|
|
OF((casio_file_t *casio__handle, void *casio__code, size_t casio__size));
|
|
|
|
CASIO_EXTERN(int) casio_get_addin_time
|
|
OF((casio_file_t *casio__handle, time_t *casio__timep));
|
|
CASIO_EXTERN(int) casio_set_addin_time
|
|
OF((casio_file_t *casio__handle, time_t const *casio__timep));
|
|
|
|
CASIO_EXTERN(int) casio_get_addin_name
|
|
OF((casio_file_t *casio__handle, char const **casio__name));
|
|
CASIO_EXTERN(int) casio_set_addin_name
|
|
OF((casio_file_t *casio__handle, char const *casio__name));
|
|
|
|
CASIO_EXTERN(int) casio_get_addin_internal_name
|
|
OF((casio_file_t *casio__handle, char const **casio__intname));
|
|
CASIO_EXTERN(int) casio_set_addin_internal_name
|
|
OF((casio_file_t *casio__handle, char const *casio__intname));
|
|
|
|
CASIO_EXTERN(int) casio_get_addin_version
|
|
OF((casio_file_t *casio__handle, casio_version_t const **casio__version));
|
|
CASIO_EXTERN(int) casio_set_addin_version
|
|
OF((casio_file_t *casio__handle, casio_version_t const *casio__version));
|
|
|
|
/* Management functions for main memory files. */
|
|
|
|
CASIO_EXTERN(int) casio_get_file_mcs
|
|
OF((casio_file_t *casio__handle, casio_mcs_t **casio__mcs));
|
|
CASIO_EXTERN(int) casio_set_file_mcs
|
|
OF((casio_file_t *casio__handle, casio_mcs_t *casio__mcs));
|
|
|
|
/* Management functions for e-activities.
|
|
* TODO */
|
|
|
|
/* Management functions for pictures. */
|
|
|
|
CASIO_EXTERN(int) casio_get_file_picture
|
|
|
|
CASIO_END_DECLS
|
|
CASIO_END_NAMESPACE
|
|
|
|
#endif /* LIBCASIO_FILE_H */
|