Add setisodate utility.

This utility is capable of setting the system clock, taking its argument
in ISO8601 format.
This commit is contained in:
Laurence Withers 2007-09-13 11:16:23 +00:00
parent 64c5ce0d65
commit 21adf7acf0
7 changed files with 121 additions and 0 deletions

1
src/setisodate/.params Normal file
View File

@ -0,0 +1 @@
app c setisodate sbin

View File

@ -0,0 +1,45 @@
/* libiso8601/src/setisodate/000_TopSource.c
*
* (c)2007, Laurence Withers, <l@lwithers.me.uk>.
* Released under the GNU GPLv2. See file COPYING or
* http://www.gnu.org/copyleft/gpl.html for details.
*/
/* Below are all the includes used throughout the application. */
#include <stdio.h>
#include "iso8601.h"
int main(int argc, char* argv[])
{
struct iso8601_date d;
char str[100];
if(argc != 2) {
fputs("Expecting one argument: date/time (in ISO8601 format) to set.\n", stderr);
return 1;
}
if(iso8601_parse(argv[1], &d, 0, 0)) {
fputs("Cannot parse date.\n", stderr);
return 1;
}
printf("Setting date to %s.\n",
iso8601_print(str, sizeof(str), &d, 0));
if(iso8601_set_sysclock(&d)) {
perror("iso8601_set_sysclock");
return 1;
}
return 0;
}
/* options for text editors
kate: replace-trailing-space-save true; space-indent true; tab-width 4;
vim: expandtab:ts=4:sw=4
*/

43
src/setisodate/build.app Normal file
View File

@ -0,0 +1,43 @@
# These are external variables, and shouldn't clash with anything else
# setisodate
# setisodate_BUILT
#
build_target libiso8601
if [ -z ${setisodate_BUILT} ]
then
setisodate="obj/setisodate"
EXTRAS="${libiso8601} ${libiso8601_DEP_CFLAGS} ${libiso8601_DEP_LIBS}"
echo "Building application ${setisodate}..."
do_cmd source src/setisodate/build.monolithic || return 1
MODIFIED=0
for test in ${MONOLITHIC_TESTS} ${SRC}
do
if [ ${test} -nt ${setisodate} ]
then
MODIFIED=1
break
fi
done
if [ ${MODIFIED} -ne 0 ]
then
echo " Compiling..."
do_cmd ${CC} ${CFLAGS} -I obj -o "${setisodate}" ${SRC} ${EXTRAS} || return 1
print_success "Application built"
else
print_success "Application up to date"
fi
setisodate_BUILT=1
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -0,0 +1 @@
source src/setisodate/build.app

View File

@ -0,0 +1 @@
source src/setisodate/build.install-app

View File

@ -0,0 +1,12 @@
build_target setisodate
# make paths (this is for Gentoo in particular)
build_dir_tree "${SBINDIR}" || return 1
# install binary
echo "Installing binaries into '${SBINDIR}'"
install_file "${setisodate}" "${SBINDIR}" 0755 || return 1
print_success "Done"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -0,0 +1,18 @@
# These are external variables, and shouldn't clash with anything else
# setisodate_MONOLITHIC
#
SRC="obj/setisodate.c"
MONOLITHIC_TESTS="src/setisodate/build.app src/setisodate/build.monolithic"
if [ -z "${setisodate_MONOLITHIC}" ]
then
MONOLITHIC_SOURCE="$(echo src/setisodate/*.c)"
make_monolithic ${SRC} C || return 1
setisodate_MONOLITHIC=1
MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}"
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4