From c3b525537e944064869a2cd6495733388144ce64 Mon Sep 17 00:00:00 2001 From: Murilo Ijanc Date: Mon, 27 Jul 2026 20:42:22 -0300 Subject: Surface the faixa a 404 now carries A CEP that fails is almost never a random number. It is someone who knows the city and guessed the last digits, and the guess is usually the -000 that 957 municipalities never received. The API answers those 404s with a faixa object naming the municipality that owns the band, which turns "not found" from a dead end into something the caller can act on - and the caller cannot reach it through this library, because the 404 path never looked at the body at all. cepis_error is where a 404 already reports itself, so faixa goes there, as inline storage rather than a pointer: the struct is documented as owning nothing and declared on the caller's stack, and that stays true. It costs sizeof(cepis_error), 272 bytes to 384, so 0.2.0 needs a recompile. The parser needed one new primitive. cepis__json_field could only pull scalars out of a flat object; splitting it over cepis__json_find, which returns a pointer to a value of any shape, reaches one level down without building a document tree - the same depth cepis__geo_parse already needs for geo. Absence is the case that matters: no faixa, an empty one, or one that is not an object all leave the error byte-for-byte what it was before. cep_ini and cep_fim are deliberately not presented as a range. They are the lowest and highest CEP that exist, the band is sparse - Areal's 118 CEPs are scattered over ~4900 numbers - and ceps is the only honest count. --- src/defs.inc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/defs.inc') diff --git a/src/defs.inc b/src/defs.inc index 4a64e0e..b0a38bf 100644 --- a/src/defs.inc +++ b/src/defs.inc @@ -43,12 +43,24 @@ #define H_RAW 40 #define H_SIZE 48 +#define F_PRESENT 0 +#define F_LOCALIDADE 4 +#define F_LOCALIDADE_MAX 72 +#define F_UF 76 +#define F_UF_MAX 3 +#define F_CEP_INI 79 +#define F_CEP_FIM 88 +#define F_CEP_MAX 9 +#define F_CEPS 104 +#define F_SIZE 112 + #define E_STATUS 0 #define E_HTTP_STATUS 4 #define E_RETRY_AFTER 8 #define E_MESSAGE 16 #define E_MSGLEN 256 -#define E_SIZE 272 +#define E_FAIXA 272 +#define E_SIZE 384 #define C_BASE_URL 0 #define C_TIMEOUT 8 -- cgit v1.3