Rework copyright notices
While at it, rename mystrtonum.[ch] to strtonum.[ch].
This commit is contained in:
parent
33cc12f030
commit
0b93ea8653
26
Makefile
26
Makefile
@ -1,6 +1,6 @@
|
||||
# otpcli - command-line interface for HOTP and TOTP
|
||||
#
|
||||
# Written in 2020 by Lucas
|
||||
# Written in 2020-2021 by Lucas
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all
|
||||
# copyright and related and neighboring rights to this software to the
|
||||
@ -17,18 +17,16 @@
|
||||
P = otpcli
|
||||
V = 0.0
|
||||
|
||||
HDR = err.h mystrtonum.h otp.h
|
||||
OBJ = cli.o err.o mystrtonum.o otp.o
|
||||
SRC = ${OBJ:.o=.c}
|
||||
DIST_FILES = COPYING Makefile ${HDR} ${SRC}
|
||||
HDR = err.h strtonum.h otp.h
|
||||
OBJ = cli.o ${HDR:.h=.o}
|
||||
SRC = ${OBJ:.o=.c}
|
||||
|
||||
LIBS = -lcrypto
|
||||
|
||||
DIST = COPYING Makefile ${HDR} ${SRC}
|
||||
|
||||
all: otpcli
|
||||
|
||||
${OBJ}: ${HDR}
|
||||
|
||||
otpcli: ${OBJ}
|
||||
${CC} ${LDFLAGS} -o $@ ${OBJ} -lcrypto
|
||||
|
||||
clean:
|
||||
rm -f otpcli ${OBJ} ${P}-${V}.tgz
|
||||
|
||||
@ -36,12 +34,16 @@ test: all run-tests.sh
|
||||
sh ./run-tests.sh
|
||||
|
||||
dist: clean
|
||||
pax -w -s '#^#${P}-${V}/#' ${DIST_FILES} | gzip >${P}-${V}.tgz
|
||||
pax -w -s ',^,$P-$V/,' ${DIST} | gzip >$P-$V.tgz
|
||||
|
||||
install: all
|
||||
mkdir -p ${PREFIX}/bin
|
||||
cp -f ${BIN} ${PREFIX}/bin
|
||||
cd ${PREFIX}/bin && chmod 555 ${BIN}
|
||||
|
||||
uninstall:
|
||||
cd ${PREFIX}/bin && rm -f ${BIN}
|
||||
|
||||
${OBJ}: ${HDR}
|
||||
|
||||
otpcli: ${OBJ}
|
||||
${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}
|
||||
|
12
cli.c
12
cli.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* otpcli - CLI utility for generating OTPs
|
||||
*
|
||||
* Written in 2020 by Lucas
|
||||
* Written in 2020-2021 by Lucas
|
||||
*
|
||||
* To the extent possible under law, the author(s) have dedicated all
|
||||
* copyright and related and neighboring rights to this software to the
|
||||
@ -23,7 +23,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "err.h"
|
||||
#include "mystrtonum.h"
|
||||
#include "strtonum.h"
|
||||
#include "otp.h"
|
||||
|
||||
#define LINE_SIZE 16384
|
||||
@ -60,12 +60,12 @@ main(int argc, char *argv[])
|
||||
while ((ch = getopt(argc, argv, "d:H:h:s:T:")) != -1) {
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
digits = mystrtonum(optarg, 6, 10, &errstr);
|
||||
digits = strtonum(optarg, 6, 10, &errstr);
|
||||
if (errstr != NULL)
|
||||
errx(1, "digits is %s: %s", errstr, optarg);
|
||||
break;
|
||||
case 'H':
|
||||
counter = mystrtonum(optarg, 0, LLONG_MAX, &errstr);
|
||||
counter = strtonum(optarg, 0, LLONG_MAX, &errstr);
|
||||
if (errstr != NULL)
|
||||
errx(1, "counter is %s: %s", errstr, optarg);
|
||||
do_hotp = 1;
|
||||
@ -81,12 +81,12 @@ main(int argc, char *argv[])
|
||||
usage();
|
||||
break;
|
||||
case 's':
|
||||
step = mystrtonum(optarg, 1, UINT_MAX, &errstr);
|
||||
step = strtonum(optarg, 1, UINT_MAX, &errstr);
|
||||
if (errstr != NULL)
|
||||
errx(1, "step is %s: %s", errstr, optarg);
|
||||
break;
|
||||
case 'T':
|
||||
counter = mystrtonum(optarg, 0, LLONG_MAX, &errstr);
|
||||
counter = strtonum(optarg, 0, LLONG_MAX, &errstr);
|
||||
if (errstr != NULL)
|
||||
errx(1, "counter is %s: %s", errstr, optarg);
|
||||
do_totp = 1;
|
||||
|
37
err.c
37
err.c
@ -1,16 +1,31 @@
|
||||
/*
|
||||
* libutil - C utility functions
|
||||
/* $OpenBSD: verr.c,v 1.11 2016/03/13 18:34:20 guenther Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Written in 2020 by Lucas
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* To the extent possible under law, the author(s) have dedicated all
|
||||
* copyright and related and neighboring rights to this software to the
|
||||
* public domain worldwide. This software is distributed without any
|
||||
* warranty.
|
||||
*
|
||||
* You should have received a copy of the CC0 Public Domain Dedication
|
||||
* along with this software. If not, see
|
||||
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Inspired by OpenBSD's `err.h' header, found at
|
||||
|
15
err.h
15
err.h
@ -1,18 +1,3 @@
|
||||
/*
|
||||
* libutil - C utility functions
|
||||
*
|
||||
* Written in 2020 by Lucas
|
||||
*
|
||||
* To the extent possible under law, the author(s) have dedicated all
|
||||
* copyright and related and neighboring rights to this software to the
|
||||
* public domain worldwide. This software is distributed without any
|
||||
* warranty.
|
||||
*
|
||||
* You should have received a copy of the CC0 Public Domain Dedication
|
||||
* along with this software. If not, see
|
||||
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
|
||||
void err(int, const char *, ...);
|
||||
void errx(int, const char *, ...);
|
||||
void warn(const char *, ...);
|
||||
|
16
mystrtonum.h
16
mystrtonum.h
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* libutil - C utility functions
|
||||
*
|
||||
* Written in 2020 by Lucas
|
||||
*
|
||||
* To the extent possible under law, the author(s) have dedicated all
|
||||
* copyright and related and neighboring rights to this software to the
|
||||
* public domain worldwide. This software is distributed without any
|
||||
* warranty.
|
||||
*
|
||||
* You should have received a copy of the CC0 Public Domain Dedication
|
||||
* along with this software. If not, see
|
||||
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
|
||||
long long mystrtonum(const char *, long long, long long, const char **);
|
@ -1,5 +1,3 @@
|
||||
/* This is OpenBSD's strtonum(3), renamed to mystrtonum */
|
||||
|
||||
/* $OpenBSD: strtonum.c,v 1.8 2015/09/13 08:31:48 guenther Exp $ */
|
||||
|
||||
/*
|
||||
@ -28,7 +26,7 @@
|
||||
#define TOOLARGE 3
|
||||
|
||||
long long
|
||||
mystrtonum(const char *numstr, long long minval, long long maxval,
|
||||
strtonum(const char *numstr, long long minval, long long maxval,
|
||||
const char **errstrp)
|
||||
{
|
||||
long long ll = 0;
|
1
strtonum.h
Normal file
1
strtonum.h
Normal file
@ -0,0 +1 @@
|
||||
long long mystrtonum(const char *, long long, long long, const char **);
|
Loading…
Reference in New Issue
Block a user