fix: added DESTDIR to makefile, checking fread() return value

master
Gillian B. 2 months ago
parent 353bcd31cf
commit ff8cc96348
  1. 28
      Makefile
  2. 4
      man/man.sh
  3. 4
      man/octapng.1
  4. 4
      man/octapng.1.ronn
  5. 12
      src/dec.c
  6. 6
      src/octapng.c

@ -15,9 +15,13 @@
#. objsufx=OBJSUFX Compiled object extension. (default=.o)
#.
#. prefix=PREFIX Installation path. (default=/usr/local)
#. Uppercase `PREFIX=...` also works.
#. bindir=BINDIR Installed binary path. (default=PREFIX/bin)
#. mandir=MANDIR Installed manuals path. (default=PREFIX/share/man)
#. datadir=DATADIR Installed data path. (default=PREFIX/share)
#. mandir=MANDIR Installed manuals path. (default=DATADIR/man)
#. man1dir=MAN1DIR Installed man1 path. (default=MANDIR/man1)
#. DESTDIR=DESTDIR Staged installation path.
#. If used, PREFIX must start with a `/` .
#.
#. warnings=... Additional warning flags.
#. cflags=... Additional general compiler flags.
@ -64,16 +68,20 @@ exeprfx=
exesufx=
objsufx=.o
# install dirs
prefix=/usr/local
DESTDIR=
PREFIX=/usr/local
prefix=$(PREFIX)
bindir=$(prefix)/bin
mandir=$(prefix)/share/man
datadir=$(prefix)/share
mandir=$(datadir)/man
man1dir=$(mandir)/man1
# compiler
CC=gcc
CCPRFX=
# compilation flags
WARNINGS=-W -Wall -Wconversion -Wshadow -Wcast-qual -Wwrite-strings $(warnings)
WARNINGS=-W -Wall -Wconversion -Wshadow -Wcast-qual -Wwrite-strings \
-Wunused-result $(warnings)
CFLAGS=-ansi -pedantic -O1 $(cflags)
LDFLAGS=-static $(ldflags)
# library flags
@ -125,14 +133,14 @@ clean:
rm -f $(EXE)
install: all
@mkdir -p "$(bindir)"
@mkdir -p "$(man1dir)"
cp -t "$(bindir)" $(EXE)
cp -t "$(man1dir)" $(MAN1)
@mkdir -p "$(DESTDIR)$(bindir)"
@mkdir -p "$(DESTDIR)$(man1dir)"
cp -t "$(DESTDIR)$(bindir)" $(EXE)
cp -t "$(DESTDIR)$(man1dir)" $(MAN1)
uninstall:
rm -f "$(bindir)/$(EXENAME)"
rm -f "$(man1dir)/$(MAN1NAME)"
rm -f "$(DESTDIR)$(bindir)/$(EXENAME)"
rm -f "$(DESTDIR)$(man1dir)/$(MAN1NAME)"
help:
@cat Makefile | grep "#\."

@ -0,0 +1,4 @@
#!/bin/sh
# 70 columns for description, 60 elsewhere
ronn --manual "octaPNG Manual" --date 2022-05-01 --organization "Gillian B." --roff octapng.1.ronn && man ./octapng.1

@ -7,10 +7,10 @@
\fBoctapng\fR \- convert any file into a PNG and back
.
.SH "SYNOPSIS"
\fBoctapng\fR [\fB\-y\fR|\fBn\fR] \fB\-e\fR \fIFILE\fR [\fIFILE\fR\.\.\.]
\fBoctapng\fR [\fB\-y\fR|\fB\-n\fR] \fB\-e\fR \fIFILE\fR [\fIFILE\fR\.\.\.]
.
.br
\fBoctapng\fR [\fB\-y\fR|\fBn\fR] \fB\-d\fR \fIFILE\.PNG\fR [\fIFILE\.PNG\fR\.\.\.]
\fBoctapng\fR [\fB\-y\fR|\fB\-n\fR] \fB\-d\fR \fIFILE\.PNG\fR [\fIFILE\.PNG\fR\.\.\.]
.
.br
.

@ -3,8 +3,8 @@ octapng(1) -- convert any file into a PNG and back
## SYNOPSIS
`octapng` [`-y`|`n`] `-e` *FILE* [*FILE*...]<br>
`octapng` [`-y`|`n`] `-d` *FILE.PNG* [*FILE.PNG*...]<br>
`octapng` [`-y`|`-n`] `-e` *FILE* [*FILE*...]<br>
`octapng` [`-y`|`-n`] `-d` *FILE.PNG* [*FILE.PNG*...]<br>
## DESCRIPTION

@ -57,8 +57,10 @@ r_opng(opng *this)
/* verify PNG header, verify oPNG "header"
open files */
FIN = fopen(FIN_S, "rb");
if ((err = r_png_hdr(this)) ||
(err = r_opng_hdr(this)) )
if (
(err = r_png_hdr(this)) ||
(err = r_opng_hdr(this))
)
{
fclose(FIN);
return err;
@ -162,8 +164,10 @@ r_png_hdr(opng *this)
int err = 0;
unsigned char header[8];
fread(header, 1, 8, FIN);
if (png_sig_cmp(header, 0, 8))
if (
fread(header, 1, 8, FIN) != 8 ||
png_sig_cmp(header, 0, 8)
)
return err = echo_opng_err(OPNG_ERR_P_NOHDR, this);
PNG_PTR = png_create_read_struct(

@ -79,10 +79,10 @@ void
prnt_usage(void)
{
printf(
"octaPNG v" OCTAPNG_VERSION_STRING "\n"
"octaPNG " OCTAPNG_VERSION_STRING "\n"
"USAGE:\n"
"\t" EXENAME " [-y|n] -e file [file...]\n"
"\t" EXENAME " [-y|n] -d file.png [file.png...]\n"
"\t" EXENAME " [-y|-n] -e file [file...]\n"
"\t" EXENAME " [-y|-n] -d file.png [file.png...]\n"
"MODES:\n"
"\t-e Encode one or more files each into an oPNG.\n"
"\t-d Decode one or more oPNGs into their original files.\n"

Loading…
Cancel
Save