Files
scallywag-ng/src/http.h
Chris Punches f6020ba96d first commit
2025-12-31 22:25:19 -05:00

47 lines
1.3 KiB
C

/*
* Scallywag-NG: Half the scally, and twice the wag.
* Copyright (C) 2025 SILO GROUP LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SCALLYWAG_HTTP_H
#define SCALLYWAG_HTTP_H
#include <stddef.h>
typedef struct {
char *data;
size_t size;
} HttpResponse;
// Initialize curl globally (call once at startup)
int http_global_init(void);
// Cleanup curl globally (call once at shutdown)
void http_global_cleanup(void);
// Perform GET request, returns NULL on failure
// Caller must free with http_response_free()
HttpResponse *http_get(const char *url);
// Free HTTP response
void http_response_free(HttpResponse *response);
// URL encode a string (uses curl)
// Caller must free with curl_free()
char *http_url_encode(const char *str);
#endif