Changeset 5253:a9d4cba9e8dc in roaraudio
- Timestamp:
- 11/13/11 17:01:45 (12 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/vio_dstr.h
r5227 r5253 140 140 141 141 union { 142 c har *file;143 int fh;142 const char * file; 143 int fh; 144 144 struct { 145 145 int domain; 146 146 int type; 147 c har* host;147 const char * host; 148 148 union { 149 149 struct sockaddr sa; -
include/libroar/vio_socket.h
r4708 r5253 51 51 int roar_vio_socket_get_port (char * service, int domain, int type); 52 52 53 int roar_vio_socket_init_unix_def (struct roar_vio_defaults * def, c har * path);53 int roar_vio_socket_init_unix_def (struct roar_vio_defaults * def, const char * path); 54 54 55 55 int roar_vio_socket_init_decnetnode_def(struct roar_vio_defaults * def); 56 int roar_vio_socket_init_decnet_def (struct roar_vio_defaults * def, c har * node, int object, char * objname);56 int roar_vio_socket_init_decnet_def (struct roar_vio_defaults * def, const char * node, int object, char * objname); 57 57 58 58 int roar_vio_socket_init_inet4host_def(struct roar_vio_defaults * def); 59 int roar_vio_socket_init_inet4_def (struct roar_vio_defaults * def, c har * host, int port, int type);60 int roar_vio_socket_init_tcp4_def (struct roar_vio_defaults * def, c har * host, int port);61 int roar_vio_socket_init_udp4_def (struct roar_vio_defaults * def, c har * host, int port);59 int roar_vio_socket_init_inet4_def (struct roar_vio_defaults * def, const char * host, int port, int type); 60 int roar_vio_socket_init_tcp4_def (struct roar_vio_defaults * def, const char * host, int port); 61 int roar_vio_socket_init_udp4_def (struct roar_vio_defaults * def, const char * host, int port); 62 62 int roar_vio_socket_init_inet6host_def(struct roar_vio_defaults * def); 63 int roar_vio_socket_init_inet6_def (struct roar_vio_defaults * def, c har * host, int port, int type);64 int roar_vio_socket_init_tcp6_def (struct roar_vio_defaults * def, c har * host, int port);65 int roar_vio_socket_init_udp6_def (struct roar_vio_defaults * def, c har * host, int port);63 int roar_vio_socket_init_inet6_def (struct roar_vio_defaults * def, const char * host, int port, int type); 64 int roar_vio_socket_init_tcp6_def (struct roar_vio_defaults * def, const char * host, int port); 65 int roar_vio_socket_init_udp6_def (struct roar_vio_defaults * def, const char * host, int port); 66 66 67 67 #endif -
libroar/vio.c
r5242 r5253 306 306 // converters: 307 307 int roar_vio_open_file (struct roar_vio_calls * calls, const char * filename, int flags, mode_t mode) { 308 #ifdef _CAN_OPERATE 309 int fh; 308 struct roar_vio_defaults def; 310 309 311 310 roar_debug_warn_obsolete("roar_vio_open_file", "roar_vio_open_dstr", NULL); 312 311 313 if ( calls == NULL || filename == NULL ) { 314 roar_err_set(ROAR_ERROR_FAULT); 315 return -1; 316 } 317 318 #ifdef ROAR_TARGET_WIN32 319 flags |= O_BINARY; 320 #endif 321 322 roar_err_clear_all(); 323 if ( (fh = open(filename, flags, mode)) == -1 ) { 324 ROAR_DBG("roar_vio_open_file(*): errno=%s", strerror(errno)); 325 roar_err_update(); 326 ROAR_DBG("roar_vio_open_file(*): errno=%s", strerror(errno)); 327 return -1; 328 } 329 330 if ( roar_vio_open_fh(calls, fh) == -1 ) { 331 close(fh); 332 roar_err_update(); 333 return -1; 334 } 335 336 roar_err_update(); 337 return 0; 338 #else 339 return -1; 340 #endif 312 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_FILE, flags, mode) == -1 ) 313 return -1; 314 315 def.d.file = filename; 316 317 return roar_vio_open_default(calls, &def, NULL); 341 318 } 342 319 -
libroar/vio_dstr.c
r5227 r5253 322 322 323 323 #ifndef ROAR_WITHOUT_VIO_DSTR 324 #ifdef ROAR_HAVE_IO_POSIX 325 static int _open_file(struct roar_vio_calls * calls, const char * filename, int flags, mode_t mode) { 326 int fh; 327 328 if ( calls == NULL || filename == NULL ) { 329 roar_err_set(ROAR_ERROR_FAULT); 330 return -1; 331 } 332 333 #ifdef ROAR_TARGET_WIN32 334 flags |= O_BINARY; 335 #endif 336 337 roar_err_clear_all(); 338 if ( (fh = open(filename, flags, mode)) == -1 ) { 339 roar_err_update(); 340 return -1; 341 } 342 343 if ( roar_vio_open_fh(calls, fh) == -1 ) { 344 close(fh); 345 roar_err_to_errno(); 346 return -1; 347 } 348 349 roar_err_update(); 350 return 0; 351 } 352 #endif 353 324 354 int roar_vio_open_default (struct roar_vio_calls * calls, struct roar_vio_defaults * def, char * opts) { 325 355 ROAR_DBG("roar_vio_open_default(calls=%p, def=%p, opts='%s') = ?", calls, def, opts); 326 356 327 if ( calls == NULL || def == NULL ) 328 return -1; 357 if ( calls == NULL || def == NULL ) { 358 roar_err_set(ROAR_ERROR_FAULT); 359 return -1; 360 } 329 361 330 362 switch (def->type) { … … 332 364 break; 333 365 case ROAR_VIO_DEF_TYPE_FILE: 334 roar_libroar_nowarn(); 335 if ( roar_vio_open_file(calls, def->d.file, def->o_flags, def->o_mode) == -1 ) { 336 roar_libroar_warn(); 366 if ( _open_file(calls, def->d.file, def->o_flags, def->o_mode) == -1 ) { 337 367 ROAR_DBG("roar_vio_open_default(*): Can not open file: %i", roar_error); 338 368 return -1; 339 369 } 340 roar_libroar_warn();341 370 break; 342 371 case ROAR_VIO_DEF_TYPE_SOCKET: -
libroar/vio_socket.c
r5248 r5253 493 493 494 494 // AF_UNIX: 495 int roar_vio_socket_init_unix_def (struct roar_vio_defaults * def, c har * path) {495 int roar_vio_socket_init_unix_def (struct roar_vio_defaults * def, const char * path) { 496 496 #if defined(ROAR_HAVE_UNIX) && defined(_CAN_OPERATE) 497 497 if ( def == NULL || path == NULL ) … … 519 519 return -1; 520 520 521 if ( (node = def->d.socket.host) == NULL ) 521 if ( def->d.socket.host == NULL ) 522 return -1; 523 524 if ( (node = roar_mm_strdup(def->d.socket.host)) == NULL ) 522 525 return -1; 523 526 … … 525 528 *ed = 0; 526 529 527 if ( (ne = getnodebyname(node)) == NULL ) { 530 ne = getnodebyname(node); 531 532 roar_mm_free(ed); 533 534 if ( ne == NULL ) { 528 535 ROAR_ERR("roar_vio_socket_init_decnetnode_def(*): Can\'t resolve node name '%s'", node); 529 if ( ed != NULL ) *ed = '/';530 536 return -1; 531 537 } … … 533 539 memcpy(&(def->d.socket.sa.dn.sdn_add.a_addr), ne->n_addr, 2); 534 540 535 if ( ed != NULL ) *ed = '/'; 536 537 538 return 0; 539 #else 540 return -1; 541 #endif 542 } 543 544 int roar_vio_socket_init_decnet_def (struct roar_vio_defaults * def, char * node, int object, char * objname) { 541 return 0; 542 #else 543 return -1; 544 #endif 545 } 546 547 int roar_vio_socket_init_decnet_def (struct roar_vio_defaults * def, const char * node, int object, char * objname) { 545 548 #if defined(ROAR_HAVE_LIBDNET) && defined(_CAN_OPERATE) 546 549 struct sockaddr_dn * dn; … … 626 629 } 627 630 628 int roar_vio_socket_init_inet4_def (struct roar_vio_defaults * def, c har * host, int port, int type) {631 int roar_vio_socket_init_inet4_def (struct roar_vio_defaults * def, const char * host, int port, int type) { 629 632 #if defined(ROAR_HAVE_IPV4) && defined(_CAN_OPERATE) 630 633 if ( roar_vio_socket_init_socket_def(def, AF_INET, type) == -1 ) … … 641 644 } 642 645 643 int roar_vio_socket_init_tcp4_def (struct roar_vio_defaults * def, c har * host, int port) {646 int roar_vio_socket_init_tcp4_def (struct roar_vio_defaults * def, const char * host, int port) { 644 647 return roar_vio_socket_init_inet4_def(def, host, port, SOCK_STREAM); 645 648 } 646 649 647 int roar_vio_socket_init_udp4_def (struct roar_vio_defaults * def, c har * host, int port) {650 int roar_vio_socket_init_udp4_def (struct roar_vio_defaults * def, const char * host, int port) { 648 651 return roar_vio_socket_init_inet4_def(def, host, port, SOCK_DGRAM); 649 652 } … … 652 655 // AF_INET6: 653 656 int roar_vio_socket_init_inet6host_def(struct roar_vio_defaults * def); 654 int roar_vio_socket_init_inet6_def (struct roar_vio_defaults * def, c har * host, int port, int type) {655 return -1; 656 } 657 658 int roar_vio_socket_init_tcp6_def (struct roar_vio_defaults * def, c har * host, int port) {657 int roar_vio_socket_init_inet6_def (struct roar_vio_defaults * def, const char * host, int port, int type) { 658 return -1; 659 } 660 661 int roar_vio_socket_init_tcp6_def (struct roar_vio_defaults * def, const char * host, int port) { 659 662 return roar_vio_socket_init_inet6_def(def, host, port, SOCK_STREAM); 660 663 } 661 664 662 int roar_vio_socket_init_udp6_def (struct roar_vio_defaults * def, c har * host, int port) {665 int roar_vio_socket_init_udp6_def (struct roar_vio_defaults * def, const char * host, int port) { 663 666 return roar_vio_socket_init_inet6_def(def, host, port, SOCK_DGRAM); 664 667 }
Note: See TracChangeset
for help on using the changeset viewer.