Page 1 of 1

C code in xHarbour

Posted: Wed Apr 28, 2021 4:46 pm
by ctoas
Hey guys

I read in several places that it would be possible to execute C code directly in xHarbour, but I didn't understand how to do it. Could you give me a help?

Thanks

Code: Select all

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.gerencianet.com.br/v1/charge");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Authorization: {{Authorization}}");
  headers = curl_slist_append(headers, "Content-Type: application/json");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\n  \"items\": [\n    {\n      \"name\": \"item\",\n      \"value\": 500,\n      \"amount\": 1\n    }\n  ]\n}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);