#include <curl/curl.h>
#include <stdio.h>
#include <string.h>

//long_url - not shortened url
//service - what service to use, see defines
int shorturl(char long_url[], char service[])
{
  //make a request url string for shortener
  char req[strlen(service) + strlen(long_url)];

  sprintf(req, service, long_url); //write a req url to string

  CURL *handle = curl_easy_init(); //curl init

  if (!handle) {
    return -1;
  } //check init

  curl_easy_setopt(handle, CURLOPT_URL, req); //setopt
  curl_easy_perform(handle); //do it
  curl_easy_cleanup(handle); //clean up

  printf("\n");
  return 0;
}
