Main Page | Data Structures | File List | Data Fields | Globals

isisutils.c File Reference

ISIS client utility functions. More...

#include "isisclient.h"

Functions

void LeftStr (char *substr, char *str, int nchar)
 Extract the n left-most characters from a given string.

void RightStr (char *substr, char *str, int nchar)
 Extract the n right-most characters from a given string.

void MidStr (char *substr, char *str, int start, int nchar)
 Extract n characters starting in the middle of a string.

void SubStr (char *substr, char *str, int first, int last)
 Extracts a substring from inside a larger string.

void UpperCase (char *str)
 Convert all characters in a string up uppercase.

void GetArg (char *cmdstr, int argnum, char *argstr)
 Extract the n-th argument from a command string with arguments separated by spaces.

char * UTCDateTag (void)
 Create a CCYYMMDD date tag string.

char * UTCDate (void)
 Return the UTC date in ISO8601 format.

char * UTCTime (void)
 Return the UTC Time in ISO8601 format.

char * ISODate (void)
 Return the UTC date and time in ISO8601 format.

char * GetFineTime (void)
 Return UTC time with microsecond precision.

double SysTimestamp (void)
 Return elapsed time since UTC 1970 Jan 1 with microsecond precision.

int MilliSleep (long msec)
 Pause execution for a certain number of msec.


Detailed Description

ISIS client utility functions.

A suite of utility functions that most ISIS client applications will find useful. These include functions for string handling (something stock C is not well-equipped with), an dfunctions for getting time and date information, including date/time in ISO8601 format.


Function Documentation

void LeftStr char *  substr,
char *  str,
int  nchar
 

Extract the n left-most characters from a given string.

Parameters:
substr Substring to extract
str Original string
nchar Number of characters to extract

void RightStr char *  substr,
char *  str,
int  nchar
 

Extract the n right-most characters from a given string.

Parameters:
substr Substring to extract
str Original string
nchar Number of characters to extract

void MidStr char *  substr,
char *  str,
int  start,
int  nchar
 

Extract n characters starting in the middle of a string.

Parameters:
substr Substring to extract
str Original string
start Starting character in str
nchar Number of characters to extract
See also:
SubStr()

void SubStr char *  substr,
char *  str,
int  first,
int  last
 

Extracts a substring from inside a larger string.

Parameters:
substr Substring to extract
str Original string
first First character in str to extract
last Last character in str to extract
See also:
MidStr()

void UpperCase char *  str  ) 
 

Convert all characters in a string up uppercase.

Parameters:
str String to be converted to uppercase

void GetArg char *  cmdstr,
int  argnum,
char *  argstr
 

Extract the n-th argument from a command string with arguments separated by spaces.

Parameters:
cmdstr Command string with space-separated arguments
argnum Number of the argument to extract (1..n)
argstr Argument string to return
Returns the n-th argument in a command string that contains a series of command-line arguments separated by spaces. Provides a very simple command parsing capability. The command looks like

cmd arg1 arg2 .. argN

With the command verb itself being considerd argument "0".

Returns a null string in argstr if argnum is out of range.

char* UTCDateTag void   ) 
 

Create a CCYYMMDD date tag string.

Reads the system timeclock and returns the UTC date in CCYYMMDD format. This is a hyphen-free variant on the standard ISO8601 format date specification.

See also:
UTCDate(), ISODate()

char* UTCDate void   ) 
 

Return the UTC date in ISO8601 format.

Reads the system clock and returns the UTC date in ISO8601-compliant CCYY-MM-DD format, where CCYY is the year (century and year), MM is the month number (01..12), and DD is the day of the month (01..28/29/30/31).

See also:
UTCDateTag(), ISODate()

char* UTCTime void   ) 
 

Return the UTC Time in ISO8601 format.

Reads the system clock and returns the UTC time in ISO8601-compliant time to the nearest second in hh:mm:ss format.

See also:
GetFineTime(), ISODate()

char* ISODate void   ) 
 

Return the UTC date and time in ISO8601 format.

Reads the system clock and returns the UTC date and time in full ISO8601-compliant date/time format:

CCYY-MM-DDThh:mm:ss

where:

  • CCYY-MM-DD is the UTC date
  • hh:mm:ss is the UTC time to the nearest second
We omit the zone specification described by ISO8601 since this only reads UTC time.

See also:
UTCDate(), UTCTime(), UTCDateTag()

char* GetFineTime void   ) 
 

Return UTC time with microsecond precision.

Reads the system's UTC time clock and returns a pointer to a string with the fine-grained UTC time in hh:mm:ss.ssssss format.

Based on gf_time() from Stevens, W.R., 1998, Unix Network Programming, Vol 2, Prentice Hall, Figure 15.6, but I make a string, and extract time to microsec instead of msec.

Note: It returns microsecond precision, accuracy is quite another matter...

See also:
UTCTime(), ISODate()

double SysTimestamp void   ) 
 

Return elapsed time since UTC 1970 Jan 1 with microsecond precision.

Reads the system's time clock and returns a double-precision value with the time in seconds and microseconds since UTC 1970 January 1. The primary use of this function is to create a fine-grained numerical timestamp for the system, but other uses are possible.

Note: It returns microsecond precision, accuracy is quite another matter...

See also:
GetFineTime()

int MilliSleep long  msec  ) 
 

Pause execution for a certain number of msec.

Parameters:
msec - time to sleep in milliseconds
Returns:
0 if successful, -1 if there were problems. errno says what is bothering it.
Acts as a convenience function for using nanosleep(), the POSIX.1b conformal way of suspending a process for a certain time. nanosleep() is a replacement for the obsolete usleep() when a sleep interval more fine-grained than sleep() is required. sleep() only allows intervals in integer seconds, which is not short enough for some applications. For most of what we do, msec are the appropriate interval, and nanosleep() can be somewhat involved to setup. This function encapsulates the nasty setup for calling nanosleep() as a convenience for users.

See "man 2 nanosleep" for details on the nanosleep() function.


Generated on Thu Jul 22 20:28:29 2004 for ISIS Client API by doxygen 1.3.7