Logo Search packages:      
Sourcecode: djvulibre version File versions  Download package

GUTF8String ByteStream::Stdio::init ( const char  mode[] )

Initializes from stdio

Definition at line 594 of file ByteStream.cpp.

References ByteStream::tell().

{
  char const *mesg=0;
  bool binary=false;
  if(!fp)
    must_close=false;
  for (const char *s=mode; s && *s; s++)
  {
    switch(*s) 
    {
      case 'r':
        can_read=true;
        if(!fp) fp=stdin;
        break;
      case 'w': 
      case 'a':
        can_write=true;
        if(!fp) fp=stdout;
        break;
      case '+':
        can_read=can_write=true;
        break;
      case 'b':
        binary=true;
        break;
      default:
        mesg= ERR_MSG("ByteStream.bad_mode"); //  Illegal mode in Stdio
    }
  }
  if(binary && fp) {
#if defined(__CYGWIN32__)
    setmode(fileno(fp), O_BINARY);
#elif defined(WIN32)
    _setmode(_fileno(fp), _O_BINARY);
#endif
  }
  GUTF8String retval;
  if(!mesg)
  {
    tell();
  }else
  {
    retval=mesg;
  }
  if(mesg &&(fp && must_close))
  {
    fclose(fp);
    fp=0;
    must_close=false;
  }
  return retval;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index