- mod_path (untested)
[assman] / src / mod_url.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #ifdef BUILD_MOD_URL
6 #include <curl/curl.h>
7
8 static const char *get_temp_dir(void);
9
10 static char *tmpdir, *cachedir;
11
12 struct ass_fileops *ass_alloc_url(const char *url)
13 {
14         static int done_init;
15         struct ass_fileops *fop;
16
17         if(!done_init) {
18                 curl_global_init(CURL_GLOBAL_ALL);
19                 atexit(curl_global_cleanup);
20                 done_init = 1;
21
22                 if(!*ass_mod_url_cachedir) {
23                         strcpy(ass_mod_url_cachedir, "assman_cache");
24                 }
25                 tmpdir = get_temp_dir();
26                 if(!(cachedir = malloc(strlen(ass_mod_url_cachedir) + strlen(tmpdir) + 2))) {
27                         fprintf(stderr, "assman: failed to allocate cachedir path buffer\n");
28                         return 0;
29                 }
30                 sprintf(cachedir, "%s/%s", tmpdir, ass_mod_url_cachedir);
31         }
32
33         if(!(fop = malloc(sizeof *fop))) {
34                 return 0;
35         }
36
37         fop->udata = 0;
38         fop->open = fop_open;
39         fop->close = fop_close;
40         fop->seek = fop_seek;
41         fop->read = fop_read;
42         return fop;
43 }
44
45 void ass_free_url(struct ass_fileops *fop)
46 {
47 }
48
49 static void *fop_open(const char *fname, void *udata)
50 {
51         return 0;       /* TODO */
52 }
53
54 static void fop_close(void *fp, void *udata)
55 {
56 }
57
58 static long fop_seek(void *fp, long offs, int whence, void *udata)
59 {
60         return 0;
61 }
62
63 static long fop_read(void *fp, void *buf, long size, void *udata)
64 {
65         return 0;
66 }
67
68 #else
69 int ass_mod_url_disabled;
70 #endif