diff --git a/Makefile b/Makefile index 1ff3556..142b100 100755 --- a/Makefile +++ b/Makefile @@ -2,8 +2,7 @@ #******************************************************************************# # Include variables and message subsystem # #******************************************************************************# -include Makefile.vars -include Makefile.msg +include Makefile.vars Makefile.msg #******************************************************************************# # General targets # @@ -13,11 +12,11 @@ all: all-lib all-doc # Mostly clean everything (remove everything but the end results). mostlyclean: mostlyclean-lib mostlyclean-doc -mclean: mostlyclean + mclean: mostlyclean # Clean everything. clean: clean-lib clean-doc -fclean: clean + fclean: clean # To original state. mrproper: clean @@ -28,10 +27,11 @@ mrproper: clean re: clean all # Install everything. -install: install-lib $(if $(INSTALL_MANPAGES),install-doc) +install: install-lib $(if $(INSTALL_MANPAGES),install-doc) \ + $(if $(INSTALL_DEVEL),install-cfgtool) # Uninstall everything. (experimental) -uninstall: uninstall-lib uninstall-doc +uninstall: uninstall-lib uninstall-doc uninstall-cfgtool # Reinstall everything. (experimental) reinstall: uninstall install @@ -81,7 +81,7 @@ reinstall: uninstall install # Library-specific targets # #******************************************************************************# # Make the library. -all-lib: $(CHECKCFG) lib$(NAME).so.$(MAJOR) + all-lib: $(CHECKCFG) lib$(NAME).so.$(MAJOR) # Make a module object directory. $(MODULES:%=$(OBJDIR)/%): @@ -100,30 +100,30 @@ $(eval $(call make-moduleobj-rule,$(mod)))) $(call bcmd,ld,$@,$(LD) -o $@ $^ $(LDFLAGS)) # Remove the objects directory. -mostlyclean-lib: + mostlyclean-lib: $(call rmsg,Removing object directory.) $(call qcmd,$(RM) -r $(OBJDIR)) -mclean-lib: mostlyclean-lib + mclean-lib: mostlyclean-lib # Clean and remove the built library. -clean-lib: mclean-lib + clean-lib: mclean-lib $(call rmsg,Removing the library.) $(call qcmd,$(RM) lib$(NAME).so.$(MAJOR)) # Remake the library. -re-lib: clean-lib all-lib + re-lib: clean-lib all-lib # Install the library and development files. -install-lib: $(CHECKCFG) lib$(NAME).so.$(MAJOR) + LINK_TO_MAJOR := $(if $(INSTALL_DEVEL),$(if $(FOR_WINDOWS),,y)) + install-lib: $(CHECKCFG) lib$(NAME).so.$(MAJOR) $(call imsg,Installing the library.) $(call qcmd,$(INST) -m 755 -d "$(ILIBDIR)") $(call qcmd,$(INST) -m 755 -t "$(ILIBDIR)" lib$(NAME).so.$(MAJOR)) - $(if $(INSTALL_DEVEL),\ + $(if $(LINK_TO_MAJOR),\ $(call imsg,Linking lib$(NAME).so to lib$(NAME).so.$(MAJOR).)) - $(if $(INSTALL_DEVEL),\ - $(call qcmd,$(LN) lib$(NAME).so.$(MAJOR) \ - "$(ILIBDIR)/lib$(NAME).so")) + $(if $(LINK_TO_MAJOR),\ + $(call qcmd,$(LN) lib$(NAME).so.$(MAJOR) "$(ILIBDIR)/lib$(NAME).so")) $(if $(INSTALL_DEVEL),\ $(call imsg,Installing development files.)) @@ -134,7 +134,7 @@ install-lib: $(CHECKCFG) lib$(NAME).so.$(MAJOR) $(call qcmd,$(INST) -m 644 $(INCDIR)/$(i).h "$(IINCDIR)/$(i).h"$(\n)))) # Uninstall the library and development files. (experimental) -uninstall-lib: $(CHECKCFG) + uninstall-lib: $(CHECKCFG) $(call rmsg,Uninstalling the library.) $(call qcmd,$(RM) "$(ILIBDIR)/lib$(NAME).a" "$(ILIBDIR)/lib$(NAME).so"*) $(call rmsg,Uninstalling development files.) @@ -144,10 +144,39 @@ uninstall-lib: $(CHECKCFG) .PHONY: all-lib mostlyclean-lib mclean-lib clean-lib re-lib .PHONY: install-lib uninstall-lib #******************************************************************************# +# Configuration tools-related # +#******************************************************************************# +# Install it. + install-cfgtool: $(CHECKCFG) + $(call imsg,Installing the configuration tool.) + $(call qcmd,$(INST) -m 755 -d "$(IBINDIR)") + $(call qcmd,tools/write-config \ + --name=lib$(NAME) --version=$(VERSION) \ + --author-name="$(AUTHOR)" --author-mail="$(AUTHOR_MAIL)" \ + --incdir="$(OIINCDIR)" --libdir="$(OILIBDIR)" \ + >"$(IBINDIR)/lib$(NAME)-config" \ + && chmod 755 "$(IBINDIR)/lib$(NAME)-config") + + $(call imsg,Installing the pkg-config configuration.) + $(call qcmd,$(INST) -m 755 -d "$(IPKGDIR)") + $(call qcmd,tools/write-pkg-config \ + --name=$(NAME) --version=$(VERSION) \ + --description="$(DESCRIPTION)" \ + --incdir="$(OIINCDIR)" --libdir="$(OILIBDIR)" \ + >"$(IPKGDIR)/lib$(NAME).pc" \ + && chmod 644 "$(IPKGDIR)/lib$(NAME).pc") + +# Uninstall it + uninstall-cfgtool: $(CHECKCFG) + $(call rmsg,Uninstalling configuration tool and package.) + $(call qcmd,$(RM) "$(IBINDIR)/lib$(NAME)-config" "$(IPKGDIR)/lib$(NAME).pc") + +.PHONY: install-cfgtool uninstall-cfgtool +#******************************************************************************# # Documentation-related # #******************************************************************************# # Make all manpages. -all-doc: $(foreach s,$(MAN_SECTIONS), $(MAN_$(s):%=$(MANDIR)/man$(s)/%.$(s))) + all-doc: $(foreach s,$(MAN_SECTIONS), $(MAN_$(s):%=$(MANDIR)/man$(s)/%.$(s))) # Make manpages directories. $(MAN_SECTIONS:%=$(MANDIR)/man%): @@ -162,17 +191,17 @@ $(foreach section, $(MAN_SECTIONS), \ $(eval $(call make-manpage-rule,$(section)))) # Mostly clean (do nothing, really) -mostlyclean-doc: -mclean-doc: mostlyclean-doc + mostlyclean-doc: + mclean-doc: mostlyclean-doc # Remove all built manpages. -clean-doc: + clean-doc: $(call rmsg,Removing manpages directory.) $(call qcmd,$(RM) -r $(MANDIR)) # Remake all manpages. # (I don't really know why some people would want to do that though) -re-doc: clean-doc all-doc + re-doc: clean-doc all-doc # Install a manpages section. define make-installmansection-rule @@ -187,7 +216,7 @@ $(foreach section, $(MAN_SECTIONS), \ $(eval $(call make-installmansection-rule,$(section)))) # Install manpages. -install-doc: $(CHECKCFG) $(MAN_SECTIONS:%=install-doc-%) + install-doc: $(CHECKCFG) $(MAN_SECTIONS:%=install-doc-%) # Clean a manpages section. define make-uninstall-doc-rule @@ -200,7 +229,7 @@ $(foreach sec,$(MAN_SECTIONS), \ $(eval $(call make-uninstall-doc-rule,$(sec)))) # Uninstall manpages -uninstall-doc: $(CHECKCFG) $(MAN_SECTIONS:%=uninstall-doc-%) + uninstall-doc: $(CHECKCFG) $(MAN_SECTIONS:%=uninstall-doc-%) .PHONY: all-doc mostlyclean-doc mclean-doc clean-doc re-doc .PHONY: install-doc uninstall-doc diff --git a/Makefile.msg b/Makefile.msg index 3e75542..186d90a 100755 --- a/Makefile.msg +++ b/Makefile.msg @@ -42,16 +42,6 @@ define bcmd $(call cmd,$1,$2,$3,$(color_green)) endef -# Remove command -define rcmd -$(call cmd,rm,$1,$2,$(color_red)) -endef - -# Install command -define icmd -$(call cmd,install,$1,$2,$(color_yellow)) -endef - #******************************************************************************# # Messages # #******************************************************************************# @@ -64,3 +54,5 @@ endef define imsg $(call msg,$1,$(color_yellow)) endef + +# End of file diff --git a/Makefile.vars b/Makefile.vars index 35494f6..d10c5ce 100755 --- a/Makefile.vars +++ b/Makefile.vars @@ -2,13 +2,21 @@ #******************************************************************************# # Include configuration # #******************************************************************************# +# Do it -include Makefile.cfg +# Correct target + TARGET := $(if $(TARGET),$(TARGET)-) + +# Check if it is for MS-Windows (damn son) + FOR_WINDOWS := $(if $(findstring mingw,$(TARGET)),y) + #******************************************************************************# # Project main information # #******************************************************************************# # Project name NAME := p7 + DESCRIPTION := Library for communicating with CASIO calculators # Author information AUTHOR := Thomas \"Cakeisalie5\" Touhey @@ -41,11 +49,21 @@ # Manpages directory - where the manpages will be put. MANDIR := ./man +#******************************************************************************# +# Object names # +#******************************************************************************# +# Dynamic library name + SONAME := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.$(MAJOR)) + SONAMES := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.*) + #******************************************************************************# # Binary utilities # #******************************************************************************# +# Package configuration + PKGCONFIG := $(TARGET)pkg-config + # C Compiler - CC := gcc + CC := $(TARGET)gcc # - Check flags (for warnings enabling) CWARN := -Wall -Wextra -Wno-unused-macros -Wno-vla # - More flags (for profiling, ...) @@ -62,20 +80,25 @@ endif -D LOGLEVEL="ll_$(LOG_LEVEL)" -D INIT_TRIES="$(INIT_TRIES)" \ -D AUTHOR="$(AUTHOR)" -D AUTHOR_MAIL="$(AUTHOR_MAIL)" \ -D LICENSE="$(LICENSE)" -D VERSION="$(VERSION)" \ + $(shell $(PKGCONFIG) --cflags libusb-1.0 2>/dev/null) \ $(CMOREFLAGS) # Linker - LD := gcc -# - Linker flags - LDFLAGS := -shared -lusb-1.0 \ + LD := $(TARGET)gcc +# - Specific linker flags + LDFLAGS_Windows := -lws2_32 + LDFLAGS_Linux := -Wl,-soname,$(SONAME) \ -e __lib$(NAME)_version \ - -Wl,-soname,lib$(NAME).so.$(MAJOR) \ -Wl,-z,relro -Wl,-z,combreloc -Wl,-z,defs +# - Linker flags + LDFLAGS := -shared \ + $(shell $(PKGCONFIG) --libs libusb-1.0 2>/dev/null) \ + $(if $(FOR_WINDOWS),$(LDFLAGS_Windows),$(LDFLAGS_Linux)) -# Symbolic link maker - LN := ln -sf # Directory maker MD := mkdir -p +# Symbolic link maker + LN := ln -sf # File remover RM := rm -f # Documentation manager (manpages generator) @@ -125,10 +148,15 @@ $(eval $(call check-man,$(patsubst .%,%,$(suffix $(doc))),$(basename $(doc))))) #******************************************************************************# # Check for DESTDIR (add as prefix to installation root) # #******************************************************************************# +# Save original library and include dir. + OIINCDIR := $(IINCDIR) + OILIBDIR := $(ILIBDIR) + +# Make it. define add-dest-dir $1 = $(DESTDIR)$($1) endef -$(if $(DESTDIR), $(foreach idir,ILIBDIR IINCDIR IMANDIR UDEVDIR, \ +$(if $(DESTDIR), $(foreach idir,IBINDIR ILIBDIR IINCDIR IMANDIR IPKGDIR, \ $(eval $(call add-dest-dir,$(idir))))) # END OF FILE diff --git a/configure b/configure index 2e5f7ce..ddd01ef 100755 --- a/configure +++ b/configure @@ -5,12 +5,17 @@ cd "$(dirname "$0")" #******************************************************************************# # Project variables name="$(make -s getname)" -author="$(make -s getauthor)" -complete_author="$author <$(make -s getmail)>" version="$(make -s getversion)" +# Author +author_name="$(make -s getauthor)" +author="$author <$(make -s getmail)>" + +# Target +target="" + # Platform -platform="$(gcc --print-multiarch)" +platform="$(command -v gcc 1>/dev/null && gcc --print-multiarch)" platform="$([ "$platform" ] && echo "/$platform")" # Make options @@ -24,9 +29,11 @@ init_tries=5 # Installation directories root='' prefix='${root}/usr' +prefix_set= bindir='${prefix}/bin' libdir='${prefix}/lib'"$platform" includedir='${prefix}/include'"$platform" +pkgdir='${libdir}/pkgconfig' mandir='${prefix}/share/man' # Installation options @@ -50,6 +57,7 @@ General options: --maintainer enable maintainer mode Build options: + --target=TARGET the target [$target] --loglevel=LEVEL library log level [$loglevel] --init-tries=TRIES default number of detection tries [$init_tries] @@ -63,11 +71,12 @@ Installation directories: Fine tuning of the installation directories: --bindir=DIR executables [$bindir] + --pkgdir=DIR pkg-config configurations directory [$pkgdir] --libdir=DIR library files of the linker [$libdir] --includedir=DIR include files for the compiler [$includedir] --mandir=DIR man root [$mandir] -Report bugs to ${complete_author}. +Report bugs to ${author}. EOF exit 0 } @@ -78,7 +87,7 @@ exit 0 version() { cat < @@ -96,15 +95,15 @@ void p7_exit(p7_handle_t *handle, int term); /* 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)(p7uint_t, p7uint_t)); + 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)(p7uint_t, p7uint_t)); + 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)(p7uint_t, p7uint_t)); + void (*disp)(p7ushort_t, p7ushort_t)); /* Delete distant file */ int p7_delfile(p7_handle_t *handle, diff --git a/include/libp7/internals.h b/include/libp7/internals.h index 9fffc8d..8105378 100644 --- a/include/libp7/internals.h +++ b/include/libp7/internals.h @@ -12,7 +12,30 @@ # include # include # include -#include +# include +# include + +/* ************************************************************************** */ +/* Macros and platform-specific functions */ +/* ************************************************************************** */ +/* MS-Windows <3 (srsly) */ +# if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) \ + && !defined(__WINDOWS__) +# define __WINDOWS__ +# endif + +/* Macros */ +# ifndef min +# define min(A, B) ((A) < (B) ? (A) : (B)) +# endif +# ifndef max +# define max(A, B) ((A) > (B) ? (A) : (B)) +# endif + +/* Platform-specific functions */ +# ifdef __WINDOWS__ +# define bzero(B, LEN) ((void)memset((B), 0, (LEN))) +# endif /* ************************************************************************** */ /* Buffer sizes */ @@ -147,6 +170,42 @@ int p7_send_check(p7_handle_t *handle); /* active response */ # define response (*handle->_response) +/* ************************************************************************** */ +/* Macros */ +/* ************************************************************************** */ +/* check if filename is ok */ +# define chk_filename(F) \ + if (!p7_validate_filename(F)) return (p7_error_filename) + +/* check if dirname is ok */ +# define chk_dirname(D) \ + if ((D) && !p7_validate_dirname(D)) return (p7_error_dirname) + +/* check if filestream is readable */ +# define chk_isread(F) \ + if (!(F) || !__freadable(F)) return (p7_error_noread) + +/* check if filestream is writable */ +# define chk_iswrite(F) \ + if (!(F) || !__fwritable(F)) return (p7_error_nowrite) + +/* check if filesize is ok */ +# define chk_filesize(S) \ + if (!(S)) return (p7_error_empty); \ + if ((S) > UINT32_MAX) return (p7_error_fullmem) + +/* check if handle is initialized */ +# define chk_handle(H) \ + if (!(H)) return (p7_error_uninitialized) + +/* check if active */ +# define chk_active(H) \ + if (!(H)->_active) return (p7_error_active) + +/* check if passive */ +# define chk_passive(H) \ + if ((H)->_active) return (p7_error_active) + /* ************************************************************************** */ /* Utilities */ /* ************************************************************************** */ diff --git a/include/libp7/internals/stdio_ext.h b/include/libp7/internals/stdio_ext.h new file mode 100644 index 0000000..1f5b6f8 --- /dev/null +++ b/include/libp7/internals/stdio_ext.h @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* _____ _ */ +/* libp7/internals/stdio_ext.h |_ _|__ _ _| |__ ___ _ _ */ +/* | Project: libp7 | |/ _ \| | | | '_ \ / _ \ | | | */ +/* | | (_) | |_| | | | | __/ |_| | */ +/* By: thomas |_|\___/ \__,_|_| |_|\___|\__, |.fr */ +/* Last updated: 2016/12/21 16:07:08 |___/ */ +/* */ +/* ************************************************************************** */ +#ifndef LIBP7_INTERNALS_STDIO_EXT_H +# define LIBP7_INTERNALS_STDIO_EXT_H + +/* MS-Windows stuff */ +# if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) \ + && !defined(__WINDOWS__) +# define __WINDOWS__ +# endif + +/* Ever heard of how annoying it is to make something platform-agnostic? */ +# if defined(__WINDOWS__) +# define __freadable(F) (1) +# define __fwritable(F) (1) +# else +# include +# endif + +#endif /* LIBP7_INTERNALS_STDIO_EXT_H */ diff --git a/include/libp7/packet.h b/include/libp7/packet.h index 1035d97..c0d3d5d 100644 --- a/include/libp7/packet.h +++ b/include/libp7/packet.h @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:36:52 |___/ */ /* */ /* ************************************************************************** */ - #ifndef LIBP7_PACKET_H # define LIBP7_PACKET_H # define MAX_COMMAND_ARGUMENT_SIZE 32 diff --git a/include/libp7/packetio.h b/include/libp7/packetio.h index 8381a56..cdea1e4 100644 --- a/include/libp7/packetio.h +++ b/include/libp7/packetio.h @@ -7,61 +7,23 @@ /* Last updated: 2016/10/13 07:36:52 |___/ */ /* */ /* ************************************************************************** */ - #ifndef LIBP7_PACKETIO_H # define LIBP7_PACKETIO_H # include -# include # define MAX_RAWDATA_SIZE 256 # ifdef __cplusplus extern "C" { # endif -/* ************************************************************************** */ -/* Macros */ -/* ************************************************************************** */ -/* check if filename is ok */ -# define chk_filename(F) \ - if (!p7_validate_filename(F)) return (p7_error_filename) - -/* check if dirname is ok */ -# define chk_dirname(D) \ - if ((D) && !p7_validate_dirname(D)) return (p7_error_dirname) - -/* check if filestream is readable */ -# define chk_isread(F) \ - if (!(F) || !__freadable(F)) return (p7_error_noread) - -/* check if filestream is writable */ -# define chk_iswrite(F) \ - if (!(F) || !__fwritable(F)) return (p7_error_nowrite) - -/* check if filesize is ok */ -# define chk_filesize(S) \ - if (!(S)) return (p7_error_empty); \ - if ((S) > UINT32_MAX) return (p7_error_fullmem) - -/* check if handle is initialized */ -# define chk_handle(H) \ - if (!(H)) return (p7_error_uninitialized) - -/* check if active */ -# define chk_active(H) \ - if (!(H)->_active) return (p7_error_active) - -/* check if passive */ -# define chk_passive(H) \ - if ((H)->_active) return (p7_error_active) - /* ************************************************************************** */ /* Utilities */ /* ************************************************************************** */ /* send some data */ int p7_send_filestream(p7_handle_t *handle, FILE *stream, p7uint_t size, - int shift, void (*disp)(p7uint_t, p7uint_t)); + int shift, void (*disp)(p7ushort_t, p7ushort_t)); /* get some data */ int p7_get_filestream(p7_handle_t *handle, FILE *stream, p7uint_t size, - int shift, void (*disp)(p7uint_t, p7uint_t)); + int shift, void (*disp)(p7ushort_t, p7ushort_t)); /* ************************************************************************** */ /* Packet sending */ diff --git a/src/core/devices.c b/src/core/devices.c index 8ea0f99..aeaaa70 100644 --- a/src/core/devices.c +++ b/src/core/devices.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include #include diff --git a/src/core/log.c b/src/core/log.c index 10415f1..278b8e5 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -7,12 +7,10 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include #include #include #include -#define min(A, B) ((A) < (B) ? (A) : (B)) /** * log_mem_hex: diff --git a/src/core/strerror.c b/src/core/strerror.c index aa52c59..ebd4bb5 100644 --- a/src/core/strerror.c +++ b/src/core/strerror.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/core/version.c b/src/core/version.c index 1027a81..48b519d 100644 --- a/src/core/version.c +++ b/src/core/version.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include #include #define Q(x) #x diff --git a/src/handle/cinit.c b/src/handle/cinit.c index 113e66a..b5ceeb9 100644 --- a/src/handle/cinit.c +++ b/src/handle/cinit.c @@ -8,10 +8,11 @@ /* */ /* ************************************************************************** */ #include -#include -#include -#include -#include +#ifdef __linux__ +# include +# include +# include +# include /** * get_hex_from_file: @@ -210,3 +211,30 @@ not_found_yet: ._rstream_close = 1 })); } + +#else + +/** + * p7_cinit: + * Initialize libp7 with char device. + * + * @arg handle the handle to create + * @arg active whether to start as active or not + * @arg check if starting as active, send initial check or not + * @arg path path to char device. + * @arg tries number of tries (0 means default). + * @return the error (0 if ok) + */ + +int p7_cinit(p7_handle_t **handle, int active, int check, + const char *path, int tries) +{ + (void)handle; + (void)active; + (void)check; + (void)path; + (void)tries; + return (p7_error_nocalc); +} + +#endif diff --git a/src/handle/stream.c b/src/handle/stream.c index 40ce690..8d83475 100644 --- a/src/handle/stream.c +++ b/src/handle/stream.c @@ -130,7 +130,10 @@ int p7_read(p7_stream_t *stream, void *dest, size_t size) if (!recv) switch (errno) { /* - timeout - */ case EINTR: /* alarm */ - case ETIME: case ETIMEDOUT: + case ETIMEDOUT: +#ifdef ETIME + case ETIME: +#endif log_error("timeout received"); return (p7_error_timeout); @@ -205,7 +208,10 @@ int p7_write(p7_stream_t *stream, const void *data, size_t size) if (!sent) switch (errno) { /* - timeout error - */ case EINTR: /* alarm */ - case ETIME: case ETIMEDOUT: + case ETIMEDOUT: +#ifdef ETIME + case ETIME: +#endif log_error("timeout received"); return (p7_error_timeout); diff --git a/src/packet/recv.c b/src/packet/recv.c index 82c6b1c..f04a038 100644 --- a/src/packet/recv.c +++ b/src/packet/recv.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include #include #include diff --git a/src/packet/send_ack.c b/src/packet/send_ack.c index 7500299..5aaa37e 100644 --- a/src/packet/send_ack.c +++ b/src/packet/send_ack.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/packet/send_check.c b/src/packet/send_check.c index 3a85d15..09ebd0d 100644 --- a/src/packet/send_check.c +++ b/src/packet/send_check.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/packet/send_command.c b/src/packet/send_command.c index 82dd81e..49917c3 100644 --- a/src/packet/send_command.c +++ b/src/packet/send_command.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include #include #include diff --git a/src/packet/send_data.c b/src/packet/send_data.c index 958cc84..4f29a2f 100644 --- a/src/packet/send_data.c +++ b/src/packet/send_data.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include #include diff --git a/src/packet/send_error.c b/src/packet/send_error.c index 079de40..ff5ee11 100644 --- a/src/packet/send_error.c +++ b/src/packet/send_error.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/packet/send_roleswp.c b/src/packet/send_roleswp.c index 7002885..69a996d 100644 --- a/src/packet/send_roleswp.c +++ b/src/packet/send_roleswp.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/packet/send_term.c b/src/packet/send_term.c index e155f09..d1aa701 100644 --- a/src/packet/send_term.c +++ b/src/packet/send_term.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/packet/shift.c b/src/packet/shift.c index 2742d41..f66b092 100644 --- a/src/packet/shift.c +++ b/src/packet/shift.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include #include diff --git a/src/protocol/backup_boot.c b/src/protocol/backup_boot.c index 81200e0..00ebe97 100644 --- a/src/protocol/backup_boot.c +++ b/src/protocol/backup_boot.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/protocol/backup_rom.c b/src/protocol/backup_rom.c index 0f49a81..1b708df 100644 --- a/src/protocol/backup_rom.c +++ b/src/protocol/backup_rom.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/protocol/copyfile.c b/src/protocol/copyfile.c index 99c4166..d86fce2 100644 --- a/src/protocol/copyfile.c +++ b/src/protocol/copyfile.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/protocol/delfile.c b/src/protocol/delfile.c index 3d9b50e..326af38 100644 --- a/src/protocol/delfile.c +++ b/src/protocol/delfile.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/protocol/getscreen.c b/src/protocol/getscreen.c index 0e761df..636a418 100644 --- a/src/protocol/getscreen.c +++ b/src/protocol/getscreen.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/protocol/lsfiles.c b/src/protocol/lsfiles.c index 071a98c..086b876 100644 --- a/src/protocol/lsfiles.c +++ b/src/protocol/lsfiles.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/protocol/optimize.c b/src/protocol/optimize.c index 2058ae1..af2fa13 100644 --- a/src/protocol/optimize.c +++ b/src/protocol/optimize.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/protocol/reqfile.c b/src/protocol/reqfile.c index 409b82a..b10a23f 100644 --- a/src/protocol/reqfile.c +++ b/src/protocol/reqfile.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/protocol/resetflash.c b/src/protocol/resetflash.c index f00c5e6..cbf7635 100644 --- a/src/protocol/resetflash.c +++ b/src/protocol/resetflash.c @@ -7,7 +7,6 @@ /* Last updated: 2016/12/17 22:06:38 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/protocol/sendexe.c b/src/protocol/sendexe.c index 29df0a4..761e586 100644 --- a/src/protocol/sendexe.c +++ b/src/protocol/sendexe.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/protocol/sendfile.c b/src/protocol/sendfile.c index 8bde545..46b4ec4 100644 --- a/src/protocol/sendfile.c +++ b/src/protocol/sendfile.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** @@ -33,7 +32,7 @@ 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)(p7uint_t, p7uint_t)) + void (*disp)(p7ushort_t, p7ushort_t)) { int err; @@ -138,7 +137,7 @@ int p7_sendstream(p7_handle_t *handle, 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)(p7uint_t, p7uint_t)) + void (*disp)(p7ushort_t, p7ushort_t)) { /* check if filestream is seekable */ if (!file) { diff --git a/src/utils/ascii.c b/src/utils/ascii.c index b98a92b..7473218 100644 --- a/src/utils/ascii.c +++ b/src/utils/ascii.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include #include diff --git a/src/utils/checksum.c b/src/utils/checksum.c index f7c9ddb..d8ac3b6 100644 --- a/src/utils/checksum.c +++ b/src/utils/checksum.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** @@ -21,7 +20,7 @@ * @return the checksum */ -unsigned int p7_checksum(unsigned char *packet, p7uint_t size) +unsigned int p7_checksum(unsigned char *packet, p7ushort_t size) { unsigned int sum = 0; packet++; size -= 3; /* remove type and checksum fields */ diff --git a/src/utils/escape.c b/src/utils/escape.c index 77a8db3..919f0b4 100644 --- a/src/utils/escape.c +++ b/src/utils/escape.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include /** diff --git a/src/utils/exchange_data.c b/src/utils/exchange_data.c index 249f52f..6a94c5f 100644 --- a/src/utils/exchange_data.c +++ b/src/utils/exchange_data.c @@ -7,11 +7,9 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include #include #include -#define min(A, B) ((A) < (B) ? (A) : (B)) /* number of buffers it will read from the file at a time */ #define BUFNUM 1024 @@ -28,7 +26,7 @@ */ int p7_send_filestream(p7_handle_t *handle, FILE *file, p7uint_t size, - int shift, void (*disp)(p7uint_t, p7uint_t)) + int shift, void (*disp)(p7ushort_t, p7ushort_t)) { int err = 0; @@ -112,7 +110,7 @@ fail: */ int p7_get_filestream(p7_handle_t *handle, FILE *file, p7uint_t size, - int shift, void (*disp)(p7uint_t, p7uint_t)) + int shift, void (*disp)(p7ushort_t, p7ushort_t)) { int err = 0; diff --git a/src/utils/validate.c b/src/utils/validate.c index aa059d9..afbf1fe 100644 --- a/src/utils/validate.c +++ b/src/utils/validate.c @@ -7,7 +7,6 @@ /* Last updated: 2016/10/13 07:33:17 |___/ */ /* */ /* ************************************************************************** */ - #include #include diff --git a/tools/write-config b/tools/write-config new file mode 100755 index 0000000..108ed2f --- /dev/null +++ b/tools/write-config @@ -0,0 +1,89 @@ +#!/bin/sh +#******************************************************************************# +# Defaults # +#******************************************************************************# +# Project variables +name="libg1m" +version="" + +# Author +author_name="Unknown name" +author_mail="unknown@mail" + +# Directories +libdir='' +incdir='' + +#******************************************************************************# +# Read arguments # +#******************************************************************************# +for arg ; do case "$arg" in +--name=*) name="${arg#*=}" ;; +--version=*) version="${arg#*=}" ;; +--author-name=*) author_name="${arg#*=}" ;; +--author-mail=*) author_mail="${arg#*=}" ;; +--libdir=*) libdir="${arg#*=}" ;; +--incdir=*) incdir="${arg#*=}" ;; +esac; done + +#******************************************************************************# +# Write result # +#******************************************************************************# +cat <<_EOF +#!/bin/sh +cfgtool=\$(basename \$0) +#******************************************************************************# +# Help message # +#******************************************************************************# +usage() { +cat <. +EOF +exit 0 +} + +#******************************************************************************# +# Version message # +#******************************************************************************# +version() { +cat <&2 ;; +esac; done + +# Put +[ \$put_cflags ] && echo "-I$incdir" +[ \$put_libs ] && echo "-L$libdir -lg1m" +[ \$put_cflags\$put_libs ] || usage + +# End of file +_EOF diff --git a/tools/write-pkg-config b/tools/write-pkg-config new file mode 100755 index 0000000..3f1d6fe --- /dev/null +++ b/tools/write-pkg-config @@ -0,0 +1,37 @@ +#!/bin/sh +#******************************************************************************# +# Defaults # +#******************************************************************************# +# Project variables +name="name" +description="my description" +version="" + +# Directories +libdir='' +incdir='' + +#******************************************************************************# +# Read arguments # +#******************************************************************************# +for arg ; do case "$arg" in +--name=*) name="${arg#*=}" ;; +--description=*) description="${arg#*=}" ;; +--version=*) version="${arg#*=}" ;; +--libdir=*) libdir="${arg#*=}" ;; +--incdir=*) incdir="${arg#*=}" ;; +esac; done + +#******************************************************************************# +# Write result # +#******************************************************************************# +cat <