Portability, some corrections.

This commit is contained in:
Thomas Touhey 2017-06-14 01:26:46 +02:00
parent e6e8cd423f
commit 35ed5d4c75
59 changed files with 564 additions and 463 deletions

View File

@ -18,13 +18,13 @@
* ************************************************************************* */
#ifndef LIBCASIO_H
# define LIBCASIO_H
# include <libcasio/cdefs.h>
# include <libcasio/error.h>
# include "libcasio/cdefs.h"
# include "libcasio/error.h"
# include <libcasio/log.h>
# include <libcasio/number.h>
# include "libcasio/log.h"
# include "libcasio/number.h"
# include <libcasio/link.h>
# include <libcasio/file.h>
# include <libcasio/utils.h>
# include "libcasio/link.h"
# include "libcasio/file.h"
# include "libcasio/utils.h"
#endif /* LIBCASIO_H */

View File

@ -18,53 +18,54 @@
* ************************************************************************* */
#ifndef LIBCASIO_BUILTIN_H
# define LIBCASIO_BUILTIN_H
# include <libcasio/cdefs.h>
# include <libcasio/stream.h>
# include "cdefs.h"
# include "stream.h"
# ifndef LIBCASIO_DISABLED_FILE
# include <stdio.h>
# endif
CASIO_BEGIN_NAMESPACE
CASIO_BEGIN_DECLS
/* Microsoft Windows thingies */
# if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) \
&& !defined(__WINDOWS__)
# define __WINDOWS__
# endif
/* ************************************************************************* */
/* Built-in streams */
/* ************************************************************************* */
/* Make a stream using the standard FILE interface. */
# ifndef LIBCASIO_DISABLED_FILE
extern int casio_open_stream_file OF((casio_stream_t **casio__stream,
FILE *casio__readstream, FILE *casio__writestream,
int casio__close_readstream, int casio__close_writestream));
CASIO_EXTERN int CASIO_EXPORT casio_open_stream_file
OF((casio_stream_t **casio__stream,
FILE *casio__readstream, FILE *casio__writestream,
int casio__close_readstream, int casio__close_writestream));
# endif
/* Make a stream using the POSIX STREAMS interface. */
# if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
extern int casio_opencom_streams OF((casio_stream_t **casio__stream,
const char *casio__path));
CASIO_EXTERN int CASIO_EXPORT casio_opencom_streams
OF((casio_stream_t **casio__stream, const char *casio__path));
extern int casio_open_stream_streams OF((casio_stream_t **casio__stream,
const char *casio__path, casio_openmode_t casio__mode));
extern int casio_open_stream_fd OF((casio_stream_t **casio__stream,
int casio__readfd, int casio__writefd,
int casio__closeread, int casio__closewrite));
CASIO_EXTERN int CASIO_EXPORT casio_open_stream_streams
OF((casio_stream_t **casio__stream,
const char *casio__path, casio_openmode_t casio__mode));
CASIO_EXTERN int CASIO_EXPORT casio_open_stream_fd
OF((casio_stream_t **casio__stream,
int casio__readfd, int casio__writefd,
int casio__closeread, int casio__closewrite));
# else
# define LIBCASIO_DISABLED_STREAMS
# endif
/* Make a stream using libusb. */
# ifndef LIBCASIO_DISABLED_LIBUSB
extern int casio_openusb_libusb OF((casio_stream_t **casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_openusb_libusb
OF((casio_stream_t **casio__stream));
# endif
/* Make a stream using the Microsoft Windows API. */
# ifdef __WINDOWS__
extern int casio_openusb_windows OF((casio_stream_t **casio__stream));
extern int casio_opencom_windows OF((casio_stream_t **casio__stream,
const char *casio__path));
# if defined(_WIN16) || defined(_WIN32) || defined(_WIN64) \
|| defined(__WINDOWS__)
CASIO_EXTERN int CASIO_EXPORT casio_openusb_windows
OF((casio_stream_t **casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_opencom_windows
OF((casio_stream_t **casio__stream, const char *casio__path));
# else
# define LIBCASIO_DISABLED_WINDOWS
# endif
@ -73,20 +74,20 @@ extern int casio_opencom_windows OF((casio_stream_t **casio__stream,
/* ************************************************************************* */
/* List serial devices on Linux. */
# ifdef __linux__
extern int casio_comlist_linux OF((casio_list_com_t *casio__callback,
void *casio__cookie));
CASIO_EXTERN int CASIO_EXPORT casio_comlist_linux
OF((casio_list_com_t *casio__callback, void *casio__cookie));
# endif
/* List serial devices on MacOS/OS X. */
# if defined(__APPLE__) && defined(__MACH__)
extern int casio_comlist_macos OF((casio_list_com_t *casio__callback,
void *casio__cookie));
CASIO_EXTERN int CASIO_EXPORT casio_comlist_macos
OF((casio_list_com_t *casio__callback, void *casio__cookie));
# endif
/* List serial devices on Microsoft Windows. */
# ifdef __WINDOWS__
extern int casio_comlist_windows OF((casio_list_com_t *casio__callback,
void *casio__cookie));
# ifndef LIBCASIO_DISABLED_WINDOWS
CASIO_EXTERN int CASIO_EXPORT casio_comlist_windows
OF((casio_list_com_t *casio__callback, void *casio__cookie));
# endif
/* ************************************************************************* */
/* Built-in sleep function */
@ -96,8 +97,10 @@ extern int casio_comlist_windows OF((casio_list_com_t *casio__callback,
typedef void casio_sleep_t OF((unsigned long casio__ms));
extern void casio_set_sleep OF((casio_sleep_t *casio__func));
extern int casio_sleep OF((unsigned long casio__ms));
CASIO_EXTERN void CASIO_EXPORT casio_set_sleep
OF((casio_sleep_t *casio__func));
CASIO_EXTERN int CASIO_EXPORT casio_sleep
OF((unsigned long casio__ms));
CASIO_END_DECLS
CASIO_END_NAMESPACE

View File

@ -18,17 +18,17 @@
* ************************************************************************* */
#ifndef LIBCASIO_CDEFS_H
# define LIBCASIO_CDEFS_H
# include <libcasio/config.h>
# include "config.h"
# include <stddef.h>
# include <time.h>
/* ************************************************************************* */
/* Check for compilers */
/* ************************************************************************* */
/* First, GCC. */
# ifdef CASIO_GNUC_PREREQ
# undef CASIO_GNUC_PREREQ
# endif
# if defined(__GNUC__) && defined(__GNUC_MINOR__)
# if defined(CASIO_GNUC_PREREQ)
# elif defined(__GNUC__) && defined(__GNUC_MINOR__)
# define CASIO_GNUC_PREREQ(CASIO__MAJ, CASIO__MIN) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((CASIO__MAJ) << 16) + (CASIO__MIN))
# else
@ -37,25 +37,28 @@
/* Then, Microsoft's Compiler. */
# ifdef CASIO_MSC_PREREQ
# undef CASIO_MSC_PREREQ
# endif
# if defined(_MSC_VER)
# if defined(CASIO_MSC_PREREQ) || defined(_MSC_VER)
# define CASIO_MSC_PREREQ(CASIO__MAJ, CASIO__MIN) \
(_MSC_VER >= (CASIO__MAJ) * 1000 + (CASIO__MIN))
# else
# define CASIO_MSC_PREREQ(CASIO__MAJ, CASIO__MIN) 0
# endif
/* ************************************************************************* */
/* Extern functions */
/* ************************************************************************* */
/* Some platforms require more than simply 'extern'.
* Here are macros to control this. */
# define CASIO_EXTERN extern
# define CASIO_EXPORT
/* ************************************************************************* */
/* Function declaration arguments */
/* ************************************************************************* */
/* Pre-ANSI C compilers don't support arguments (and argument types) in
* function declarations. This macro is inspired from zlib. */
# ifdef OF
# undef OF
# endif
# if defined(__STDC__) && __STDC__
# if defined(OF)
# elif defined(__STDC__) && __STDC__
# define OF(CASIO_ARGS) CASIO_ARGS
# else
# define OF(CASIO_ARGS) ()
@ -65,19 +68,6 @@
/* ************************************************************************* */
/* libcasio is made in C. */
# ifdef CASIO_BEGIN_DECLS
# undef CASIO_BEGIN_DECLS
# endif
# ifdef CASIO_END_DECLS
# undef CASIO_END_DECLS
# endif
# ifdef CASIO_BEGIN_NAMESPACE
# undef CASIO_BEGIN_NAMESPACE
# endif
# ifdef CASIO_END_NAMESPACE
# undef CASIO_END_NAMESPACE
# endif
# if 0 /* hey, what about this? */
# define CASIO_BEGIN_NAMESPACE namespace casio {
# define CASIO_END_NAMESPACE }
@ -99,9 +89,6 @@
/* ************************************************************************* */
/* That's pretty much all of it. */
# ifdef casio_attr_wur
# undef casio_attr_wur
# endif
# if CASIO_GNUC_PREREQ(4, 0)
# define casio_attr_wur __attribute__((warn_unused_result))
# elif CASIO_MSC_PREREQ(17, 0)
@ -109,6 +96,6 @@
# define casio_attr_wur _Check_return_
# endif
# include <libcasio/cdefs/integers.h>
# include <libcasio/cdefs/endian.h>
# include "cdefs/integers.h"
# include "cdefs/endian.h"
#endif /* LIBCASIO_CDEFS_H */

View File

@ -18,21 +18,29 @@
* ************************************************************************* */
#ifndef LIBCASIO_CDEFS_ENDIAN_H
# define LIBCASIO_CDEFS_ENDIAN_H
# include <libcasio/cdefs.h>
# include "../cdefs.h"
/* These function always exist. They are the default ones, if the platform
* does not have any equivalent function (or has one but indicates that
* fact badly). */
extern casio_uint16_t casio_be16toh OF((casio_uint16_t casio__x));
extern casio_uint16_t casio_le16toh OF((casio_uint16_t casio__x));
extern casio_uint32_t casio_be32toh OF((casio_uint32_t casio__x));
extern casio_uint32_t casio_le32toh OF((casio_uint32_t casio__x));
CASIO_EXTERN casio_uint16_t CASIO_EXPORT casio_be16toh
OF((casio_uint16_t casio__x));
CASIO_EXTERN casio_uint16_t CASIO_EXPORT casio_le16toh
OF((casio_uint16_t casio__x));
CASIO_EXTERN casio_uint32_t CASIO_EXPORT casio_be32toh
OF((casio_uint32_t casio__x));
CASIO_EXTERN casio_uint32_t CASIO_EXPORT casio_le32toh
OF((casio_uint32_t casio__x));
extern casio_uint16_t casio_htobe16 OF((casio_uint16_t casio__x));
extern casio_uint16_t casio_htole16 OF((casio_uint16_t casio__x));
extern casio_uint32_t casio_htobe32 OF((casio_uint32_t casio__x));
extern casio_uint32_t casio_htole32 OF((casio_uint32_t casio__x));
CASIO_EXTERN casio_uint16_t CASIO_EXPORT casio_htobe16
OF((casio_uint16_t casio__x));
CASIO_EXTERN casio_uint16_t CASIO_EXPORT casio_htole16
OF((casio_uint16_t casio__x));
CASIO_EXTERN casio_uint32_t CASIO_EXPORT casio_htobe32
OF((casio_uint32_t casio__x));
CASIO_EXTERN casio_uint32_t CASIO_EXPORT casio_htole32
OF((casio_uint32_t casio__x));
# if defined(__APPLE__)
# include <libkern/OSByteOrder.h>

View File

@ -18,7 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_CDEFS_INTEGERS_H
# define LIBCASIO_CDEFS_INTEGERS_H 1
# include <libcasio/cdefs.h>
# include "../cdefs.h"
CASIO_BEGIN_NAMESPACE
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_DATE_H
# define LIBCASIO_DATE_H
# include <libcasio/cdefs.h>
# include <time.h>
# include "cdefs.h"
CASIO_BEGIN_NAMESPACE
/* CASIO's dates look like 'YYYY.MMDD.HHmm', where 'YYYY' is the major,
@ -27,10 +26,12 @@ CASIO_BEGIN_NAMESPACE
* minutes. The date is considered UTC. */
CASIO_BEGIN_DECLS
extern int casio_decode_date OF((time_t *casio__date,
const char *casio__raw));
extern int casio_encode_date OF((char *casio__raw,
const time_t *casio__date));
CASIO_EXTERN int CASIO_EXPORT casio_decode_date
OF((time_t *casio__date, const char *casio__raw));
CASIO_EXTERN int CASIO_EXPORT casio_encode_date
OF((char *casio__raw, const time_t *casio__date));
CASIO_END_DECLS
CASIO_END_NAMESPACE

View File

@ -18,15 +18,17 @@
* ************************************************************************* */
#ifndef LIBCASIO_ENCODING_H
# define LIBCASIO_ENCODING_H
# include <libcasio/cdefs.h>
# include "cdefs.h"
typedef int casio_encode_string_t OF((void *casio__dest,
const void *casio__data, size_t *casio__size));
extern int casio_register_conv OF((const char *casio__to,
const char *casio__from, casio_encode_t *casio__encode_from));
CASIO_EXTERN int CASIO_EXPORT casio_register_conv
OF((const char *casio__to, const char *casio__from,
casio_encode_t *casio__encode_from));
extern int casio_encode_string OF((void *casio__dest, const void *casio__data,
size_t *casio__size));
CASIO_EXTERN int CASIO_EXPORT casio_encode_string
OF((void *casio__dest, const void *casio__data,
size_t *casio__size));
#endif /* LIBCASIO_ENCODING_H */

View File

@ -18,7 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_ERROR_H
# define LIBCASIO_ERROR_H
# include <libcasio/cdefs.h>
# include "cdefs.h"
CASIO_BEGIN_NAMESPACE
/* ************************************************************************* */
@ -84,10 +84,13 @@ typedef enum casio_error_e {
} casio_error_t;
/* Get a string describing the error. */
extern const char *casio_error_strings[];
CASIO_EXTERN const char* CASIO_EXPORT casio_error_strings[];
CASIO_EXTERN const char* CASIO_EXPORT casio_strerror
OF((int casio__error));
# define casio_strerror(CASIO_N) casio_error_strings[(CASIO_N)]
# define casio_geterror(CASIO_N) casio_error_strings[(CASIO_N)]
# ifndef LIBCASIO_NO_STRERROR
# define casio_strerror(CASIO_N) casio_error_strings[(CASIO_N)]
# endif
CASIO_END_NAMESPACE
#endif /* LIBCASIO_ERROR_H */

View File

@ -18,9 +18,10 @@
* ************************************************************************* */
#ifndef LIBCASIO_FILE_H
# define LIBCASIO_FILE_H
# include <libcasio/mcsfile.h>
# include <libcasio/version.h>
# include <libcasio/date.h>
# include "cdefs.h"
# include "mcsfile.h"
# include "version.h"
# include "date.h"
/* ************************************************************************* */
/* Description */
@ -94,38 +95,47 @@ typedef struct casio_file_s {
/* ************************************************************************* */
/* Make a file. */
extern int casio_make_picture OF((casio_file_t **casio__handle,
unsigned int casio__width, unsigned int casio__height));
extern int casio_make_mcs OF((casio_file_t **casio__handle,
int casio__count));
extern int casio_make_fkey OF((casio_file_t **casio__handle,
casio_filefor_t casio__for, int casio__count));
extern int casio_make_lang OF((casio_file_t **casio__handle,
casio_filefor_t casio__for, int casio__count));
extern int casio_make_addin OF((casio_file_t **casio__handle,
casio_filefor_t casio__for, size_t casio__size,
const char *casio__name, const char *casio__internal,
const casio_version_t *casio__version, const time_t *casio__created));
CASIO_EXTERN int CASIO_EXPORT casio_make_picture
OF((casio_file_t **casio__handle,
unsigned int casio__width, unsigned int casio__height));
CASIO_EXTERN int CASIO_EXPORT casio_make_mcs
OF((casio_file_t **casio__handle, int casio__count));
CASIO_EXTERN int CASIO_EXPORT casio_make_fkey
OF((casio_file_t **casio__handle,
casio_filefor_t casio__for, int casio__count));
CASIO_EXTERN int CASIO_EXPORT casio_make_lang
OF((casio_file_t **casio__handle,
casio_filefor_t casio__for, int casio__count));
CASIO_EXTERN int CASIO_EXPORT casio_make_addin
OF((casio_file_t **casio__handle,
casio_filefor_t casio__for, size_t casio__size,
const char *casio__name, const char *casio__internal,
const casio_version_t *casio__version, const time_t *casio__created));
/* Manage an MCS archive. */
extern int casio_mcs_insert OF((casio_file_t *handle, casio_mcsfile_t **tofile,
const casio_mcshead_t *head));
extern int casio_mcs_sort OF((casio_file_t *handle));
CASIO_EXTERN int CASIO_EXPORT casio_mcs_insert
OF((casio_file_t *handle, casio_mcsfile_t **tofile,
const casio_mcshead_t *head));
CASIO_EXTERN int CASIO_EXPORT casio_mcs_sort
OF((casio_file_t *handle));
/* Free a file. */
extern void casio_free_file OF((casio_file_t *casio__handle));
CASIO_EXTERN void CASIO_EXPORT casio_free_file
OF((casio_file_t *casio__handle));
/* Decode a file. */
extern int casio_decode OF((casio_file_t **casio__handle,
const char *casio__path, casio_stream_t *casio__buffer,
casio_filetype_t casio__expected_types));
CASIO_EXTERN int CASIO_EXPORT casio_decode
OF((casio_file_t **casio__handle,
const char *casio__path, casio_stream_t *casio__buffer,
casio_filetype_t casio__expected_types));
/* Open and decode a file. */
extern int casio_open_file OF((casio_file_t **casio__handle,
const char *casio__path, casio_filetype_t casio__expected_types));
CASIO_EXTERN int CASIO_EXPORT casio_open_file
OF((casio_file_t **casio__handle,
const char *casio__path, casio_filetype_t casio__expected_types));
#endif /* LIBCASIO_FILE_H */

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_H
# define LIBCASIO_FORMAT_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "cdefs.h"
/* Welcome on this new episode of the Monster Circus show! Today we'll present
* to you the different formats surrounding CASIO calculators: open or closed,
@ -38,7 +37,7 @@
*
* You can find its description in the following header: */
# include <libcasio/format/cas.h>
# include "format/cas.h"
/* ************************************************************************* */
/* The GraphCard (GRC) format */
/* ************************************************************************* */
@ -66,7 +65,9 @@
/* Followed by loads of zero, then, the content. The description of the rest
* of the format is described in this header: */
/*# include <libcasio/format/fxi.h> -- TODO */
# if 0
# include "format/fxi.h" -- TODO */
# endif
/* ************************************************************************* */
/* The Casemul format */
/* ************************************************************************* */
@ -84,7 +85,7 @@
/* Discover the rest in its dedicated header: */
# include <libcasio/format/casemul.h>
# include "format/casemul.h"
/* ************************************************************************* */
/* The G1S format */
/* ************************************************************************* */
@ -92,7 +93,7 @@
* It won't work with fx-CP or fx-CG calculators, as the storage memory
* has changed since. */
# include <libcasio/format/storage.h>
# include "format/storage.h"
/* ************************************************************************* */
/* The standard format */
/* ************************************************************************* */
@ -105,5 +106,5 @@
* It doesn't have one single magic string, but a few, although the standard
* header has the same format, so we consider it as the same format. */
# include <libcasio/format/std.h>
# include "format/std.h"
#endif /* LIBCASIO_FORMAT_H */

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_CAS_H
# define LIBCASIO_FORMAT_CAS_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE
@ -231,10 +230,10 @@ typedef struct casio_cas100info_s {
CASIO_END_NAMESPACE
# pragma pack()
# include <libcasio/format/cas/program.h> /* programs, f-mem */
# include <libcasio/format/cas/cell.h> /* list, matrix, variable */
# include <libcasio/format/cas/backup.h>
# include <libcasio/format/cas/picture.h>
# include <libcasio/format/cas/graph.h>
# include <libcasio/format/cas/gmem.h>
# include "cas/program.h" /* programs, f-mem */
# include "cas/cell.h" /* lists, matrixes, variables */
# include "cas/backup.h"
# include "cas/picture.h"
# include "cas/graph.h"
# include "cas/gmem.h"
#endif /* LIBCASIO_FORMAT_CAS_H */

View File

@ -18,6 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_CAS_BACKUP_H
# define LIBCASIO_FORMAT_CAS_BACKUP_H
# include "../../cdefs.h"
/* Backups are raw backups from the calculator.
*

View File

@ -18,6 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_CAS_CELL_H
# define LIBCASIO_FORMAT_CAS_CELL_H
# include "../../cdefs.h"
/* Lists, matrixes and variables are sent/stored the same way.
* Variables are either 1*1 matrixes, or 0*0 matrixes if unused.

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_CAS_GMEM_H
# define LIBCASIO_FORMAT_CAS_GMEM_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,6 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_CAS_GRAPH_H
# define LIBCASIO_FORMAT_CAS_GRAPH_H
# include "../../cdefs.h"
/* This is the data type used for the expression of each function which can be
* used to draw a graph. They are sent when you select 'Y=Data' in the

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_CAS_PICTURE_H
# define LIBCASIO_FORMAT_CAS_PICTURE_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_CAS_PROGRAM_H
# define LIBCASIO_FORMAT_CAS_PROGRAM_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,9 +18,8 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_CASEMUL_H
# define LIBCASIO_FORMAT_CASEMUL_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include <libcasio/number.h>
# include "../cdefs.h"
# include "../number.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_FXI_H
# define LIBCASIO_FORMAT_FXI_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,9 +18,8 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_MCS_CELLS_H
# define LIBCASIO_FORMAT_MCS_CELLS_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include <libcasio/number.h>
# include "../../cdefs.h"
# include "../../number.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_MCS_PICTURE_H
# define LIBCASIO_FORMAT_MCS_PICTURE_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_MCS_PROGRAM_H
# define LIBCASIO_FORMAT_MCS_PROGRAM_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,9 +18,10 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_MCS_SETUP_H
# define LIBCASIO_FORMAT_MCS_SETUP_H
# include "../../cdefs.h"
/* Setup files have no headers, they are just a bunch of bytes you can copy.
* Legacy fx setup files have 100 entries (100 bytes), fx-CG setup files
* Legacy fx setup files have 0x64 (100) byte entries, fx-CG setup files
* have twice as much (even though the first 100 entries have the same
* signification in the two).
*

View File

@ -18,9 +18,8 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_MCS_SPREADSHEET_H
# define LIBCASIO_FORMAT_MCS_SPREADSHEET_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include <libcasio/number.h>
# include "../../cdefs.h"
# include "../../number.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_STD_H
# define LIBCASIO_FORMAT_STD_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE
@ -251,10 +250,10 @@ typedef struct casio_standard_picheader_s {
CASIO_END_NAMESPACE
# pragma pack()
# include <libcasio/format/std/addin.h>
# include <libcasio/format/std/eact.h>
# include <libcasio/format/std/mcs.h>
# include <libcasio/format/std/picture.h>
# include <libcasio/format/std/lang.h>
# include <libcasio/format/std/fkey.h>
# include "std/addin.h"
# include "std/eact.h"
# include "std/mcs.h"
# include "std/picture.h"
# include "std/lang.h"
# include "std/fkey.h"
#endif /* LIBCASIO_FORMAT_STD_H */

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_STD_ADDIN_H
# define LIBCASIO_FORMAT_STD_ADDIN_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_STD_EACT_H
# define LIBCASIO_FORMAT_STD_EACT_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_STD_FKEY_H
# define LIBCASIO_FORMAT_STD_FKEY_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_STD_LANG_H
# define LIBCASIO_FORMAT_STD_LANG_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_STD_MCS_H
# define LIBCASIO_FORMAT_STD_MCS_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE
@ -76,9 +75,9 @@ CASIO_END_NAMESPACE
/* Beneath the file header, the file have different structures according to
* their group name and MCS type. Pick your poison, once again! */
# include <libcasio/format/mcs/cells.h>
# include <libcasio/format/mcs/picture.h>
# include <libcasio/format/mcs/program.h>
# include <libcasio/format/mcs/setup.h>
# include <libcasio/format/mcs/spreadsheet.h>
# include "../mcs/cells.h"
# include "../mcs/picture.h"
# include "../mcs/program.h"
# include "../mcs/setup.h"
# include "../mcs/spreadsheet.h"
#endif /* LIBCASIO_FORMAT_STD_MCS_H */

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_STD_PICTURE_H
# define LIBCASIO_FORMAT_STD_PICTURE_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE

View File

@ -18,8 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_FORMAT_STORAGE_H
# define LIBCASIO_FORMAT_STORAGE_H
# include <libcasio/cdefs.h>
# include <stdint.h>
# include "../cdefs.h"
# pragma pack(1)
CASIO_BEGIN_NAMESPACE
@ -109,7 +108,7 @@ typedef struct casio_storage_sector_s {
/* ************************************************************************* */
/* After the sectors come the directories.
*
* Their special nibble is either 0x05 if active or 0x00 if deleted.
* Their spec# include "../cdefs.h"ial nibble is either 0x05 if active or 0x00 if deleted.
* Here is their subheader structure: */
typedef struct casio_storage_directory_s {

View File

@ -1,5 +1,5 @@
/* ****************************************************************************
* libcasio/filesystem.h -- libcasio filesystems.
* libcasio/fs.h -- libcasio filesystems.
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
*
* This file is part of libcasio.
@ -16,10 +16,10 @@
* 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_FILESYSTEM_H
# define LIBCASIO_FILESYSTEM_H
# include <libcasio/cdefs.h>
# include <libcasio/stream.h>
#ifndef LIBCASIO_FS_H
# define LIBCASIO_FS_H
# include "cdefs.h"
# include "stream.h"
CASIO_BEGIN_NAMESPACE
/* forward structure declarations (don't mind) */
@ -92,13 +92,14 @@ struct casio_fsfuncs_s {
/* ************************************************************************* */
CASIO_BEGIN_DECLS
extern int casio_open_fs OF((casio_filesystem_t **casio__fs,
void *casio__cookie, const char *casio__dirsep,
const casio_fsfuncs_t *casio__funcs));
CASIO_EXTERN int CASIO_EXPORT casio_open_fs
OF((casio_filesystem_t **casio__fs,
void *casio__cookie, const char *casio__dirsep,
const casio_fsfuncs_t *casio__funcs));
extern int casio_makedir OF((casio_filesystem_t *casio__fs,
const char *casio__path));
CASIO_EXTERN int CASIO_EXPORT casio_makedir
OF((casio_filesystem_t *casio__fs, const char *casio__path));
CASIO_END_DECLS
CASIO_END_NAMESPACE
#endif /* LIBCASIO_FILESYSTEM_H */
#endif /* LIBCASIO_FS_H */

View File

@ -18,11 +18,11 @@
* ************************************************************************* */
#ifndef LIBCASIO_LINK_H
# define LIBCASIO_LINK_H
# include <libcasio/cdefs.h>
# include <libcasio/stream.h>
# include <libcasio/filesystem.h>
# include <libcasio/version.h>
# include <libcasio/picture.h>
# include "cdefs.h"
# include "stream.h"
# include "fs.h"
# include "version.h"
# include "picture.h"
CASIO_BEGIN_NAMESPACE
/* ************************************************************************* */
@ -109,24 +109,24 @@ typedef void casio_link_list_t OF((void *casio__cookie,
CASIO_BEGIN_DECLS
/* Cross-platform initialization. */
extern int casio_open_usb OF((casio_link_t **casio__h,
CASIO_EXTERN int casio_open_usb OF((casio_link_t **casio__h,
unsigned long casio__flags));
extern int casio_open_com OF((casio_link_t **casio__h,
CASIO_EXTERN int casio_open_com OF((casio_link_t **casio__h,
unsigned long casio__flags, const char *casio__path,
const casio_streamattrs_t *casio__attributes));
/* Initialize a handle using a custom stream. */
extern int casio_open_link OF((casio_link_t **casio__h,
CASIO_EXTERN int casio_open_link OF((casio_link_t **casio__h,
unsigned long casio__flags, casio_stream_t *casio__stream,
const casio_streamattrs_t *casio__attributes));
/* Get things. */
extern const casio_link_info_t *casio_get_link_info OF((
CASIO_EXTERN const casio_link_info_t *casio_get_link_info OF((
casio_link_t *casio__handle));
/* De-initialize. */
extern void casio_close_link OF((casio_link_t *casio__h));
CASIO_EXTERN void casio_close_link OF((casio_link_t *casio__h));
/* ************************************************************************* */
/* Run servers. */
/* ************************************************************************* */
@ -135,49 +135,53 @@ extern void casio_close_link OF((casio_link_t *casio__h));
typedef int casio_seven_server_func_t OF((void *casio__cookie,
casio_link_t *casio__handle));
extern int casio_seven_serve OF((casio_link_t *casio__handle,
CASIO_EXTERN int casio_seven_serve OF((casio_link_t *casio__handle,
casio_seven_server_func_t **casio__callbacks, void *casio__cookie));
/* ************************************************************************* */
/* General-purpose link operations */
/* ************************************************************************* */
/* Set the link settings. */
extern int casio_setlink OF((casio_link_t *casio__handle,
const casio_streamattrs_t *casio__attrs));
CASIO_EXTERN int CASIO_EXPORT casio_setlink
OF((casio_link_t *casio__handle, const casio_streamattrs_t *casio__attrs));
/* Set up a screen streaming receiver. */
extern int casio_getscreen OF((casio_link_t *casio__handle,
casio_link_screen_t *casio__callback, void *casio__scookie));
CASIO_EXTERN int CASIO_EXPORT casio_getscreen
OF((casio_link_t *casio__handle,
casio_link_screen_t *casio__callback, void *casio__scookie));
/* Backup the ROM. */
extern int casio_backup_rom OF((casio_link_t *casio__handle,
casio_stream_t *casio__buffer, casio_link_progress_t *casio__progress,
void *casio__pcookie));
CASIO_EXTERN int CASIO_EXPORT casio_backup_rom
OF((casio_link_t *casio__handle,
casio_stream_t *casio__buffer, casio_link_progress_t *casio__progress,
void *casio__pcookie));
# ifndef LIBCASIO_DISABLED_FILE
extern int casio_backup_rom_file OF((casio_link_t *casio__handle,
FILE *casio__file, casio_link_progress_t *casio__progress,
void *casio__pcookie));
CASIO_EXTERN int CASIO_EXPORT casio_backup_rom_file
OF((casio_link_t *casio__handle,
FILE *casio__file, casio_link_progress_t *casio__progress,
void *casio__pcookie));
# endif
/* Upload and run an executable. */
extern int casio_upload_and_run OF((casio_link_t *casio__handle,
casio_stream_t *casio__buffer, casio_off_t casio__size,
unsigned long casio__loadaddr, unsigned long casio__straddr,
casio_link_progress_t *casio__disp, void *casio__pcookie));
CASIO_EXTERN int CASIO_EXPORT casio_upload_and_run
OF((casio_link_t *casio__handle,
casio_stream_t *casio__buffer, casio_off_t casio__size,
unsigned long casio__loadaddr, unsigned long casio__straddr,
casio_link_progress_t *casio__disp, void *casio__pcookie));
# ifndef LIBCASIO_DISABLED_FILE
extern int casio_upload_and_run_file OF((
casio_link_t *casio__handle, FILE *casio__program,
unsigned long casio__loadaddr, unsigned long casio__straddr,
casio_link_progress_t *casio__disp, void *casio__pcookie));
CASIO_EXTERN int CASIO_EXPORT casio_upload_and_run_file
OF((casio_link_t *casio__handle, FILE *casio__program,
unsigned long casio__loadaddr, unsigned long casio__straddr,
casio_link_progress_t *casio__disp, void *casio__pcookie));
# endif
CASIO_END_DECLS
CASIO_END_NAMESPACE
# include <libcasio/protocol/legacy.h>
# include <libcasio/protocol/seven.h>
# include "protocol/legacy.h"
# include "protocol/seven.h"
#endif /* LIBCASIO_LINK_H */

View File

@ -18,7 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_LOG_H
# define LIBCASIO_LOG_H
# include <libcasio/cdefs.h>
# include "cdefs.h"
CASIO_BEGIN_NAMESPACE
/* Log levels -- prefer the functions to these values, that can change! */
@ -32,22 +32,24 @@ typedef int casio_loglevel_t;
CASIO_BEGIN_DECLS
/* Get and set the log level at runtime */
extern void casio_setlog OF((casio_loglevel_t casio__level));
extern casio_loglevel_t casio_getlog OF((void));
CASIO_EXTERN void CASIO_EXPORT casio_setlog
OF((casio_loglevel_t casio__level));
CASIO_EXTERN casio_loglevel_t CASIO_EXPORT casio_getlog
OF((void));
/* Get, set and list log level strings */
extern const char *casio_loglevel_tostring OF((
casio_loglevel_t casio__level));
extern casio_loglevel_t casio_loglevel_fromstring OF((
const char *casio__string));
CASIO_EXTERN const char* CASIO_EXPORT casio_loglevel_tostring
OF((casio_loglevel_t casio__level));
CASIO_EXTERN casio_loglevel_t CASIO_EXPORT casio_loglevel_fromstring
OF((const char *casio__string));
/* List log levels */
typedef void casio_log_list_t OF((void *casio__cookie,
const char *casio__str));
extern void casio_listlog OF((casio_log_list_t *casio__callback,
void *casio__cookie));
CASIO_EXTERN void CASIO_EXPORT casio_listlog
OF((casio_log_list_t *casio__callback, void *casio__cookie));
CASIO_END_DECLS
CASIO_END_NAMESPACE

26
include/libcasio/mcs.h Normal file
View File

@ -0,0 +1,26 @@
/* ****************************************************************************
* libcasio/mcs.h -- libcasio RAM filesystem.
* 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_MCS_H
# define LIBCASIO_MCS_H
# include "cdefs.h"
# include "mcsfile.h"
/* TODO: something similar to `fs.h`, but for MCS. */
#endif /* LIBCASIO_MCS_H */

View File

@ -18,9 +18,10 @@
* ************************************************************************* */
#ifndef LIBCASIO_MCSFILE_H
# define LIBCASIO_MCSFILE_H
# include <libcasio/cdefs.h>
# include <libcasio/number.h>
# include <libcasio/picture.h>
# include "cdefs.h"
# include "number.h"
# include "picture.h"
# define casio_theta 27
# define casio_r 28
# define casio_ans 29
@ -279,47 +280,55 @@ typedef struct casio_mcsfile_s {
CASIO_BEGIN_DECLS
/* Manage a main memory file from a head, and free a main memory file. */
extern int casio_make_mcsfile OF((casio_mcsfile_t **casio__handle,
const casio_mcshead_t *casio__head));
extern void casio_free_mcsfile OF((casio_mcsfile_t *casio__handle));
CASIO_EXTERN int CASIO_EXPORT casio_make_mcsfile
OF((casio_mcsfile_t **casio__handle, const casio_mcshead_t *casio__head));
CASIO_EXTERN void CASIO_EXPORT casio_free_mcsfile
OF((casio_mcsfile_t *casio__handle));
/* Decode and encode an MCS file from an MCS archive. */
extern int casio_decode_mcsfile_head OF((casio_mcshead_t *casio__head,
int casio__raw_type, const unsigned char *casio__groupname,
const unsigned char *casio__dirname, const unsigned char *casio__filename,
unsigned long filesize));
CASIO_EXTERN int CASIO_EXPORT casio_decode_mcsfile_head
OF((casio_mcshead_t *casio__head, int casio__raw_type,
const unsigned char *casio__groupname,
const unsigned char *casio__dirname,
const unsigned char *casio__filename,
unsigned long casio__filesize));
extern int casio_decode_mcsfile OF((casio_mcsfile_t **casio__handle,
const casio_mcshead_t *casio__head, casio_stream_t *casio__buffer));
extern int casio_decode_mcsfile_data OF((casio_mcsfile_t **casio__handle,
const casio_mcshead_t *casio__head,
const void *casio__data, size_t casio__size));
CASIO_EXTERN int CASIO_EXPORT casio_decode_mcsfile
OF((casio_mcsfile_t **casio__handle,
const casio_mcshead_t *casio__head,
casio_stream_t *casio__buffer));
CASIO_EXTERN int CASIO_EXPORT casio_decode_mcsfile_data
OF((casio_mcsfile_t **casio__handle,
const casio_mcshead_t *casio__head,
const void *casio__data, size_t casio__size));
extern int casio_encode_mcsfile OF((casio_mcsfile_t *casio__handle,
casio_stream_t *casio__buffer));
CASIO_EXTERN int CASIO_EXPORT casio_encode_mcsfile
OF((casio_mcsfile_t *casio__handle, casio_stream_t *casio__buffer));
/* Decode and encode an MCS file from a CASIOLINK environment. */
extern int casio_decode_casfile_head OF((casio_mcshead_t *casio__head,
casio_stream_t *casio__buffer));
extern int casio_decode_casfile_part OF((casio_mcsfile_t *casio__file,
casio_stream_t *casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_decode_casfile_head
OF((casio_mcshead_t *casio__head, casio_stream_t *casio__buffer));
CASIO_EXTERN int CASIO_EXPORT casio_decode_casfile_part
OF((casio_mcsfile_t *casio__file, casio_stream_t *casio__stream));
extern int casio_encode_casfile_head OF((casio_mcshead_t *casio__head,
casio_stream_t *casio__buffer));
extern int casio_encode_casfile_part OF((casio_mcsfile_t *casio__file,
casio_stream_t *casio__buffer));
CASIO_EXTERN int CASIO_EXPORT casio_encode_casfile_head
OF((casio_mcshead_t *casio__head, casio_stream_t *casio__buffer));
CASIO_EXTERN int CASIO_EXPORT casio_encode_casfile_part
OF((casio_mcsfile_t *casio__file, casio_stream_t *casio__buffer));
/* Correct a head (add raw data). */
extern int casio_correct_mcsfile_head OF((casio_mcshead_t *casio__head));
extern int casio_correct_casfile_head OF((casio_mcshead_t *casio__head));
CASIO_EXTERN int CASIO_EXPORT casio_correct_mcsfile_head
OF((casio_mcshead_t *casio__head));
CASIO_EXTERN int CASIO_EXPORT casio_correct_casfile_head
OF((casio_mcshead_t *casio__head));
/* Compare MCS files (for ordering). */
extern int casio_compare_mcsfiles OF((const casio_mcsfile_t *first,
const casio_mcsfile_t *second));
CASIO_EXTERN int CASIO_EXPORT casio_compare_mcsfiles
OF((const casio_mcsfile_t *first, const casio_mcsfile_t *second));
CASIO_END_DECLS
CASIO_END_NAMESPACE

View File

@ -24,8 +24,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_NUMBER_H
# define LIBCASIO_NUMBER_H
# include <libcasio/cdefs.h>
# include <stddef.h>
# include "cdefs.h"
CASIO_BEGIN_NAMESPACE
# define CASIO_BCD_MANTISSA_SIZE 16
@ -39,7 +38,6 @@ CASIO_BEGIN_NAMESPACE
# define CASIO_BCD_GOODBUFSIZE \
(2 + CASIO_BCD_MANTISSA_SIZE + 4 + 2 + 1)
/* ************************************************************************* */
/* Main type */
/* ************************************************************************* */
@ -117,25 +115,26 @@ typedef struct casio_mcsbcd_s {
CASIO_BEGIN_DECLS
/* From and to MCS BCD. */
extern int casio_bcd_frommcs OF((casio_bcd_t *casio__bcd,
const casio_mcsbcd_t *casio__raw));
extern int casio_bcd_tomcs OF((casio_mcsbcd_t *casio__raw,
const casio_bcd_t *casio__bcd));
CASIO_EXTERN int CASIO_EXPORT casio_bcd_frommcs
OF((casio_bcd_t *casio__bcd, const casio_mcsbcd_t *casio__raw));
CASIO_EXTERN int CASIO_EXPORT casio_bcd_tomcs
OF((casio_mcsbcd_t *casio__raw, const casio_bcd_t *casio__bcd));
/* From and to CAS BCD. */
extern int casio_bcd_fromcas OF((casio_bcd_t *casio__bcd,
const casio_casbcd_t *casio__raw));
extern int casio_bcd_tocas OF((casio_casbcd_t *casio__raw,
const casio_bcd_t *casio__bcd));
CASIO_EXTERN int CASIO_EXPORT casio_bcd_fromcas
OF((casio_bcd_t *casio__bcd, const casio_casbcd_t *casio__raw));
CASIO_EXTERN int CASIO_EXPORT casio_bcd_tocas
OF((casio_casbcd_t *casio__raw, const casio_bcd_t *casio__bcd));
/* From and to C-double */
extern void casio_bcd_fromdouble OF((casio_bcd_t *casio__bcd,
double casio__raw));
extern double casio_bcd_todouble OF((const casio_bcd_t *casio__bcd));
CASIO_EXTERN void CASIO_EXPORT casio_bcd_fromdouble
OF((casio_bcd_t *casio__bcd, double casio__raw));
CASIO_EXTERN double CASIO_EXPORT casio_bcd_todouble
OF((const casio_bcd_t *casio__bcd));
/* Make a string out of a BCD */
extern size_t casio_bcdtoa OF((char *casio__buf, size_t casio__len,
const casio_bcd_t *casio__bcd));
CASIO_EXTERN size_t CASIO_EXPORT casio_bcdtoa
OF((char *casio__buf, size_t casio__len, const casio_bcd_t *casio__bcd));
CASIO_END_DECLS
CASIO_END_NAMESPACE

View File

@ -18,7 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_PICTURE_H
# define LIBCASIO_PICTURE_H
# include <libcasio/cdefs.h>
# include "cdefs.h"
CASIO_BEGIN_NAMESPACE
/* This file describes the picture formats CASIO has used for various purposes
@ -38,7 +38,7 @@ typedef casio_uint32_t casio_pixel_t;
* Do not use the format described above other than to define your own
* formats, as it might change! */
typedef enum casio_pictureformat_s {
typedef enum casio_pictureformat_e {
/* ************************************************************************* */
/* Monochrome pictures with fill bits */
/* ************************************************************************* */
@ -170,17 +170,20 @@ typedef enum casio_pictureformat_s {
CASIO_BEGIN_DECLS
extern size_t casio_get_picture_size OF((casio_pixel_t **casio__pixels,
casio_pictureformat_t casio__format,
unsigned int casio__width, unsigned int casio__height));
CASIO_EXTERN size_t CASIO_EXPORT casio_get_picture_size
OF((casio_pixel_t **casio__pixels,
casio_pictureformat_t casio__format,
unsigned int casio__width, unsigned int casio__height));
extern int casio_decode_picture OF((casio_pixel_t **casio__pixels,
const void *casio__raw, casio_pictureformat_t casio__format,
unsigned int casio__width, unsigned casio__height));
CASIO_EXTERN int CASIO_EXPORT casio_decode_picture
OF((casio_pixel_t **casio__pixels,
const void *casio__raw, casio_pictureformat_t casio__format,
unsigned int casio__width, unsigned casio__height));
extern int casio_encode_picture OF((void *casio__raw,
const casio_pixel_t **casio__pixels, casio_pictureformat_t casio__format,
unsigned int casio__width, unsigned casio__height));
CASIO_EXTERN int CASIO_EXPORT casio_encode_picture
OF((void *casio__raw, const casio_pixel_t **casio__pixels,
casio_pictureformat_t casio__format,
unsigned int casio__width, unsigned casio__height));
CASIO_END_DECLS
CASIO_END_NAMESPACE

View File

@ -23,7 +23,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_PROTOCOL_LEGACY_H
# define LIBCASIO_PROTOCOL_LEGACY_H
# include <libcasio/cdefs.h>
# include "../cdefs.h"
/* In these protocols, there are two types of packets: one-byte packets,
* and multi-byte packets (headers, headers data, data).

View File

@ -18,9 +18,9 @@
* ************************************************************************* */
#ifndef LIBCASIO_PROTOCOL_SEVEN_H
# define LIBCASIO_PROTOCOL_SEVEN_H
# include <libcasio/cdefs.h>
# include <libcasio/link.h>
# include <libcasio/protocol/typz.h>
# include "../cdefs.h"
# include "../link.h"
# include "typz.h"
CASIO_BEGIN_NAMESPACE
/* ************************************************************************* */
@ -178,8 +178,8 @@ CASIO_BEGIN_DECLS
* to checksums; for example, in the screenstreaming packet flow, where the
* receiver should not send anything. */
extern int casio_seven_receive OF((casio_link_t *casio__handle,
int casio__care_about_checksums));
CASIO_EXTERN int CASIO_EXPORT casio_seven_receive
OF((casio_link_t *casio__handle, int casio__care_about_checksums));
/* These are the base functions to send a packet.
* Unless `resp` is zero, it will also get the response to the packet,
@ -187,13 +187,15 @@ extern int casio_seven_receive OF((casio_link_t *casio__handle,
*
* You shouldn't use them directly to send a packet, but here they are: */
extern int casio_seven_send_basic OF((casio_link_t *casio__handle,
casio_seven_type_t casio__type, unsigned int casio__subtype,
int casio__resp));
extern int casio_seven_send_ext OF((casio_link_t *casio__handle,
casio_seven_type_t casio__type, unsigned int casio__subtype,
const void *casio__data, unsigned int casio__size,
int casio__resp));
CASIO_EXTERN int CASIO_EXPORT casio_seven_send_basic
OF((casio_link_t *casio__handle,
casio_seven_type_t casio__type, unsigned int casio__subtype,
int casio__resp));
CASIO_EXTERN int CASIO_EXPORT casio_seven_send_ext
OF((casio_link_t *casio__handle,
casio_seven_type_t casio__type, unsigned int casio__subtype,
const void *casio__data, unsigned int casio__size,
int casio__resp));
/* Send checks.
* Initial checks are useful to check if there is another device speaking
@ -219,8 +221,8 @@ extern int casio_seven_send_ext OF((casio_link_t *casio__handle,
0x00, (CASIO__R)))
# define casio_seven_confirm_ow(CASIO__H) \
(casio_seven_send_basic((CASIO__H), casio_seven_type_ack, 0x01, 1))
extern int casio_seven_send_eack OF((casio_link_t *casio__handle,
casio_link_info_t *casio__info));
CASIO_EXTERN int CASIO_EXPORT casio_seven_send_eack
OF((casio_link_t *casio__handle, casio_link_info_t *casio__info));
/* Send negative acknowledgements (NAK packets).
* These are used to report errors. */
@ -250,14 +252,16 @@ extern int casio_seven_send_eack OF((casio_link_t *casio__handle,
* There are specific command-sending in `libcasio/protocol/seven/commands.h`,
* so if you're using a classical command, you should use them instead. */
extern int casio_seven_send_cmd OF((casio_link_t *casio__handle,
unsigned int casio__subtype));
extern int casio_seven_send_cmd_data OF((casio_link_t *casio__handle,
unsigned int casio__subtype, int casio__overwrite,
unsigned int casio__datatype, unsigned long casio__filesize,
const char *casio__arg0, const char *casio__arg1,
const char *casio__arg2, const char *casio__arg3,
const char *casio__arg4, const char *casio__arg5));
CASIO_EXTERN int CASIO_EXPORT casio_seven_send_cmd
OF((casio_link_t *casio__handle,
unsigned int casio__subtype));
CASIO_EXTERN int CASIO_EXPORT casio_seven_send_cmd_data
OF((casio_link_t *casio__handle,
unsigned int casio__subtype, int casio__overwrite,
unsigned int casio__datatype, unsigned long casio__filesize,
const char *casio__arg0, const char *casio__arg1,
const char *casio__arg2, const char *casio__arg3,
const char *casio__arg4, const char *casio__arg5));
CASIO_END_DECLS
CASIO_END_NAMESPACE
@ -279,10 +283,10 @@ typedef struct casio_seven_env_s {
CASIO_BEGIN_DECLS
/* And here is everything you need lol. */
extern int casio_seven_getenv OF((casio_seven_env_t *casio__env,
const char *casio__id));
extern int casio_seven_command_is_supported OF((
const casio_seven_env_t *casio__env, unsigned int casio__code));
CASIO_EXTERN int CASIO_EXPORT casio_seven_getenv
OF((casio_seven_env_t *casio__env, const char *casio__id));
CASIO_EXTERN int CASIO_EXPORT casio_seven_command_is_supported
OF((const casio_seven_env_t *casio__env, unsigned int casio__code));
CASIO_END_DECLS
/* ************************************************************************* */
@ -364,8 +368,10 @@ CASIO_BEGIN_DECLS
* you shouldn't use them unless you know what you're doing
* (and you probably don't if you actually want to use them). */
extern int casio_seven_start OF((casio_link_t *casio__handle));
extern int casio_seven_end OF((casio_link_t *casio__handle));
CASIO_EXTERN int CASIO_EXPORT casio_seven_start
OF((casio_link_t *casio__handle));
CASIO_EXTERN int CASIO_EXPORT casio_seven_end
OF((casio_link_t *casio__handle));
/* Send and receive data, using buffers.
* This will automatically divide your data into packets, or make up the
@ -377,36 +383,41 @@ extern int casio_seven_end OF((casio_link_t *casio__handle));
* It is advised not to use it for receiving data, or for sensitive
* data. */
extern int casio_seven_send_buffer OF((casio_link_t *casio__handle,
casio_stream_t *casio__stream, casio_off_t casio__size,
int casio__shift, casio_link_progress_t *casio__progress,
void *casio__pcookie));
CASIO_EXTERN int CASIO_EXPORT casio_seven_send_buffer
OF((casio_link_t *casio__handle,
casio_stream_t *casio__stream, casio_off_t casio__size,
int casio__shift, casio_link_progress_t *casio__progress,
void *casio__pcookie));
extern int casio_seven_get_buffer OF((casio_link_t *casio__handle,
casio_stream_t *casio__stream, casio_off_t casio__size,
int casio__shift, casio_link_progress_t *casio__progress,
void *casio__pcookie));
CASIO_EXTERN int CASIO_EXPORT casio_seven_get_buffer
OF((casio_link_t *casio__handle,
casio_stream_t *casio__stream, casio_off_t casio__size,
int casio__shift, casio_link_progress_t *casio__progress,
void *casio__pcookie));
/* Send and receive data, using memory areas.
* Beyond the buffer/memory difference, those and the previous ones are
* basically the same thing. */
extern int casio_seven_send_data OF((casio_link_t *casio__handle,
const void *casio__buf, casio_off_t casio__size,
int casio__shift, casio_link_progress_t *casio__progress,
void *casio__pcookie));
CASIO_EXTERN int CASIO_EXPORT casio_seven_send_data
OF((casio_link_t *casio__handle,
const void *casio__buf, casio_off_t casio__size,
int casio__shift, casio_link_progress_t *casio__progress,
void *casio__pcookie));
extern int casio_seven_get_data OF((casio_link_t *casio__handle,
void *casio__buf, casio_off_t casio__size,
int casio__shift, casio_link_progress_t *casio__progress,
void *casio__pcookie));
CASIO_EXTERN int CASIO_EXPORT casio_seven_get_data
OF((casio_link_t *casio__handle,
void *casio__buf, casio_off_t casio__size,
int casio__shift, casio_link_progress_t *casio__progress,
void *casio__pcookie));
/* Send and receive data, using a stream.
* This is practicle when you want to encode and write on the fly. */
extern int casio_seven_open_data_stream OF((casio_stream_t **casio__stream,
casio_link_t *casio__link, casio_off_t casio__size,
casio_link_progress_t *casio__disp, void *casio__dcookie));
CASIO_EXTERN int CASIO_EXPORT casio_seven_open_data_stream
OF((casio_stream_t **casio__stream,
casio_link_t *casio__link, casio_off_t casio__size,
casio_link_progress_t *casio__disp, void *casio__dcookie));
CASIO_END_DECLS
CASIO_END_NAMESPACE

View File

@ -16,21 +16,19 @@
* 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_PROTOCOL_SEVEN_H
# include <libcasio/protocol/seven.h>
#endif
#ifndef LIBCASIO_PROTOCOL_SEVEN_COMMANDS_H
# define LIBCASIO_PROTOCOL_SEVEN_COMMANDS_H
# include <libcasio/mcsfile.h>
# include "../seven.h"
# include "../../mcsfile.h"
CASIO_BEGIN_NAMESPACE
CASIO_BEGIN_DECLS
/* Utility for MCS commands */
extern int casio_seven_send_typical_mcs_command OF((
casio_link_t *casio__handle,
int casio__code, casio_mcshead_t *casio__head,
casio_mcsfile_t *casio__file,
int casio__ow));
CASIO_EXTERN int CASIO_EXPORT casio_seven_send_typical_mcs_command
OF((casio_link_t *casio__handle,
int casio__code, casio_mcshead_t *casio__head,
casio_mcsfile_t *casio__file,
int casio__ow));
/*
size_t sz = casio__file ? get_the_file_size(casio__file) : 0;
return (casio_seven_send_cmd_data(casio__handle, casio__code, casio__ow,
@ -50,9 +48,9 @@ extern int casio_seven_send_typical_mcs_command OF((
/* Set the link settings */
# define casio_seven_cmdsys_setlink 0x02
extern int casio_seven_send_cmdsys_setlink OF((
casio_link_t *casio__handle,
int casio__baudrate, int casio__parity, int casio__stopbits));
CASIO_EXTERN int CASIO_EXPORT casio_seven_send_cmdsys_setlink
OF((casio_link_t *casio__handle,
int casio__baudrate, int casio__parity, int casio__stopbits));
/* ************************************************************************* */
/* Backup commands */
/* ************************************************************************* */
@ -210,10 +208,10 @@ extern int casio_seven_send_cmdsys_setlink OF((
/* ************************************************************************* */
/* Upload and run */
# define casio_seven_cmdosu_upandrun 0x56
extern int casio_seven_send_cmdosu_upandrun OF((
casio_link_t *casio__handle,
unsigned long casio__upsize, unsigned long casio__loadaddr,
unsigned long casio__straddr));
CASIO_EXTERN int CASIO_EXPORT casio_seven_send_cmdosu_upandrun
OF((casio_link_t *casio__handle,
unsigned long casio__upsize, unsigned long casio__loadaddr,
unsigned long casio__straddr));
CASIO_END_DECLS
CASIO_END_NAMESPACE

View File

@ -18,7 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_PROTOCOL_TYPZ_H
# define LIBCASIO_PROTOCOL_TYPZ_H
# include <libcasio/cdefs.h>
# include "../cdefs.h"
CASIO_BEGIN_NAMESPACE
/* In both Protocol 7.00 and extended SCSI protocols, recent CASIO

View File

@ -26,8 +26,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_STREAM_H
# define LIBCASIO_STREAM_H
# include <libcasio/cdefs.h>
# include <stddef.h>
# include "cdefs.h"
CASIO_BEGIN_NAMESPACE
/* forward structure declarations (don't mind) */
@ -263,91 +262,110 @@ struct casio_scsi_s {
CASIO_BEGIN_DECLS
/* Default stream serial settings utilities. */
extern int casio_make_attrs OF((casio_streamattrs_t *casio__attrs,
const char *casio__raw));
CASIO_EXTERN int CASIO_EXPORT casio_make_attrs
OF((casio_streamattrs_t *casio__attrs, const char *casio__raw));
/* List serial devices (platform agnostic). */
typedef void casio_list_com_t OF((void *casio__cookie,
const char *casio__str));
extern int casio_comlist OF((casio_list_com_t *casio__callback,
void *casio__cookie));
CASIO_EXTERN int CASIO_EXPORT casio_comlist
OF((casio_list_com_t *casio__callback, void *casio__cookie));
/* Open and close a stream. */
extern int casio_open OF((casio_stream_t **casio__stream,
casio_openmode_t mode,
casio_streamtype_t casio__type, void *casio__cookie,
const casio_streamfuncs_t *casio__callbacks));
extern int casio_close OF((casio_stream_t *casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_open
OF((casio_stream_t **casio__stream, casio_openmode_t mode,
casio_streamtype_t casio__type, void *casio__cookie,
const casio_streamfuncs_t *casio__callbacks));
CASIO_EXTERN int CASIO_EXPORT casio_close
OF((casio_stream_t *casio__stream));
/* Get stream various data. */
extern int casio_isreadable OF((casio_stream_t *casio__stream));
extern int casio_iswritable OF((casio_stream_t *casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_isreadable
OF((casio_stream_t *casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_iswritable
OF((casio_stream_t *casio__stream));
# define casio_isreadable(CASIO__STREAM) \
(casio_get_openmode(CASIO__STREAM) & CASIO_OPENMODE_READ)
# define casio_iswritable(CASIO__STREAM) \
(casio_get_openmode(CASIO__STREAM) & CASIO_OPENMODE_WRITE)
extern casio_streamtype_t casio_get_type OF((casio_stream_t *casio__stream));
extern casio_openmode_t casio_get_openmode OF((casio_stream_t *casio__stream));
extern void *casio_get_cookie OF((casio_stream_t *casio__stream));
extern int casio_get_lasterr OF((casio_stream_t *casio__stream));
CASIO_EXTERN casio_streamtype_t CASIO_EXPORT casio_get_type
OF((casio_stream_t *casio__stream));
CASIO_EXTERN casio_openmode_t CASIO_EXPORT casio_get_openmode
OF((casio_stream_t *casio__stream));
CASIO_EXTERN void* CASIO_EXPORT casio_get_cookie
OF((casio_stream_t *casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_get_lasterr
OF((casio_stream_t *casio__stream));
/* Read and write data from and to a stream. */
extern int casio_read OF((casio_stream_t *casio__stream,
void *casio__dest, size_t casio__size));
extern int casio_write OF((casio_stream_t *casio__stream,
const void *casio__data, size_t casio__size));
CASIO_EXTERN int CASIO_EXPORT casio_read
OF((casio_stream_t *casio__stream,
void *casio__dest, size_t casio__size));
CASIO_EXTERN int CASIO_EXPORT casio_write
OF((casio_stream_t *casio__stream,
const void *casio__data, size_t casio__size));
extern int casio_write_char OF((casio_stream_t *casio__stream,
int casio__char));
CASIO_EXTERN int CASIO_EXPORT casio_write_char
OF((casio_stream_t *casio__stream, int casio__char));
/* Skip bytes from a stream. */
extern int casio_skip OF((casio_stream_t *casio__stream, size_t casio__size));
CASIO_EXTERN int CASIO_EXPORT casio_skip
OF((casio_stream_t *casio__stream, size_t casio__size));
/* Set and get the attributes of a stream. */
extern int casio_init_attrs OF((casio_stream_t *stream));
extern int casio_set_attrs OF((casio_stream_t *casio__stream,
const casio_streamattrs_t *casio__attrs));
extern int casio_get_attrs OF((casio_stream_t *casio__stream,
casio_streamattrs_t *casio__attrs));
CASIO_EXTERN int CASIO_EXPORT casio_init_attrs
OF((casio_stream_t *stream));
CASIO_EXTERN int CASIO_EXPORT casio_set_attrs
OF((casio_stream_t *casio__stream,
const casio_streamattrs_t *casio__attrs));
CASIO_EXTERN int CASIO_EXPORT casio_get_attrs
OF((casio_stream_t *casio__stream, casio_streamattrs_t *casio__attrs));
/* Set and get the timeouts of a stream. */
extern int casio_init_timeouts OF((casio_stream_t *casio__stream));
extern int casio_set_timeouts OF((casio_stream_t *casio__stream,
const casio_timeouts_t *casio__timeouts));
extern int casio_get_timeouts OF((casio_stream_t *casio__stream,
casio_timeouts_t *casio__timeouts));
CASIO_EXTERN int CASIO_EXPORT casio_init_timeouts
OF((casio_stream_t *casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_set_timeouts
OF((casio_stream_t *casio__stream,
const casio_timeouts_t *casio__timeouts));
CASIO_EXTERN int CASIO_EXPORT casio_get_timeouts
OF((casio_stream_t *casio__stream, casio_timeouts_t *casio__timeouts));
/* Move in a file. */
extern int casio_seek OF((casio_stream_t *casio__stream,
casio_off_t casio__offset, casio_whence_t casio__whence));
extern casio_off_t casio_tell OF((casio_stream_t *casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_seek
OF((casio_stream_t *casio__stream,
casio_off_t casio__offset, casio_whence_t casio__whence));
CASIO_EXTERN casio_off_t CASIO_EXPORT casio_tell
OF((casio_stream_t *casio__stream));
/* Make out the size of a file (shortcut for making out the size). */
extern int casio_getsize OF((casio_stream_t *casio__stream,
casio_off_t *casio__size));
CASIO_EXTERN int CASIO_EXPORT casio_getsize
OF((casio_stream_t *casio__stream, casio_off_t *casio__size));
/* Make a stream out of memory. */
extern int casio_open_memory OF((casio_stream_t **casio__stream,
const void *casio__memory, size_t casio__size));
CASIO_EXTERN int CASIO_EXPORT casio_open_memory
OF((casio_stream_t **casio__stream,
const void *casio__memory, size_t casio__size));
/* Make a stream out of another, with a limit (and empty it). */
extern int casio_open_limited OF((casio_stream_t **casio__stream,
casio_stream_t *casio__original, size_t casio__size));
extern int casio_empty_limited OF((casio_stream_t *casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_open_limited
OF((casio_stream_t **casio__stream,
casio_stream_t *casio__original, size_t casio__size));
CASIO_EXTERN int CASIO_EXPORT casio_empty_limited
OF((casio_stream_t *casio__stream));
/* ************************************************************************* */
/* USB or serial stream opening management */
/* ************************************************************************* */
@ -356,30 +374,33 @@ extern int casio_empty_limited OF((casio_stream_t *casio__stream));
*
* Communication port listing. */
typedef int casio_comlist_t OF((casio_list_com_t *casio__callback,
typedef int casio_comlist_t OF((casio_list_com_t *casio__callback,
void *casio__cookie));
extern int casio_add_default_comlist OF((casio_comlist_t *casio__function));
CASIO_EXTERN int CASIO_EXPORT casio_add_default_comlist
OF((casio_comlist_t *casio__function));
/* Serial communication stream opening. */
typedef int casio_opencomstream_t OF((casio_stream_t **casio__stream,
typedef int casio_opencomstream_t OF((casio_stream_t **casio__stream,
const char *casio__path));
extern int casio_open_com_stream OF((casio_stream_t **casio__stream,
const char *casio__path));
extern int casio_add_default_com_stream OF((
casio_opencomstream_t *casio__function));
CASIO_EXTERN int CASIO_EXPORT casio_open_com_stream
OF((casio_stream_t **casio__stream,
const char *casio__path));
CASIO_EXTERN int CASIO_EXPORT casio_add_default_com_stream
OF((casio_opencomstream_t *casio__function));
/* USB stream opening. */
typedef int casio_openusbstream_t OF((casio_stream_t **casio__stream));
typedef int casio_openusbstream_t OF((casio_stream_t **casio__stream));
extern int casio_open_usb_stream OF((casio_stream_t **casio__stream));
extern int casio_add_default_usb_stream OF((
casio_openusbstream_t *casio__function));
CASIO_EXTERN int CASIO_EXPORT casio_open_usb_stream
OF((casio_stream_t **casio__stream));
CASIO_EXTERN int CASIO_EXPORT casio_add_default_usb_stream
OF((casio_openusbstream_t *casio__function));
CASIO_END_DECLS
CASIO_END_NAMESPACE
# include <libcasio/builtin.h>
# include "builtin.h"
#endif /* LIBCASIO_STREAM_H */

View File

@ -18,14 +18,17 @@
* ************************************************************************* */
#ifndef LIBCASIO_UTILS_H
# define LIBCASIO_UTILS_H 1
# include "cdefs.h"
/* ASCII-HEX, ASCII-DEC utilities */
extern void casio_putascii OF((unsigned char *casio__p,
unsigned long casio__i, int casio__n));
extern unsigned long casio_getascii OF((const unsigned char *casio__p,
int casio__n));
CASIO_EXTERN void CASIO_EXPORT casio_putascii
OF((unsigned char *casio__p, unsigned long casio__i, int casio__n));
CASIO_EXTERN unsigned long CASIO_EXPORT casio_getascii
OF((const unsigned char *casio__p, int casio__n));
extern unsigned long casio_getdec OF((unsigned long casio__h));
extern unsigned long casio_gethex OF((unsigned long casio__d));
CASIO_EXTERN unsigned long CASIO_EXPORT casio_getdec
OF((unsigned long casio__h));
CASIO_EXTERN unsigned long CASIO_EXPORT casio_gethex
OF((unsigned long casio__d));
#endif /* LIBCASIO_UTILS_H */

View File

@ -18,7 +18,7 @@
* ************************************************************************* */
#ifndef LIBCASIO_VERSION_H
# define LIBCASIO_VERSION_H
# include <libcasio/cdefs.h>
# include "cdefs.h"
CASIO_BEGIN_NAMESPACE
/* CASIO's versions look like 'MM.mm.ABCD', where 'MM' is the major, 'mm' is
@ -70,11 +70,12 @@ CASIO_BEGIN_DECLS
* right format (for user interface, such as command-line argument checking),
* and to decode/encode a version. */
extern int casio_check_version OF((const char *casio__raw));
extern int casio_decode_version OF((casio_version_t *casio__version,
const char *casio__raw));
extern int casio_encode_version OF((char *casio__raw,
const casio_version_t *casio__version));
CASIO_EXTERN int CASIO_EXPORT casio_check_version
OF((const char *casio__raw));
CASIO_EXTERN int CASIO_EXPORT casio_decode_version
OF((casio_version_t *casio__version, const char *casio__raw));
CASIO_EXTERN int CASIO_EXPORT casio_encode_version
OF((char *casio__raw, const casio_version_t *casio__version));
CASIO_END_DECLS
CASIO_END_NAMESPACE

View File

@ -16,6 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with libcasio; if not, see <http://www.gnu.org/licenses/>.
* ************************************************************************* */
#define LIBCASIO_NO_STRERROR
#include "internals.h"
const char *casio_error_strings[128] = {
@ -69,3 +70,16 @@ const char *casio_error_strings[128] = {
"invalid checksum",
"was recognized but not one of the allowed file types."
};
/**
* casio_strerror:
* Get the error string.
*
* @arg error the error code.
* @return the error string.
*/
const char *casio_strerror(int error)
{
return (casio_error_strings[error]);
}

View File

@ -63,9 +63,11 @@ int casio_decode_std_mcs(casio_file_t **h, casio_stream_t *buffer,
/* foreach subpart */
for (i = 0; i < hd.casio_mcs_subheader_subcount; i++) {
casio_mcs_fileheader_t fhd;
casio_uint32_t datalength;
/* get the part header */
GDREAD(fhd)
datalength = be32toh(fhd.casio_mcs_fileheader_datalength);
/* log info about the subpart */
msg((ll_info, "[%lu] directory name is '%.8s'",
@ -73,7 +75,7 @@ int casio_decode_std_mcs(casio_file_t **h, casio_stream_t *buffer,
msg((ll_info, "[%lu] filename is '%.8s'", i,
fhd.casio_mcs_fileheader_filename));
msg((ll_info, "[%lu] data length is %" CASIO_PRIu32,
i, fhd.casio_mcs_fileheader_datalength));
i, datalength));
/* decode the head */
casio_decode_mcsfile_head(&head,
@ -81,7 +83,7 @@ int casio_decode_std_mcs(casio_file_t **h, casio_stream_t *buffer,
hd.casio_mcs_subheader_intname,
fhd.casio_mcs_fileheader_dirname,
fhd.casio_mcs_fileheader_filename,
be32toh(fhd.casio_mcs_fileheader_datalength));
datalength);
/* decode */
handle->casio_file_mcsfiles[handle->casio_file_count] = NULL;

View File

@ -258,7 +258,6 @@ fail:
casio_free_file(*h); *h = NULL;
return (casio_error_alloc);
}
/* ************************************************************************* */
/* Free a handle */
/* ************************************************************************* */
@ -285,15 +284,13 @@ void casio_free_file(casio_file_t *handle)
/* mcs time! */
if (handle->casio_file_type & casio_filetype_mcs) {
casio_mcsfile_t **files;
casio_mcsfile_t **files = handle->casio_file_mcsfiles;
/* check if mcs */
if (!handle->casio_file_mcsfiles)
return ;
if (!files) return ;
/* foreach file in mcs */
files = handle->casio_file_mcsfiles;
for (i = handle->casio_file_count; i >= 0; i--) {
for (i = handle->casio_file_count - 1; i >= 0; i--) {
/* free the file if exists */
if (files[i]) casio_free_mcsfile(files[i]);
}

View File

@ -51,9 +51,11 @@
/* Checksum. */
extern unsigned char casio_checksum8 OF((void *casio__mem,
size_t casio__size, unsigned char casio__current));
extern casio_uint32_t casio_checksum32 OF((void *casio__mem,
extern int casio_checksum_cas OF((void *casio__mem,
size_t casio__size, int casio__current));
extern int casio_checksum_sub OF((void *casio__mem,
size_t casio__size, int casio__current));
extern casio_uint32_t casio_checksum32 OF((void *casio__mem,
size_t casio__size, casio_uint32_t casio__current));
/* Extension. */

View File

@ -23,7 +23,7 @@
#include <stdlib.h>
#include <string.h>
#define checksub8(BUF, SIZE, INI) \
casio_checksum8(&((char*)(BUF))[1], (SIZE) - 3, (INI))
casio_checksum_sub(&((char*)(BUF))[1], (SIZE) - 3, (INI))
/* ************************************************************************* */
/* Logging */

View File

@ -22,7 +22,7 @@
#include <stdio.h>
#include <string.h>
#define checksub8(BUF, SIZE) \
casio_checksum8(&((char*)(BUF))[1], (SIZE) - 3, 0)
casio_checksum_sub(&((char*)(BUF))[1], (SIZE) - 3, 0)
/* Internal macros. */
#define buffer \

View File

@ -97,7 +97,7 @@ static int decode_cas50(casio_mcshead_t *head, casio_stream_t *buffer,
mem((ll_info, &hd, sizeof(casio_cas50_t)));
/* check the checksum */
csum = casio_checksum8(&hd, sizeof(casio_cas50_t) - 1, 0);
csum = casio_checksum_cas(&hd, sizeof(casio_cas50_t) - 1, 0);
if (csum != hd.casio_cas50_checksum) {
msg((ll_error, "Checksum mismatch: expected 0x%02X, got 0x%02X",
hd.casio_cas50_checksum, csum));
@ -153,14 +153,14 @@ int casio_decode_casfile_head(casio_mcshead_t *head, casio_stream_t *buffer)
{
unsigned char buf[39], csum;
casio_casdyn_t *dhd = (void*)buf;
casio_cas40_t *hd = (void*)buf;
casio_cas40_t *hd = (void*)buf;
/* check that the head exists */
if (!head) return (-1);
memset(head, 0, sizeof(casio_mcshead_t));
/* read beginning of the header, check if is an extended header */
READ(buf, 4) csum = casio_checksum8(buf, 4, 0);
READ(buf, 4) csum = casio_checksum_cas(buf, 4, 0);
if (!casio_maketype_casapp(head, dhd->casio_casdyn_ext,
(char*)dhd->casio_casdyn_app))
switch (head->casio_mcshead_info) {
@ -176,7 +176,7 @@ int casio_decode_casfile_head(casio_mcshead_t *head, casio_stream_t *buffer)
/* is a CAS40 head, read it. */
READ(&buf[4], 35)
csum = casio_checksum8(&buf[4], 34, csum);
csum = casio_checksum_cas(&buf[4], 34, csum);
msg((ll_info, "Raw CAS40 (CAS) header:"));
mem((ll_info, hd, sizeof(casio_cas40_t)));
if (casio_maketype_cas(head, (char*)hd->casio_cas40_data))

View File

@ -44,15 +44,15 @@ static int decode_cell(casio_stream_t *buffer, casio_mcscell_t *cell,
/* read position */
DREAD(fx) *x = be16toh(fx) - 1;
DREAD(fy) *y = be16toh(fy) - 1;
csum = casio_checksum8(&fx, sizeof(uint16_t), csum);
csum = casio_checksum8(&fy, sizeof(uint16_t), csum);
csum = casio_checksum_cas(&fx, sizeof(uint16_t), csum);
csum = casio_checksum_cas(&fy, sizeof(uint16_t), csum);
/* read the parts */
DREAD(wkg)
csum = casio_checksum8(&wkg, sizeof(casio_casbcd_t), csum);
csum = casio_checksum_cas(&wkg, sizeof(casio_casbcd_t), csum);
if (casio_bcd_fromcas(&cell->casio_mcscell_real, &wkg)) {
READ(&wkg, sizeof(casio_casbcd_t))
csum = casio_checksum8(&wkg, sizeof(casio_casbcd_t), csum);
csum = casio_checksum_cas(&wkg, sizeof(casio_casbcd_t), csum);
casio_bcd_fromcas(&cell->casio_mcscell_imgn, &wkg);
}

View File

@ -41,7 +41,7 @@ int casio_decode_caspart_program(casio_mcsfile_t *handle,
/* check the sum */
DREAD(checksum)
csum = casio_checksum8(handle->casio_mcsfile_content,
csum = casio_checksum_cas(handle->casio_mcsfile_content,
handle->casio_mcsfile_head.casio_mcshead_size, 0);
if (checksum != csum) {
msg((ll_error, "Checksum mismatch: expected 0x%02X, got 0x%02X",

View File

@ -31,15 +31,11 @@
int casio_decode_mcs_setup(casio_mcsfile_t **h, casio_stream_t *buffer,
casio_mcshead_t *head)
{
int err;
unsigned char *content = NULL;
int err; unsigned char content[100];
casio_setup_t *sp;
/* read content */
err = casio_error_alloc;
content = malloc(head->casio_mcshead_size);
if (!content) goto fail;
GREAD(content, head->casio_mcshead_size)
READ(content, 100)
/* make final head and file */
err = casio_make_mcsfile(h, head);
@ -64,12 +60,5 @@ int casio_decode_mcs_setup(casio_mcsfile_t **h, casio_stream_t *buffer,
/* TODO: decode more options! */
/* no error! */
err = 0;
fail:
free(content);
if (err) {
casio_free_mcsfile(*h);
*h = NULL;
}
return (0);
}

View File

@ -42,7 +42,7 @@ int casio_make_mcsfile(casio_mcsfile_t **h, const casio_mcshead_t *rawhead)
if (!handle) return (casio_error_alloc);
/* initialize the handle, copy the head */
memset(h, 0, sizeof(casio_mcsfile_t));
memset(handle, 0, sizeof(casio_mcsfile_t));
memcpy(&handle->casio_mcsfile_head, rawhead, sizeof(casio_mcshead_t));
head = &handle->casio_mcsfile_head;

View File

@ -70,7 +70,6 @@ int casio_open(casio_stream_t **pstream, casio_openmode_t mode,
casio_init_timeouts(stream);
/* no error! */
msg((ll_info, "Stream successfully created!"));
err = 0;
fail:
if (err) {

View File

@ -19,7 +19,7 @@
#include "../internals.h"
/**
* casio_checksum8:
* casio_checksum_cas:
* Make checksums great again.
*
* @arg mem the memory zone.
@ -28,12 +28,31 @@
* @return the new checksum.
*/
unsigned char casio_checksum8(void *mem, size_t size, unsigned char cs)
int casio_checksum_cas(void *mem, size_t size, int cs)
{
unsigned char *m = mem;
while (size--)
cs -= *m++;
cs = (cs - *m++) & 255;
return (cs);
}
/**
* casio_checksum_sub:
* Make the CASIOWIN type of checksums.
*
* @arg mem the memory zone.
* @arg size the memory zone size.
* @arg cs the current checksum.
* @return the new checksum.
*/
int casio_checksum_sub(void *mem, size_t size, int cs)
{
unsigned char *m = mem;
while (size--)
cs = (cs - *m++) & 255;
return (cs);
}