Changeset 75:bca1641a0cd8 in roaraudio


Ignore:
Timestamp:
07/12/08 17:18:37 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support to open files like sockets

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/socket.h

    r69 r75  
    1212#define ROAR_SOCKET_TYPE_FORK 3 
    1313#define ROAR_SOCKET_TYPE_PIPE ROAR_SOCKET_TYPE_FORK 
     14#define ROAR_SOCKET_TYPE_FILE 4 
    1415 
    1516#define ROAR_SOCKET_QUEUE_LEN 8 
     
    2728int roar_socket_open       (int mode, int type, char * host, int port); 
    2829int roar_socket_open_fork  (int mode, char * host, int port); 
     30int roar_socket_open_file  (int mode, char * host, int port); 
    2931int roar_socket_open_proxy (int mode, int type, char * host, int port, char * proxy_type); 
    3032 
  • libroar/socket.c

    r71 r75  
    126126 } else if ( type == ROAR_SOCKET_TYPE_FORK ) { 
    127127  return roar_socket_open_fork(mode, host, port); 
     128 } else if ( type == ROAR_SOCKET_TYPE_FILE ) { 
     129  return roar_socket_open_file(mode, host, port); 
    128130 } else { 
    129131  return -1; 
     
    178180 
    179181 return -1; 
     182} 
     183 
     184int roar_socket_open_file  (int mode, char * host, int port) { 
     185 int fh; 
     186 
     187 if ( mode == MODE_LISTEN ) 
     188  return -1; 
     189 
     190 if ( (fh = open(host, O_RDONLY, 0644)) == -1 ) { 
     191  ROAR_ERR("roar_socket_open_file(*): Can not open file %s: %s", host, strerror(errno)); 
     192 } 
     193 
     194 return fh; 
    180195} 
    181196 
Note: See TracChangeset for help on using the changeset viewer.