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