GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> CLI / V0-1-2 > cli / rhel6-64
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <CLI/CLI_msgs.h>
#include <CLI/CLI_pubdefs.h>
#include <MDB/MDB_pubdefs.h>
#include <CLI_prvdefs.h>
Functions | |
static void | clearValueList (CLI_Valu *head) |
Clear out a value list. | |
static unsigned int | saveValue (char *tbeg, char *tend, unsigned short type, CLI_KeyList *keys, CLI_Valu **last) |
Save a parsed value. | |
static unsigned int | validateKey (char *tbeg, char *tend, CLI_KeyList *list, CLI_KeyDef **key) |
Validate a value as a member of a keyword list. | |
static unsigned int | validateTime (const char *tbeg, const char *tend, struct tm *bdt) |
Validate/parse a timestamp string. | |
unsigned int | CLI_parseValue (char *tbeg, char *tend, unsigned short type, CLI_KeyList *keys, CLI_Valu **list) |
Parse a command line value. | |
time_t | CLI_timeString2Unix (const char *text, CLI_Timezone zone) |
Parse a string timestamp into a unix calendar time. | |
void | CLI_timeUnix2String (time_t time, char *text, CLI_Timezone zone) |
Parse a unix calendar time into a string timestamp. |
CVS $Id: CLI_parseValue.c,v 1.7 2011/03/25 00:51:25 apw Exp $
static void clearValueList | ( | CLI_Valu * | head | ) | [static] |
Clear out a value list.
head | Head of list of values |
References _CLI_Valu::next, and _CLI_Valu::text.
Referenced by CLI_parseValue().
unsigned int CLI_parseValue | ( | char * | tbeg, | |
char * | tend, | |||
unsigned short | type, | |||
CLI_KeyList * | keys, | |||
CLI_Valu ** | list | |||
) |
Parse a command line value.
tbeg | First character | |
tend | (One past) the last character | |
type | Type constraints on value(s) | |
keys | Keyword list (if needed) | |
list | Location where the value list should be saved |
CLI_BADPAREN | Unexpected/unbalanced parentheses | |
CLI_BADQUOTE | Unexpected/unbalanced quotation marks | |
CLI_KEYAMBG | Keyword is ambiguous | |
CLI_KEYUND | Value is not a valid keyword | |
CLI_NOTALLOC | Memory allocation failure | |
CLI_SUCCESS | Success | |
CLI_VALEND | Unexpected end of value | |
CLI_VALLIST | Unexpected list of values | |
CLI_VALNTFLT | Value is not a floating point number | |
CLI_VALNTINT | Value is not an integer |
References clearValueList(), and saveValue().
Referenced by savePval(), and saveQval().
time_t CLI_timeString2Unix | ( | const char * | text, | |
CLI_Timezone | zone | |||
) |
Parse a string timestamp into a unix calendar time.
text | String timestamp (presumably a token from CLI parsing) | |
zone | Zone in which to perform the conversion |
x Unix calendar time
References CLI_K_TIMEZONE_UTC, and validateTime().
void CLI_timeUnix2String | ( | time_t | time, | |
char * | text, | |||
CLI_Timezone | zone | |||
) |
Parse a unix calendar time into a string timestamp.
time | Unix calendar time | |
text | String timestamp | |
zone | Zone in which to perform the conversion |
x Unix calendar time
References CLI_K_TIMEZONE_UTC.
static unsigned int saveValue | ( | char * | tbeg, | |
char * | tend, | |||
unsigned short | type, | |||
CLI_KeyList * | keys, | |||
CLI_Valu ** | last | |||
) | [static] |
Save a parsed value.
tbeg | Start of value to save (token begin) | |
tend | End of value to save plus one (token end) | |
type | Type constraints on value | |
keys | Keyword list | |
last | Last value structure in value list |
CLI_KEYAMBG | Keyword is ambiguous | |
CLI_KEYUND | Value is not a valid keyword | |
CLI_NOTALLOC | Memory allocation failure | |
CLI_SUCCESS | Success | |
CLI_VALNTFLT | Value is not a floating point number | |
CLI_VALNTINT | Value is not an integer |
References _CLI_Valu::next, _CLI_Valu::text, _CLI_KeyDef::text, validateKey(), and validateTime().
Referenced by CLI_parseValue().
static unsigned int validateKey | ( | char * | tbeg, | |
char * | tend, | |||
CLI_KeyList * | list, | |||
CLI_KeyDef ** | key | |||
) | [static] |
Validate a value as a member of a keyword list.
list | Head of the list of keywords | |
tbeg | Start of value to test (token begin) | |
tend | End of value to test plus one (token end) | |
key | Valid key definition (returned) |
CLI_KEYAMBG | Keyword is ambiguous | |
CLI_KEYUND | Value is not a valid keyword | |
CLI_SUCCESS | Success |
References _CLI_KeyList::key, _CLI_KeyDef::next, _CLI_KeyDef::text, and _CLI_KeyDef::tlen.
Referenced by saveValue().
static unsigned int validateTime | ( | const char * | tbeg, | |
const char * | tend, | |||
struct tm * | bdt | |||
) | [static] |
Validate/parse a timestamp string.
tbeg | Start of value to test (token begin) | |
tend | End of value to test plus one (token end) | |
bdt | Caller provided "broken-down-time" structure |
CLI_SUCCESS | Success | |
CLI_VALNTTIM | Value is not a valid timestamp |
"YYYY-MM-DD HH:MI:SS"
Or in regular expression speak:
"[\d]{4:4}-[\d]{1:2}-[\d]{1:2} [\d]{1:2}:[\d]{1:2}:[\d]{1:2}"
As a courtesy, allow the string to be truncated from the right, defaulting any missing fields to zero.
Referenced by CLI_timeString2Unix(), and saveValue().