Changeset 4832:085f96f6555c in roaraudio


Ignore:
Timestamp:
04/03/11 11:02:47 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

support gopher URLs not starting with /. report mime types for gopher objects if a 1:1 mapping is possible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/vio_proto.c

    r4830 r4832  
    3636#include "libroar.h" 
    3737 
     38#ifndef ROAR_WITHOUT_VIO_PROTO 
     39#include <roaraudio/proto_gopher.h> 
     40#endif 
     41 
    3842int roar_vio_proto_init_def  (struct roar_vio_defaults * def, char * dstr, int proto, struct roar_vio_defaults * odef) { 
    3943#ifndef ROAR_WITHOUT_VIO_PROTO 
     
    525529 
    526530int roar_vio_open_proto_gopher (struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * host, char * file) { 
     531 struct roar_vio_proto * self; 
     532 char type; 
     533 const char * mime = NULL; 
     534 
    527535 if ( calls == NULL || dst == NULL || host == NULL || file == NULL ) 
    528536  return -1; 
    529537 
     538 self         = calls->inst; 
    530539 calls->write = NULL; // Disable write as we do not support this 
    531540 
    532541 ROAR_DBG("roar_vio_open_proto_gopher(calls=%p, dst=%p, host='%s', file='%s') = ?", calls, dst, host, file); 
    533542 
    534  if ( file[1] == '/' ) 
    535   file += 2; 
    536  
    537  roar_vio_printf(dst, "/%s\r\n", file); 
     543 type = file[0]; 
     544 
     545 file++; 
     546 
     547 ROAR_DBG("roar_vio_open_proto_gopher(*): type='%c'", type); 
     548 
     549 switch (type) { 
     550  case ROAR_GOPHER_TYPE_FILE: 
     551    mime = "text/plain"; 
     552   break; 
     553  case ROAR_GOPHER_TYPE_DIR: 
     554    mime = "inode/directory"; 
     555   break; 
     556  case ROAR_GOPHER_TYPE_BIN: 
     557    mime = "application/octet-stream"; 
     558   break; 
     559  case ROAR_GOPHER_TYPE_GIF: 
     560    mime = "image/gif"; 
     561   break; 
     562  case ROAR_GOPHER_TYPE_HTML: 
     563    mime = "text/html"; 
     564   break; 
     565 } 
     566 
     567 if ( mime != NULL ) { 
     568  self->content_type = roar_mm_strdup(mime); 
     569 } 
     570 
     571 roar_vio_printf(dst, "%s\r\n", file); 
    538572 
    539573 roar_vio_sync(dst); // for encryption/compression layers 
Note: See TracChangeset for help on using the changeset viewer.