diff --git a/.gitignore b/.gitignore index 34e3ef8..e0ee592 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ /Makefile.cfg +/include/lib*/config.h /obj /libg1m.so* -/libg1m.dll +/libg1m.dll* /man .*.swp diff --git a/Makefile b/Makefile index 37c1c6b..6850ce4 100755 --- a/Makefile +++ b/Makefile @@ -4,16 +4,13 @@ #******************************************************************************# include Makefile.vars Makefile.msg -# Check if we're a git repository - ISGIT := $(shell test -e .git && echo y) - #******************************************************************************# # General targets # #******************************************************************************# # Build everything. -all: all-lib all-doc +all: all-lib $(if $(INSTALL_MANPAGES),all-doc) -# Mostly clean everything. (remove everything but the end results) +# Mostly clean everything (remove everything but the end results). mostlyclean: mostlyclean-lib mostlyclean-doc mclean: mostlyclean @@ -21,27 +18,27 @@ mostlyclean: mostlyclean-lib mostlyclean-doc clean: clean-lib clean-doc fclean: clean -# Clean everything, and configuration. +# To original state. mrproper: clean $(call rmsg,Removing configuration.) $(call qcmd,$(RM) Makefile.cfg) $(call qcmd,$(RM) -r lib$(NAME)-*) + $(call qcmd,$(RM) $(INCDIR)/lib$(NAME)/config.h) -# Remake everything. (clean and build) +# Remake everything (clean and build). re: clean all # Install everything. -install: install-lib $(if $(INSTALL_MANPAGES),install-doc) \ - $(if $(INSTALL_DEVEL),install-cfgtool) +install: install-lib $(if $(INSTALL_MANPAGES),install-doc) -# Uninstall everything. (EXPERIMENTAL) -uninstall: uninstall-lib uninstall-doc uninstall-cfgtool +# Uninstall everything. (experimental) +uninstall: uninstall-lib uninstall-doc -# Reinstall everything. (EXPERIMENTAL) +# Reinstall everything. (experimental) reinstall: uninstall install # Make a distribution tarball -dist: mrproper $(if $(ISGIT),reinit-gitmodules) +dist: mrproper $(call bcmd,mkdir,lib$(NAME)-$(VERSION),\ $(MD) .dist) $(call bcmd,cp,* lib$(NAME)-$(VERSION),\ @@ -56,27 +53,14 @@ dist: mrproper $(if $(ISGIT),reinit-gitmodules) .PHONY: all mostlyclean mclean clean fclean mrproper re .PHONY: dist install uninstall reinstall #******************************************************************************# -# Git submodules management # -#******************************************************************************# -# Main rule. - reinit-gitmodules: - $(call bcmd,Deinitializing git submodules.) - $(call qcmd,git submodule deinit -f --quiet -- \ - $(shell grep path .gitmodules | sed 's/.*= //')) - $(call bcmd,Reinitializing git submodules.) - $(call qcmd,git submodule update --init --recursive --quiet) - -.PHONY: reinit-gitmodules -#******************************************************************************# -# Checking dependencies # +# Configuration (version) checking dependencies # #******************************************************************************# # Define the dependencies. CHECKCFG := $(if $(shell test -f Makefile.cfg || echo y),check-config, \ $(if $(shell [ "$(VERSION)" = "$(CONFIG_VERSION)" ] || echo y), \ check-config-version)) - CHECKFC := $(if $(ISGIT),check-gitmodules) -# Configuration checking. +# Define the rules. check-config: @echo -e "\033[1;31mNo configuration file found!" @echo -e "You should configure before re-running this target.\033[0m" @@ -86,12 +70,7 @@ dist: mrproper $(if $(ISGIT),reinit-gitmodules) @echo -e "You should re-configure before re-running this target.\033[0m" @false -# Git submodules checking. - check-gitmodules: - $(call bcmd,Checking git modules.) - $(call qcmd,git submodule update --init --recursive) - -.PHONY: check-config check-config-version check-gitmodules +.PHONY: check-config check-config-version #******************************************************************************# # Information getting from the Makefile variables # #******************************************************************************# @@ -99,20 +78,20 @@ dist: mrproper $(if $(ISGIT),reinit-gitmodules) getname: @echo lib$(NAME) -# Get the project maintainer. - getmaintainer: - @echo "$(MAINTAINER_NAME) <$(MAINTAINER_MAIL)>" - # Get the project version. getversion: @echo $(VERSION) -.PHONY: getname getmaintainer getversion +# Get the maintainer. + getmaintainer: + @echo "$(MAINTAINER_NAME) <$(MAINTAINER_MAIL)>" + +.PHONY: getname getauthor getmail getversion #******************************************************************************# # Library-specific targets # #******************************************************************************# # Make the library. - all-lib: $(CHECKCFG) $(SONAME) + all-lib: $(CHECKCFG) $(if $(STATIC),$(ANAME),$(SONAME)) # Make a module object directory. $(MODULES:%=$(OBJDIR)/%): @@ -120,17 +99,20 @@ dist: mrproper $(if $(ISGIT),reinit-gitmodules) # Make a module object out of a module source file. define make-moduleobj-rule - $(OBJDIR)/$1/%.o: $(SRCDIR)/$1/%.c $(INC:%=$(INCDIR)/%.h) | $(OBJDIR)/$1 + $(OBJDIR)/$1/%.o: $(SRCDIR)/$1/%.c $(INC) | $(OBJDIR)/$1 $(call bcmd,cc,$$@,$(CC) -c -o $$@ $$< $(CFLAGS)) endef $(foreach mod,$(MODULES), \ $(eval $(call make-moduleobj-rule,$(mod)))) -# Make the library (shared). - $(SONAME): \ - $(foreach m,$(MODULES),$(SRC_$(m):%=$(OBJDIR)/$(m)/%.o)) +# Make the shared library. + $(SONAME): $(foreach m,$(MODULES),$(SRC_$(m):%=$(OBJDIR)/$(m)/%.o)) $(call bcmd,ld,$@,$(LD) -o $@ $^ $(LDFLAGS)) +# Make the static library. + lib$(NAME).a: $(foreach m,$(MODULES),$(SRC_$(m):%=$(OBJDIR)/$(m)/%.o)) + $(call bcmd,ar rc,$@,$(AR) rcs $@ $^) + # Remove the objects directory. mostlyclean-lib: $(call rmsg,Removing object directory.) @@ -140,34 +122,47 @@ $(eval $(call make-moduleobj-rule,$(mod)))) # Clean and remove the built library. clean-lib: mclean-lib $(call rmsg,Removing the library.) - $(call qcmd,$(RM) $(SONAMES)) + $(call qcmd,$(RM) $(SONAMES) $(ANAMES)) # Remake the library. re-lib: clean-lib all-lib -# Install the library, development files and udev rule. - LINK_TO_MAJOR := $(if $(INSTALL_DEVEL),$(if $(FOR_WINDOWS),,y)) - install-lib: $(CHECKCFG) $(SONAME) +# Install the library and development files. + LINK_TO_MAJOR := $(if $(INSTALL_DEVEL),$(if $(STATIC),,$(if $(FOR_WINDOWS),,y))) + IWINDLL := $(if $(FOR_WINDOWS),$(if $(STATIC),,y)) + install-lib: all-lib $(if $(INSTALL_DEVEL),install-cfgtool) $(call imsg,Installing the library.) $(call qcmd,$(INST) -m 755 -d "$(ILIBDIR)") - $(call qcmd,$(INST) -m 755 -t "$(ILIBDIR)" $(SONAME)) + $(call qcmd,$(INST) -m 755 -t "$(ILIBDIR)" $(if $(STATIC),\ + $(if $(FOR_WINDOWS),lib$(NAME).lib,lib$(NAME).a),\ + $(if $(FOR_WINDOWS),lib$(NAME).dll.a,$(SONAME)))) + + $(if $(IWINDLL),$(call qcmd,$(INST) -m 755 -d "$(IBINDIR)")) + $(if $(IWINDLL),$(call qcmd,$(INST) -m 644 -t "$(IBINDIR)" \ + lib$(NAME).dll)) + $(if $(LINK_TO_MAJOR),\ $(call imsg,Linking lib$(NAME).so to lib$(NAME).so.$(MAJOR).)) $(if $(LINK_TO_MAJOR),\ $(call qcmd,$(LN) lib$(NAME).so.$(MAJOR) "$(ILIBDIR)/lib$(NAME).so")) + $(if $(INSTALL_DEVEL),\ $(call imsg,Installing development files.)) - $(if $(INSTALL_DEVEL),$(call qcmd,$(INST) -m 755 -d $(patsubst %,\ - "$(IINCDIR)/lib$(NAME)-$(VERSION)/%",$(sort $(dir $(INCPUB)))))) + $(if $(INSTALL_DEVEL),\ + $(call qcmd,$(INST) -m 755 -d $(patsubst %,\ + "$(IINCDIR)/lib$(NAME)-$(VERSION)/%", $(sort $(dir $(INCPUB)))))) $(if $(INSTALL_DEVEL),$(foreach i,$(INCPUB),\ - $(call qcmd,$(INST) -m 644 $(INCDIR)/$(i).h \ - "$(IINCDIR)/lib$(NAME)-$(VERSION)/$(i).h"$(\n)))) + $(call qcmd,$(INST) -m 644 $(INCDIR)/$(i) \ + "$(IINCDIR)/lib$(NAME)-$(VERSION)/$(i)"$(\n)))) -# Uninstall the library, development files and udev rule. (experimental) - uninstall-lib: $(CHECKCFG) +# Uninstall the library and development files. (experimental) + uninstall-lib: $(CHECKCFG) uninstall-cfgtool $(call rmsg,Uninstalling the library.) - $(call qcmd,$(RM) "$(ILIBDIR)/lib$(NAME).a" \ - "$(ILIBDIR)/lib$(NAME).so"* "$(ILIBDIR)/lib$(NAME).dll") + $(call qcmd,$(RM) "$(IBINDIR)/lib$(NAME).dll") + $(call qcmd,$(RM) "$(ILIBDIR)/lib$(NAME).so"* \ + "$(ILIBDIR)/lib$(NAME).a" "$(ILIBDIR)/lib$(NAME).dll"*) + $(call rmsg,Uninstalling development files.) + $(call qcmd,$(RM) -r "$(IINCDIR)/lib$(NAME)-$(VERSION)") $(call qcmd,$(RM) "$(IINCDIR)/lib$(NAME).h") $(call qcmd,$(RM) -r "$(IINCDIR)/lib$(NAME)") @@ -181,11 +176,12 @@ $(eval $(call make-moduleobj-rule,$(mod)))) $(call imsg,Installing the configuration tool.) $(call qcmd,$(INST) -m 755 -d "$(IBINDIR)") $(call qcmd,tools/write-config \ - --name=lib$(NAME) --version=$(VERSION) \ + --name=$(NAME) --version=$(VERSION) \ --maintainer="$(MAINTAINER_NAME) <$(MAINTAINER_MAIL)>" \ --incdir="$(OIINCDIR)/lib$(NAME)-$(VERSION)" --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 \ @@ -251,10 +247,9 @@ $(eval $(call make-installmansection-rule,$(section)))) define make-uninstall-doc-rule uninstall-doc-$1: $(call rmsg,Uninstalling manpages section $1.) - $(call rcmd,man$1/lib$(NAME).$1) - $(call rcmd,man$1/$(NAME)_*.$1) $(call qcmd,$(RM) "$(IMANDIR)/man$1/lib$(NAME).$1"* \ - "$(IMANDIR)/man$1/$(NAME)_"*".$1"*) + "$(IMANDIR)/man$1/$(NAME)_"*".$1"* \ + "$(IMANDIR)/man$1/lib$(NAME)-config.$1"*) endef $(foreach sec,$(MAN_SECTIONS), \ $(eval $(call make-uninstall-doc-rule,$(sec)))) @@ -265,4 +260,4 @@ $(eval $(call make-uninstall-doc-rule,$(sec)))) .PHONY: all-doc mostlyclean-doc mclean-doc clean-doc re-doc .PHONY: install-doc uninstall-doc .PHONY: $(foreach s,$(MAN_SECTIONS),install-doc-$(s) uninstall-doc-$(s)) -# End of file. +# End of file diff --git a/Makefile.vars b/Makefile.vars index d0cefae..8e5262c 100755 --- a/Makefile.vars +++ b/Makefile.vars @@ -8,9 +8,6 @@ # 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 # #******************************************************************************# @@ -26,6 +23,8 @@ MAJOR := 0 MINOR := 1 INDEV := yes + +# Project version string VERSION := $(MAJOR).$(MINOR)$(if $(INDEV),-indev) #******************************************************************************# @@ -53,6 +52,13 @@ SONAME := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.$(MAJOR)) SONAMES := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.*) +# Static library name + ANAME := $(if $(FOR_WINDOWS),lib$(NAME).lib,lib$(NAME).a) + ANAMES := lib$(NAME).lib lib$(NAME).a lib$(NAME).dll.a + +# Required libs + LIBS := zlib + #******************************************************************************# # Binary utilities # #******************************************************************************# @@ -62,28 +68,40 @@ # Compiler CC := $(TARGET)gcc # - Check flags (warnings) - CHKFLAGS := -Wall -Wextra -Wno-attributes + CWERROR := all extra no-attributes no-unused-macros no-vla +ifdef MORE_WARNINGS + CWERROR += shadow write-strings redundant-decls format format-nonliteral \ + format-security implicit-function-declaration \ + date-time missing-prototypes return-type pointer-arith \ + stack-protector no-unused-parameter +endif + CWARN := $(CWERROR:%=-W%) # - For random manipulations (profiling, ...) - CMOREFLAGS := +#CMOREFLAGS := # - All C compiling flags - CFLAGS := -I $(INCDIR) $(CHKFLAGS) -std=gnu11 -fPIC -O2 \ + CFLAGS := -I $(INCDIR) $(CWARN) -std=gnu11 \ + $(if $(STATIC),,-fPIC) $(if $(OPTIMIZE_SIZE),-Os,-O2) \ -D LOGLEVEL="ll_$(LOG_LEVEL)" \ -D MAINTAINER="$(MAINTAINER_NAME) <$(MAINTAINER_MAIL)>" \ -D LICENSE="$(LICENSE)" -D VERSION="$(VERSION)" \ - $(shell $(PKGCONFIG) --cflags zlib 2>/dev/null ) \ + $(shell $(PKGCONFIG) --cflags $(LIBS) 2>/dev/null) \ $(CMOREFLAGS) # Linker LD := $(TARGET)gcc # - Specific linker flags - LDFLAGS_Windows := -lws2_32 - LDFLAGS_Linux := -Wl,-soname,$(SONAME) \ + LDFLAGS_Windows := -lws2_32 -Wl,--out-implib,lib$(NAME).dll.a + LDFLAGS_Linux := $(if $(STATIC),,-Wl,-soname,$(SONAME) \ -e __lib$(NAME)_version \ - -Wl,-z,relro -Wl,-z,combreloc -Wl,-z,defs + -Wl,-z,relro -Wl,-z,combreloc -Wl,-z,defs) # - Linker flags - LDFLAGS := -shared \ - $(shell $(PKGCONFIG) --libs zlib 2>/dev/null ) \ - $(if $(FOR_WINDOWS),$(LDFLAGS_Windows),$(LDFLAGS_Linux)) + LDFLAGS := $(if $(STATIC),,-shared) \ + $(shell $(PKGCONFIG) --libs $(LIBS) 2>/dev/null) \ + $(if $(FOR_WINDOWS),$(LDFLAGS_Windows),$(LDFLAGS_Linux)) \ + $(LDMOREFLAGS) + +# Archive manager + AR := $(TARGET)ar # Directory maker MD := mkdir -p @@ -120,14 +138,12 @@ $(eval $(call get-module-source,$(mod)))) #******************************************************************************# # Look for headers # #******************************************************************************# -# All headers - INC := $(basename $(shell find $(INCDIR) -name "*.h" -printf "%P\n")) - # Public headers only (not internals.h or internals/**/*.h) - INCPUB := \ - $(basename $(shell find $(INCDIR) \ - \( -name "*.h" -and -not -path "*internals*" \) \ - -printf "%P\n" | sort)) + INCPUB := $(shell find $(INCDIR) \ + -name "*.h" -and -not -path "*internals*" -printf "%P\n" | sort) + +# ... and for headers (dependencies) + INC := $(shell find $(INCDIR) -name "*.h") #******************************************************************************# # Look for manpages # diff --git a/configure b/configure index 74f7c7d..b7fb374 100755 --- a/configure +++ b/configure @@ -6,8 +6,6 @@ cd "$(dirname $0)" # Project variables name="$(make -s getname)" version="$(make -s getversion)" - -# Maintainer maintainer="$(make -s getmaintainer)" # Platform @@ -16,11 +14,14 @@ platform="$([ "$platform" ] && echo "/$platform")" # Make options make_full_log= +more_warnings= # Build options target= +static= +windows= +optimize_size= loglevel=none # none, info, warn, error, fatal -fcset=$(tools/list-sets --default) # Installation directories root='' @@ -36,6 +37,10 @@ mandir='${prefix}/share/man' install_manpages=yes install_devel=yes +# Tweaks +cflags= +ldflags= + #******************************************************************************# # Help message # #******************************************************************************# @@ -50,10 +55,13 @@ General options: --help display this help and exit --version display version information and quit --make-full-log display full commands while making + --maintainer enable maintainer mode Build options: - --set=SET the FONTCHARACTER set (if none, default one) --target=TARGET the target (if none, native) + --static build a static library (by default, dynamic) + --windows build DLLs and .libs instead of ELF and archives + --optimize-size optimize size instead of speed --loglevel=LOGLEVEL library log level [$loglevel] Installation options: @@ -71,10 +79,9 @@ Fine tuning of the installation directories: --includedir=DIR include files for the compiler [$includedir] --mandir=DIR man root [$mandir] -Available FONTCHARACTER sets are: -EOF -./tools/list-sets --long -cat <&2 - fi ;; --noinstall-manpages) install_manpages= ;; --noinstall-devel) install_devel= ;; --root=*) root="${arg#*=}" ;; @@ -143,6 +147,8 @@ got '$level'" --libdir=*) libdir="${arg#*=}" ;; --includedir=*) includedir="${arg#*=}" ;; --mandir=*) mandir="${arg#*=}" ;; +CFLAGS=*) cflags="${arg#*=}" ;; +LDFLAGS=*) ldflags="${arg#*=}" ;; *) echo "$arg: didn't read" ;; esac; done @@ -154,14 +160,64 @@ if [ ! $prefix_set ] && [ $target ]; then prefix="$prefix"/"$target" fi +# Check MS-Windows targets +win_target= +case "$target" in *-mingw32) if [ ! "$static" ]; then + windows=y; win_target=y +fi;; esac + # Evaluate variables -for var in prefix sysconfdir bindir libdir pkgdir includedir mandir; do +vars="prefix bindir libdir pkgdir includedir mandir" +for var in $vars; do eval $var'='$(eval 'echo $'$var) done +# Check that static and MS-Windows are not asked. +if [ "$static" ] && [ "$windows" ]; then +cat >&2 <&2 <&2 </dev/null 2>/dev/null + +# Create the configuration header +opt= +# [no option yet.] +tools/write-header-config $opt >include/libg1m/config.h + +# Do it! exec 3>&1 1>Makefile.cfg cat <&3 3>&- chmod +x Makefile.cfg -#******************************************************************************# -# Finish # -#******************************************************************************# +# Print the end message. echo "Configuration loaded, you can make now." # End of file. diff --git a/include/libg1m/internals.h b/include/libg1m/internals.h index 521382f..31a9e95 100644 --- a/include/libg1m/internals.h +++ b/include/libg1m/internals.h @@ -44,15 +44,17 @@ #define READ(TO, SZ) { \ size_t READ_size = fread(TO, 1, SZ, stream); \ if (!READ_size) { \ - log_error("READING failed: read %zu/%zu bytes, %zu missing.", \ - READ_size, SZ, (SZ) - READ_size); \ + log_error("READING failed: read %" PRIuSIZE "/%" PRIuSIZE \ + " bytes, %" PRIuSIZE " missing.", READ_size, SZ, \ + (SZ) - READ_size); \ return (g1m_error_eof); \ }} #define GREAD(TO, SZ) { \ size_t READ_size = fread(TO, 1, SZ, stream); \ if (!READ_size) { \ - log_error("READING failed: read %zu/%zu bytes, %zu missing.", \ - READ_size, SZ, (SZ) - READ_size); \ + log_error("READING failed: read %" PRIuSIZE "/%" PRIuSIZE \ + " bytes, %" PRIuSIZE " missing.", READ_size, SZ, \ + (SZ) - READ_size); \ err = g1m_error_eof; \ goto fail; \ }} @@ -126,6 +128,9 @@ G1M_PROTOTYPE_PIX(16bits) int g1m_parse(g1m_t *handle, const char *path, FILE *stream, g1m_type_t expected_type); +/* Making */ +int g1m_make_mcs(g1m_t **h); + /* Free-ing */ void g1m_free_content(g1m_t *handle); void g1m_free_mcsfile_content(g1m_mcsfile_t *handle); diff --git a/include/libg1m/internals/log.h b/include/libg1m/internals/log.h index d8be7c3..ee71e43 100644 --- a/include/libg1m/internals/log.h +++ b/include/libg1m/internals/log.h @@ -12,6 +12,15 @@ # include # include +/* Some printf types */ +# ifdef _WIN64 +# define PRIuSIZE "l64u" +# elif _WIN32 +# define PRIuSIZE "u" +# else +# define PRIuSIZE "zu" +# endif + /* ************************************************************************** */ /* Log utility */ /* ************************************************************************** */ diff --git a/src/parse/addin.c b/src/parse/addin.c index 0160a37..1651a5c 100644 --- a/src/parse/addin.c +++ b/src/parse/addin.c @@ -142,7 +142,7 @@ int g1m_parse_addin_cg(g1m_t *handle, FILE *stream, - hd.magic[1] ? 0x7000 : 0x1000; if (hd.control != content_size) { log_fatal("control value is incorrect!"); - log_fatal("calculated %zu, expected %" PRIu32, + log_fatal("calculated %" PRIuSIZE ", expected %" PRIu32, content_size, hd.control); return (g1m_error_magic); } diff --git a/src/parse/eact.c b/src/parse/eact.c index 4be1af3..e663c7e 100644 --- a/src/parse/eact.c +++ b/src/parse/eact.c @@ -125,7 +125,7 @@ fail: /* ************************************************************************** */ /* Correspondance type */ struct eact_content_type_corresp { - char *type; + const char *type; int (*parse)(g1m_line_t*, uint8_t*, size_t); }; @@ -354,7 +354,7 @@ struct eact_line_type_corresp { int rawtype; int (*parse)(g1m_line_t*, uint8_t*, size_t); - char *info; + const char *info; }; /* All correspondances */ diff --git a/src/parse/lang.c b/src/parse/lang.c index 3b3594f..ce93c91 100644 --- a/src/parse/lang.c +++ b/src/parse/lang.c @@ -163,8 +163,10 @@ static int g1m_parse_lang_cg_content(g1m_t *handle, FILE *stream, checksum = g1m_checksum32(msg, msg_size, checksum); /* copy it */ - handle->messages[i] = strndup((char*)msg, msg_size); + handle->messages[i] = malloc(msg_size + 1); if (!handle->messages[i]) goto fail; + handle->messages[i][msg_size] = 0; + strncpy(handle->messages[i], (char*)msg, msg_size); handle->count += (next - i); /* log it */ diff --git a/src/parse/mcs.c b/src/parse/mcs.c index 97073fc..5ad6f1e 100644 --- a/src/parse/mcs.c +++ b/src/parse/mcs.c @@ -91,7 +91,7 @@ static int mcs_parse_program(g1m_mcsfile_t *handle, FILE *stream, /* get content */ size_t content_size = length - sizeof(struct mcs_programheader); - log_info("Getting program content (%zuo)", content_size); + log_info("Getting program content (%" PRIuSIZE "o)", content_size); handle->content = malloc(content_size + 1); handle->content_size = content_size + 1; if (!handle->content) return (g1m_error_alloc); @@ -768,13 +768,15 @@ int g1m_parse_mcs(g1m_t *handle, FILE *stream, fhd.datalength = be32toh(fhd.datalength); /* log info about the subpart */ - log_info("[%lu] directory name is '%.8s'", i, fhd.dirname); - log_info("[%lu] filename is '%.8s'", i, fhd.filename); - log_info("[%lu] data length is %" PRIu32, i, fhd.datalength); + log_info("[%" PRIuFAST32 "] directory name is '%.8s'", + i, fhd.dirname); + log_info("[%" PRIuFAST32 "] filename is '%.8s'", i, fhd.filename); + log_info("[%" PRIuFAST32 "] data length is %" PRIu32, + i, fhd.datalength); /* decode */ handle->files[handle->count] = NULL; - int err = g1m_parse_mcsfile_content(&handle->files[handle->count], + err = g1m_parse_mcsfile_content(&handle->files[handle->count], stream, fhd.filetype, hd.intname, fhd.dirname, fhd.filename, fhd.datalength); if (err) return (err); diff --git a/src/parse/picture.c b/src/parse/picture.c index 0ae8c26..01ff7f7 100644 --- a/src/parse/picture.c +++ b/src/parse/picture.c @@ -70,7 +70,7 @@ int g1m_parse_g3p(g1m_t *handle, FILE *stream, ihd.width, ihd.height); log_info("Pixel depth: %s", (ihd.color_depth == g3p_color_4bit) ? "4-bit" : "16-bit"); - log_info("Deflated image length: %zuo", deflated_image_size); + log_info("Deflated image length: %" PRIuSIZE "o", deflated_image_size); log_info("Is obfuscated: %s", is_obfuscated ? "yes" : "no"); /* read image */ @@ -102,7 +102,7 @@ int g1m_parse_g3p(g1m_t *handle, FILE *stream, log_fatal("Zlib error: error #%d", z_err); return (g1m_error_magic); } - log_info("Inflated image size is %zu", inflated_size); + log_info("Inflated image size is %lu", inflated_size); /* allocate space for it, and uncompress */ uint8_t inflated_image[inflated_size]; @@ -149,7 +149,7 @@ int g1m_parse_c2p(g1m_t *handle, FILE *stream, (void)stream; /* TODO */ log_info("C2P files are not managed yet."); - log_info("Size is %zx", sizeof(struct c2p_subheader)); + log_info("Size is %" PRIuSIZE " o", sizeof(struct c2p_subheader)); /* no error */ return (0); diff --git a/src/parse/storage.c b/src/parse/storage.c index 7c97cb8..0757d85 100644 --- a/src/parse/storage.c +++ b/src/parse/storage.c @@ -73,11 +73,12 @@ int g1m_parse_storage(g1m_t *handle, FILE *stream, int unused = (sh->logical_sector_number == 0xFFFFFFFF); log_info("[%02d,%02" PRIu16 "] Is a%ssector.", id, entry.uuid, (unused) ? "n unused " : " "); - log_info("- Starts at address 0x%08" PRIx32, - be32toh(sh->startaddr)); + sh->startaddr = be32toh(sh->startaddr); + log_info("- Starts at address 0x%08" PRIx32, sh->startaddr); #if LOGLEVEL <= ll_info + sh->logical_sector_number = be32toh(sh->logical_sector_number); if (!unused) log_info("- Logical number: 0x%08" PRIu32, - be32toh(sh->logical_sector_number)); + sh->logical_sector_number); #endif break; diff --git a/src/utils/skip.c b/src/utils/skip.c index 71c26bc..df4629f 100644 --- a/src/utils/skip.c +++ b/src/utils/skip.c @@ -40,8 +40,10 @@ int g1m_parse_skip(FILE *stream, size_t size, uint_fast32_t *checksum) size_t read_len = fread(buf, 1, curlen, stream); size -= read_len; if (read_len < curlen) { - log_error("SKIPPING failed, skipped %zu/%zu bytes, " - "%zu missing", size_ini - size, size_ini, size); + log_error("SKIPPING failed, skipped " + "%" PRIuSIZE "/%" PRIuSIZE " bytes, " + "%" PRIuSIZE " missing", + size_ini - size, size_ini, size); return (g1m_error_eof); } @@ -61,8 +63,10 @@ int g1m_parse_skip(FILE *stream, size_t size, uint_fast32_t *checksum) size_t read_len = fread(buf, 1, curlen, stream); size -= read_len; if (read_len < curlen) { - log_error("SKIPPING failed, skipped %zu/%zu bytes, " - "%zu missing", size_ini - size, size_ini, size); + log_error("SKIPPING failed, skipped " + "%" PRIuSIZE "/%" PRIuSIZE " bytes, " + "%" PRIuSIZE " missing", + size_ini - size, size_ini, size); return (g1m_error_eof); } } diff --git a/tools/check-set b/tools/check-set deleted file mode 100755 index 0217927..0000000 --- a/tools/check-set +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python3 -# Dependencies -import os, sys -from fontcharacter import Reference - -# Open the reference -refpath = os.path.join(os.path.dirname(__file__), 'fontcharacter_reference') -ref = Reference(refpath, sets_only=True) - -# Exit with the correct code -exit(not sys.argv[1] in ref.sets.keys()) diff --git a/tools/list-sets b/tools/list-sets deleted file mode 100755 index af927cb..0000000 --- a/tools/list-sets +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -# Dependencies -import os, sys -from fontcharacter import Reference - -# Open the reference -refpath = os.path.join(os.path.dirname(__file__), 'fontcharacter_reference') -ref = Reference(refpath, sets_only=True) - -# Put the default -if "--default" in sys.argv: - print(ref.default_set) - exit(0) - -# List them -lg = "--long" in sys.argv -k = sorted(ref.sets.keys()) -for name, s in zip(k, map(ref.sets.__getitem__, k)): - if lg: - print('* %s: %s%s'%(name, s['description'], \ - ' (default)' if name == ref.default_set else '')) - else: - print(name) diff --git a/tools/write-config b/tools/write-config index d4062d2..7d258ff 100755 --- a/tools/write-config +++ b/tools/write-config @@ -3,11 +3,11 @@ # Defaults # #******************************************************************************# # Project variables -name="useless" +name="libg1m" version="" # Maintainer -maintainer="Unknown " +maintainer="Some unknown guy " # Directories libdir='' @@ -75,7 +75,7 @@ esac; done # Put [ \$put_cflags ] && echo "-I$incdir" -[ \$put_libs ] && echo "-L$libdir -lg1m" +[ \$put_libs ] && echo "-L$libdir -l$name" [ \$put_cflags\$put_libs ] || usage # End of file diff --git a/tools/write-header-config b/tools/write-header-config new file mode 100755 index 0000000..a837879 --- /dev/null +++ b/tools/write-header-config @@ -0,0 +1,26 @@ +#!/bin/sh +#******************************************************************************# +# Arguments # +#******************************************************************************# +# Initialize the variables +gint= +no_file= + +# Read the arguments +for arg ; do case "$arg" in +--gint) gint=y ;; +--no-file) no_file=y ;; +*) echo "'${arg}': Did not read." ;; +esac; done + +#******************************************************************************# +# Write the file # +#******************************************************************************# +cat <<_EOF +#ifndef LIBG1M_CONFIG_H +# define LIBG1M_CONFIG_H + +# --- no option yet! --- + +#endif /* LIBG1M_CONFIG_H */ +_EOF diff --git a/tools/write-pkg-config b/tools/write-pkg-config index ea2eb76..3f1d6fe 100755 --- a/tools/write-pkg-config +++ b/tools/write-pkg-config @@ -3,7 +3,7 @@ # Defaults # #******************************************************************************# # Project variables -name="useless" +name="name" description="my description" version=""