81 "Example of C++ using librnr grab bag of goodies.",
84 "The %P command demonstrates compiling-linking C++ with librnr facilities.",
106 "Set the logging test(s) to conduct.\n" 129 double f,
int hex,
bool_t bAreRipe)
138 LOGDIAG2(
"There are %d juicy %s in %s", n, sFruit,
"Tuscany");
142 LOGDIAG2(
"There are %d green %s in %s", n, sFruit,
"Utah");
154 const char *sFileName =
"PackingShedOnStrike.newsflash";
162 LOGERROR(
"Salmonella scare %d...", count);
166 if( (fp = fopen(sFileName,
"r")) ==
NULL )
172 LOGDIAG4(
"%s: what a pleasant surprise", sFileName);
192 logtest_num1(&i,
"apples", 53, h, 123.5, 0xdead,
false);
226 Mars, Phobos, Deimos,
228 Jupiter, Io, Europa, Ganymede, Callisto,
243 {
"unknown", unknown},
245 {
"Mercury", Mercury},
252 {
"Jupiter", Jupiter},
255 {
"Ganymede", Ganymede},
256 {
"Callisto", Callisto},
260 {
"Titania", Titania},
261 {
"Neptune", Neptune},
275 cout << oid <<
" --> " 287 cout << name <<
" --> " 304 byte_t buf[] =
"\x04\xf3 apple\t\n\va day.";
323 string path[] = {
".",
"./examples",
"/prj/pkg/librnr/examples"};
329 filepath = path[i] +
"/" + inifile;
357 DListStrAppend(dlist, (
char *)
"elephant");
358 DListStrAppend(dlist, (
char *)
"rhinocerus");
359 DListStrPrepend(dlist, (
char *)
"hippopotomous");
361 cout <<
"count = " << DListStrCount(dlist) << endl;
363 for(s=DListStrIterDataFirst(dlist, &iter);
365 s=DListStrIterDataNext(&iter))
386 {
"mt_elbert",
"14,433"},
387 {
"mt_massive",
"14,421"},
388 {
"mt_harvard",
"14,420"},
389 {
"blanca_peak",
"14,345"},
390 {
"la_plata_peak",
"14,336"},
391 {
"uncompahgre_peak",
"14,309"},
392 {
"crestone_peak",
"14,294"},
393 {
"mt_lincoln",
"14,286"},
394 {
"grays_peak",
"14,270"},
395 {
"mt_antero",
"14,269"},
396 {
"torreys_peak",
"14,267"},
397 {
"castle_peak",
"14,265"},
398 {
"quandary_peak",
"14,265"},
399 {
"mt_evans",
"14,264"},
400 {
"longs_peak",
"14,255"},
401 {
"mt_wilson",
"14,246"}
465 static int init(
int argc,
char *argv[])
471 Argv0 = basename(argv[0]);
483 LOGDIAG1(
"Post options processed non-option arguments:");
485 for(i=0; i<argc; ++i)
487 fprintf(fp,
" argv[%d]=\"%s\"\n", i, argv[i]);
503 int main(
int argc,
char *argv[])
505 cout <<
"Testing librnr Linkage" << endl
506 <<
"----------------------" << endl;
508 cout <<
"* Validate options and logging." << endl;
509 if( !
init(argc, argv) )
515 cout <<
"* Validate associative mapping." << endl;
520 cout <<
"* Validate char." << endl;
524 cout <<
"* Validate config (ini)." << endl;
528 cout <<
"* Validate string dlist." << endl;
532 cout <<
"* Validate hash and new." << endl;
static int logtest_num2(int count)
Log test number 2.
Simple associative map data and operator declarations.
#define _THEX(var)
int (hex)
#define CHKEXPR_INT(val, expr,...)
check integer
static char * Argv0
the command
const char * NvpVal2Name(Nvp_T tbl[], size_t nTblEntries, int iVal)
Get the name associated with the value.
#define _TINT(var)
int (decimal)
#define hnode_getkey(N)
Get hash node hash key.
FILE * LOG_GET_LOGFP()
Get current logging output stream file pointer.
#define HASHCOUNT_T_MAX
Maximum maximum hash table size.
static int runlogtests()
Run log test(s).
hnode_t * hash_scan_next(hscan_t *scan)
Retrieve the next node from the hash table.
char * new_strdup(const char *s)
Duplicate a string.
static OptsInfo_T LogExampleOptsInfo[]
Command line options information.
Doubly linked list of character strings "inherited" from dlistvoid.
Standard command-line options options and parsing.
Program Description Strings Info Structure.
int main(int argc, char *argv[])
Example main.
Configuration parser declarations.
char * OptsFmtInt(char *buf, size_t buflen, void *pOptVal)
Integer option value string formatter.
General purpose hash data and function declarations.
#define _TSHORT(var)
short int (decimal)
Memory allocation and deallocation declarations.
void del_node_data(void *key, void *val)
Delete node data - both key and value are dynamically allocated.
Simple character manipulations.
#define LOGDIAG1(fmt,...)
Standard Diagnostic Level 1 logging.
void ConfigDbPrint(Config_T *pConfig, FILE *fp)
Print configuration database to the output file stream.
#define LOGSYSERROR(fmt,...)
Standard System Error logging.
void hash_set_self_verify(bool_t selfverify)
Enable (disable) automatic self-checks during hash table modification operatations.
static OptsPgmInfo_T LogExamplePgmInfo
Program information.
#define arraysize(array)
array size, i.e. number of array entries
#define LOGDIAG2(fmt,...)
Standard Diagnostic Level 2 logging.
void test_config(string inifile)
Test INI configuration routines.
int PrettyPrintBuf(FILE *fp, byte_t buf[], size_t len)
Print out 'prettified' readable version of the contents of the given (binary) buffer.
#define LOGERROR(fmt,...)
Standard Error logging.
#define LOGABLE(level)
Test if given level is logable at current threshold.
unsigned long hashcount_t
maximum hash table size type
void test_dlist()
Test doubly-linked list routines.
int OptsCvtArgInt(const char *argv0, const char *sOptName, char *optarg, void *pOptVal)
Convert options integer argument to integer.
void test_assoc(BodyId_T oid)
Test value to name association.
Nvp_T SolarBodyNames[]
Solar body name-id pairs (partial).
static int OptsTest
test option value
#define LOGDIAG4(fmt,...)
Standard Diagnostic Level 4 logging.
static string Colorado14ers[][2]
Colorado's 14,000+ foot mountains.
static const PkgInfo_T PkgInfo
void hash_scan_begin(hscan_t *scan, hash_t *hash)
Reset the hash scanner (iterator).
void test_hash()
Test hash and new routines.
RoadNarrows Robotics common configuration file.
char ** OptsGet(const char *argv0, const PkgInfo_T *pPkgInfo, OptsPgmInfo_T *pPgmInfo, OptsInfo_T *pOptsInfo, bool_t bHasLogging, int *pargc, char *argv[])
Gets, validates, and sets all command line options.
#define _TBOOL(var)
boolean
static int init(int argc, char *argv[])
Main initialization.
Package version information.
#define _TSTR(var)
string variable
#define hnode_get(N)
Get hash node user data.
hash_t * hash_table_create(bool_t isdynamic, hashcount_t minsize, hashcount_t maxsize, hash_comp_t compfun, hash_fun_t hashfun, hnode_data_free_t freedatafun)
Create a dynamic hash table.
#define LOG_LEVEL_DIAG1
diagnostic level 1
void test_char()
Test character routine(s).
#define _TPTR(var)
pointer
static DListStr_T * DListStrNewDft()
Allocator and initializer new empty string dlist with default callbacks.
#define _TFLOAT(var)
float
Hash table control structure.
Hash chain node structure.
bool_t hash_insert(hash_t *hash, void *key, void *data)
Insert user data with the given key into the hash table.
#define LOGDIAG2CALL(...)
Standard Diagnostic Level 2 function call tracing.
static void logtest_num1(void *p, const char *sFruit, int n, int half, double f, int hex, bool_t bAreRipe)
Log test number 1.
Short and Long Options Info.
#define LOGDIAG1CALL(...)
Standard Diagnostic Level 1 function call tracing.
Config_T * ConfigDbRead(const char *sFileName)
Create a new configuration database from a configuration file.
BodyId_T
Major and minor solar body ids (partial, of course).
int NvpName2Val(Nvp_T tbl[], size_t nTblEntries, const char *sName)
Get the value associated with the name.