Changeset 1352:32e2b93fd9b5 in roaraudio for libroar/vio_proto.c
- Timestamp:
- 03/23/09 18:54:52 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/vio_proto.c
r1349 r1352 112 112 113 113 int roar_vio_open_proto_http (struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * host, char * file) { 114 return -1; 114 char buf[1024]; 115 char b0[80], b1[80]; 116 int status; 117 int len; 118 119 if ( calls == NULL || dst == NULL || host == NULL || file == NULL ) 120 return -1; 121 122 roar_vio_printf(dst, "GET /%s HTTP/1.1\r\n", file); 123 roar_vio_printf(dst, "Host: %s\r\n", host); 124 roar_vio_printf(dst, "User-Agent: roar_vio_open_proto_http() $Revision$\r\n"); 125 roar_vio_printf(dst, "Connection: close\r\n"); 126 roar_vio_printf(dst, "\r\n"); 127 128 roar_vio_sync(dst); 129 130 if ( (len = roar_vio_read(dst, buf, 1023)) < 1 ) 131 return -1; 132 133 buf[len] = 0; 134 135 if ( sscanf(buf, "%79s %i %79s\n", b0, &status, b1) != 3 ) { 136 return -1; 137 } 138 139 if ( status != 200 ) 140 return -1; 141 142 ROAR_WARN("roar_vio_open_proto_http(*): status=%i", status); 143 // ROAR_WARN("roar_vio_open_proto_http(*): buf='%s'", buf); 144 145 if ( !strcmp((buf+len)-4, "\r\n\r\n") ) 146 return 0; 147 148 while (*buf != '\r' && *buf != '\n') { 149 if ( (len = roar_vio_read(dst, buf, 1023)) < 1 ) 150 return -1; 151 } 152 153 return 0; 115 154 } 116 155 117 156 int roar_vio_open_proto_gopher (struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * host, char * file) { 118 int len;119 120 157 if ( calls == NULL || dst == NULL || host == NULL || file == NULL ) 121 158 return -1; … … 123 160 ROAR_DBG("roar_vio_open_proto_gopher(calls=%p, dst=%p, host='%s', file='%s') = ?", calls, dst, host, file); 124 161 125 len = strlen(file); 162 if ( file[1] == '/' ) 163 file += 2; 126 164 127 if ( roar_vio_write(dst, file, len) != len ) 128 return -1; 129 130 if ( roar_vio_write(dst, "\n", 1) != 1 ) 131 return -1; 165 roar_vio_printf(dst, "/%s\r\n", file); 132 166 133 167 roar_vio_sync(dst); // for encryption/compression layers
Note: See TracChangeset
for help on using the changeset viewer.