summaryrefslogtreecommitdiff
path: root/vp8/common/duck_io.h
blob: 43daa65bc11fb9771201e23cd7e6f9d02a102e08 (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE 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.
 */


#ifndef _duck_io_h
#define _duck_io_h

#if defined(__cplusplus)
extern "C" {
#endif

#if defined (_WIN32)
    typedef __int64 int64_t;
#elif defined(__MWERKS__)
    typedef long long int64_t;
#elif defined(__APPLE__) || defined(__POWERPC)
#include <ppc/types.h>
#else
    typedef long long int64_t;
#endif

    typedef struct
    {
        int64_t  offset;     // offset to start from
        int    blocking;    // non-zero for blocking
    } re_open_t;


    typedef enum
    {
        SAL_ERR_MAX                 = -10,
        SAL_ERROR                   = -11, // Default error
        SAL_ERR_WSASTARTUP          = -12,
        SAL_ERR_SOCKET_CREATE       = -13,
        SAL_ERR_RESOLVING_HOSTNAME  = -14,
        SAL_ERR_SERVER_CONNECTION   = -15,
        SAL_ERR_SENDING_DATA        = -16,
        SAL_ERR_RECEIVING_DATA      = -17,
        SAL_ERR_404_FILE_NOT_FOUND  = -18,
        SAL_ERR_PARSING_HTTP_HEADER = -19,
        SAL_ERR_PARSING_CONTENT_LEN = -20,
        SAL_ERR_CONNECTION_TIMEOUT  = -21,
        SAL_ERR_FILE_OPEN_FAILED    = -22,
        SAL_ERR_MIN                 = -23
    } SAL_ERR; /* EMH 1-15-03 */


    typedef struct sal_err_map_temp
    {
        SAL_ERR code;
        const char *decode;

    } sal_err_map_t;


    static char *sal_err_text(SAL_ERR e)
    {
        int t;
        const sal_err_map_t g_sal_err_map[] =
        {
            {   SAL_ERR_WSASTARTUP,             "Error with WSAStartup"         },
            {   SAL_ERR_SOCKET_CREATE,          "Error creating socket"         },
            {   SAL_ERR_RESOLVING_HOSTNAME,     "Error resolving hostname"      },
            {   SAL_ERR_SERVER_CONNECTION,      "Error connecting to server"    },
            {   SAL_ERR_SENDING_DATA,           "Error sending data"            },
            {   SAL_ERR_RECEIVING_DATA,         "Error receiving data"          },
            {   SAL_ERR_404_FILE_NOT_FOUND,     "Error file not found "         },
            {   SAL_ERR_PARSING_HTTP_HEADER,    "Error parsing http header"     },
            {   SAL_ERR_PARSING_CONTENT_LEN,    "Error parsing content length"  },
            {   SAL_ERR_CONNECTION_TIMEOUT,     "Error Connection timed out"    },
            {   SAL_ERR_FILE_OPEN_FAILED,       "Error opening file"            }
        };

        for (t = 0; t < sizeof(g_sal_err_map) / sizeof(sal_err_map_t); t++)
        {
            if (e == g_sal_err_map[t].code)
                return (char *) g_sal_err_map[t].decode;
        }

        return 0;
    }







    int duck_open(const char *fname, unsigned long user_data);

    void duck_close(int ghndl);

    int duck_read(int ghndl, unsigned char *buf, int nbytes);

    int64_t duck_seek(int g_hndl, int64_t offs, int origin);

    int duck_read_finished(int han, int flag); /* FWG 7-9-99 */

    int duck_name(int handle, char name[], size_t max_len); /* EMH 9-23-03 */

    int duck_read_blocking(int handle, unsigned char *buffer, int bytes); /* EMH 9-23-03 */

    int64_t duck_available_data(int handle); /* EMH 10-23-03 */

#if defined(__cplusplus)
}
#endif

#endif