Changeset 3030:fa315d423443 in roaraudio for libroar/vio_string.c


Ignore:
Timestamp:
11/07/09 06:04:08 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roar_vio_fgets()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/vio_string.c

    r2060 r3030  
    6060} 
    6161 
     62char *  roar_vio_fgets   (struct roar_vio_calls * vio, char * s, size_t size) { 
     63 size_t have = 0; 
     64 char   cur; 
     65 
     66 if ( size == 0 ) 
     67  return s; 
     68 
     69 if ( vio == NULL || s == NULL ) 
     70  return NULL; 
     71 
     72 // space for the \0 
     73 size -= 1; 
     74 
     75/* 
     76 if ( roar_vio_lseek(vio, 0, SEEK_CUR) == (off_t)-1 ) { 
     77*/ 
     78  // need to use the one byte at a time methode 
     79  while ( have < size ) { 
     80   if ( roar_vio_read(vio, &cur, 1) != 1 ) 
     81    break; 
     82 
     83   s[have] = cur; 
     84     have++; 
     85 
     86   if ( cur == '\n' ) 
     87    break; 
     88  } 
     89/* 
     90 } else { 
     91  // can use the optimized version 
     92 } 
     93*/ 
     94 
     95 s[size] = 0; 
     96 
     97 return s; 
     98} 
    6299 
    63100//ll 
Note: See TracChangeset for help on using the changeset viewer.