Changeset 2059:916b1d6f2b91 in roaraudio


Ignore:
Timestamp:
07/08/09 01:44:25 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

moved vio interface to stdio out of the main vio code

Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/libroar.h

    r2058 r2059  
    9393#include "vio_magic.h" 
    9494#include "vio_bio.h" 
     95#include "vio_stdio.h" 
    9596#include "vio_stack.h" 
    9697#include "vio_pipe.h" 
  • include/libroar/vio.h

    r2058 r2059  
    9090                                                               char * server, int dir, char * name); 
    9191 
    92 int     roar_vio_open_stdio    (struct roar_vio_calls * calls, FILE * dst); 
    93  
    94 FILE *  roar_vio_to_stdio      (struct roar_vio_calls * calls, int flags); 
    95 #if defined(ROAR_HAVE_FOPENCOOKIE) || defined(ROAR_HAVE_FUNOPEN) 
    96 int roar_vio_to_stdio_close (void *__cookie); 
    97 #endif 
    98 #if defined(ROAR_HAVE_FOPENCOOKIE) 
    99 __ssize_t roar_vio_to_stdio_read (void *__cookie, char *__buf, size_t __nbytes); 
    100 __ssize_t roar_vio_to_stdio_write (void *__cookie, __const char *__buf, size_t __n); 
    101 int roar_vio_to_stdio_lseek (void *__cookie, _IO_off64_t *__pos, int __w); 
    102 #elif defined(ROAR_HAVE_FUNOPEN) 
    103 int roar_vio_to_stdio_read(void *__cookie, char *__buf, int __nbytes); 
    104 int roar_vio_to_stdio_write(void *__cookie, const char *__buf, int __n); 
    105 fpos_t roar_vio_to_stdio_lseek(void *__cookie, fpos_t __pos, int __w); 
    106 #endif 
    107  
    108  
    10992// possible VIOs: 
    11093 
     
    150133off_t   roar_vio_re_lseek(struct roar_vio_calls * vio, off_t offset, int whence); 
    151134 
    152 // stdio 
    153 ssize_t roar_vio_stdio_read    (struct roar_vio_calls * vio, void *buf, size_t count); 
    154 ssize_t roar_vio_stdio_write   (struct roar_vio_calls * vio, void *buf, size_t count); 
    155 off_t   roar_vio_stdio_lseek   (struct roar_vio_calls * vio, off_t offset, int whence); 
    156 int     roar_vio_stdio_sync    (struct roar_vio_calls * vio); 
    157 int     roar_vio_stdio_ctl     (struct roar_vio_calls * vio, int cmd, void * data); 
    158 int     roar_vio_stdio_close   (struct roar_vio_calls * vio); 
    159  
    160135#endif 
    161136 
  • libroar/Makefile

    r2050 r2059  
    44 
    55TARGETS=$(SLIB) libroar.a 
    6 VIO=vio.o vio_cmd.o vio_ops.o vio_magic.o vio_pipe.o vio_socket.o vio_bio.o vio_stack.o vio_proto.o vio_dstr.o vio_select.o 
     6VIO_META=vio.o vio_select.o 
     7VIO_BRIDGE=vio_bio.o vio_stdio.o 
     8VIO=$(VIO_META) $(VIO_BRIDGE) vio_cmd.o vio_ops.o vio_magic.o vio_pipe.o vio_socket.o vio_stack.o vio_proto.o vio_dstr.o 
    79OBJS=libroar.o basic.o stream.o simple.o auth.o socket.o ctl.o buffer.o meta.o file.o acl.o cdrom.o pinentry.o sshaskpass.o $(VIO) stack.o slp.o 
    810 
  • libroar/vio.c

    r2054 r2059  
    280280} 
    281281 
    282  
    283 int     roar_vio_open_stdio    (struct roar_vio_calls * calls, FILE * dst) { 
    284 #ifndef ROAR_WITHOUT_VIO_STDIO 
    285  if ( calls == NULL || dst == NULL ) 
    286   return -1; 
    287  
    288  memset(calls, 0, sizeof(struct roar_vio_calls)); 
    289  
    290  calls->read  = roar_vio_stdio_read; 
    291  calls->write = roar_vio_stdio_write; 
    292  calls->lseek = roar_vio_stdio_lseek; 
    293  calls->sync  = roar_vio_stdio_sync; 
    294  calls->close = roar_vio_stdio_close; 
    295  
    296  calls->inst  = dst; 
    297  
    298  return 0; 
    299 #else 
    300  return -1; 
    301 #endif 
    302 } 
    303  
    304 FILE *  roar_vio_to_stdio      (struct roar_vio_calls * calls, int flags) { 
    305 #ifdef ROAR_HAVE_FOPENCOOKIE 
    306  cookie_io_functions_t foc_funcs; 
    307 #endif 
    308  
    309  if ( calls == NULL ) 
    310   return NULL; 
    311  
    312 #if defined(ROAR_HAVE_FOPENCOOKIE) 
    313  memset(&foc_funcs, 0, sizeof(cookie_io_functions_t)); 
    314  
    315  foc_funcs.close = roar_vio_to_stdio_close; 
    316  foc_funcs.read  = roar_vio_to_stdio_read; 
    317  foc_funcs.write = roar_vio_to_stdio_write; 
    318  
    319  return fopencookie((void*) calls, "rw", foc_funcs); 
    320 #elif defined(ROAR_HAVE_FUNOPEN) 
    321  return funopen((void*) calls, roar_vio_to_stdio_read,  roar_vio_to_stdio_write, 
    322                                roar_vio_to_stdio_lseek, roar_vio_to_stdio_close); 
    323 #else 
    324  return NULL; 
    325 #endif 
    326 } 
    327  
    328 #if defined(ROAR_HAVE_FOPENCOOKIE) || defined(ROAR_HAVE_FUNOPEN) 
    329 int roar_vio_to_stdio_close (void *__cookie) { 
    330  return roar_vio_close((struct roar_vio_calls *) __cookie); 
    331 } 
    332  
    333 #if defined(ROAR_HAVE_FOPENCOOKIE) 
    334 __ssize_t roar_vio_to_stdio_read (void *__cookie, char *__buf, size_t __nbytes) { 
    335 #elif defined(ROAR_HAVE_FUNOPEN) 
    336 int roar_vio_to_stdio_read(void *__cookie, char *__buf, int __nbytes) { 
    337 #endif 
    338  return roar_vio_read((struct roar_vio_calls *) __cookie, __buf, __nbytes); 
    339 } 
    340  
    341 #if defined(ROAR_HAVE_FOPENCOOKIE) 
    342 __ssize_t roar_vio_to_stdio_write (void *__cookie, __const char *__buf, size_t __n) { 
    343 #elif defined(ROAR_HAVE_FUNOPEN) 
    344 int roar_vio_to_stdio_write(void *__cookie, const char *__buf, int __n) { 
    345 #endif 
    346  return roar_vio_write((struct roar_vio_calls *) __cookie, (char *) __buf, __n); 
    347 } 
    348  
    349 #if defined(ROAR_HAVE_FOPENCOOKIE) 
    350 int roar_vio_to_stdio_lseek (void *__cookie, _IO_off64_t *__pos, int __w); 
    351 #elif defined(ROAR_HAVE_FUNOPEN) 
    352 fpos_t roar_vio_to_stdio_lseek(void *__cookie, fpos_t __pos, int __w) { 
    353  return roar_vio_lseek((struct roar_vio_calls *) __cookie, __pos, __w); 
    354 } 
    355 #endif 
    356 #endif 
    357  
    358282// VIOs: 
    359283 
     
    610534} 
    611535 
    612 // stdio: 
    613 #ifndef ROAR_WITHOUT_VIO_STDIO 
    614 ssize_t roar_vio_stdio_read    (struct roar_vio_calls * vio, void *buf, size_t count) { 
    615  return fread(buf, 1, count, (FILE*)(vio->inst)); 
    616 } 
    617  
    618 ssize_t roar_vio_stdio_write   (struct roar_vio_calls * vio, void *buf, size_t count) { 
    619  return fwrite(buf, 1, count, (FILE*)(vio->inst)); 
    620 } 
    621  
    622 off_t   roar_vio_stdio_lseek   (struct roar_vio_calls * vio, off_t offset, int whence) { 
    623  if ( fseek((FILE*)(vio->inst), offset, whence) == -1 ) 
    624   return -1; 
    625  
    626  return ftell((FILE*)(vio->inst)); 
    627 } 
    628  
    629 int     roar_vio_stdio_sync    (struct roar_vio_calls * vio) { 
    630  return fflush((FILE*)(vio->inst)); 
    631 } 
    632  
    633 int     roar_vio_stdio_ctl     (struct roar_vio_calls * vio, int cmd, void * data) { 
    634  
    635  if ( vio == NULL || cmd == -1 ) 
    636   return -1; 
    637  
    638  switch (cmd) { 
    639   case ROAR_VIO_CTL_GET_FH: 
    640   case ROAR_VIO_CTL_GET_READ_FH: 
    641   case ROAR_VIO_CTL_GET_WRITE_FH: 
    642    *(int*)data = fileno((FILE*)(vio->inst)); 
    643     return 0; 
    644    break; 
    645  } 
    646  
    647  return -1; 
    648 } 
    649  
    650 int     roar_vio_stdio_close   (struct roar_vio_calls * vio) { 
    651  return fclose((FILE*)(vio->inst)); 
    652 } 
    653 #endif 
    654  
    655536//ll 
Note: See TracChangeset for help on using the changeset viewer.