/[tivodecode]/t2sami/trunk/happyfile.h
ViewVC logotype

Contents of /t2sami/trunk/happyfile.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 251 - (show annotations) (download)
Fri Aug 31 06:19:10 2007 UTC (14 years, 11 months ago) by jeremyd2019
File MIME type: text/plain
File size: 1200 byte(s)
sync common files between t2sami and tivodecode.  remove extraneous extern "C" around includes in t2sami because tivodecode headers now have them

1 /*
2 * tivodecode, (c) 2006, Jeremy Drake
3 * See COPYING file for license terms
4 */
5
6 #ifndef HAPPY_FILE_H_
7 #define HAPPY_FILE_H_
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #include <stdio.h>
13 #include <stddef.h>
14 #ifdef HAVE_STDLIB_H
15 # include <stdlib.h>
16 #endif
17 #ifdef HAVE_SYS_TYPES_H
18 # include <sys/types.h>
19 #endif
20
21 #ifdef HAVE_UNISTD_H
22 # include <unistd.h>
23 #endif
24
25 #if defined(WIN32)
26 # include <io.h>
27 #endif
28
29 #ifndef BUFFERSIZE
30 #define BUFFERSIZE 4096
31 #endif
32
33 #if SIZEOF_OFF_T == 8
34 typedef off_t hoff_t;
35 #elif defined (WIN32)
36 typedef __int64 hoff_t;
37 #else
38 #warning Large file support is questionable on this platform
39 typedef off_t hoff_t;
40 #endif
41
42 typedef struct
43 {
44 FILE * fh;
45 hoff_t pos;
46
47 /* buffer stuff */
48 hoff_t buffer_start;
49 hoff_t buffer_fill;
50
51 char buffer[BUFFERSIZE];
52 } happy_file;
53
54 happy_file * hopen (const char * filename, const char * mode);
55 happy_file * hattach (FILE * fh);
56
57 int hclose(happy_file * fh);
58 int hdetach(happy_file * fh);
59
60 size_t hread (void * ptr, size_t size, happy_file * fh);
61 size_t hwrite (const void * ptr, size_t size, happy_file * fh);
62
63 hoff_t htell (happy_file * fh);
64 int hseek (happy_file * fh, hoff_t offset, int whence);
65
66 #ifdef __cplusplus
67 }
68 #endif
69 #endif

cvs@jdrake.com
ViewVC Help
Powered by ViewVC 1.1.13