void httpdata_free(struct httpdata *e) { httpdata_reset(e); mpg123_free_string(&e->proxyhost); mpg123_free_string(&e->proxyport); }
/* 1 on success, 0 on failure */ int open_track(char *fname) { filept=-1; httpdata_reset(&htd); if(MPG123_OK != mpg123_param(mh, MPG123_ICY_INTERVAL, 0, 0)) error1("Cannot (re)set ICY interval: %s", mpg123_strerror(mh)); if(!strcmp(fname, "-")) { filept = STDIN_FILENO; #ifdef WIN32 _setmode(STDIN_FILENO, _O_BINARY); #endif return open_track_fd(); } else if (!strncmp(fname, "http://", 7)) /* http stream */ { #if defined (WANT_WIN32_SOCKETS) if(param.streamdump != NULL) { fprintf(stderr, "\nWarning: win32 networking conflicts with stream dumping. Aborting the dump.\n"); dump_close(); } /*Use recv instead of stdio functions */ win32_net_replace(mh); filept = win32_net_http_open(fname, &htd); #else filept = http_open(fname, &htd); #endif network_sockets_used = 1; /* utf-8 encoded URLs might not work under Win32 */ /* now check if we got sth. and if we got sth. good */ if( (filept >= 0) && (htd.content_type.p != NULL) && !APPFLAG(MPG123APP_IGNORE_MIME) && !(debunk_mime(htd.content_type.p) & IS_FILE) ) { error1("Unknown mpeg MIME type %s - is it perhaps a playlist (use -@)?", htd.content_type.p == NULL ? "<nil>" : htd.content_type.p); error("If you know the stream is mpeg1/2 audio, then please report this as "PACKAGE_NAME" bug"); return 0; } if(filept < 0) { error1("Access to http resource %s failed.", fname); return 0; } if(MPG123_OK != mpg123_param(mh, MPG123_ICY_INTERVAL, htd.icy_interval, 0)) error1("Cannot set ICY interval: %s", mpg123_strerror(mh)); if(param.verbose > 1) fprintf(stderr, "Info: ICY interval %li\n", (long)htd.icy_interval); } if(param.icy_interval > 0) { if(MPG123_OK != mpg123_param(mh, MPG123_ICY_INTERVAL, param.icy_interval, 0)) error1("Cannot set ICY interval: %s", mpg123_strerror(mh)); if(param.verbose > 1) fprintf(stderr, "Info: Forced ICY interval %li\n", param.icy_interval); } debug("OK... going to finally open."); /* Now hook up the decoder on the opened stream or the file. */ if(network_sockets_used) { return open_track_fd(); } else if(mpg123_open(mh, fname) != MPG123_OK) { error2("Cannot open %s: %s", fname, mpg123_strerror(mh)); return 0; } debug("Track successfully opened."); fresh = TRUE; return 1; }