converter.h   converter.h 
skipping to change at line 21 skipping to change at line 21
#ifndef CV_CONVERTER_H_INCLUDED #ifndef CV_CONVERTER_H_INCLUDED
#define CV_CONVERTER_H_INCLUDED #define CV_CONVERTER_H_INCLUDED
#include <stddef.h> #include <stddef.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifndef EXTERNL
#define EXTERNL extern
#endif
typedef union cv_converter cv_converter; typedef union cv_converter cv_converter;
/* /*
* Returns the trivial converter (i.e., y = x). * Returns the trivial converter (i.e., y = x).
* When finished with the converter, the client should pass the converter t o * When finished with the converter, the client should pass the converter t o
* cv_free(). * cv_free().
* RETURNS: * RETURNS:
* The trivial converter. * The trivial converter.
*/ */
cv_converter* EXTERNL cv_converter*
cv_get_trivial(void); cv_get_trivial(void);
/* /*
* Returns the reciprocal converter (i.e., y = 1/x). * Returns the reciprocal converter (i.e., y = 1/x).
* When finished with the converter, the client should pass the converter t o * When finished with the converter, the client should pass the converter t o
* cv_free(). * cv_free().
* RETURNS: * RETURNS:
* The reciprocal converter. * The reciprocal converter.
*/ */
cv_converter* EXTERNL cv_converter*
cv_get_inverse(void); cv_get_inverse(void);
/* /*
* Returns a scaling converter (i.e., y = ax). * Returns a scaling converter (i.e., y = ax).
* When finished with the converter, the client should pass the converter t o * When finished with the converter, the client should pass the converter t o
* cv_free(). * cv_free().
* RETURNS: * RETURNS:
* The scaling converter. * The scaling converter.
*/ */
cv_converter* EXTERNL cv_converter*
cv_get_scale( cv_get_scale(
const double slope); const double slope);
/* /*
* Returns a converter that adds a number to values (i.e., y = x + b). * Returns a converter that adds a number to values (i.e., y = x + b).
* When finished with the converter, the client should pass the converter t o * When finished with the converter, the client should pass the converter t o
* cv_free(). * cv_free().
* ARGUMENTS: * ARGUMENTS:
* intercept The number to be added. * intercept The number to be added.
* RETURNS: * RETURNS:
* NULL Necessary memory couldn't be allocated. * NULL Necessary memory couldn't be allocated.
* else A converter that adds the given number to values. * else A converter that adds the given number to values.
*/ */
cv_converter* EXTERNL cv_converter*
cv_get_offset( cv_get_offset(
const double intercept); const double intercept);
/* /*
* Returns a Galilean converter (i.e., y = ax + b). * Returns a Galilean converter (i.e., y = ax + b).
* When finished with the converter, the client should pass the converter t o * When finished with the converter, the client should pass the converter t o
* cv_free(). * cv_free().
* ARGUMENTS: * ARGUMENTS:
* slope The number by which to multiply values. * slope The number by which to multiply values.
* intercept The number to be added. * intercept The number to be added.
* RETURNS: * RETURNS:
* NULL Necessary memory couldn't be allocated. * NULL Necessary memory couldn't be allocated.
* else A Galilean converter corresponding to the inputs. * else A Galilean converter corresponding to the inputs.
*/ */
cv_converter* EXTERNL cv_converter*
cv_get_galilean( cv_get_galilean(
const double slope, const double slope,
const double intercept); const double intercept);
/* /*
* Returns a logarithmic converter (i.e., y = log(x) in some base). * Returns a logarithmic converter (i.e., y = log(x) in some base).
* When finished with the converter, the client should pass the converter t o * When finished with the converter, the client should pass the converter t o
* cv_free(). * cv_free().
* ARGUMENTS: * ARGUMENTS:
* base The logarithmic base (e.g., 2, M_E, 10). Must be * base The logarithmic base (e.g., 2, M_E, 10). Must be
* greater than one. * greater than one.
* RETURNS: * RETURNS:
* NULL "base" is not greater than one or necessary * NULL "base" is not greater than one or necessary
* memory couldn't be allocated. * memory couldn't be allocated.
* else A logarithmic converter corresponding to the inputs. * else A logarithmic converter corresponding to the inputs.
*/ */
cv_converter* EXTERNL cv_converter*
cv_get_log( cv_get_log(
const double base); const double base);
/* /*
* Returns an exponential converter (i.e., y = pow(b, x) in some base "b"). * Returns an exponential converter (i.e., y = pow(b, x) in some base "b").
* When finished with the converter, the client should pass the converter t o * When finished with the converter, the client should pass the converter t o
* cv_free(). * cv_free().
* *
* Arguments: * Arguments:
* base The desired base. Must be positive. * base The desired base. Must be positive.
* Returns: * Returns:
* NULL "base" is invalid or necessary memory couldn't be * NULL "base" is invalid or necessary memory couldn't be
* allocated. * allocated.
* else An exponential converter corresponding to the inputs . * else An exponential converter corresponding to the inputs .
*/ */
cv_converter* EXTERNL cv_converter*
cv_get_pow( cv_get_pow(
const double base); const double base);
/* /*
* Returns a converter corresponding to the sequential application of two * Returns a converter corresponding to the sequential application of two
* other converters. * other converters.
* ARGUMENTS: * ARGUMENTS:
* first The converter to be applied first. * first The converter to be applied first.
* second The converter to be applied second. * second The converter to be applied second.
* RETURNS: * RETURNS:
* NULL Either "first" or "second" is NULL or necessary memory could n't * NULL Either "first" or "second" is NULL or necessary memory could n't
* be allocated. * be allocated.
* else A converter corresponding to the sequential application of the * else A converter corresponding to the sequential application of the
* given converters. If one of the input converters is the tr ivial * given converters. If one of the input converters is the tr ivial
* converter, then the returned converter will be the other in put * converter, then the returned converter will be the other in put
* converter. * converter.
*/ */
cv_converter* EXTERNL cv_converter*
cv_combine( cv_combine(
cv_converter* const first, cv_converter* const first,
cv_converter* const second); cv_converter* const second);
/* /*
* Frees resources associated with a converter. * Frees resources associated with a converter.
* ARGUMENTS: * ARGUMENTS:
* conv The converter to have its resources freed or NULL. * conv The converter to have its resources freed or NULL.
*/ */
void EXTERNL void
cv_free( cv_free(
cv_converter* const conv); cv_converter* const conv);
/* /*
* Converts a float. * Converts a float.
* ARGUMENTS: * ARGUMENTS:
* converter The converter. * converter The converter.
* value The value to be converted. * value The value to be converted.
* RETURNS: * RETURNS:
* The converted value. * The converted value.
*/ */
float EXTERNL float
cv_convert_float( cv_convert_float(
const cv_converter* converter, const cv_converter* converter,
const float value); const float value);
/* /*
* Converts a double. * Converts a double.
* ARGUMENTS: * ARGUMENTS:
* converter The converter. * converter The converter.
* value The value to be converted. * value The value to be converted.
* RETURNS: * RETURNS:
* The converted value. * The converted value.
*/ */
double EXTERNL double
cv_convert_double( cv_convert_double(
const cv_converter* converter, const cv_converter* converter,
const double value); const double value);
/* /*
* Converts an array of floats. * Converts an array of floats.
* ARGUMENTS: * ARGUMENTS:
* converter The converter. * converter The converter.
* in The values to be converted. * in The values to be converted.
* count The number of values to be converted. * count The number of values to be converted.
* out The output array for the converted values. May * out The output array for the converted values. May
* be the same array as "in" or overlap it. * be the same array as "in" or overlap it.
* RETURNS: * RETURNS:
* NULL "out" is NULL. * NULL "out" is NULL.
* else A pointer to the output array. * else A pointer to the output array.
*/ */
float* EXTERNL float*
cv_convert_floats( cv_convert_floats(
const cv_converter* converter, const cv_converter* converter,
const float* const in, const float* const in,
const size_t count, const size_t count,
float* out); float* out);
/* /*
* Converts an array of doubles. * Converts an array of doubles.
* ARGUMENTS: * ARGUMENTS:
* converter The converter. * converter The converter.
* in The values to be converted. * in The values to be converted.
* count The number of values to be converted. * count The number of values to be converted.
* out The output array for the converted values. May * out The output array for the converted values. May
* be the same array as "in" or overlap it. * be the same array as "in" or overlap it.
* RETURNS: * RETURNS:
* NULL "out" is NULL. * NULL "out" is NULL.
* else A pointer to the output array. * else A pointer to the output array.
*/ */
double* EXTERNL double*
cv_convert_doubles( cv_convert_doubles(
const cv_converter* converter, const cv_converter* converter,
const double* const in, const double* const in,
const size_t count, const size_t count,
double* out); double* out);
/* /*
* Returns a string representation of a converter. * Returns a string representation of a converter.
* ARGUMENTS: * ARGUMENTS:
* conv The converter. * conv The converter.
* buf The buffer into which to write the expression. * buf The buffer into which to write the expression.
* max The size of the buffer. * max The size of the buffer.
* variable The string to be used as the input value for the * variable The string to be used as the input value for the
* converter. * converter.
* RETURNS * RETURNS
* <0 An error was encountered. * <0 An error was encountered.
* else The number of bytes formatted excluding the terminating null . * else The number of bytes formatted excluding the terminating null .
*/ */
int EXTERNL int
cv_get_expression( cv_get_expression(
const cv_converter* const conv, const cv_converter* const conv,
char* const buf, char* const buf,
size_t max, size_t max,
const char* const variable); const char* const variable);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
 End of changes. 15 change blocks. 
14 lines changed or deleted 18 lines changed or added


 udunits.h   udunits.h 
skipping to change at line 15 skipping to change at line 15
* in the top-level source-directory of the package for copying and * in the top-level source-directory of the package for copying and
* redistribution conditions. * redistribution conditions.
*/ */
/* /*
* Public header-file for the Unidata units(3) library. * Public header-file for the Unidata units(3) library.
*/ */
#ifndef UT_UNITS_H_INCLUDED #ifndef UT_UNITS_H_INCLUDED
#define UT_UNITS_H_INCLUDED #define UT_UNITS_H_INCLUDED
#ifdef _MSC_VER
<io.h>
#define snprintf _snprintf
#define close _close
#define open _open
#define read _read
#endif
#include "udunits2.h" #include "udunits2.h"
#define UT_NAMELEN 32 /* maximum length of a unit string #define UT_NAMELEN 32 /* maximum length of a unit string
* (including all prefixes and EOS) */ * (including all prefixes and EOS) */
/* /*
* Macro for declaring functions regardless of the availability of * Macro for declaring functions regardless of the availability of
* function prototypes. NB: will need double parens in actual use (e.g . * function prototypes. NB: will need double parens in actual use (e.g .
* "int func PROTO((int a, char *cp))"). * "int func PROTO((int a, char *cp))").
*/ */
skipping to change at line 60 skipping to change at line 68
typedef double UtFactor; /* conversion-factor datatype */ typedef double UtFactor; /* conversion-factor datatype */
/* /*
* Unit-structure. Don't rely on or mess with the members! * Unit-structure. Don't rely on or mess with the members!
*/ */
typedef struct utUnit { typedef struct utUnit {
ut_unit* unit2; ut_unit* unit2;
} utUnit; } utUnit;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { EXTERNL "C" {
#endif #endif
/* /*
* Initialize the units(3) package. * Initialize the units(3) package.
*/ */
extern int utInit PROTO(( EXTERNL int utInit PROTO((
const char *path const char *path
)); ));
/* /*
* Indicate if the units(3) package has been initialized. * Indicate if the units(3) package has been initialized.
*/ */
extern int utIsInit PROTO((void)); EXTERNL int utIsInit PROTO((void));
/* /*
* Initialize a unit-structure. * Initialize a unit-structure.
*/ */
extern void utIni PROTO(( EXTERNL void utIni PROTO((
utUnit* const unit utUnit* const unit
)); ));
/* /*
* Decode a formatted unit specification into a unit-structure. * Decode a formatted unit specification into a unit-structure.
*/ */
extern int utScan PROTO(( EXTERNL int utScan PROTO((
const char *spec, const char *spec,
utUnit *up utUnit *up
)); ));
/* /*
* Convert a temporal value into a UTC Gregorian date and time. * Convert a temporal value into a UTC Gregorian date and time.
*/ */
extern int utCalendar PROTO(( EXTERNL int utCalendar PROTO((
double value, double value,
const utUnit *unit, const utUnit *unit,
int *year, int *year,
int *month, int *month,
int *day, int *day,
int *hour, int *hour,
int *minute, int *minute,
float *second float *second
)); ));
/* /*
* Convert a date into a temporal value. The date is assumed to * Convert a date into a temporal value. The date is assumed to
* use the Gregorian calendar if on or after noon, October 15, 1582; * use the Gregorian calendar if on or after noon, October 15, 1582;
* otherwise, the date is assumed to use the Julian calendar. * otherwise, the date is assumed to use the Julian calendar.
*/ */
extern int utInvCalendar PROTO(( EXTERNL int utInvCalendar PROTO((
int year, int year,
int month, int month,
int day, int day,
int hour, int hour,
int minute, int minute,
double second, double second,
const utUnit *unit, const utUnit *unit,
double *value double *value
)); ));
/* /*
* Indicate if a unit structure refers to a unit of time. * Indicate if a unit structure refers to a unit of time.
*/ */
extern int utIsTime PROTO(( EXTERNL int utIsTime PROTO((
const utUnit *up const utUnit *up
)); ));
/* /*
* Indicate if a unit structure has an origin. * Indicate if a unit structure has an origin.
*/ */
extern int utHasOrigin PROTO(( EXTERNL int utHasOrigin PROTO((
const utUnit *up const utUnit *up
)); ));
/* /*
* Clear a unit structure. * Clear a unit structure.
*/ */
extern utUnit* utClear PROTO(( EXTERNL utUnit* utClear PROTO((
utUnit *unit utUnit *unit
)); ));
/* /*
* Copy a unit-strcture. * Copy a unit-strcture.
*/ */
extern utUnit* utCopy PROTO(( EXTERNL utUnit* utCopy PROTO((
const utUnit *source, const utUnit *source,
utUnit *dest utUnit *dest
)); ));
/* /*
* Multiply one unit-structure by another. * Multiply one unit-structure by another.
*/ */
extern utUnit* utMultiply PROTO(( EXTERNL utUnit* utMultiply PROTO((
const utUnit *term1, const utUnit *term1,
const utUnit *term2, const utUnit *term2,
utUnit *result utUnit *result
)); ));
/* /*
* Divide one unit-structure by another. * Divide one unit-structure by another.
*/ */
extern utUnit* utDivide PROTO(( EXTERNL utUnit* utDivide PROTO((
const utUnit *numer, const utUnit *numer,
const utUnit *denom, const utUnit *denom,
utUnit *result utUnit *result
)); ));
/* /*
* Form the reciprocal of a unit-structure. * Form the reciprocal of a unit-structure.
*/ */
extern utUnit* utInvert PROTO(( EXTERNL utUnit* utInvert PROTO((
const utUnit *source, const utUnit *source,
utUnit *dest utUnit *dest
)); ));
/* /*
* Raise a unit-structure to a power. * Raise a unit-structure to a power.
*/ */
extern utUnit* utRaise PROTO(( EXTERNL utUnit* utRaise PROTO((
const utUnit *source, const utUnit *source,
int power, int power,
utUnit *result utUnit *result
)); ));
/* /*
* Shift the origin of a unit-structure by an arithmetic amount. * Shift the origin of a unit-structure by an arithmetic amount.
*/ */
extern utUnit* utShift PROTO(( EXTERNL utUnit* utShift PROTO((
const utUnit *source, const utUnit *source,
double amount, double amount,
utUnit *result utUnit *result
)); ));
/* /*
* Scale a unit-structure. * Scale a unit-structure.
*/ */
extern utUnit* utScale PROTO(( EXTERNL utUnit* utScale PROTO((
const utUnit *source, const utUnit *source,
double factor, double factor,
utUnit *result utUnit *result
)); ));
/* /*
* Compute the conversion factor between two unit-structures. * Compute the conversion factor between two unit-structures.
*/ */
extern int utConvert PROTO(( EXTERNL int utConvert PROTO((
const utUnit *from, const utUnit *from,
const utUnit *to, const utUnit *to,
double *slope, double *slope,
double *intercept double *intercept
)); ));
/* /*
* Encode a unit-structure into a formatted unit-specification. * Encode a unit-structure into a formatted unit-specification.
*/ */
extern int utPrint PROTO(( EXTERNL int utPrint PROTO((
const utUnit *unit, const utUnit *unit,
char **buf char **buf
)); ));
/* /*
* Add a unit-structure to the units-table. * Add a unit-structure to the units-table.
*/ */
extern int utAdd PROTO(( EXTERNL int utAdd PROTO((
char *name, char *name,
int HasPlural, int HasPlural,
const utUnit *unit const utUnit *unit
)); ));
/* /*
* Return the unit-structure corresponding to a unit-specification. * Return the unit-structure corresponding to a unit-specification.
*/ */
extern int utFind PROTO(( EXTERNL int utFind PROTO((
char *spec, char *spec,
utUnit *up utUnit *up
)); ));
/* /*
* Free the resources of a unit-structure. * Free the resources of a unit-structure.
*/ */
extern void utFree PROTO(( EXTERNL void utFree PROTO((
utUnit* const unit utUnit* const unit
)); ));
/* /*
* Terminate use of this package. * Terminate use of this package.
*/ */
extern void utTerm PROTO((void)); EXTERNL void utTerm PROTO((void));
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* UT_UNITS_H_INCLUDED not defined */ #endif /* UT_UNITS_H_INCLUDED not defined */
 End of changes. 24 change blocks. 
23 lines changed or deleted 31 lines changed or added


 udunits2.h   udunits2.h 
skipping to change at line 14 skipping to change at line 14
* This file is part of the UDUNITS-2 package. See the file COPYRIGHT * This file is part of the UDUNITS-2 package. See the file COPYRIGHT
* in the top-level source-directory of the package for copying and * in the top-level source-directory of the package for copying and
* redistribution conditions. * redistribution conditions.
*/ */
#ifndef UT_UNITS2_H_INCLUDED #ifndef UT_UNITS2_H_INCLUDED
#define UT_UNITS2_H_INCLUDED #define UT_UNITS2_H_INCLUDED
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
#ifdef _MSC_VER
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <io.h>
#define _USE_MATH_DEFINES
/* Define a bunch of variables to use the ISO C++ conformant name instead
of the POSIX name. This quiets a lot of the warnings thrown by MSVC. */
#define read _read
#define open _open
#define close _close
#define strdup _strdup
#define strcasecmp stricmp
#define stricmp _stricmp
#define isatty _isatty
//We must accomodate the lack of snprintf in MSVC.
//c99_snprintf is defined in c99_snprintf.c, in lib/.
#define snprintf c99_snprintf
int c99_snprintf(
char* str,
size_t size,
const char* format,
...);
int c99_vsnprintf(
char* str,
size_t size,
const char* format,
va_list ap);
#endif
/* If we are working in Visual Studio and have a
shared library, we will need to do some slight-of-hand
in order to make it generate a proper export library.
*/
#if defined(DLL_UDUNITS2) /* define when library is a DLL */
# if defined(DLL_EXPORT) /* defined when building the library */
# define MSC_EXTRA __declspec(dllexport)
# else
# define MSC_EXTRA __declspec(dllimport)
# endif
#else
# define MSC_EXTRA
#endif /* defined(DLL_UDUNITS2) */
#define EXTERNL MSC_EXTRA extern
#include "converter.h" #include "converter.h"
typedef struct ut_system ut_system; typedef struct ut_system ut_system;
typedef union ut_unit ut_unit; typedef union ut_unit ut_unit;
enum utStatus { enum utStatus {
UT_SUCCESS = 0, /* Success */ UT_SUCCESS = 0, /* Success */
UT_BAD_ARG, /* An argument violates the function's contr act */ UT_BAD_ARG, /* An argument violates the function's contr act */
UT_EXISTS, /* Unit, prefix, or identifier already exists */ UT_EXISTS, /* Unit, prefix, or identifier already exists */
UT_NO_UNIT, /* No such unit exists */ UT_NO_UNIT, /* No such unit exists */
skipping to change at line 139 skipping to change at line 192
* UT_SUCCESS Success. * UT_SUCCESS Success.
* else Failure. * else Failure.
*/ */
ut_status (*visit_logarithmic)(const ut_unit* unit, double base, ut_status (*visit_logarithmic)(const ut_unit* unit, double base,
const ut_unit* reference, void* arg); const ut_unit* reference, void* arg);
} ut_visitor; } ut_visitor;
typedef int (*ut_error_message_handler)(const char* fmt, va_list args); typedef int (*ut_error_message_handler)(const char* fmt, va_list args);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { EXTERNL "C" {
#endif #endif
/************************************************************************** **** /************************************************************************** ****
* Unit System: * Unit System:
************************************************************************** ****/ ************************************************************************** ****/
/** /**
* Returns the pathname of the XML database. * Returns the pathname of the XML database.
* *
* @param path The pathname of the XML file or NULL. * @param path The pathname of the XML file or NULL.
* @param status Status. One of UT_OPEN_ARG, UT_OPEN_ENV, or UT_OPEN_DEF AULT. * @param status Status. One of UT_OPEN_ARG, UT_OPEN_ENV, or UT_OPEN_DEF AULT.
* @return If "path" is not NULL, then it is returned; otherwise, the * @return If "path" is not NULL, then it is returned; otherwise, the
* pathname specified by the environment variable * pathname specified by the environment variable
* UDUNITS2_XML_PATH is returned if set; otherwise, the * UDUNITS2_XML_PATH is returned if set; otherwise, the
* compile-time pathname of the installed, default, unit * compile-time pathname of the installed, default, unit
* database is returned. * database is returned.
*/ */
const char* EXTERNL const char*
ut_get_path_xml( ut_get_path_xml(
const char* path, const char* path,
ut_status* status); ut_status* status);
/* /*
* Returns the unit-system corresponding to an XML file. This is the usual way * Returns the unit-system corresponding to an XML file. This is the usual way
* that a client will obtain a unit-system. * that a client will obtain a unit-system.
* *
* Arguments: * Arguments:
* path The pathname of the XML file or NULL. If NULL, then the * path The pathname of the XML file or NULL. If NULL, then the
skipping to change at line 188 skipping to change at line 241
* reason. * reason.
* UT_OPEN_DEFAULT "path" is NULL, environment variable * UT_OPEN_DEFAULT "path" is NULL, environment variable
* UDUNITS2_XML_PATH is unset, and the * UDUNITS2_XML_PATH is unset, and the
* installed, default, unit database * installed, default, unit database
* couldn't be opened. See "errno" for * couldn't be opened. See "errno" for
* reason. * reason.
* UT_PARSE Couldn't parse unit database. * UT_PARSE Couldn't parse unit database.
* UT_OS Operating-system error. See "errno" . * UT_OS Operating-system error. See "errno" .
* else Pointer to the unit-system defined by "path". * else Pointer to the unit-system defined by "path".
*/ */
ut_system* EXTERNL ut_system*
ut_read_xml( ut_read_xml(
const char* path); const char* path);
/* /*
* Returns a new unit-system. On success, the unit-system will only contai n * Returns a new unit-system. On success, the unit-system will only contai n
* the dimensionless unit one. See "ut_get_dimensionless_unit_one()". * the dimensionless unit one. See "ut_get_dimensionless_unit_one()".
* *
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be: * NULL Failure. "ut_get_status()" will be:
* UT_OS Operating-system error. See "errno". * UT_OS Operating-system error. See "errno".
* else Pointer to a new unit system. * else Pointer to a new unit system.
*/ */
ut_system* EXTERNL ut_system*
ut_new_system(void); ut_new_system(void);
/* /*
* Frees a unit-system. All unit-to-identifier and identifier-to-unit mapp ings * Frees a unit-system. All unit-to-identifier and identifier-to-unit mapp ings
* will be removed. * will be removed.
* *
* Arguments: * Arguments:
* system Pointer to the unit-system to be freed. Use of "sys tem" * system Pointer to the unit-system to be freed. Use of "sys tem"
* upon return results in undefined behavior. * upon return results in undefined behavior.
*/ */
void EXTERNL void
ut_free_system( ut_free_system(
ut_system* system); ut_system* system);
/* /*
* Returns the unit-system to which a unit belongs. * Returns the unit-system to which a unit belongs.
* *
* Arguments: * Arguments:
* unit Pointer to the unit in question. * unit Pointer to the unit in question.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be * NULL Failure. "ut_get_status()" will be
* UT_BAD_ARG "unit" is NULL. * UT_BAD_ARG "unit" is NULL.
* else Pointer to the unit-system to which "unit" belongs. * else Pointer to the unit-system to which "unit" belongs.
*/ */
ut_system* EXTERNL ut_system*
ut_get_system( ut_get_system(
const ut_unit* const unit); const ut_unit* const unit);
/* /*
* Returns the dimensionless-unit one of a unit-system. * Returns the dimensionless-unit one of a unit-system.
* *
* Arguments: * Arguments:
* system Pointer to the unit-system for which the dimensionless-unit one * system Pointer to the unit-system for which the dimensionless-unit one
* will be returned. * will be returned.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be: * NULL Failure. "ut_get_status()" will be:
* UT_BAD_ARG "system" is NULL. * UT_BAD_ARG "system" is NULL.
* else Pointer to the dimensionless-unit one associated with "syste m". * else Pointer to the dimensionless-unit one associated with "syste m".
* While not necessary, the pointer may be passed to ut_free() * While not necessary, the pointer may be passed to ut_free()
* when the unit is no longer needed by the client. * when the unit is no longer needed by the client.
*/ */
ut_unit* EXTERNL ut_unit*
ut_get_dimensionless_unit_one( ut_get_dimensionless_unit_one(
const ut_system* const system); const ut_system* const system);
/* /*
* Returns the unit with a given name from a unit-system. Name comparisons * Returns the unit with a given name from a unit-system. Name comparisons
* are case-insensitive. * are case-insensitive.
* *
* Arguments: * Arguments:
* system Pointer to the unit-system. * system Pointer to the unit-system.
* name Pointer to the name of the unit to be returned. * name Pointer to the name of the unit to be returned.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be * NULL Failure. "ut_get_status()" will be
* UT_SUCCESS "name" doesn't map to a unit of * UT_SUCCESS "name" doesn't map to a unit of
* "system". * "system".
* UT_BAD_ARG "system" or "name" is NULL. * UT_BAD_ARG "system" or "name" is NULL.
* else Pointer to the unit of the unit-system with the given name. * else Pointer to the unit of the unit-system with the given name.
* The pointer should be passed to ut_free() when the unit is * The pointer should be passed to ut_free() when the unit is
* no longer needed. * no longer needed.
*/ */
ut_unit* EXTERNL ut_unit*
ut_get_unit_by_name( ut_get_unit_by_name(
const ut_system* const system, const ut_system* const system,
const char* const name); const char* const name);
/* /*
* Returns the unit with a given symbol from a unit-system. Symbol * Returns the unit with a given symbol from a unit-system. Symbol
* comparisons are case-sensitive. * comparisons are case-sensitive.
* *
* Arguments: * Arguments:
* system Pointer to the unit-system. * system Pointer to the unit-system.
skipping to change at line 285 skipping to change at line 338
* returned. * returned.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be * NULL Failure. "ut_get_status()" will be
* UT_SUCCESS "symbol" doesn't map to a unit of * UT_SUCCESS "symbol" doesn't map to a unit of
* "system". * "system".
* UT_BAD_ARG "system" or "symbol" is NULL. * UT_BAD_ARG "system" or "symbol" is NULL.
* else Pointer to the unit in the unit-system with the given symbol . * else Pointer to the unit in the unit-system with the given symbol .
* The pointer should be passed to ut_free() when the unit is n o * The pointer should be passed to ut_free() when the unit is n o
* longer needed. * longer needed.
*/ */
ut_unit* EXTERNL ut_unit*
ut_get_unit_by_symbol( ut_get_unit_by_symbol(
const ut_system* const system, const ut_system* const system,
const char* const symbol); const char* const symbol);
/* /*
* Sets the "second" unit of a unit-system. This function must be called b efore * Sets the "second" unit of a unit-system. This function must be called b efore
* the first call to "ut_offset_by_time()". ut_read_xml() calls this functi on if the * the first call to "ut_offset_by_time()". ut_read_xml() calls this functi on if the
* resulting unit-system contains a unit named "second". * resulting unit-system contains a unit named "second".
* *
* Arguments: * Arguments:
* second Pointer to the "second" unit. * second Pointer to the "second" unit.
* Returns: * Returns:
* UT_BAD_ARG "second" is NULL. * UT_BAD_ARG "second" is NULL.
* UT_EXISTS The second unit of the unit-system to which "second" * UT_EXISTS The second unit of the unit-system to which "second"
* belongs is set to a different unit. * belongs is set to a different unit.
* UT_SUCCESS Success. * UT_SUCCESS Success.
*/ */
ut_status EXTERNL ut_status
ut_set_second( ut_set_second(
const ut_unit* const second); const ut_unit* const second);
/************************************************************************** **** /************************************************************************** ****
* Defining Unit Prefixes: * Defining Unit Prefixes:
************************************************************************** ****/ ************************************************************************** ****/
/* /*
* Adds a name-prefix to a unit-system. A name-prefix is something like "m ega" * Adds a name-prefix to a unit-system. A name-prefix is something like "m ega"
* or "milli". Comparisons between name-prefixes are case-insensitive. * or "milli". Comparisons between name-prefixes are case-insensitive.
skipping to change at line 326 skipping to change at line 379
* system Pointer to the unit-system. * system Pointer to the unit-system.
* name Pointer to the name-prefix (e.g., "mega"). May be f reed * name Pointer to the name-prefix (e.g., "mega"). May be f reed
* upon return. * upon return.
* value The value of the prefix (e.g., 1e6). * value The value of the prefix (e.g., 1e6).
* Returns: * Returns:
* UT_SUCCESS Success. * UT_SUCCESS Success.
* UT_BAD_ARG "system" or "name" is NULL, or "value" is 0. * UT_BAD_ARG "system" or "name" is NULL, or "value" is 0.
* UT_EXISTS "name" already maps to a different value. * UT_EXISTS "name" already maps to a different value.
* UT_OS Operating-system failure. See "errno". * UT_OS Operating-system failure. See "errno".
*/ */
ut_status EXTERNL ut_status
ut_add_name_prefix( ut_add_name_prefix(
ut_system* const system, ut_system* const system,
const char* const name, const char* const name,
const double value); const double value);
/* /*
* Adds a symbol-prefix to a unit-system. A symbol-prefix is something lik e * Adds a symbol-prefix to a unit-system. A symbol-prefix is something lik e
* "M" or "y". Comparisons between symbol-prefixes are case-sensitive. * "M" or "y". Comparisons between symbol-prefixes are case-sensitive.
* *
* Arguments: * Arguments:
skipping to change at line 348 skipping to change at line 401
* symbol Pointer to the symbol-prefix (e.g., "M"). May be fr eed * symbol Pointer to the symbol-prefix (e.g., "M"). May be fr eed
* upon return. * upon return.
* value The value of the prefix (e.g., 1e6). * value The value of the prefix (e.g., 1e6).
* Returns: * Returns:
* UT_SUCCESS Success. * UT_SUCCESS Success.
* UT_BADSYSTEM "system" or "symbol" is NULL. * UT_BADSYSTEM "system" or "symbol" is NULL.
* UT_BAD_ARG "value" is 0. * UT_BAD_ARG "value" is 0.
* UT_EXISTS "symbol" already maps to a different value. * UT_EXISTS "symbol" already maps to a different value.
* UT_OS Operating-system failure. See "errno". * UT_OS Operating-system failure. See "errno".
*/ */
ut_status EXTERNL ut_status
ut_add_symbol_prefix( ut_add_symbol_prefix(
ut_system* const system, ut_system* const system,
const char* const symbol, const char* const symbol,
const double value); const double value);
/************************************************************************** **** /************************************************************************** ****
* Defining and Deleting Units: * Defining and Deleting Units:
************************************************************************** ****/ ************************************************************************** ****/
/* /*
skipping to change at line 372 skipping to change at line 425
* Arguments: * Arguments:
* system Pointer to the unit-system to which to add the new base-unit . * system Pointer to the unit-system to which to add the new base-unit .
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be * NULL Failure. "ut_get_status()" will be
* UT_BAD_ARG "system" or "name" is NULL. * UT_BAD_ARG "system" or "name" is NULL.
* UT_OS Operating-system error. See "errno" . * UT_OS Operating-system error. See "errno" .
* else Pointer to the new base-unit. The pointer should be passed to * else Pointer to the new base-unit. The pointer should be passed to
* ut_free() when the unit is no longer needed by the client (t he * ut_free() when the unit is no longer needed by the client (t he
* unit will remain in the unit-system). * unit will remain in the unit-system).
*/ */
ut_unit* EXTERNL ut_unit*
ut_new_base_unit( ut_new_base_unit(
ut_system* const system); ut_system* const system);
/* /*
* Adds a dimensionless-unit to a unit-system. In the SI system of units, the * Adds a dimensionless-unit to a unit-system. In the SI system of units, the
* derived-unit radian is a dimensionless-unit. Clients that use ut_read_x ml() * derived-unit radian is a dimensionless-unit. Clients that use ut_read_x ml()
* should not normally need to call this function. * should not normally need to call this function.
* *
* Arguments: * Arguments:
* system Pointer to the unit-system to which to add the new * system Pointer to the unit-system to which to add the new
* dimensionless-unit. * dimensionless-unit.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be * NULL Failure. "ut_get_status()" will be
* UT_BAD_ARG "system" is NULL. * UT_BAD_ARG "system" is NULL.
* UT_OS Operating-system error. See "errno" . * UT_OS Operating-system error. See "errno" .
* else Pointer to the new dimensionless-unit. The pointer should b e * else Pointer to the new dimensionless-unit. The pointer should b e
* passed to ut_free() when the unit is no longer needed by the * passed to ut_free() when the unit is no longer needed by the
* client (the unit will remain in the unit-system). * client (the unit will remain in the unit-system).
*/ */
ut_unit* EXTERNL ut_unit*
ut_new_dimensionless_unit( ut_new_dimensionless_unit(
ut_system* const system); ut_system* const system);
/* /*
* Returns a clone of a unit. * Returns a clone of a unit.
* *
* Arguments: * Arguments:
* unit Pointer to the unit to be cloned. * unit Pointer to the unit to be cloned.
* Returns: * Returns:
* NULL Failure. ut_get_status() will be * NULL Failure. ut_get_status() will be
* UT_OS Operating-system failure. See "errno". * UT_OS Operating-system failure. See "errno".
* UT_BAD_ARG "unit" is NULL. * UT_BAD_ARG "unit" is NULL.
* else Pointer to the clone of "unit". The pointer should be * else Pointer to the clone of "unit". The pointer should be
* passed to ut_free() when the unit is no longer needed by the * passed to ut_free() when the unit is no longer needed by the
* client. * client.
*/ */
ut_unit* EXTERNL ut_unit*
ut_clone( ut_clone(
const ut_unit* unit); const ut_unit* unit);
/* /*
* Frees resources associated with a unit. This function should be invoked on * Frees resources associated with a unit. This function should be invoked on
* all units that are no longer needed by the client. Use of the unit upon * all units that are no longer needed by the client. Use of the unit upon
* return from this function will result in undefined behavior. * return from this function will result in undefined behavior.
* *
* Arguments: * Arguments:
* unit Pointer to the unit to have its resources freed or NULL. * unit Pointer to the unit to have its resources freed or NULL.
*/ */
void EXTERNL void
ut_free( ut_free(
ut_unit* const unit); ut_unit* const unit);
/************************************************************************** **** /************************************************************************** ****
* Mapping between Units and Names: * Mapping between Units and Names:
************************************************************************** ****/ ************************************************************************** ****/
/* /*
* Returns the name in a given encoding to which a unit maps. * Returns the name in a given encoding to which a unit maps.
* *
skipping to change at line 443 skipping to change at line 496
* unit Pointer to the unit whose name should be returned. * unit Pointer to the unit whose name should be returned.
* encoding The desired encoding of the name. * encoding The desired encoding of the name.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be * NULL Failure. "ut_get_status()" will be
* UT_BAD_ARG "unit" is NULL. * UT_BAD_ARG "unit" is NULL.
* UT_SUCCESS "unit" doesn't map to a name in * UT_SUCCESS "unit" doesn't map to a name in
* in the given encoding. * in the given encoding.
* else Pointer to the name in the given encoding to which * else Pointer to the name in the given encoding to which
* "unit" maps. * "unit" maps.
*/ */
const char* EXTERNL const char*
ut_get_name( ut_get_name(
const ut_unit* const unit, const ut_unit* const unit,
const ut_encoding encoding); const ut_encoding encoding);
/* /*
* Adds a mapping from a name to a unit. * Adds a mapping from a name to a unit.
* *
* Arguments: * Arguments:
* name Pointer to the name to be mapped to "unit". May be * name Pointer to the name to be mapped to "unit". May be
* freed upon return. * freed upon return.
* encoding The character encoding of "name". * encoding The character encoding of "name".
* unit Pointer to the unit to be mapped-to by "name". May be * unit Pointer to the unit to be mapped-to by "name". May be
* freed upon return. * freed upon return.
* Returns: * Returns:
* UT_BAD_ARG "name" or "unit" is NULL. * UT_BAD_ARG "name" or "unit" is NULL.
* UT_OS Operating-system error. See "errno". * UT_OS Operating-system error. See "errno".
* UT_EXISTS "name" already maps to a different unit. * UT_EXISTS "name" already maps to a different unit.
* UT_SUCCESS Success. * UT_SUCCESS Success.
*/ */
ut_status EXTERNL ut_status
ut_map_name_to_unit( ut_map_name_to_unit(
const char* const name, const char* const name,
const ut_encoding encoding, const ut_encoding encoding,
const ut_unit* const unit); const ut_unit* const unit);
/* /*
* Removes a mapping from a name to a unit. After this function, * Removes a mapping from a name to a unit. After this function,
* ut_get_unit_by_name(system,name) will no longer return a unit. * ut_get_unit_by_name(system,name) will no longer return a unit.
* *
* Arguments: * Arguments:
* system The unit-system to which the unit belongs. * system The unit-system to which the unit belongs.
* name The name of the unit. * name The name of the unit.
* encoding The character encoding of "name". * encoding The character encoding of "name".
* Returns: * Returns:
* UT_SUCCESS Success. * UT_SUCCESS Success.
* UT_BAD_ARG "system" or "name" is NULL. * UT_BAD_ARG "system" or "name" is NULL.
*/ */
ut_status EXTERNL ut_status
ut_unmap_name_to_unit( ut_unmap_name_to_unit(
ut_system* system, ut_system* system,
const char* const name, const char* const name,
const ut_encoding encoding); const ut_encoding encoding);
/* /*
* Adds a mapping from a unit to a name. * Adds a mapping from a unit to a name.
* *
* Arguments: * Arguments:
* unit Pointer to the unit to be mapped to "name". May be * unit Pointer to the unit to be mapped to "name". May be
skipping to change at line 503 skipping to change at line 556
* name Pointer to the name to be mapped-to by "unit". May be * name Pointer to the name to be mapped-to by "unit". May be
* freed upon return. * freed upon return.
* encoding The encoding of "name". * encoding The encoding of "name".
* Returns: * Returns:
* UT_SUCCESS Success. * UT_SUCCESS Success.
* UT_BAD_ARG "unit" or "name" is NULL, or "name" is not in the * UT_BAD_ARG "unit" or "name" is NULL, or "name" is not in the
* specified encoding. * specified encoding.
* UT_OS Operating-system error. See "errno". * UT_OS Operating-system error. See "errno".
* UT_EXISTS "unit" already maps to a name. * UT_EXISTS "unit" already maps to a name.
*/ */
ut_status EXTERNL ut_status
ut_map_unit_to_name( ut_map_unit_to_name(
const ut_unit* const unit, const ut_unit* const unit,
const char* const name, const char* const name,
ut_encoding encoding); ut_encoding encoding);
/* /*
* Removes a mapping from a unit to a name. * Removes a mapping from a unit to a name.
* *
* Arguments: * Arguments:
* unit Pointer to the unit. May be freed upon return. * unit Pointer to the unit. May be freed upon return.
* encoding The encoding to be removed. No other encodings will be * encoding The encoding to be removed. No other encodings will be
* removed. * removed.
* Returns: * Returns:
* UT_BAD_ARG "unit" is NULL. * UT_BAD_ARG "unit" is NULL.
* UT_SUCCESS Success. * UT_SUCCESS Success.
*/ */
ut_status EXTERNL ut_status
ut_unmap_unit_to_name( ut_unmap_unit_to_name(
const ut_unit* const unit, const ut_unit* const unit,
ut_encoding encoding); ut_encoding encoding);
/************************************************************************** **** /************************************************************************** ****
* Mapping between Units and Symbols: * Mapping between Units and Symbols:
************************************************************************** ****/ ************************************************************************** ****/
/* /*
* Returns the symbol in a given encoding to which a unit maps. * Returns the symbol in a given encoding to which a unit maps.
skipping to change at line 543 skipping to change at line 596
* unit Pointer to the unit whose symbol should be returned. * unit Pointer to the unit whose symbol should be returned.
* encoding The desired encoding of the symbol. * encoding The desired encoding of the symbol.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be * NULL Failure. "ut_get_status()" will be
* UT_BAD_ARG "unit" is NULL. * UT_BAD_ARG "unit" is NULL.
* UT_SUCCESS "unit" doesn't map to a symb ol * UT_SUCCESS "unit" doesn't map to a symb ol
* in the given encoding. * in the given encoding.
* else Pointer to the symbol in the given encoding to which * else Pointer to the symbol in the given encoding to which
* "unit" maps. * "unit" maps.
*/ */
const char* EXTERNL const char*
ut_get_symbol( ut_get_symbol(
const ut_unit* const unit, const ut_unit* const unit,
const ut_encoding encoding); const ut_encoding encoding);
/* /*
* Adds a mapping from a symbol to a unit. * Adds a mapping from a symbol to a unit.
* *
* Arguments: * Arguments:
* symbol Pointer to the symbol to be mapped to "unit". May b e * symbol Pointer to the symbol to be mapped to "unit". May b e
* freed upon return. * freed upon return.
* ut_encoding The character encoding of "symbol". * ut_encoding The character encoding of "symbol".
* unit Pointer to the unit to be mapped-to by "symbol". Ma y * unit Pointer to the unit to be mapped-to by "symbol". Ma y
* be freed upon return. * be freed upon return.
* Returns: * Returns:
* UT_BAD_ARG "symbol" or "unit" is NULL. * UT_BAD_ARG "symbol" or "unit" is NULL.
* UT_OS Operating-system error. See "errno". * UT_OS Operating-system error. See "errno".
* UT_EXISTS "symbol" already maps to a different unit. * UT_EXISTS "symbol" already maps to a different unit.
* UT_SUCCESS Success. * UT_SUCCESS Success.
*/ */
ut_status EXTERNL ut_status
ut_map_symbol_to_unit( ut_map_symbol_to_unit(
const char* const symbol, const char* const symbol,
const ut_encoding encoding, const ut_encoding encoding,
const ut_unit* const unit); const ut_unit* const unit);
/* /*
* Removes a mapping from a symbol to a unit. After this function, * Removes a mapping from a symbol to a unit. After this function,
* ut_get_unit_by_symbol(system,symbol) will no longer return a unit. * ut_get_unit_by_symbol(system,symbol) will no longer return a unit.
* *
* Arguments: * Arguments:
* system The unit-system to which the unit belongs. * system The unit-system to which the unit belongs.
* symbol The symbol of the unit. * symbol The symbol of the unit.
* encoding The character encoding of "symbol". * encoding The character encoding of "symbol".
* Returns: * Returns:
* UT_SUCCESS Success. * UT_SUCCESS Success.
* UT_BAD_ARG "system" or "symbol" is NULL. * UT_BAD_ARG "system" or "symbol" is NULL.
*/ */
ut_status EXTERNL ut_status
ut_unmap_symbol_to_unit( ut_unmap_symbol_to_unit(
ut_system* system, ut_system* system,
const char* const symbol, const char* const symbol,
const ut_encoding encoding); const ut_encoding encoding);
/* /*
* Adds a mapping from a unit to a symbol. * Adds a mapping from a unit to a symbol.
* *
* Arguments: * Arguments:
* unit Pointer to the unit to be mapped to "symbol". May b e * unit Pointer to the unit to be mapped to "symbol". May b e
* freed upon return. * freed upon return.
* symbol Pointer to the symbol to be mapped-to by "unit". Ma y * symbol Pointer to the symbol to be mapped-to by "unit". Ma y
* be freed upon return. * be freed upon return.
* encoding The encoding of "symbol". * encoding The encoding of "symbol".
* Returns: * Returns:
* UT_SUCCESS Success. * UT_SUCCESS Success.
* UT_BAD_ARG "unit" or "symbol" is NULL. * UT_BAD_ARG "unit" or "symbol" is NULL.
* UT_OS Operating-system error. See "errno". * UT_OS Operating-system error. See "errno".
* UT_EXISTS "unit" already maps to a symbol. * UT_EXISTS "unit" already maps to a symbol.
*/ */
ut_status EXTERNL ut_status
ut_map_unit_to_symbol( ut_map_unit_to_symbol(
const ut_unit* unit, const ut_unit* unit,
const char* const symbol, const char* const symbol,
ut_encoding encoding); ut_encoding encoding);
/* /*
* Removes a mapping from a unit to a symbol. * Removes a mapping from a unit to a symbol.
* *
* Arguments: * Arguments:
* unit Pointer to the unit to be unmapped to a symbol. May be * unit Pointer to the unit to be unmapped to a symbol. May be
* freed upon return. * freed upon return.
* encoding The encoding to be removed. The mappings for "unit" in * encoding The encoding to be removed. The mappings for "unit" in
* other encodings will not be removed. * other encodings will not be removed.
* Returns: * Returns:
* UT_SUCCESS Success. * UT_SUCCESS Success.
* UT_BAD_ARG "unit" is NULL. * UT_BAD_ARG "unit" is NULL.
*/ */
ut_status EXTERNL ut_status
ut_unmap_unit_to_symbol( ut_unmap_unit_to_symbol(
const ut_unit* const unit, const ut_unit* const unit,
ut_encoding encoding); ut_encoding encoding);
/************************************************************************** **** /************************************************************************** ****
* Getting Information about a Unit: * Getting Information about a Unit:
************************************************************************** ****/ ************************************************************************** ****/
/* /*
* Indicates if a given unit is dimensionless or not. Note that logarithmi c * Indicates if a given unit is dimensionless or not. Note that logarithmi c
skipping to change at line 642 skipping to change at line 695
* *
* Arguments: * Arguments:
* unit Pointer to the unit in question. * unit Pointer to the unit in question.
* Returns: * Returns:
* 0 "unit" is dimensionfull or an error occurred. "ut_get_statu s()" * 0 "unit" is dimensionfull or an error occurred. "ut_get_statu s()"
* will be * will be
* UT_BAD_ARG "unit" is NULL. * UT_BAD_ARG "unit" is NULL.
* UT_SUCCESS "unit" is dimensionfull. * UT_SUCCESS "unit" is dimensionfull.
* else "unit" is dimensionless. * else "unit" is dimensionless.
*/ */
int EXTERNL int
ut_is_dimensionless( ut_is_dimensionless(
const ut_unit* const unit); const ut_unit* const unit);
/* /*
* Indicates if two units belong to the same unit-system. * Indicates if two units belong to the same unit-system.
* *
* Arguments: * Arguments:
* unit1 Pointer to a unit. * unit1 Pointer to a unit.
* unit2 Pointer to another unit. * unit2 Pointer to another unit.
* Returns: * Returns:
* 0 Failure or the units belong to different unit-system s. * 0 Failure or the units belong to different unit-system s.
* "ut_get_status()" will be * "ut_get_status()" will be
* UT_BAD_ARG "unit1" or "unit2" is NULL. * UT_BAD_ARG "unit1" or "unit2" is NULL.
* UT_SUCCESS The units belong to differen t * UT_SUCCESS The units belong to differen t
* unit-systems. * unit-systems.
* else The units belong to the same unit-system. * else The units belong to the same unit-system.
*/ */
int EXTERNL int
ut_same_system( ut_same_system(
const ut_unit* const unit1, const ut_unit* const unit1,
const ut_unit* const unit2); const ut_unit* const unit2);
/* /*
* Compares two units. Returns a value less than, equal to, or greater tha n * Compares two units. Returns a value less than, equal to, or greater tha n
* zero as the first unit is considered less than, equal to, or greater tha n * zero as the first unit is considered less than, equal to, or greater tha n
* the second unit, respectively. Units from different unit-systems never * the second unit, respectively. Units from different unit-systems never
* compare equal. * compare equal.
* *
* Arguments: * Arguments:
* unit1 Pointer to a unit or NULL. * unit1 Pointer to a unit or NULL.
* unit2 Pointer to another unit or NULL. * unit2 Pointer to another unit or NULL.
* Returns: * Returns:
* <0 The first unit is less than the second unit. * <0 The first unit is less than the second unit.
* 0 The first and second units are equal or both units are NULL. * 0 The first and second units are equal or both units are NULL.
* >0 The first unit is greater than the second unit. * >0 The first unit is greater than the second unit.
*/ */
int EXTERNL int
ut_compare( ut_compare(
const ut_unit* const unit1, const ut_unit* const unit1,
const ut_unit* const unit2); const ut_unit* const unit2);
/* /*
* Indicates if numeric values in one unit are convertible to numeric value s in * Indicates if numeric values in one unit are convertible to numeric value s in
* another unit via "ut_get_converter()". In making this determination, * another unit via "ut_get_converter()". In making this determination,
* dimensionless units are ignored. * dimensionless units are ignored.
* *
* Arguments: * Arguments:
skipping to change at line 703 skipping to change at line 756
* 0 Failure. "ut_get_status()" will be * 0 Failure. "ut_get_status()" will be
* UT_BAD_ARG "unit1" or "unit2" is NULL. * UT_BAD_ARG "unit1" or "unit2" is NULL.
* UT_NOT_SAME_SYSTEM "unit1" and "unit2" belong t o * UT_NOT_SAME_SYSTEM "unit1" and "unit2" belong t o
* different unit-sytems. * different unit-sytems.
* UT_SUCCESS Conversion between the units is * UT_SUCCESS Conversion between the units is
* not possible (e.g., "unit1" is * not possible (e.g., "unit1" is
* "meter" and "unit2" is * "meter" and "unit2" is
* "kilogram"). * "kilogram").
* else Numeric values can be converted between the units. * else Numeric values can be converted between the units.
*/ */
int EXTERNL int
ut_are_convertible( ut_are_convertible(
const ut_unit* const unit1, const ut_unit* const unit1,
const ut_unit* const unit2); const ut_unit* const unit2);
/* /*
* Returns a converter of numeric values in one unit to numeric values in * Returns a converter of numeric values in one unit to numeric values in
* another unit. The returned converter should be passed to cv_free() when it is * another unit. The returned converter should be passed to cv_free() when it is
* no longer needed by the client. * no longer needed by the client.
* *
* NOTE: Leap seconds are not taken into account when converting between * NOTE: Leap seconds are not taken into account when converting between
skipping to change at line 731 skipping to change at line 784
* UT_BAD_ARG "from" or "to" is NULL. * UT_BAD_ARG "from" or "to" is NULL.
* UT_NOT_SAME_SYSTEM "from" and "to" belong to * UT_NOT_SAME_SYSTEM "from" and "to" belong to
* different unit-systems. * different unit-systems.
* UT_MEANINGLESS Conversion between the units is * UT_MEANINGLESS Conversion between the units is
* not possible. See * not possible. See
* "ut_are_convertible()". * "ut_are_convertible()".
* else Pointer to the appropriate converter. The pointer * else Pointer to the appropriate converter. The pointer
* should be passed to cv_free() when no longer needed by * should be passed to cv_free() when no longer needed by
* the client. * the client.
*/ */
cv_converter* EXTERNL cv_converter*
ut_get_converter( ut_get_converter(
ut_unit* const from, ut_unit* const from,
ut_unit* const to); ut_unit* const to);
/************************************************************************** **** /************************************************************************** ****
* Arithmetic Unit Manipulation: * Arithmetic Unit Manipulation:
************************************************************************** ****/ ************************************************************************** ****/
/* /*
* Returns a unit equivalent to another unit scaled by a numeric factor, * Returns a unit equivalent to another unit scaled by a numeric factor,
skipping to change at line 758 skipping to change at line 811
* unit Pointer to the unit to be scaled. * unit Pointer to the unit to be scaled.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be * NULL Failure. "ut_get_status()" will be
* UT_BAD_ARG "factor" is 0 or "unit" is N ULL. * UT_BAD_ARG "factor" is 0 or "unit" is N ULL.
* UT_OS Operating-system error. See * UT_OS Operating-system error. See
* "errno". * "errno".
* else Pointer to the resulting unit. The pointer should b e * else Pointer to the resulting unit. The pointer should b e
* passed to ut_free() when the unit is no longer neede d by * passed to ut_free() when the unit is no longer neede d by
* the client. * the client.
*/ */
ut_unit* EXTERNL ut_unit*
ut_scale( ut_scale(
const double factor, const double factor,
const ut_unit* const unit); const ut_unit* const unit);
/* /*
* Returns a unit equivalent to another unit offset by a numeric amount, * Returns a unit equivalent to another unit offset by a numeric amount,
* e.g., * e.g.,
* const ut_unit* kelvin = ... * const ut_unit* kelvin = ...
* const ut_unit* celsius = ut_offset(kelvin, 273.15); * const ut_unit* celsius = ut_offset(kelvin, 273.15);
* *
skipping to change at line 781 skipping to change at line 834
* offset The numeric offset. * offset The numeric offset.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be * NULL Failure. "ut_get_status()" will be
* UT_BAD_ARG "unit" is NULL. * UT_BAD_ARG "unit" is NULL.
* UT_OS Operating-system error. See * UT_OS Operating-system error. See
* "errno". * "errno".
* else Pointer to the resulting unit. The pointer should b e * else Pointer to the resulting unit. The pointer should b e
* passed to ut_free() when the unit is no longer neede d by * passed to ut_free() when the unit is no longer neede d by
* the client. * the client.
*/ */
ut_unit* EXTERNL ut_unit*
ut_offset( ut_offset(
const ut_unit* const unit, const ut_unit* const unit,
const double offset); const double offset);
/* /*
* Returns a unit equivalent to another unit relative to a particular time. * Returns a unit equivalent to another unit relative to a particular time.
* e.g., * e.g.,
* const ut_unit* second = ... * const ut_unit* second = ...
* const ut_unit* secondsSinceTheEpoch = * const ut_unit* secondsSinceTheEpoch =
* ut_offset_by_time(second, ut_encode_time(1970, 1, 1, 0, 0, 0.0)); * ut_offset_by_time(second, ut_encode_time(1970, 1, 1, 0, 0, 0.0));
skipping to change at line 808 skipping to change at line 861
* UT_BAD_ARG "unit" is NULL. * UT_BAD_ARG "unit" is NULL.
* UT_OS Operating-system error. See "errno" . * UT_OS Operating-system error. See "errno" .
* UT_MEANINGLESS Creation of a timestamp unit based o n * UT_MEANINGLESS Creation of a timestamp unit based o n
* "unit" is not meaningful. * "unit" is not meaningful.
* UT_NO_SECOND The associated unit-system doesn't * UT_NO_SECOND The associated unit-system doesn't
* contain a "second" unit. See * contain a "second" unit. See
* ut_set_second(). * ut_set_second().
* else Pointer to the resulting unit. The pointer should be passed * else Pointer to the resulting unit. The pointer should be passed
* to ut_free() when the unit is no longer needed by the client . * to ut_free() when the unit is no longer needed by the client .
*/ */
ut_unit* EXTERNL ut_unit*
ut_offset_by_time( ut_offset_by_time(
const ut_unit* const unit, const ut_unit* const unit,
const double origin); const double origin);
/* /*
* Returns the result of multiplying one unit by another unit. * Returns the result of multiplying one unit by another unit.
* *
* Arguments: * Arguments:
* unit1 Pointer to a unit. * unit1 Pointer to a unit.
* unit2 Pointer to another unit. * unit2 Pointer to another unit.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be: * NULL Failure. "ut_get_status()" will be:
* UT_BAD_ARG "unit1" or "unit2" is NULL. * UT_BAD_ARG "unit1" or "unit2" is NULL.
* UT_NOT_SAME_SYSTEM "unit1" and "unit2" belong to * UT_NOT_SAME_SYSTEM "unit1" and "unit2" belong to
* different unit-systems. * different unit-systems.
* UT_OS Operating-system error. See "errno". * UT_OS Operating-system error. See "errno".
* else Pointer to the resulting unit. The pointer should be passed * else Pointer to the resulting unit. The pointer should be passed
* to ut_free() when the unit is no longer needed by the client . * to ut_free() when the unit is no longer needed by the client .
*/ */
ut_unit* EXTERNL ut_unit*
ut_multiply( ut_multiply(
const ut_unit* const unit1, const ut_unit* const unit1,
const ut_unit* const unit2); const ut_unit* const unit2);
/* /*
* Returns the inverse (i.e., reciprocal) of a unit. This convenience func tion * Returns the inverse (i.e., reciprocal) of a unit. This convenience func tion
* is equal to "ut_raise(unit, -1)". * is equal to "ut_raise(unit, -1)".
* *
* Arguments: * Arguments:
* unit Pointer to the unit. * unit Pointer to the unit.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be: * NULL Failure. "ut_get_status()" will be:
* UT_BAD_ARG "unit" is NULL. * UT_BAD_ARG "unit" is NULL.
* UT_OS Operating-system error. See "errno". * UT_OS Operating-system error. See "errno".
* else Pointer to the resulting unit. The pointer should be passed to * else Pointer to the resulting unit. The pointer should be passed to
* ut_free() when the unit is no longer needed by the client. * ut_free() when the unit is no longer needed by the client.
*/ */
ut_unit* EXTERNL ut_unit*
ut_invert( ut_invert(
const ut_unit* const unit); const ut_unit* const unit);
/* /*
* Returns the result of dividing one unit by another unit. This convenien ce * Returns the result of dividing one unit by another unit. This convenien ce
* function is equivalent to the following sequence: * function is equivalent to the following sequence:
* { * {
* ut_unit* inverse = ut_invert(denom); * ut_unit* inverse = ut_invert(denom);
* ut_multiply(numer, inverse); * ut_multiply(numer, inverse);
* ut_free(inverse); * ut_free(inverse);
skipping to change at line 871 skipping to change at line 924
* denom Pointer to the denominator (bottom, divisor) unit. * denom Pointer to the denominator (bottom, divisor) unit.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be: * NULL Failure. "ut_get_status()" will be:
* UT_BAD_ARG "numer" or "denom" is NULL. * UT_BAD_ARG "numer" or "denom" is NULL.
* UT_NOT_SAME_SYSTEM "unit1" and "unit2" belong to * UT_NOT_SAME_SYSTEM "unit1" and "unit2" belong to
* different unit-systems. * different unit-systems.
* UT_OS Operating-system error. See "errno". * UT_OS Operating-system error. See "errno".
* else Pointer to the resulting unit. The pointer should be passed to * else Pointer to the resulting unit. The pointer should be passed to
* ut_free() when the unit is no longer needed by the client. * ut_free() when the unit is no longer needed by the client.
*/ */
ut_unit* EXTERNL ut_unit*
ut_divide( ut_divide(
const ut_unit* const numer, const ut_unit* const numer,
const ut_unit* const denom); const ut_unit* const denom);
/* /*
* Returns the result of raising a unit to a power. * Returns the result of raising a unit to a power.
* *
* Arguments: * Arguments:
* unit Pointer to the unit. * unit Pointer to the unit.
* power The power by which to raise "unit". Must be greater than or * power The power by which to raise "unit". Must be greater than or
* equal to -255 and less than or equal to 255. * equal to -255 and less than or equal to 255.
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be: * NULL Failure. "ut_get_status()" will be:
* UT_BAD_ARG "unit" is NULL or "power" is invalid . * UT_BAD_ARG "unit" is NULL or "power" is invalid .
* UT_OS Operating-system error. See "errno". * UT_OS Operating-system error. See "errno".
* else Pointer to the resulting unit. The pointer should be passed to * else Pointer to the resulting unit. The pointer should be passed to
* ut_free() when the unit is no longer needed by the client. * ut_free() when the unit is no longer needed by the client.
*/ */
ut_unit* EXTERNL ut_unit*
ut_raise( ut_raise(
const ut_unit* const unit, const ut_unit* const unit,
const int power); const int power);
/* /*
* Returns the result of taking the root of a unit. * Returns the result of taking the root of a unit.
* *
* Arguments: * Arguments:
* unit Pointer to the unit. * unit Pointer to the unit.
* root The root to take of "unit". Must be greater than or * root The root to take of "unit". Must be greater than or
skipping to change at line 912 skipping to change at line 965
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be: * NULL Failure. "ut_get_status()" will be:
* UT_BAD_ARG "unit" is NULL, or "root" is invalid . * UT_BAD_ARG "unit" is NULL, or "root" is invalid .
* In particular, all powers of base un its * In particular, all powers of base un its
* in "unit" must be integral multiples of * in "unit" must be integral multiples of
* "root". * "root".
* UT_OS Operating-system error. See "errno". * UT_OS Operating-system error. See "errno".
* else Pointer to the resulting unit. The pointer should be passed to * else Pointer to the resulting unit. The pointer should be passed to
* ut_free() when the unit is no longer needed by the client. * ut_free() when the unit is no longer needed by the client.
*/ */
ut_unit* EXTERNL ut_unit*
ut_root( ut_root(
const ut_unit* const unit, const ut_unit* const unit,
const int root); const int root);
/* /*
* Returns the logarithmic unit corresponding to a logarithmic base and a * Returns the logarithmic unit corresponding to a logarithmic base and a
* reference level. For example, the following creates a decibel unit with a * reference level. For example, the following creates a decibel unit with a
* one milliwatt reference level: * one milliwatt reference level:
* *
* const ut_unit* watt = ...; * const ut_unit* watt = ...;
skipping to change at line 956 skipping to change at line 1009
* Returns: * Returns:
* NULL Failure. "ut_get_status()" will be: * NULL Failure. "ut_get_status()" will be:
* UT_BAD_ARG "base" is invalid or "refere nce" * UT_BAD_ARG "base" is invalid or "refere nce"
* is NULL. * is NULL.
* UT_OS Operating-system error. See * UT_OS Operating-system error. See
* "errno". * "errno".
* else Pointer to the resulting unit. The pointer should b e * else Pointer to the resulting unit. The pointer should b e
* passed to ut_free() when the unit is no longer neede d by * passed to ut_free() when the unit is no longer neede d by
* the client. * the client.
*/ */
ut_unit* EXTERNL ut_unit*
ut_log( ut_log(
const double base, const double base,
const ut_unit* const reference); const ut_unit* const reference);
/************************************************************************** **** /************************************************************************** ****
* Parsing and Formatting Units: * Parsing and Formatting Units:
************************************************************************** ****/ ************************************************************************** ****/
/* /*
* Returns the binary representation of a unit corresponding to a string * Returns the binary representation of a unit corresponding to a string
skipping to change at line 987 skipping to change at line 1040
* NULL Failure. "ut_get_status()" will be one of * NULL Failure. "ut_get_status()" will be one of
* UT_BAD_ARG "system" or "string" is NULL . * UT_BAD_ARG "system" or "string" is NULL .
* UT_SYNTAX "string" contained a syntax * UT_SYNTAX "string" contained a syntax
* error. * error.
* UT_UNKNOWN "string" contained an unknow n * UT_UNKNOWN "string" contained an unknow n
* identifier. * identifier.
* UT_OS Operating-system failure. S ee * UT_OS Operating-system failure. S ee
* "errno". * "errno".
* else Pointer to the unit corresponding to "string". * else Pointer to the unit corresponding to "string".
*/ */
ut_unit* EXTERNL ut_unit*
ut_parse( ut_parse(
const ut_system* const system, const ut_system* const system,
const char* const string, const char* const string,
const ut_encoding encoding); const ut_encoding encoding);
/* /*
* Removes leading and trailing whitespace from a string. * Removes leading and trailing whitespace from a string.
* *
* Arguments: * Arguments:
* string NUL-terminated string. Will be modified if it conta ins * string NUL-terminated string. Will be modified if it conta ins
* whitespace.. * whitespace..
* encoding The character-encoding of "string". * encoding The character-encoding of "string".
* Returns: * Returns:
* "string", with all leading and trailing whitespace removed. * "string", with all leading and trailing whitespace removed.
*/ */
char* EXTERNL char*
ut_trim( ut_trim(
char* const string, char* const string,
const ut_encoding encoding); const ut_encoding encoding);
/* /*
* Formats a unit. * Formats a unit.
* *
* Arguments: * Arguments:
* unit Pointer to the unit to be formatted. * unit Pointer to the unit to be formatted.
* buf Pointer to the buffer into which to format "unit". * buf Pointer to the buffer into which to format "unit".
skipping to change at line 1044 skipping to change at line 1097
* Returns: * Returns:
* -1 Failure: "ut_get_status()" will be * -1 Failure: "ut_get_status()" will be
* UT_BAD_ARG "unit" or "buf" is NULL, or both * UT_BAD_ARG "unit" or "buf" is NULL, or both
* UT_LATIN1 and UT_UTF8 speci fied. * UT_LATIN1 and UT_UTF8 speci fied.
* UT_CANT_FORMAT "unit" can't be formatted in * UT_CANT_FORMAT "unit" can't be formatted in
* the desired manner. * the desired manner.
* else Success. Number of characters printed in "buf". If * else Success. Number of characters printed in "buf". If
* the number is equal to the size of the buffer, then the * the number is equal to the size of the buffer, then the
* buffer is too small to have a terminating NUL charac ter. * buffer is too small to have a terminating NUL charac ter.
*/ */
int EXTERNL int
ut_format( ut_format(
const ut_unit* const unit, const ut_unit* const unit,
char* buf, char* buf,
size_t size, size_t size,
unsigned opts); unsigned opts);
/* /*
* Accepts a visitor to a unit. * Accepts a visitor to a unit.
* *
* Arguments: * Arguments:
* unit Pointer to the unit to accept the visitor. * unit Pointer to the unit to accept the visitor.
* visitor Pointer to the visitor of "unit". * visitor Pointer to the visitor of "unit".
* arg An arbitrary pointer that will be passed to "visitor ". * arg An arbitrary pointer that will be passed to "visitor ".
* Returns: * Returns:
* UT_BAD_ARG "unit" or "visitor" is NULL. * UT_BAD_ARG "unit" or "visitor" is NULL.
* UT_VISIT_ERROR A error occurred in "visitor" while visiting "unit". * UT_VISIT_ERROR A error occurred in "visitor" while visiting "unit".
* UT_SUCCESS Success. * UT_SUCCESS Success.
*/ */
ut_status EXTERNL ut_status
ut_accept_visitor( ut_accept_visitor(
const ut_unit* const unit, const ut_unit* const unit,
const ut_visitor* const visitor, const ut_visitor* const visitor,
void* const arg); void* const arg);
/************************************************************************** **** /************************************************************************** ****
* Time Handling: * Time Handling:
************************************************************************** ****/ ************************************************************************** ****/
/* /*
* Encodes a date as a double-precision value. * Encodes a date as a double-precision value.
* *
* Arguments: * Arguments:
* year The year. * year The year.
* month The month. * month The month.
* day The day (1 = the first of the month). * day The day (1 = the first of the month).
* Returns: * Returns:
* The date encoded as a scalar value. * The date encoded as a scalar value.
*/ */
double EXTERNL double
ut_encode_date( ut_encode_date(
int year, int year,
int month, int month,
int day); int day);
/* /*
* Encodes a time as a double-precision value. * Encodes a time as a double-precision value.
* *
* Arguments: * Arguments:
* hours The number of hours (0 = midnight). * hours The number of hours (0 = midnight).
* minutes The number of minutes. * minutes The number of minutes.
* seconds The number of seconds. * seconds The number of seconds.
* Returns: * Returns:
* The clock-time encoded as a scalar value. * The clock-time encoded as a scalar value.
*/ */
double EXTERNL double
ut_encode_clock( ut_encode_clock(
int hours, int hours,
int minutes, int minutes,
double seconds); double seconds);
/* /*
* Encodes a time as a double-precision value. The convenience function is * Encodes a time as a double-precision value. The convenience function is
* equivalent to "ut_encode_date(year,month,day) + * equivalent to "ut_encode_date(year,month,day) +
* ut_encode_clock(hour,minute,second)" * ut_encode_clock(hour,minute,second)"
* *
* Arguments: * Arguments:
* year The year. * year The year.
* month The month. * month The month.
* day The day. * day The day.
* hour The hour. * hour The hour.
* minute The minute. * minute The minute.
* second The second. * second The second.
* Returns: * Returns:
* The time encoded as a scalar value. * The time encoded as a scalar value.
*/ */
double EXTERNL double
ut_encode_time( ut_encode_time(
const int year, const int year,
const int month, const int month,
const int day, const int day,
const int hour, const int hour,
const int minute, const int minute,
const double second); const double second);
/* /*
* Decodes a time from a double-precision value. * Decodes a time from a double-precision value.
skipping to change at line 1143 skipping to change at line 1196
* value The value to be decoded. * value The value to be decoded.
* year Pointer to the variable to be set to the year. * year Pointer to the variable to be set to the year.
* month Pointer to the variable to be set to the month. * month Pointer to the variable to be set to the month.
* day Pointer to the variable to be set to the day. * day Pointer to the variable to be set to the day.
* hour Pointer to the variable to be set to the hour. * hour Pointer to the variable to be set to the hour.
* minute Pointer to the variable to be set to the minute. * minute Pointer to the variable to be set to the minute.
* second Pointer to the variable to be set to the second. * second Pointer to the variable to be set to the second.
* resolution Pointer to the variable to be set to the resolution * resolution Pointer to the variable to be set to the resolution
* of the decoded time in seconds. * of the decoded time in seconds.
*/ */
void EXTERNL void
ut_decode_time( ut_decode_time(
double value, double value,
int *year, int *year,
int *month, int *month,
int *day, int *day,
int *hour, int *hour,
int *minute, int *minute,
double *second, double *second,
double *resolution); double *resolution);
/************************************************************************** **** /************************************************************************** ****
* Error Handling: * Error Handling:
************************************************************************** ****/ ************************************************************************** ****/
/* /*
* Returns the status of the last operation by the units module. This func tion * Returns the status of the last operation by the units module. This func tion
* will not change the status. * will not change the status.
*/ */
ut_status EXTERNL ut_status
ut_get_status(void); ut_get_status(void);
/* /*
* Sets the status of the units module. This function would not normally b e * Sets the status of the units module. This function would not normally b e
* called by the user unless they were doing their own parsing or formattin g. * called by the user unless they were doing their own parsing or formattin g.
* *
* Arguments: * Arguments:
* status The status of the units module. * status The status of the units module.
*/ */
void EXTERNL void
ut_set_status( ut_set_status(
ut_status status); ut_status status);
/* /*
* Handles an error-message. * Handles an error-message.
* *
* Arguments: * Arguments:
* fmt The format for the error-message. * fmt The format for the error-message.
* ... The arguments for "fmt". * ... The arguments for "fmt".
* Returns: * Returns:
* <0 An output error was encountered. * <0 An output error was encountered.
* else The number of bytes of "fmt" and "arg" written excluding any * else The number of bytes of "fmt" and "arg" written excluding any
* terminating NUL. * terminating NUL.
*/ */
int EXTERNL int
ut_handle_error_message( ut_handle_error_message(
const char* const fmt, const char* const fmt,
...); ...);
/* /*
* Returns the previously-installed error-message handler and optionally * Returns the previously-installed error-message handler and optionally
* installs a new handler. The initial handler is "ut_write_to_stderr()". * installs a new handler. The initial handler is "ut_write_to_stderr()".
* *
* Arguments: * Arguments:
* handler NULL or pointer to the error-message handler . If NULL, * handler NULL or pointer to the error-message handler . If NULL,
* then the handler is not changed. The * then the handler is not changed. The
* currently-installed handler can be obtained this way . * currently-installed handler can be obtained this way .
* Returns: * Returns:
* Pointer to the previously-installed error-message handler. * Pointer to the previously-installed error-message handler.
*/ */
ut_error_message_handler EXTERNL ut_error_message_handler
ut_set_error_message_handler( ut_set_error_message_handler(
ut_error_message_handler handler); ut_error_message_handler handler);
/* /*
* Writes an error-message to the standard-error stream when received and * Writes an error-message to the standard-error stream when received and
* appends a newline. This is the initial error-message handler. * appends a newline. This is the initial error-message handler.
* *
* Arguments: * Arguments:
* fmt The format for the error-message. * fmt The format for the error-message.
* args The arguments of "fmt". * args The arguments of "fmt".
* Returns: * Returns:
* <0 A output error was encountered. See "errno". * <0 A output error was encountered. See "errno".
* else The number of bytes of "fmt" and "arg" written excluding any * else The number of bytes of "fmt" and "arg" written excluding any
* terminating NUL. * terminating NUL.
*/ */
int EXTERNL int
ut_write_to_stderr( ut_write_to_stderr(
const char* const fmt, const char* const fmt,
va_list args); va_list args);
/* /*
* Does nothing with an error-message. * Does nothing with an error-message.
* *
* Arguments: * Arguments:
* fmt The format for the error-message. * fmt The format for the error-message.
* args The arguments of "fmt". * args The arguments of "fmt".
* Returns: * Returns:
* 0 Always. * 0 Always.
*/ */
int EXTERNL int
ut_ignore( ut_ignore(
const char* const fmt, const char* const fmt,
va_list args); va_list args);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 55 change blocks. 
54 lines changed or deleted 107 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/