Merge "vp8_rd_pick_best_mbsegmentation code restructure"
[libvpx.git] / vp8 / common / duck_io.h
blob43daa65bc11fb9771201e23cd7e6f9d02a102e08
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
12 #ifndef _duck_io_h
13 #define _duck_io_h
15 #if defined(__cplusplus)
16 extern "C" {
17 #endif
19 #if defined (_WIN32)
20 typedef __int64 int64_t;
21 #elif defined(__MWERKS__)
22 typedef long long int64_t;
23 #elif defined(__APPLE__) || defined(__POWERPC)
24 #include <ppc/types.h>
25 #else
26 typedef long long int64_t;
27 #endif
29 typedef struct
31 int64_t offset; // offset to start from
32 int blocking; // non-zero for blocking
33 } re_open_t;
36 typedef enum
38 SAL_ERR_MAX = -10,
39 SAL_ERROR = -11, // Default error
40 SAL_ERR_WSASTARTUP = -12,
41 SAL_ERR_SOCKET_CREATE = -13,
42 SAL_ERR_RESOLVING_HOSTNAME = -14,
43 SAL_ERR_SERVER_CONNECTION = -15,
44 SAL_ERR_SENDING_DATA = -16,
45 SAL_ERR_RECEIVING_DATA = -17,
46 SAL_ERR_404_FILE_NOT_FOUND = -18,
47 SAL_ERR_PARSING_HTTP_HEADER = -19,
48 SAL_ERR_PARSING_CONTENT_LEN = -20,
49 SAL_ERR_CONNECTION_TIMEOUT = -21,
50 SAL_ERR_FILE_OPEN_FAILED = -22,
51 SAL_ERR_MIN = -23
52 } SAL_ERR; /* EMH 1-15-03 */
55 typedef struct sal_err_map_temp
57 SAL_ERR code;
58 const char *decode;
60 } sal_err_map_t;
63 static char *sal_err_text(SAL_ERR e)
65 int t;
66 const sal_err_map_t g_sal_err_map[] =
68 { SAL_ERR_WSASTARTUP, "Error with WSAStartup" },
69 { SAL_ERR_SOCKET_CREATE, "Error creating socket" },
70 { SAL_ERR_RESOLVING_HOSTNAME, "Error resolving hostname" },
71 { SAL_ERR_SERVER_CONNECTION, "Error connecting to server" },
72 { SAL_ERR_SENDING_DATA, "Error sending data" },
73 { SAL_ERR_RECEIVING_DATA, "Error receiving data" },
74 { SAL_ERR_404_FILE_NOT_FOUND, "Error file not found " },
75 { SAL_ERR_PARSING_HTTP_HEADER, "Error parsing http header" },
76 { SAL_ERR_PARSING_CONTENT_LEN, "Error parsing content length" },
77 { SAL_ERR_CONNECTION_TIMEOUT, "Error Connection timed out" },
78 { SAL_ERR_FILE_OPEN_FAILED, "Error opening file" }
81 for (t = 0; t < sizeof(g_sal_err_map) / sizeof(sal_err_map_t); t++)
83 if (e == g_sal_err_map[t].code)
84 return (char *) g_sal_err_map[t].decode;
87 return 0;
96 int duck_open(const char *fname, unsigned long user_data);
98 void duck_close(int ghndl);
100 int duck_read(int ghndl, unsigned char *buf, int nbytes);
102 int64_t duck_seek(int g_hndl, int64_t offs, int origin);
104 int duck_read_finished(int han, int flag); /* FWG 7-9-99 */
106 int duck_name(int handle, char name[], size_t max_len); /* EMH 9-23-03 */
108 int duck_read_blocking(int handle, unsigned char *buffer, int bytes); /* EMH 9-23-03 */
110 int64_t duck_available_data(int handle); /* EMH 10-23-03 */
112 #if defined(__cplusplus)
114 #endif
116 #endif