add libcurl basic example

This commit is contained in:
talksik
2025-07-26 18:30:12 -07:00
parent 3bb287fcd5
commit 1d0cb5bb93
3 changed files with 44 additions and 1 deletions
+27
View File
@@ -3,6 +3,7 @@
#include <alsa/asoundlib.h>
#include <alsa/control.h>
#include <alsa/pcm.h>
#include <curl/curl.h>
// NOTE: find this via `arecord -l`
#define ALSA_MIC_HARDWARE_DEVICE "hw:3"
@@ -13,6 +14,32 @@ void print_pcm_state(snd_pcm_t *pcm_handle) {
printf("State of pcm handle: %s\n", state_name);
}
size_t write_callback(void *contents, size_t size, size_t nmemb, void *userp) {
size_t total_size = size * nmemb;
printf("%.*s", (int)total_size, (char*)contents);
return total_size;
}
void test_request() {
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.com");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
res = curl_easy_perform(curl);
if (res != CURLE_OK)
{
fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));
return;
}
curl_easy_cleanup(curl);
}
}
int main() {
snd_pcm_t *pcm_handle = NULL;