From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- mpeglib/lib/input/httpInputStream.cpp | 327 ++++++++++++++++++++++++++++++++++ 1 file changed, 327 insertions(+) create mode 100644 mpeglib/lib/input/httpInputStream.cpp (limited to 'mpeglib/lib/input/httpInputStream.cpp') diff --git a/mpeglib/lib/input/httpInputStream.cpp b/mpeglib/lib/input/httpInputStream.cpp new file mode 100644 index 00000000..df2f09c4 --- /dev/null +++ b/mpeglib/lib/input/httpInputStream.cpp @@ -0,0 +1,327 @@ +/* + reads input data + Copyright (C) 1999 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + + +#include "httpInputStream.h" + +#ifndef INADDR_NONE +#define INADDR_NONE 0xffffffff +#endif + +#include + +using namespace std; + +static const char *httpstr="http://"; + + + +static char *strndup(char *src,int num) { + char *dst; + + if(!(dst=(char *)malloc(num+1)))return NULL; + dst[num]='\0'; + + return strncpy(dst, src, num); +} + +static char *url2hostport(char *url,char **hname, + unsigned long *hip,unsigned int *port) { + char *cptr; + struct hostent *myhostent; + struct in_addr myaddr; + int isip=1; + + if(!(strncmp(url,httpstr,7)))url+=7; + cptr=url; + while(*cptr && *cptr!=':' && *cptr!='/') { + if((*cptr<'0' || *cptr>'9') && *cptr!='.')isip=0; + cptr++; + } + if(!(*hname=strndup(url,cptr-url))) { + *hname=NULL; + return NULL; + } + if(!isip) + { + if (!(myhostent=gethostbyname(*hname)))return NULL; + memcpy(&myaddr,myhostent->h_addr,sizeof(myaddr)); + *hip=myaddr.s_addr; + } + else if((*hip=inet_addr(*hname))==INADDR_NONE)return NULL; + if(!*cptr || *cptr=='/') { + *port=80; + return cptr; + } + *port=atoi(++cptr); + while(*cptr && *cptr!='/')cptr++; + return cptr; +} + + + + + + + + + + + + + +HttpInputStream::HttpInputStream() { + + proxyurl=NULL; + proxyip=0; + lopen=false; + byteCnt=0; +} + + +HttpInputStream::~HttpInputStream() { + close(); +} + + +int HttpInputStream::open(const char* filename) { + close(); + if (filename == NULL) { + return false; + } + /* + int matchPos=InputStream::getPath(filename,"http"); + if (matchPos=0) { + return false; + } + */ + + char* filename2=strdup(filename); + if((fp=http_open(filename2))==NULL) { + cout << "seterrorcode(SOUND_ERROR_FILEOPENFAIL)"<