// SPDX-License-Identifier: Apache-2.0 #pragma once #include #include /** Fallback provider that looks up the location of the public IP address with ip-api.com */ extern const LocationProviderApi ip_location_provider; #define IP_API_MESSAGE_MAX_LENGTH 63 struct IpApiResponse { /** HTTP status code */ int status_code; /** Requests left in the rate limit window, -1 when unknown */ int rate_remaining; /** Seconds until the rate limit window resets, -1 when unknown */ int rate_reset_seconds; bool success; /** Reason of failure, empty on success */ char message[IP_API_MESSAGE_MAX_LENGTH + 1]; double latitude; double longitude; }; /** * Parse an HTTP response of the newline separated ip-api endpoint, requested with fields "status,message,lat,lon" * @param[in] response the NUL-terminated response, including the status line and headers * @return false when the response is malformed */ bool ip_api_parse_response(const char* response, IpApiResponse* out);