bashed curl instead of libcurl

master
q3k 2012-04-28 21:10:15 +00:00
parent 545a7bf041
commit 5cabf543ff
1 changed files with 18 additions and 20 deletions

View File

@ -1,7 +1,7 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <unistd.h>
#include "base64.h"
@ -22,26 +22,24 @@ void tts_speak(char *Text)
char *URL = (char *)malloc(strlen(B64Output) + strlen(g_IvonaURL));
sprintf(URL, g_IvonaURL, B64Output);
printf("URL: %s\n", URL);
if (!fork())
{
printf("Forking...\n");
char *CommandLine = malloc(strlen(URL) + 100);
sprintf(CommandLine, "curl -L -A Mozilla \"%s\" | mpg123 -2 -q -", URL);
printf("Cline: %s\n", CommandLine);
char *Arguments[4];
Arguments[0] = "bash";
Arguments[1] = "-c";
Arguments[2] = CommandLine;
Arguments[3] = 0;
char *Environment[1];
Environment[0] = 0;
execve("/bin/bash", Arguments, Environment);
}
CURL *Curl;
CURLcode Result;
FILE *File;
File = fopen("/tmp/hf-tts.mp3", "w");
Curl = curl_easy_init();
curl_easy_setopt(Curl, CURLOPT_URL, URL);
curl_easy_setopt(Curl, CURLOPT_WRITEFUNCTION, tts_write_data);
curl_easy_setopt(Curl, CURLOPT_WRITEDATA, File);
curl_easy_setopt(Curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS);
curl_easy_setopt(Curl, CURLOPT_FOLLOWLOCATION, 1);
Result = curl_easy_perform(Curl);
curl_easy_cleanup(Curl);
fclose(File);
system("mpg123 -q -2 /tmp/hf-tts.mp3");
free((void *)URL);
free((void *)B64Output);
}