Files
MicrOBU/obu-firmware/external/vanetza-idf/vanetza/asn1/support/asn_internal.c
T
Ashin Walpola d107534eb2 Keep vanetza-idf in obu-firmware, so a plain clone builds the firmware
obu-firmware builds against the vanetza-idf C-ITS library, which until now
came from the colleague's microbu-esp32c5 tree beside the repository and was
not tracked here, so a clone of this repository could not build the firmware
it ships. The library alone is now part of obu-firmware, as
obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit
cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from
there by default; -DVANETZA_IDF_DIR still points the build elsewhere.

The rest of the colleague's tree (their own VAM firmware, PKI tooling,
station-link Python tools, the V2X2MAP bridge) stays out of this repository
and gitignored; nothing is pushed to their repository. NOTES.md, docs/06,
TODO.md and the pcap verifier's usage line point at the new location.
2026-09-24 10:56:05 +02:00

51 lines
1.1 KiB
C

#include "asn_internal.h"
ssize_t
asn__format_to_callback(int (*cb)(const void *, size_t, void *key), void *key,
const char *fmt, ...) {
char scratch[64];
char *buf = scratch;
size_t buf_size = sizeof(scratch);
int wrote;
int cb_ret;
do {
va_list args;
va_start(args, fmt);
wrote = vsnprintf(buf, buf_size, fmt, args);
va_end(args);
if(wrote < (ssize_t)buf_size) {
if(wrote < 0) {
if(buf != scratch) FREEMEM(buf);
return -1;
}
break;
}
buf_size <<= 1;
if(buf == scratch) {
buf = MALLOC(buf_size);
if(!buf) {
return -1;
}
} else {
void *p = REALLOC(buf, buf_size);
if(!p) {
FREEMEM(buf);
return -1;
}
buf = p;
}
} while(1);
cb_ret = cb(buf, wrote, key);
if(buf != scratch) FREEMEM(buf);
if(cb_ret < 0) {
return -1;
}
return wrote;
}