File: unicode_gif.h

package info (click to toggle)
golang-github-bep-gowebp 0.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,660 kB
  • sloc: ansic: 76,136; sh: 1,085; makefile: 585; python: 416; cpp: 262
file content (76 lines) | stat: -rw-r--r-- 1,936 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2018 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// giflib doesn't have a Unicode DGifOpenFileName(). Let's make one.
//
// Author: Yannis Guyon (yguyon@google.com)

#ifndef WEBP_EXAMPLES_UNICODE_GIF_H_
#define WEBP_EXAMPLES_UNICODE_GIF_H_

#include "./unicode.h"
#ifdef HAVE_CONFIG_H
#include "webp/config.h"  // For WEBP_HAVE_GIF
#endif

#if defined(WEBP_HAVE_GIF)

#ifdef _WIN32
#include <fcntl.h>  // Not standard, needed for _topen and flags.
#include <io.h>
#endif

#include <gif_lib.h>
#include <string.h>
#include "./gifdec.h"

#if !defined(STDIN_FILENO)
#define STDIN_FILENO 0
#endif

static GifFileType* DGifOpenFileUnicode(const W_CHAR* file_name, int* error) {
  if (!WSTRCMP(file_name, "-")) {
#if LOCAL_GIF_PREREQ(5, 0)
    return DGifOpenFileHandle(STDIN_FILENO, error);
#else
    (void)error;
    return DGifOpenFileHandle(STDIN_FILENO);
#endif
  }

#if defined(_WIN32) && defined(_UNICODE)
  {
    int file_handle = _wopen(file_name, _O_RDONLY | _O_BINARY);
    if (file_handle == -1) {
      if (error != NULL) *error = D_GIF_ERR_OPEN_FAILED;
      return NULL;
    }

#if LOCAL_GIF_PREREQ(5, 0)
    return DGifOpenFileHandle(file_handle, error);
#else
    return DGifOpenFileHandle(file_handle);
#endif
  }

#else

#if LOCAL_GIF_PREREQ(5, 0)
  return DGifOpenFileName(file_name, error);
#else
  return DGifOpenFileName(file_name);
#endif

#endif  // defined(_WIN32) && defined(_UNICODE)
  // DGifCloseFile() is called later.
}

#endif  // defined(WEBP_HAVE_GIF)

#endif  // WEBP_EXAMPLES_UNICODE_GIF_H_