"Fossies" - the Fresh Open Source Software Archive 
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 /* Copyright (C) 2000-2005 Ghostgum Software Pty Ltd. All rights reserved.
2
3 This software is provided AS-IS with no warranty, either express or
4 implied.
5
6 This software is distributed under licence and may not be copied,
7 modified or distributed except as expressly authorised under the terms
8 of the licence contained in the file LICENCE in this distribution.
9
10 For more information about licensing, please refer to
11 http://www.ghostgum.com.au/ or contact Ghostsgum Software Pty Ltd,
12 218 Gallaghers Rd, Glen Waverley VIC 3150, AUSTRALIA,
13 Fax +61 3 9886 6616.
14 */
15
16 /* $Id: cfile.h,v 1.4 2005/06/10 09:39:24 ghostgum Exp $ */
17
18 /* GFile is similar but to MFC CFile but is implemented as C, not C++.
19 * It may also support long files if FILE_POS is > 32-bits.
20 * FILE_OFFSET is a signed integer used for positioning a file.
21 * FILE_POS is an unsigned integer used for positioning a file.
22 *
23 * GFile should really be buffered, but it isn't a disaster
24 * if it is unbuffered. Reading of PostScript files for parsing
25 * or DSC comments uses 4kbyte blocks, while normal reading uses 1kbyte.
26 * Handling of bitmap files will generally read/write headers in
27 * 2 and 4 blocks, but read/write raster data in text line or
28 * scan line blocks.
29 */
30
31
32 #if defined(STDIO) || defined(MEMORYFILE) || !defined(_Windows) || defined(OS2)
33 # ifndef LPCTSTR
34 # define LPCTSTR const char *
35 # endif
36 # ifndef GENERIC_READ
37 # define GENERIC_READ (0x80000000L)
38 # endif
39 # ifndef FILE_SHARE_READ
40 # define FILE_SHARE_READ 0x00000001
41 # endif
42 #endif
43
44 #ifndef FILE_OFFSET
45 # define FILE_OFFSET long
46 #endif
47 #ifndef FILE_POS
48 # define FILE_POS unsigned FILE_OFFSET
49 #endif
50
51 typedef struct GFile_s GFile;
52
53 /* for gfile_open nOpenFlags */
54 enum OpenFlags {gfile_modeRead = 0x0000, gfile_modeWrite = 0x0001,
55 gfile_shareExclusive=0x0010, gfile_shareDenyWrite=0x0020,
56 gfile_modeCreate=0x1000};
57
58 /* for gfile_seek nFrom */
59 enum {gfile_begin, gfile_current, gfile_end};
60
61 /* Open a file from a Windows or OS handle */
62 /* We use "void *" instead of "int" because Windows handles
63 * are the same size as pointers, while int is smaller for Win64.
64 */
65 GFile *gfile_open_handle(void *hFile, unsigned int nOpenFlags);
66
67 /* Open a file */
68 GFile *gfile_open(LPCTSTR lpszFileName, unsigned int nOpenFlags);
69
70 /* Close a file */
71 void gfile_close(GFile *gf);
72
73 /* Read from a file */
74 unsigned int gfile_read(GFile *gf, void *lpBuf, unsigned int nCount);
75
76 /* Write to a file */
77 unsigned int gfile_write(GFile *gf, const void *lpBuf, unsigned int nCount);
78
79 /* Seek to a position in the file. */
80 /* Reset any file errors. */
81 int gfile_seek(GFile *gf, FILE_OFFSET lOff, unsigned int nFrom);
82
83 /* Get the current file position */
84 FILE_POS gfile_get_position(GFile *gf);
85
86 /* Get the file length */
87 FILE_POS gfile_get_length(GFile *gf);
88
89 /* Get the file date and time. The actual data format
90 * in pdt_low and pdt_high is undefined, and is only used
91 * for comparison by gfile_changed().
92 * Return 0 if success, -ve for failure.
93 */
94 int gfile_get_datetime(GFile *gf, unsigned long *pdt_low,
95 unsigned long *pdt_high);
96
97 /* Check if the length or datetime has changed. Use gfile_get_length
98 * and gfile_get_datetime.
99 * Return non-zero if changed, zero if unchanged.
100 */
101 int gfile_changed(GFile *gf, FILE_POS length,
102 unsigned long dt_low, unsigned long dt_high);
103
104 /* Return non-zero if a file error occurred */
105 int gfile_error(GFile *gf);
106
107 /* For memory mapped file, set the base address and length of the
108 * memory block.
109 */
110 void gfile_set_memory(GFile *gf, const char *base, FILE_POS len);
111
112
113 /***********************************************************/
114 /* These are implementation independent */
115
116 int gfile_puts(GFile *gf, const char *str);
117
118