cake
/
libg1m
Archived
1
0
Fork 0

Corrected things in the lib.

This commit is contained in:
Thomas Touhey 2017-01-27 21:49:04 +01:00
parent b3abff698b
commit 9ea6f8bf5b
18 changed files with 253 additions and 165 deletions

3
.gitignore vendored
View File

@ -1,7 +1,8 @@
/Makefile.cfg
/include/lib*/config.h
/obj
/libg1m.so*
/libg1m.dll
/libg1m.dll*
/man
.*.swp

119
Makefile
View File

@ -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

View File

@ -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 #

103
configure vendored
View File

@ -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 <<EOF
Other tweaks:
CFLAGS=CFLAGS some more compilation flags
LDFLAGS=LDFLAGS some more linker flags
Report bugs to ${maintainer}.
EOF
@ -112,8 +119,12 @@ esac; done
# Parse arguments #
#******************************************************************************#
for arg ; do case "$arg" in
--target=*) target="${arg#*=}" ;;
--make-full-log) make_full_log=yes ;;
--maintainer) more_warnings=yes; loglevel=info ;;
--target=*) target="${arg#*=}" ;;
--static) static=y ;;
--windows) windows=y ;;
--optimize-size) optimize_size=y ;;
--loglevel=*)
level="${arg#*=}"
# check if is in array
@ -127,13 +138,6 @@ got '$level'"
fi
# then set
loglevel=$level ;;
--set=*)
s="${arg#*=}"
# check if in array
if tools/check-set $s
then fcset="$s"
else echo "$0: --set: not a valid set (see the help page)" >&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 <<EOF
Sadly, there is no equivalent of MSVC's LIB.EXE for GNU/Linux.
If you know one, contact the maintainer: see \`./configure --help\`.
EOF
exit 1
fi
# Check that MS-Windows has a target.
if [ "$windows" ] && [ ! "$target" ]; then
cat >&2 <<EOF
You have selected the --windows option, but have selected no target.
If you want to build for native use, use a mingw32/mingw64 target.
If you want to build for a cross-compiling use, specify an other target!
EOF
exit 1
fi
# Check if is on Cygwin
[ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ] && windows=y
# Check that MS-Windows has a mingw* target.
if [ "$windows" ] && [ ! "$win_target" ]; then
cat >&2 <<EOF
You have selected the --windows option, but have not selected a mingw32/mingw64
BFD target. We supposed that it is because you are compiling libp7 for a
cross-compiler compiled for MS-Windows (that's why configuration won't fail).
If it is not, please reconfigure to use a mingw32/mingw64 toolchain!
EOF
fi
#******************************************************************************#
# Create Makefile configuration #
#******************************************************************************#
# Clean before
make mrproper MAKE_FULL_LOG=y 1>/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 <<EOF
#!/usr/bin/make -f
@ -171,11 +227,14 @@ cat <<EOF
# Configuration version and messages configuration
CONFIG_VERSION = $version
MAKE_FULL_LOG = $make_full_log
MORE_WARNINGS := $more_warnings
FOR_WINDOWS := $windows
# Build options
STATIC := $static
TARGET = $target
OPTIMIZE_SIZE := $optimize_size
LOG_LEVEL = $loglevel
SET := $fcset
# Installation directories
IBINDIR = $bindir
@ -188,14 +247,16 @@ cat <<EOF
INSTALL_MANPAGES = $install_manpages
INSTALL_DEVEL = $install_devel
# Other tweaks
CMOREFLAGS := $cflags
LDMOREFLAGS := $ldflags
# End of file.
EOF
exec 1>&3 3>&-
chmod +x Makefile.cfg
#******************************************************************************#
# Finish #
#******************************************************************************#
# Print the end message.
echo "Configuration loaded, you can make now."
# End of file.

View File

@ -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);

View File

@ -12,6 +12,15 @@
# include <stdint.h>
# include <inttypes.h>
/* Some printf types */
# ifdef _WIN64
# define PRIuSIZE "l64u"
# elif _WIN32
# define PRIuSIZE "u"
# else
# define PRIuSIZE "zu"
# endif
/* ************************************************************************** */
/* Log utility */
/* ************************************************************************** */

View File

@ -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);
}

View File

@ -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 */

View File

@ -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 */

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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())

View File

@ -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)

View File

@ -3,11 +3,11 @@
# Defaults #
#******************************************************************************#
# Project variables
name="useless"
name="libg1m"
version="<unknown version>"
# Maintainer
maintainer="Unknown <mail@world>"
maintainer="Some unknown guy <anon@localhost>"
# 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

26
tools/write-header-config Executable file
View File

@ -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

View File

@ -3,7 +3,7 @@
# Defaults #
#******************************************************************************#
# Project variables
name="useless"
name="name"
description="my description"
version="<unknown version>"