Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef PB071_OSC_H
- #define PB071_OSC_H
- #include <stdint.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define OSC_TIMETAG_IMMEDIATE(p_osc_timetag) ((p_osc_timetag)->sec = 0, (p_osc_timetag)->frac = 1)
- #define OSC_TIMETAG_NULL(p_osc_timetag) ((p_osc_timetag)->sec = 0, (p_osc_timetag)->frac = 0)
- #define OSC_TT_INT 'i'
- #define OSC_TT_STRING 's'
- #define OSC_TT_FLOAT 'f'
- #define OSC_TT_TIMETAG 't'
- #define OSC_TYPETAG(...) (',', __ - VA_ARGS__, '\0')
- #define OSC_MESSAGE_NULL(p_struct_osc_message) ((p_struct_osc_message)->raw_data = NULL, (p_struct_osc_message)->address = NULL, (p_struct_osc_message)->typetag = NULL)
- #define OSC_BUNDLE_NULL(p_struct_osc_bundle) ((p_struct_osc_bundle)->raw_data = NULL, (p_struct_osc_bundle)->timetag = NULL)
- struct osc_timetag
- {
- uint32_t sec;
- uint32_t frac;
- };
- union osc_msg_argument
- {
- const int32_t i;
- const char s;
- const float f;
- const struct osc_timetag t;
- };
- struct osc_message
- {
- char *address;
- char *typetag;
- void *raw_data;
- };
- struct osc_bundle
- {
- struct osc_timetag *timetag;
- void *raw_data;
- };
- int osc_message_new(struct osc_message *msg);
- void osc_message_destroy(struct osc_message *msg);
- int osc_message_set_address(struct osc_message *msg, const char *address);
- size_t get_raw_data_length(struct osc_message *msg);
- size_t get_address_or_typetag_length(const char *address);
- int osc_message_add_int32(struct osc_message *msg, int32_t data);
- int osc_message_add_float(struct osc_message *msg, float data);
- int osc_message_add_timetag(struct osc_message *msg, struct osc_timetag tag);
- int osc_message_add_string(struct osc_message *msg, const char *data);
- size_t osc_message_argc(const struct osc_message *msg);
- size_t osc_message_serialized_length(const struct osc_message *msg);
- const union osc_msg_argument *osc_message_arg(const struct osc_message *msg, size_t arg_index);
- // OSC BUNDLE
- int osc_bundle_new(struct osc_bundle *bnd);
- void osc_bundle_destroy(struct osc_bundle *bn);
- void osc_bundle_set_timetag(struct osc_bundle *bn, struct osc_timetag tag);
- int osc_bundle_add_message(struct osc_bundle *bundle, const struct osc_message *msg);
- size_t osc_bundle_serialized_length(const struct osc_bundle *bundle);
- struct osc_message osc_bundle_next_message(const struct osc_bundle *bundle, struct osc_message prev);
- #endif // PB071_OSC_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement