summaryrefslogtreecommitdiff
authorsimon <simon>2002-04-30 06:23:23 (UTC)
committer simon <simon>2002-04-30 06:23:23 (UTC)
commit702c4b745d42d9ad5fdcede0a40d85ea1b0577a6 (patch) (unidiff)
treefbe3d9080bd8e8c851464bf2b3e2c5c3c2383c97
parent06be684b1ad4f17fdb5e9ea55560c1d6e4b4bf7d (diff)
downloadopie-702c4b745d42d9ad5fdcede0a40d85ea1b0577a6.zip
opie-702c4b745d42d9ad5fdcede0a40d85ea1b0577a6.tar.gz
opie-702c4b745d42d9ad5fdcede0a40d85ea1b0577a6.tar.bz2
- read(2) and write(2) are not part of the std namespace
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
index 319e0ff..eda5859 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
@@ -272,49 +272,49 @@ int LibMadPlugin::tcp_open(char *address, int port) {
272 if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (char *)&l, sizeof(l)) < 0) { 272 if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (char *)&l, sizeof(l)) < 0) {
273 return (0); 273 return (0);
274 } 274 }
275 275
276 if (connect(sock, (struct sockaddr *)&stAddr, sizeof(stAddr)) < 0) { 276 if (connect(sock, (struct sockaddr *)&stAddr, sizeof(stAddr)) < 0) {
277 return (0); 277 return (0);
278 } 278 }
279 279
280 return (sock); 280 return (sock);
281} 281}
282 282
283 283
284/** 284/**
285 * Read a http line header. 285 * Read a http line header.
286 * This function read character by character. 286 * This function read character by character.
287 * @param tcp_sock the socket use to read the stream 287 * @param tcp_sock the socket use to read the stream
288 * @param buf a buffer to receive the data 288 * @param buf a buffer to receive the data
289 * @param size size of the buffer 289 * @param size size of the buffer
290 * @return the size of the stream read or -1 if an error occured 290 * @return the size of the stream read or -1 if an error occured
291 */ 291 */
292int LibMadPlugin::http_read_line(int tcp_sock, char *buf, int size) { 292int LibMadPlugin::http_read_line(int tcp_sock, char *buf, int size) {
293 int offset = 0; 293 int offset = 0;
294 294
295 do { 295 do {
296 if (std::read(tcp_sock, buf + offset, 1) < 0) 296 if (::read(tcp_sock, buf + offset, 1) < 0)
297 return -1; 297 return -1;
298 if (buf[offset] != '\r') /* Strip \r from answer */ 298 if (buf[offset] != '\r') /* Strip \r from answer */
299 offset++; 299 offset++;
300 } while (offset < size - 1 && buf[offset - 1] != '\n'); 300 } while (offset < size - 1 && buf[offset - 1] != '\n');
301 301
302 buf[offset] = 0; 302 buf[offset] = 0;
303 return offset; 303 return offset;
304} 304}
305 305
306int LibMadPlugin::http_open(const QString& path ) { 306int LibMadPlugin::http_open(const QString& path ) {
307 char *host; 307 char *host;
308 int port; 308 int port;
309 char *request; 309 char *request;
310 int tcp_sock; 310 int tcp_sock;
311 char http_request[PATH_MAX]; 311 char http_request[PATH_MAX];
312 char filename[PATH_MAX]; 312 char filename[PATH_MAX];
313 //char c; 313 //char c;
314 char *arg =strdup(path.latin1()); 314 char *arg =strdup(path.latin1());
315 315
316 /* Check for URL syntax */ 316 /* Check for URL syntax */
317 if (strncmp(arg, "http://", strlen("http://"))) { 317 if (strncmp(arg, "http://", strlen("http://"))) {
318 return (0); 318 return (0);
319 } 319 }
320 320
@@ -364,49 +364,49 @@ int LibMadPlugin::http_open(const QString& path ) {
364 } while (c != '\r'); 364 } while (c != '\r');
365 fprintf(stderr, "\n"); 365 fprintf(stderr, "\n");
366 return (0); 366 return (0);
367 } 367 }
368#endif 368#endif
369 369
370 QString name; 370 QString name;
371 QString genre; 371 QString genre;
372 QString bitrate; 372 QString bitrate;
373 QString url; 373 QString url;
374 QString message = tr("Info: "); 374 QString message = tr("Info: ");
375 do { 375 do {
376 376
377 int len; 377 int len;
378 378
379 len = http_read_line(tcp_sock, http_request, sizeof(http_request)); 379 len = http_read_line(tcp_sock, http_request, sizeof(http_request));
380 380
381 if (len == -1) { 381 if (len == -1) {
382 qDebug( "http_open: "+ QString(strerror(errno)) +"\n"); 382 qDebug( "http_open: "+ QString(strerror(errno)) +"\n");
383 return 0; 383 return 0;
384 } 384 }
385 385
386 if (QString(http_request).left(9) == "Location:") { 386 if (QString(http_request).left(9) == "Location:") {
387 /* redirect */ 387 /* redirect */
388 std::close(tcp_sock); 388 ::close(tcp_sock);
389 http_request[strlen(http_request) - 1] = '\0'; 389 http_request[strlen(http_request) - 1] = '\0';
390 return http_open(&http_request[10]); 390 return http_open(&http_request[10]);
391 } 391 }
392 392
393 if (QString(http_request).left(4) == "ICY ") { 393 if (QString(http_request).left(4) == "ICY ") {
394 /* This is shoutcast/icecast streaming */ 394 /* This is shoutcast/icecast streaming */
395 if (strncmp(http_request + 4, "200 ", 4)) { 395 if (strncmp(http_request + 4, "200 ", 4)) {
396 qDebug("http_open: " + QString(http_request) + "\n"); 396 qDebug("http_open: " + QString(http_request) + "\n");
397 return 0; 397 return 0;
398 } 398 }
399 } else if (QString(http_request).left(4) == "icy-") { 399 } else if (QString(http_request).left(4) == "icy-") {
400 /* we can have: icy-noticeX, icy-name, icy-genre, icy-url, icy-pub, icy-metaint, icy-br */ 400 /* we can have: icy-noticeX, icy-name, icy-genre, icy-url, icy-pub, icy-metaint, icy-br */
401 if ( QString( http_request ).left( 8 ) == "icy-name" ) { 401 if ( QString( http_request ).left( 8 ) == "icy-name" ) {
402 name = tr("Name: ") + QString(http_request).mid(9, (QString(http_request).length())- 9 ); 402 name = tr("Name: ") + QString(http_request).mid(9, (QString(http_request).length())- 9 );
403 } else if ( QString( http_request ).left( 9 ) == "icy-genre" ) { 403 } else if ( QString( http_request ).left( 9 ) == "icy-genre" ) {
404 genre = tr("Genre: ") + QString(http_request).mid(10, (QString(http_request).length())-10 ); 404 genre = tr("Genre: ") + QString(http_request).mid(10, (QString(http_request).length())-10 );
405 } else if ( QString( http_request ).left( 6 ) == "icy-br" ) { 405 } else if ( QString( http_request ).left( 6 ) == "icy-br" ) {
406 bitrate = tr("Bitrate: ") + QString(http_request).mid(7, (QString(http_request).length())- 7 ); 406 bitrate = tr("Bitrate: ") + QString(http_request).mid(7, (QString(http_request).length())- 7 );
407 } else if ( QString( http_request ).left( 7 ) == "icy-url" ) { 407 } else if ( QString( http_request ).left( 7 ) == "icy-url" ) {
408 url = tr("URL: ") + QString(http_request).mid(8, (QString(http_request).length())- 8 ); 408 url = tr("URL: ") + QString(http_request).mid(8, (QString(http_request).length())- 8 );
409 } else if ( QString( http_request ).left( 10 ) == "icy-notice" ) { 409 } else if ( QString( http_request ).left( 10 ) == "icy-notice" ) {
410 message += QString(http_request).mid(11, QString(http_request).length()-11 ) ; 410 message += QString(http_request).mid(11, QString(http_request).length()-11 ) ;
411 } 411 }
412 } 412 }