Revision a2da678c chunker_player/http.c

View differences:

chunker_player/http.c
1 1
// based on curl/examples/{simple,getinmemory,ftpget}.c
2 2

  
3
#include <string.h>
4
#include <stdlib.h>
3 5
#include <stdio.h>
4 6
#include <curl/curl.h>
5 7

  
......
30 32
  return fwrite(buffer, size, nmemb, out->stream);
31 33
}
32 34

  
33
int http_get2file(char *uri, char*fname)
35
int http_get2file(char *uri, char *fname)
34 36
{
35 37
  CURL *curl;
36 38
  CURLcode res;
......
39 41
    NULL
40 42
  };
41 43

  
44
  if (strncmp(fname, "~/", 2) == 0) {	/* curl can't handle ~ in the filename */
45
    char *fname2;
46
    char *home = getenv("HOME");
47
    if (!home) return -1;
48

  
49
    fname2 = malloc(strlen(home) + strlen(fname));
50
    if (!fname2) return -1;
51

  
52
    strcpy(fname2, home);
53
    strcpy(fname2 + strlen(home), fname+1);
54
    ftpfile.filename = fname2;
55
  }
56

  
42 57
  curl_global_init(CURL_GLOBAL_DEFAULT);
43 58

  
44 59
  curl = curl_easy_init();

Also available in: Unified diff