cake
/
libp7
Archived
1
0
Fork 1
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.
libp7/include/libp7.h

146 lines
5.0 KiB
C

/* ************************************************************************** */
/* _____ _ */
/* libp7.h |_ _|__ _ _| |__ ___ _ _ */
/* | Project: libp7 | |/ _ \| | | | '_ \ / _ \ | | | */
/* | | (_) | |_| | | | | __/ |_| | */
/* By: thomas <thomas@touhey.fr> |_|\___/ \__,_|_| |_|\___|\__, |.fr */
/* Last updated: 2016/10/13 07:36:52 |___/ */
/* */
/* ************************************************************************** */
#ifndef LIBP7_H
# define LIBP7_H
# include <stdint.h>
# include <stdio.h>
# ifdef __cplusplus
extern "C" {
# endif
/* types */
typedef uint_fast16_t p7ushort_t;
typedef uint_fast32_t p7uint_t;
/* handle-related */
struct p7_handle_s;
typedef struct p7_handle_s p7_handle_t;
/* ************************************************************************** */
/* libp7 errors */
/* ************************************************************************** */
/* Enumeration */
/* - Whenever you add/remove errors, think about updating core/strerror ! - */
typedef enum {
p7_noerror,
/* basic communication errors */
p7_error_uninitialized,
p7_error_nocalc,
p7_error_noaccess,
p7_error_timeout,
p7_error_checksum, /* not actually meant to be used */
p7_error_irrecoverable,
/* stream */
p7_error_nostream,
p7_error_noread,
p7_error_nowrite,
p7_error_noseek,
/* user interface */
p7_error_active,
p7_error_doubleshift,
p7_error_empty,
p7_error_filename,
p7_error_dirname,
p7_error_fullmem,
p7_error_notfound,
p7_error_denied_overwrite,
/* others */
p7_error_unsupported,
p7_error_unsupported_device,
p7_error_alloc,
p7_error_unknown
} p7_error_t;
/* Message getting macro */
extern const char *p7_error_strings[];
#define p7_strerror(N) p7_error_strings[N]
#define p7_geterror(N) p7_error_strings[N]
/* ************************************************************************** */
/* Validating stuff */
/* ************************************************************************** */
/* Filename and dirname */
int p7_validate_filename(const char *filename);
int p7_validate_dirname(const char *dirname);
/* ************************************************************************** */
/* Core functions */
/* ************************************************************************** */
/* Initialization */
int p7_init(p7_handle_t **handle, int active, int check);
int p7_cinit(p7_handle_t **handle, int active, int check,
const char *path, int tries);
int p7_finit(p7_handle_t **handle, int active, int check,
FILE *readstream, FILE *writestream);
/* Find */
int p7_cfind(char *devbuf);
/* De-initialization */
void p7_exit(p7_handle_t *handle, int term);
/* ************************************************************************** */
/* Protocol */
/* ************************************************************************** */
/* Send file */
int p7_sendstream(p7_handle_t *handle, FILE *file, p7uint_t size,
const char *dirname, const char *filename, const char *devname,
int overwrite, int (*ow_conf)(void), void (*disp)(p7ushort_t, p7ushort_t));
int p7_sendfile(p7_handle_t *handle, FILE *file,
const char *dirname, const char *filename, const char *devname,
int overwrite, int (*ow_conf)(void), void (*disp)(p7ushort_t, p7ushort_t));
/* Request file */
int p7_reqfile(p7_handle_t *handle, FILE *file,
const char *dirname, const char *filename, const char *devname,
void (*disp)(p7ushort_t, p7ushort_t));
/* Delete distant file */
int p7_delfile(p7_handle_t *handle,
const char *dirname, const char *filename, const char *devname);
/* Copy file on distant device */
int p7_copyfile(p7_handle_t *handle,
const char *dirname, const char *filename,
const char *newdir, const char *newname, const char *devname);
/* List files */
int p7_lsfiles(p7_handle_t *handle, const char *devname,
void (*callback)(const char*, const char*, p7uint_t));
/* Reset flash memory of a distant device */
int p7_resetflash(p7_handle_t *handle, const char *devname);
/* Optimize distant device */
int p7_optimize(p7_handle_t *handle, const char *devname);
/* Send an update.exe */
int p7_sendexe_stream(p7_handle_t *handle,
FILE *exe, p7uint_t size, p7uint_t loadaddr, p7uint_t straddr);
int p7_sendexe(p7_handle_t *handle,
FILE *exe, p7uint_t loadaddr, p7uint_t straddr);
/* Backup Flash ROM */
int p7_backup_rom(p7_handle_t *handle, FILE *file);
/* Backup boot code */
int p7_backup_boot(p7_handle_t *handle, FILE *file);
/* Display streamed screen */
int p7_getscreen(p7_handle_t *handle, int (*callback)(int, int, uint32_t**));
# ifdef __cplusplus
}
# endif
#endif /* LIBP7_H */