X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=assman;a=blobdiff_plain;f=src%2Fmod_url.c;fp=src%2Fmod_url.c;h=f254b6833067c373eacb9af7688d9078ad9aad40;hp=0000000000000000000000000000000000000000;hb=b8fc7437862ca32cf79108c7715b8e2566211fb1;hpb=8d90197913f1c5d813b43854f5f769bade5296a8 diff --git a/src/mod_url.c b/src/mod_url.c new file mode 100644 index 0000000..f254b68 --- /dev/null +++ b/src/mod_url.c @@ -0,0 +1,70 @@ +#include +#include +#include + +#ifdef BUILD_MOD_URL +#include + +static const char *get_temp_dir(void); + +static char *tmpdir, *cachedir; + +struct ass_fileops *ass_alloc_url(const char *url) +{ + static int done_init; + struct ass_fileops *fop; + + if(!done_init) { + curl_global_init(CURL_GLOBAL_ALL); + atexit(curl_global_cleanup); + done_init = 1; + + if(!*ass_mod_url_cachedir) { + strcpy(ass_mod_url_cachedir, "assman_cache"); + } + tmpdir = get_temp_dir(); + if(!(cachedir = malloc(strlen(ass_mod_url_cachedir) + strlen(tmpdir) + 2))) { + fprintf(stderr, "assman: failed to allocate cachedir path buffer\n"); + return 0; + } + sprintf(cachedir, "%s/%s", tmpdir, ass_mod_url_cachedir); + } + + if(!(fop = malloc(sizeof *fop))) { + return 0; + } + + fop->udata = 0; + fop->open = fop_open; + fop->close = fop_close; + fop->seek = fop_seek; + fop->read = fop_read; + return fop; +} + +void ass_free_url(struct ass_fileops *fop) +{ +} + +static void *fop_open(const char *fname, void *udata) +{ + return 0; /* TODO */ +} + +static void fop_close(void *fp, void *udata) +{ +} + +static long fop_seek(void *fp, long offs, int whence, void *udata) +{ + return 0; +} + +static long fop_read(void *fp, void *buf, long size, void *udata) +{ + return 0; +} + +#else +int ass_mod_url_disabled; +#endif