building fieldset and probe modules
This commit is contained in:
@@ -7,55 +7,12 @@
|
||||
|
||||
#include "../lib/logger.h"
|
||||
|
||||
// maximum number of records that can be stored in a fieldset
|
||||
#define MAX_FIELDS 128
|
||||
|
||||
// types of data that can be stored in a field
|
||||
#define FS_STRING 0
|
||||
#define FS_UINT64 1
|
||||
#define FS_BINARY 2
|
||||
|
||||
// definition of a field that's provided by a probe module
|
||||
// these are used so that users can ask at the command-line
|
||||
// what fields are available for consumption
|
||||
typedef struct field_def {
|
||||
const char *name;
|
||||
const char *type;
|
||||
const char *desc;
|
||||
} field_def_t;
|
||||
|
||||
// the internal field type used by fieldset
|
||||
typedef struct field {
|
||||
const char *name;
|
||||
int type;
|
||||
int free_;
|
||||
size_t len;
|
||||
void *value;
|
||||
} field_t;
|
||||
|
||||
// data structure that is populated by the probe module
|
||||
// and translated into the data structure that's passed
|
||||
// to the output module
|
||||
typedef struct fieldset {
|
||||
int len;
|
||||
field_t fields[MAX_FIELDS];
|
||||
} fieldset_t;
|
||||
|
||||
// we pass a different fieldset to an output module than
|
||||
// the probe module generates for us because a user may
|
||||
// only want certain fields and will expect them in a certain
|
||||
// order. We generate a translated fieldset that contains
|
||||
// only the fields we want to export to the output module.
|
||||
// a translation specifies how to efficiently convert the fs
|
||||
// povided by the probe module to the fs for the output module.
|
||||
typedef struct translation {
|
||||
int len;
|
||||
int translation[MAX_FIELDS];
|
||||
} translation_t;
|
||||
|
||||
int fs_split_string(int *len, char**results)
|
||||
{
|
||||
|
||||
(void)len;
|
||||
(void)results;
|
||||
return 0;
|
||||
}
|
||||
|
||||
fieldset_t *fs_new_fieldset(void)
|
||||
@@ -112,7 +69,7 @@ void fs_free(fieldset_t *fs)
|
||||
|
||||
translation_t *fs_generate_fieldset_translation()
|
||||
{
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fieldset_t *translate_fieldset(fieldset_t *fs, translation_t *t)
|
||||
@@ -126,4 +83,6 @@ fieldset_t *translate_fieldset(fieldset_t *fs, translation_t *t)
|
||||
memcpy(&(retv->fields[i]), &(fs->fields[o]), sizeof(field_t));
|
||||
}
|
||||
retv->len = t->len;
|
||||
return retv;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user