The R Project SVN R

Rev

Rev 55547 | Rev 77674 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 55547 Rev 55623
Line 179... Line 179...
179
        for (len = 0; len < 2; len++) (void) get_byte(s);
179
        for (len = 0; len < 2; len++) (void) get_byte(s);
180
    }
180
    }
181
    s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
181
    s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
182
}
182
}
183
 
183
 
184
static gzFile R_gzopen (const char *path, const char *mode)
184
gzFile R_gzopen (const char *path, const char *mode)
185
{
185
{
186
    int err;
186
    int err;
187
    int level = Z_DEFAULT_COMPRESSION; /* compression level */
187
    int level = Z_DEFAULT_COMPRESSION; /* compression level */
188
    int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
188
    int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
189
    char *p = (char *) mode;
189
    char *p = (char *) mode;
Line 362... Line 362...
362
        (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
362
        (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
363
        return -1;
363
        return -1;
364
    return (int)(len - s->stream.avail_out);
364
    return (int)(len - s->stream.avail_out);
365
}
365
}
366
 
366
 
-
 
367
/* for devPS.c */
-
 
368
char *R_gzgets(gzFile file, char *buf, int len)
-
 
369
{
-
 
370
    char *b = buf;
-
 
371
    if (buf == Z_NULL || len <= 0) return Z_NULL;
-
 
372
 
-
 
373
    while (--len > 0 && R_gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
-
 
374
    *buf = '\0';
-
 
375
    return b == buf && len > 0 ? Z_NULL : b;
-
 
376
}
-
 
377
 
-
 
378
 
367
static int R_gzwrite (gzFile file, voidpc buf, unsigned len)
379
static int R_gzwrite (gzFile file, voidpc buf, unsigned len)
368
{
380
{
369
    gz_stream *s = (gz_stream*) file;
381
    gz_stream *s = (gz_stream*) file;
370
 
382
 
371
    if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
383
    if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
Line 508... Line 520...
508
        offset -= size;
520
        offset -= size;
509
    }
521
    }
510
    return 0;
522
    return 0;
511
}
523
}
512
 
524
 
513
static int R_gzclose (gzFile file)
525
int R_gzclose (gzFile file)
514
{
526
{
515
    gz_stream *s = (gz_stream*) file;
527
    gz_stream *s = (gz_stream*) file;
516
    if (s == NULL) return Z_STREAM_ERROR;
528
    if (s == NULL) return Z_STREAM_ERROR;
517
    if (s->mode == 'w') {
529
    if (s->mode == 'w') {
518
        if (gz_flush (file, Z_FINISH) != Z_OK) 
530
        if (gz_flush (file, Z_FINISH) != Z_OK)