Ignore:
Timestamp:
Oct 24, 2012, 7:56:20 PM (13 years ago)
Author:
Silvan Scherrer
Message:

SMplayer: update vendor to 0.8.1

Location:
smplayer/vendor/current/zlib
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • smplayer/vendor/current/zlib/gzlib.c

    r121 r133  
    11/* gzlib.c -- zlib functions common to reading and writing gzip files
    2  * Copyright (C) 2004, 2010, 2011 Mark Adler
     2 * Copyright (C) 2004, 2010, 2011, 2012 Mark Adler
    33 * For conditions of distribution and use, see copyright notice in zlib.h
    44 */
     
    1818/* Local functions */
    1919local void gz_reset OF((gz_statep));
    20 local gzFile gz_open OF((const char *, int, const char *));
     20local gzFile gz_open OF((const void *, int, const char *));
    2121
    2222#if defined UNDER_CE
     
    9090/* Open a gzip file either by name or file descriptor. */
    9191local gzFile gz_open(path, fd, mode)
    92     const char *path;
     92    const void *path;
    9393    int fd;
    9494    const char *mode;
    9595{
    9696    gz_statep state;
     97    size_t len;
     98    int oflag;
     99#ifdef O_CLOEXEC
     100    int cloexec = 0;
     101#endif
     102#ifdef O_EXCL
     103    int exclusive = 0;
     104#endif
    97105
    98106    /* check input */
     
    134142            case 'b':       /* ignore -- will request binary anyway */
    135143                break;
     144#ifdef O_CLOEXEC
     145            case 'e':
     146                cloexec = 1;
     147                break;
     148#endif
     149#ifdef O_EXCL
     150            case 'x':
     151                exclusive = 1;
     152                break;
     153#endif
    136154            case 'f':
    137155                state->strategy = Z_FILTERED;
     
    169187
    170188    /* save the path name for error messages */
    171     state->path = malloc(strlen(path) + 1);
     189#ifdef _WIN32
     190    if (fd == -2) {
     191        len = wcstombs(NULL, path, 0);
     192        if (len == (size_t)-1)
     193            len = 0;
     194    }
     195    else
     196#endif
     197        len = strlen(path);
     198    state->path = malloc(len + 1);
    172199    if (state->path == NULL) {
    173200        free(state);
    174201        return NULL;
    175202    }
    176     strcpy(state->path, path);
    177 
    178     /* open the file with the appropriate mode (or just use fd) */
    179     state->fd = fd != -1 ? fd :
    180         open(path,
     203#ifdef _WIN32
     204    if (fd == -2)
     205        if (len)
     206            wcstombs(state->path, path, len + 1);
     207        else
     208            *(state->path) = 0;
     209    else
     210#endif
     211        strcpy(state->path, path);
     212
     213    /* compute the flags for open() */
     214    oflag =
    181215#ifdef O_LARGEFILE
    182             O_LARGEFILE |
     216        O_LARGEFILE |
    183217#endif
    184218#ifdef O_BINARY
    185             O_BINARY |
    186 #endif
    187             (state->mode == GZ_READ ?
    188                 O_RDONLY :
    189                 (O_WRONLY | O_CREAT | (
    190                     state->mode == GZ_WRITE ?
    191                         O_TRUNC :
    192                         O_APPEND))),
    193             0666);
     219        O_BINARY |
     220#endif
     221#ifdef O_CLOEXEC
     222        (cloexec ? O_CLOEXEC : 0) |
     223#endif
     224        (state->mode == GZ_READ ?
     225         O_RDONLY :
     226         (O_WRONLY | O_CREAT |
     227#ifdef O_EXCL
     228          (exclusive ? O_EXCL : 0) |
     229#endif
     230          (state->mode == GZ_WRITE ?
     231           O_TRUNC :
     232           O_APPEND)));
     233
     234    /* open the file with the appropriate flags (or just use fd) */
     235    state->fd = fd > -1 ? fd : (
     236#ifdef _WIN32
     237        fd == -2 ? _wopen(path, oflag, 0666) :
     238#endif
     239        open(path, oflag, 0666));
    194240    if (state->fd == -1) {
    195241        free(state->path);
     
    244290    return gz;
    245291}
     292
     293/* -- see zlib.h -- */
     294#ifdef _WIN32
     295gzFile ZEXPORT gzopen_w(path, mode)
     296    const wchar_t *path;
     297    const char *mode;
     298{
     299    return gz_open(path, -2, mode);
     300}
     301#endif
    246302
    247303/* -- see zlib.h -- */
Note: See TracChangeset for help on using the changeset viewer.