Add default path for iso8601_leap_table_load()

This commit is contained in:
Laurence Withers 2009-05-29 14:51:26 +00:00
parent b7d039a32c
commit 7ba82a2988
4 changed files with 9 additions and 3 deletions

2
config
View File

@ -32,5 +32,7 @@
source "scripts/paths"
# Project-specific variables below.
[ -z "${DEFAULT_LEAP_TABLE}" ] && DEFAULT_LEAP_TABLE="${SHAREDIR}/libiso8601/leap-table"
[ -z "${CC}" ] && CC="gcc"
[ -z "${CFLAGS}" ] && CFLAGS="-g -O2 -W -Wall"

View File

@ -96,6 +96,8 @@ int iso8601_leap_table_load(const char* fname)
int fd, saved_errno, i, new_size, * days = 0;
char buf[12];
if(!fname) fname = DEFAULT_LEAP_TABLE;
if(stat(fname, &st)) return -1;
if(st.st_size < 12) {
errno = EINVAL;

View File

@ -91,17 +91,19 @@ void iso8601_leap_table_set(int* new_table, int new_size) __attribute__((nonnull
/*! \brief Load new table of leap seconds from disk.
\param fname Filename.
\param fname Filename. May be 0 for system default.
\retval 0 on success.
\retval -1 on error (and see \a errno).
This function attempts to load a new table of leap seconds from disk, using the filename \a fname.
If \a fname is not specified, the system default (set at compile time) will be used.
If the table is loaded successfully, it will be set with \ref iso8601_leap_table_set(). On any
error, -1 will be returned, and \a errno will be set appropriately. If \a errno is \c EINVAL, then
the file does not contain a valid leap second table.
*/
int iso8601_leap_table_load(const char* fname) __attribute__((nonnull));
int iso8601_leap_table_load(const char* fname);

View File

@ -14,7 +14,7 @@ then
libiso8601="obj/${libiso8601_BASE}.so.${SOMAJOR}.${SOMICRO}"
libiso8601_DEP_CFLAGS=""
libiso8601_DEP_LIBS="-lrt"
SO_EXTRA="-std=gnu99 -D_GNU_SOURCE ${libiso8601_DEP_CFLAGS} ${libiso8601_DEP_LIBS} -lc"
SO_EXTRA="-std=gnu99 -D_GNU_SOURCE -DDEFAULT_LEAP_TABLE=\"${DEFAULT_LEAP_TABLE}\" ${libiso8601_DEP_CFLAGS} ${libiso8601_DEP_LIBS} -lc"
echo "Building library ${libiso8601}..."