gxPL  1.0
Tools, Application and Framework for xPL
util.h
1 
9 #ifndef _GXPL_UTIL_HEADER_
10 #define _GXPL_UTIL_HEADER_
11 
12 #include <gxPL/defs.h>
13 __BEGIN_C_DECLS
14 /* ========================================================================== */
15 
16 
17 /* internal public functions ================================================ */
18 
46 int gxPLStrCpy (char * dst, const char * src);
47 
53 const char * gxPLLongToStr (long value);
54 
61 const char * gxPLDoubleToStr (double value, int precision);
62 
81 const char * gxPLConfigPath (const char * filename);
82 
90 xVector * gxPLConfigReadFile (const char * filename, const char * vendor_id,
91  const char * device_id);
104 typedef struct _gxPLPair {
105  char * name;
106  char * value;
107 } gxPLPair;
108 
114 gxPLPair * gxPLPairFromString (char *str);
115 
121 gxPLPair * gxPLPairFromLine (char * line);
122 
128 void gxPLPairDelete (void * pair);
129 
136 int gxPLPairMatch (const void *key1, const void *key2);
137 
143 const void * gxPLPairKey (const void * pair);
144 
162 int gxPLIdSet (gxPLId * id, const char * vendor_id, const char * device_id, const char * instance_id);
163 
170 int gxPLIdVendorIdSet (gxPLId * id, const char * vendor_id);
171 
178 int gxPLIdDeviceIdSet (gxPLId * id, const char * device_id);
179 
186 int gxPLIdInstanceIdSet (gxPLId * id, const char * instance_id);
187 
194 int gxPLIdCopy (gxPLId * dst, const gxPLId * src);
195 
203 int gxPLIdCmp (const gxPLId * id1, const gxPLId * id2);
204 
212 int gxPLIdFromString (gxPLId * dest, char * src);
213 
230 int gxPLSchemaCmp (const gxPLSchema * s1, const gxPLSchema * s2);
231 
239 int gxPLSchemaMatch (const gxPLSchema * s1, const char * schema_class, const char * schema_type);
240 
247 int gxPLSchemaClassSet (gxPLSchema * s, const char * schema_class);
248 
255 int gxPLSchemaTypeSet (gxPLSchema * s, const char * schema_type);
256 
264 int gxPLSchemaSet (gxPLSchema * schema, const char * schema_class, const char * schema_type);
265 
272 int gxPLSchemaCopy (gxPLSchema * dst, const gxPLSchema * src);
273 
280 int gxPLSchemaFromString (gxPLSchema * schema, const char * str);
281 
287 int gxPLSchemaIsEmpty (const gxPLSchema * schema);
302 unsigned long gxPLTime (void);
303 
309 int gxPLTimeMs (unsigned long * ms);
310 
317 char * gxPLDateTimeStr (unsigned long t, const char * format);
318 
325 char * gxPLDateStr (unsigned long t, const char * format);
326 
333 char * gxPLTimeStr (unsigned long t, const char * format);
334 
340 int gxPLTimeDelayMs (unsigned long ms);
341 
342 
350 #if !defined(__DOXYGEN__)
351 // -----------------------------------------------------------------------------
352 
353 #if defined(__AVR__)
354 // -----------------------------------------------------------------------------
355 #include <avrio/memdebug.h>
356 
357 INLINE int
358 gxPLDynamicMemoryUsed (void) {
359 
360  return ulMemoryUsed();
361 }
362 #elif (__unix__)
363 // -----------------------------------------------------------------------------
364 #include <malloc.h>
365 
366 INLINE int
367 gxPLDynamicMemoryUsed (void) {
368 
369  struct mallinfo mi = mallinfo();
370  return mi.uordblks;
371 }
372 #else /* __unix__ && __AVR__ not defined */
373 // -----------------------------------------------------------------------------
374 INLINE int
375 gxPLDynamicMemoryUsed (void) {
376  return -1;
377 }
378 #endif /* __unix__ && __AVR__ not defined */
379 // -----------------------------------------------------------------------------
380 #endif /* !defined(__DOXYGEN__) */
381 
382 /* ========================================================================== */
383 __END_C_DECLS
384 #endif /* _GXPL_UTIL_HEADER_ defined */
const void * gxPLPairKey(const void *pair)
Returns the name of a pair as a const void * pointer Used by sysio vector.
int gxPLSchemaFromString(gxPLSchema *schema, const char *str)
Describe a source or destination xPL identifier.
Definition: defs.h:279
char * gxPLDateStr(unsigned long t, const char *format)
converts the system time t into a null-terminated string
int gxPLIdVendorIdSet(gxPLId *id, const char *vendor_id)
Sets vendor identifier.
char * gxPLTimeStr(unsigned long t, const char *format)
converts the system time t into a null-terminated string
unsigned long gxPLTime(void)
System time This time can be an absolute time (a date) or relative to the system startup (on embedded...
void gxPLPairDelete(void *pair)
Release a pair allocte on the heap Used by sysio vector and dlist.
int gxPLStrCpy(char *dst, const char *src)
Copy string in accordance with xPL.
char * gxPLDateTimeStr(unsigned long t, const char *format)
converts the system time t into a null-terminated string
Describe a name=value pair.
Definition: util.h:104
int gxPLIdCmp(const gxPLId *id1, const gxPLId *id2)
Compare two identifiers.
int gxPLSchemaCopy(gxPLSchema *dst, const gxPLSchema *src)
int gxPLSchemaCmp(const gxPLSchema *s1, const gxPLSchema *s2)
Compare two schemas.
int gxPLIdCopy(gxPLId *dst, const gxPLId *src)
Copy two identifiers.
int gxPLPairMatch(const void *key1, const void *key2)
Compares name of 2 pair s.
struct _gxPLPair gxPLPair
Describe a name=value pair.
int gxPLSchemaIsEmpty(const gxPLSchema *schema)
int gxPLIdSet(gxPLId *id, const char *vendor_id, const char *device_id, const char *instance_id)
Sets an identifier.
xVector * gxPLConfigReadFile(const char *filename, const char *vendor_id, const char *device_id)
int gxPLIdFromString(gxPLId *dest, char *src)
Gets an identifier from a string.
Describe a xPL schema.
Definition: defs.h:288
int gxPLSchemaMatch(const gxPLSchema *s1, const char *schema_class, const char *schema_type)
Compare two schemas.
int gxPLSchemaTypeSet(gxPLSchema *s, const char *schema_type)
int gxPLIdInstanceIdSet(gxPLId *id, const char *instance_id)
Sets instance identifier.
gxPLPair * gxPLPairFromLine(char *line)
Sets a name/value form a string.
const char * gxPLLongToStr(long value)
Quickly to convert an long integer to string.
const char * gxPLDoubleToStr(double value, int precision)
Quickly to convert an double to string.
int gxPLSchemaSet(gxPLSchema *schema, const char *schema_class, const char *schema_type)
int gxPLTimeDelayMs(unsigned long ms)
suspends execution for (at least) ms milliseconds
const char * gxPLConfigPath(const char *filename)
Returns the path of a configuration file.
int gxPLIdDeviceIdSet(gxPLId *id, const char *device_id)
Sets device identifier.
int gxPLSchemaClassSet(gxPLSchema *s, const char *schema_class)
int gxPLTimeMs(unsigned long *ms)
System time in milliseconds.
gxPLPair * gxPLPairFromString(char *str)
Sets a name/value form a string.