#include #include #include #include #include "midimcast.h" void env_read_common(const char **const mcast_group, uint16_t *const mcast_port) { midimcast_debug = getenv("DEBUG") != NULL; *mcast_group = getenv("MCAST_GROUP"); if (!*mcast_group) *mcast_group = "224.212.21.175"; debug("Using multicast group %s", *mcast_group); const char *const mcast_port_str = getenv("MCAST_PORT"); if (mcast_port_str) { const long mcast_port_untrunc = strtol(mcast_port_str, NULL, 0); if (mcast_port_untrunc < 0 || mcast_port_untrunc > UINT16_MAX) err("Port %ld does not exist", mcast_port_untrunc); *mcast_port = mcast_port_untrunc; } else { *mcast_port = 8000; } debug("Using multicast port %" PRIu16, *mcast_port); } uint64_t now() { struct timespec ts; err_std(clock_gettime, CLOCK_REALTIME, &ts); return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; }