2
* Id: file.c,v 1.2 1999/11/02 06:16:47 keithp Exp $
4
* Copyright 1999 SuSE, Inc.
6
* Permission to use, copy, modify, distribute, and sell this software and its
7
* documentation for any purpose is hereby granted without fee, provided that
8
* the above copyright notice appear in all copies and that both that
9
* copyright notice and this permission notice appear in supporting
10
* documentation, and that the name of SuSE not be used in advertising or
11
* publicity pertaining to distribution of the software without specific,
12
* written prior permission. SuSE makes no representations about the
13
* suitability of this software for any purpose. It is provided "as is"
14
* without express or implied warranty.
16
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
18
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
* Author: Keith Packard, SuSE, Inc.
25
/* $XFree86: xc/lib/font/builtins/file.c,v 1.4 2000/02/23 20:29:33 dawes Exp $ */
29
typedef struct _BuiltinIO {
32
} BuiltinIORec, *BuiltinIOPtr;
39
BuiltinIOPtr io = ((BuiltinIOPtr) f->private);
41
left = io->file->len - io->offset;
50
bcopy (io->file->bits + io->offset, f->buffer, len);
53
f->bufp = f->buffer + 1;
58
BuiltinSkip (f, count)
62
BuiltinIOPtr io = ((BuiltinIOPtr) f->private);
68
curoff = f->bufp - f->buffer;
69
fileoff = curoff + f->left;
70
if (curoff + count <= fileoff) {
74
todo = count - (fileoff - curoff);
76
if (io->offset > io->file->len)
77
io->offset = io->file->len;
86
BuiltinClose (f, doClose)
89
BuiltinIOPtr io = ((BuiltinIOPtr) f->private);
97
BuiltinFileOpen (name)
102
BufFilePtr raw, cooked;
104
if (*name == '/') name++;
105
for (i = 0; i < builtin_files_count; i++)
106
if (!strcmp (name, builtin_files[i].name))
108
if (i == builtin_files_count)
110
io = (BuiltinIOPtr) xalloc (sizeof (BuiltinIORec));
114
io->file = (void *) &builtin_files[i];
115
raw = BufFileCreate ((char *) io, BuiltinFill, 0, BuiltinSkip, BuiltinClose);
121
if (cooked = BufFilePushCompressed (raw))
125
raw->left += raw->bufp - raw->buffer;
126
raw->bufp = raw->buffer;
128
return (FontFilePtr) raw;
134
return BufFileClose ((BufFilePtr) f, TRUE);