2
// "$Id: ppdc-file.cxx 3755 2012-03-30 05:59:14Z msweet $"
4
// File class for the CUPS PPD Compiler.
6
// Copyright 2007-2010 by Apple Inc.
7
// Copyright 2002-2005 by Easy Software Products.
9
// These coded instructions, statements, and computer programs are the
10
// property of Apple Inc. and are protected by Federal copyright
11
// law. Distribution and use rights are outlined in the file "LICENSE.txt"
12
// which should have been included with this file. If this file is
13
// file is missing or damaged, see the license at "http://www.cups.org/".
17
// ppdcFile::ppdcFile() - Create (open) a file.
18
// ppdcFile::~ppdcFile() - Delete (close) a file.
19
// ppdcFile::get() - Get a character from a file.
20
// ppdcFile::peek() - Look at the next character from a file.
24
// Include necessary headers...
27
#include "ppdc-private.h"
31
// 'ppdcFile::ppdcFile()' - Create (open) a file.
34
ppdcFile::ppdcFile(const char *f, // I - File to open
35
cups_file_t *ffp) // I - File pointer to use
43
fp = cupsFileOpen(f, "r");
45
close_on_delete = !ffp;
50
_cupsLangPrintf(stderr, _("ppdc: Unable to open %s: %s"), f,
56
// 'ppdcFile::~ppdcFile()' - Delete (close) a file.
61
if (close_on_delete && fp)
67
// 'ppdcFile::get()' - Get a character from a file.
73
int ch; // Character from file
76
// Return EOF if there is no open file...
80
// Get the character...
81
ch = cupsFileGetChar(fp);
83
// Update the line number as needed...
87
// Return the character...
93
// 'ppdcFile::peek()' - Look at the next character from a file.
96
int // O - Next character in file
99
// Return immediaely if there is no open file...
103
// Otherwise return the next character without advancing...
104
return (cupsFilePeekChar(fp));
109
// End of "$Id: ppdc-file.cxx 3755 2012-03-30 05:59:14Z msweet $".