]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/file-private.h
Import CUPS v2.0b1
[thirdparty/cups.git] / cups / file-private.h
CommitLineData
b9faaae1 1/*
1a18c85c 2 * "$Id: file-private.h 11627 2014-02-20 16:15:09Z msweet $"
b9faaae1 3 *
1a18c85c 4 * Private file definitions for CUPS.
b9faaae1 5 *
1a18c85c
MS
6 * Since stdio files max out at 256 files on many systems, we have to
7 * write similar functions without this limit. At the same time, using
8 * our own file functions allows us to provide transparent support of
9 * gzip'd print files, PPD files, etc.
b9faaae1 10 *
1a18c85c
MS
11 * Copyright 2007-2014 by Apple Inc.
12 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
b9faaae1 13 *
1a18c85c
MS
14 * These coded instructions, statements, and computer programs are the
15 * property of Apple Inc. and are protected by Federal copyright
16 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
17 * which should have been included with this file. If this file is
18 * file is missing or damaged, see the license at "http://www.cups.org/".
71f63681 19 *
1a18c85c 20 * This file is subject to the Apple OS-Developed Software exception.
b9faaae1
MS
21 */
22
23#ifndef _CUPS_FILE_PRIVATE_H_
24# define _CUPS_FILE_PRIVATE_H_
25
26/*
27 * Include necessary headers...
28 */
29
71e16022 30# include "cups-private.h"
b9faaae1
MS
31# include <stdio.h>
32# include <stdlib.h>
33# include <stdarg.h>
b9faaae1 34# include <fcntl.h>
b9faaae1
MS
35
36# ifdef HAVE_LIBZ
37# include <zlib.h>
38# endif /* HAVE_LIBZ */
39# ifdef WIN32
40# include <io.h>
41# include <sys/locking.h>
42# endif /* WIN32 */
43
44
45/*
46 * Some operating systems support large files via open flag O_LARGEFILE...
47 */
48
49# ifndef O_LARGEFILE
50# define O_LARGEFILE 0
51# endif /* !O_LARGEFILE */
52
53
54/*
55 * Some operating systems don't define O_BINARY, which is used by Microsoft
56 * and IBM to flag binary files...
57 */
58
59# ifndef O_BINARY
60# define O_BINARY 0
61# endif /* !O_BINARY */
62
63
22c9029b
MS
64# ifdef __cplusplus
65extern "C" {
66# endif /* __cplusplus */
67
68
b9faaae1
MS
69/*
70 * Types and structures...
71 */
72
22c9029b
MS
73typedef enum /**** _cupsFileCheck return values ****/
74{
75 _CUPS_FILE_CHECK_OK = 0, /* Everything OK */
76 _CUPS_FILE_CHECK_MISSING = 1, /* File is missing */
77 _CUPS_FILE_CHECK_PERMISSIONS = 2, /* File (or parent dir) has bad perms */
88f9aafc
MS
78 _CUPS_FILE_CHECK_WRONG_TYPE = 3, /* File has wrong type */
79 _CUPS_FILE_CHECK_RELATIVE_PATH = 4 /* File contains a relative path */
22c9029b
MS
80} _cups_fc_result_t;
81
82typedef enum /**** _cupsFileCheck file type values ****/
83{
84 _CUPS_FILE_CHECK_FILE = 0, /* Check the file and parent directory */
85 _CUPS_FILE_CHECK_PROGRAM = 1, /* Check the program and parent directory */
86 _CUPS_FILE_CHECK_FILE_ONLY = 2, /* Check the file only */
87 _CUPS_FILE_CHECK_DIRECTORY = 3 /* Check the directory */
88} _cups_fc_filetype_t;
89
90typedef void (*_cups_fc_func_t)(void *context, _cups_fc_result_t result,
91 const char *message);
92
b9faaae1
MS
93struct _cups_file_s /**** CUPS file structure... ****/
94
95{
96 int fd; /* File descriptor */
97 char mode, /* Mode ('r' or 'w') */
98 compressed, /* Compression used? */
99 is_stdio, /* stdin/out/err? */
100 eof, /* End of file? */
101 buf[4096], /* Buffer */
102 *ptr, /* Pointer into buffer */
103 *end; /* End of buffer data */
104 off_t pos, /* Position in file */
105 bufpos; /* File position for start of buffer */
106
107#ifdef HAVE_LIBZ
108 z_stream stream; /* (De)compression stream */
109 Bytef cbuf[4096]; /* (De)compression buffer */
110 uLong crc; /* (De)compression CRC */
111#endif /* HAVE_LIBZ */
112
113 char *printf_buffer; /* cupsFilePrintf buffer */
114 size_t printf_size; /* Size of cupsFilePrintf buffer */
115};
116
117
22c9029b
MS
118/*
119 * Prototypes...
120 */
121
122extern _cups_fc_result_t _cupsFileCheck(const char *filename,
123 _cups_fc_filetype_t filetype,
124 int dorootchecks,
125 _cups_fc_func_t cb,
126 void *context);
127extern void _cupsFileCheckFilter(void *context,
128 _cups_fc_result_t result,
129 const char *message);
130
131# ifdef __cplusplus
132}
133# endif /* __cplusplus */
134
b9faaae1
MS
135#endif /* !_CUPS_FILE_PRIVATE_H_ */
136
137/*
1a18c85c 138 * End of "$Id: file-private.h 11627 2014-02-20 16:15:09Z msweet $".
b9faaae1 139 */