UniRec
2.9.3
|
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include "fields.c"
Go to the source code of this file.
Functions | |
UR_FIELDS (uint32 FOO, uint32 BAR, ipaddr IP, string STR1, string STR2,) int main(int argc | |
ur_set (tmplt, rec, F_FOO, 12345) | |
ur_set (tmplt, rec, F_BAR, 54321) | |
ur_set (tmplt, rec, F_IP, ip_from_int(12345678)) | |
ur_set_string (tmplt, rec, F_STR1, "Hello World!") | |
memcpy (buffer, rec, ur_rec_size(tmplt, rec)) | |
free (rec) | |
ur_free_template (tmplt) | |
printf ("%u %u %u %s\, ur_get(tmplt, buffer, F_FOO), ip_get_v4_as_int(&(ur_get(tmplt, buffer, F_IP))), ur_get_var_len(tmplt, buffer, F_STR1), ur_get_ptr(tmplt, buffer, F_STR1)) | |
if (new_id< 0) | |
ur_copy_fields (tmplt2, buffer2, tmplt1, buffer) | |
ur_set_string (tmplt2, buffer2, F_STR2, "The second string") | |
*uint16_t * | ur_get_ptr_by_id (tmplt2, buffer2, new_id)) |
ur_free_template (tmplt1) | |
ur_free_template (tmplt2) | |
printf (" new field %d\, new_id) | |
printf ("%u %u %s %u %s %u\, ur_get(tmplt, buffer2, F_BAR), ur_get_var_len(tmplt, buffer2, F_STR1), ur_get_ptr(tmplt, buffer2, F_STR1), ur_get_var_len(tmplt, buffer2, F_STR2), ur_get_ptr(tmplt, buffer2, F_STR2), *(uint16_t *) ur_get_ptr_by_id(tmplt, buffer2, new_id)) | |
free (buffer) | |
free (buffer2) | |
ur_finalize () | |
Variables | |
char ** | argv |
void * | rec = ur_create_record(tmplt, 512) |
buffer = malloc(ur_rec_size(tmplt, rec)) | |
ur_template_t * | tmplt1 = ur_create_template("FOO,BAR,IP,STR1", NULL) |
ur_template_t * | tmplt2 = ur_create_template("BAR,STR1,STR2,NEW", NULL) |
buffer2 = ur_create_record(tmplt2, ur_get_var_len(tmplt1, buffer, F_STR1) + 64) | |
ur_field_id_t | new_id = ur_get_id_by_name("NEW") |
return | |
free | ( | rec | ) |
free | ( | buffer | ) |
free | ( | buffer2 | ) |
if | ( | ) |
Definition at line 78 of file example_unirec.c.
memcpy | ( | buffer | , |
rec | , | ||
ur_rec_size(tmplt, rec) | |||
) |
printf | ( | "%u %u %u %s\ | , |
ur_get(tmplt, buffer, F_FOO) | , | ||
ip_get_v4_as_int(&(ur_get(tmplt, buffer, F_IP))) | , | ||
ur_get_var_len(tmplt, buffer, F_STR1) | , | ||
ur_get_ptr(tmplt, buffer, F_STR1) | |||
) |
printf | ( | " new field %d\ | , |
new_id | |||
) |
printf | ( | "%u %u %s %u %s %u\ | , |
ur_get(tmplt, buffer2, F_BAR) | , | ||
ur_get_var_len(tmplt, buffer2, F_STR1) | , | ||
ur_get_ptr(tmplt, buffer2, F_STR1) | , | ||
ur_get_var_len(tmplt, buffer2, F_STR2) | , | ||
ur_get_ptr(tmplt, buffer2, F_STR2) | , | ||
* | uint16_t *) ur_get_ptr_by_id(tmplt, buffer2, new_id | ||
) |
UR_FIELDS | ( | uint32 | FOO, |
uint32 | BAR, | ||
ipaddr | IP, | ||
string | STR1, | ||
string | STR2 | ||
) |
ur_free_template | ( | tmplt | ) |
ur_free_template | ( | tmplt1 | ) |
ur_free_template | ( | tmplt2 | ) |
ur_set | ( | tmplt | , |
rec | , | ||
F_FOO | , | ||
12345 | |||
) |
ur_set | ( | tmplt | , |
rec | , | ||
F_BAR | , | ||
54321 | |||
) |
ur_set | ( | tmplt | , |
rec | , | ||
F_IP | , | ||
ip_from_int(12345678) | |||
) |
ur_set_string | ( | tmplt | , |
rec | , | ||
F_STR1 | , | ||
"Hello World!" | |||
) |
char** argv |
Definition at line 26 of file example_unirec.c.
buffer = malloc(ur_rec_size(tmplt, rec)) |
Definition at line 43 of file example_unirec.c.
buffer2 = ur_create_record(tmplt2, ur_get_var_len(tmplt1, buffer, F_STR1) + 64) |
Definition at line 88 of file example_unirec.c.
ur_field_id_t new_id = ur_get_id_by_name("NEW") |
Definition at line 115 of file example_unirec.c.
void* rec = ur_create_record(tmplt, 512) |
Definition at line 35 of file example_unirec.c.
return |
Definition at line 135 of file example_unirec.c.
ur_template_t* tmplt1 = ur_create_template("FOO,BAR,IP,STR1", NULL) |
Definition at line 84 of file example_unirec.c.
ur_template_t* tmplt2 = ur_create_template("BAR,STR1,STR2,NEW", NULL) |
Definition at line 85 of file example_unirec.c.