]>
Commit | Line | Data |
---|---|---|
b9faaae1 | 1 | /* |
6539a0af | 2 | * Private file definitions for CUPS. |
b9faaae1 | 3 | * |
6539a0af MS |
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 | |
2a75f21b | 7 | * different line endings, gzip'd print files, PPD files, etc. |
b9faaae1 | 8 | * |
2a75f21b | 9 | * Copyright 2007-2017 by Apple Inc. |
6539a0af | 10 | * Copyright 1997-2007 by Easy Software Products, all rights reserved. |
b9faaae1 | 11 | * |
e3101897 | 12 | * Licensed under Apache License v2.0. See the file "LICENSE" for more information. |
b9faaae1 MS |
13 | */ |
14 | ||
15 | #ifndef _CUPS_FILE_PRIVATE_H_ | |
16 | # define _CUPS_FILE_PRIVATE_H_ | |
17 | ||
18 | /* | |
19 | * Include necessary headers... | |
20 | */ | |
21 | ||
71e16022 | 22 | # include "cups-private.h" |
b9faaae1 MS |
23 | # include <stdio.h> |
24 | # include <stdlib.h> | |
25 | # include <stdarg.h> | |
b9faaae1 | 26 | # include <fcntl.h> |
b9faaae1 MS |
27 | |
28 | # ifdef HAVE_LIBZ | |
29 | # include <zlib.h> | |
30 | # endif /* HAVE_LIBZ */ | |
31 | # ifdef WIN32 | |
32 | # include <io.h> | |
33 | # include <sys/locking.h> | |
34 | # endif /* WIN32 */ | |
35 | ||
36 | ||
37 | /* | |
38 | * Some operating systems support large files via open flag O_LARGEFILE... | |
39 | */ | |
40 | ||
41 | # ifndef O_LARGEFILE | |
42 | # define O_LARGEFILE 0 | |
43 | # endif /* !O_LARGEFILE */ | |
44 | ||
45 | ||
46 | /* | |
47 | * Some operating systems don't define O_BINARY, which is used by Microsoft | |
48 | * and IBM to flag binary files... | |
49 | */ | |
50 | ||
51 | # ifndef O_BINARY | |
52 | # define O_BINARY 0 | |
53 | # endif /* !O_BINARY */ | |
54 | ||
55 | ||
22c9029b MS |
56 | # ifdef __cplusplus |
57 | extern "C" { | |
58 | # endif /* __cplusplus */ | |
59 | ||
60 | ||
b9faaae1 MS |
61 | /* |
62 | * Types and structures... | |
63 | */ | |
64 | ||
22c9029b MS |
65 | typedef enum /**** _cupsFileCheck return values ****/ |
66 | { | |
67 | _CUPS_FILE_CHECK_OK = 0, /* Everything OK */ | |
68 | _CUPS_FILE_CHECK_MISSING = 1, /* File is missing */ | |
69 | _CUPS_FILE_CHECK_PERMISSIONS = 2, /* File (or parent dir) has bad perms */ | |
88f9aafc MS |
70 | _CUPS_FILE_CHECK_WRONG_TYPE = 3, /* File has wrong type */ |
71 | _CUPS_FILE_CHECK_RELATIVE_PATH = 4 /* File contains a relative path */ | |
22c9029b MS |
72 | } _cups_fc_result_t; |
73 | ||
74 | typedef enum /**** _cupsFileCheck file type values ****/ | |
75 | { | |
76 | _CUPS_FILE_CHECK_FILE = 0, /* Check the file and parent directory */ | |
77 | _CUPS_FILE_CHECK_PROGRAM = 1, /* Check the program and parent directory */ | |
78 | _CUPS_FILE_CHECK_FILE_ONLY = 2, /* Check the file only */ | |
79 | _CUPS_FILE_CHECK_DIRECTORY = 3 /* Check the directory */ | |
80 | } _cups_fc_filetype_t; | |
81 | ||
82 | typedef void (*_cups_fc_func_t)(void *context, _cups_fc_result_t result, | |
83 | const char *message); | |
84 | ||
b9faaae1 MS |
85 | struct _cups_file_s /**** CUPS file structure... ****/ |
86 | ||
87 | { | |
88 | int fd; /* File descriptor */ | |
89 | char mode, /* Mode ('r' or 'w') */ | |
90 | compressed, /* Compression used? */ | |
91 | is_stdio, /* stdin/out/err? */ | |
92 | eof, /* End of file? */ | |
93 | buf[4096], /* Buffer */ | |
94 | *ptr, /* Pointer into buffer */ | |
95 | *end; /* End of buffer data */ | |
96 | off_t pos, /* Position in file */ | |
97 | bufpos; /* File position for start of buffer */ | |
98 | ||
99 | #ifdef HAVE_LIBZ | |
100 | z_stream stream; /* (De)compression stream */ | |
101 | Bytef cbuf[4096]; /* (De)compression buffer */ | |
102 | uLong crc; /* (De)compression CRC */ | |
103 | #endif /* HAVE_LIBZ */ | |
104 | ||
105 | char *printf_buffer; /* cupsFilePrintf buffer */ | |
106 | size_t printf_size; /* Size of cupsFilePrintf buffer */ | |
107 | }; | |
108 | ||
109 | ||
22c9029b MS |
110 | /* |
111 | * Prototypes... | |
112 | */ | |
113 | ||
114 | extern _cups_fc_result_t _cupsFileCheck(const char *filename, | |
115 | _cups_fc_filetype_t filetype, | |
116 | int dorootchecks, | |
117 | _cups_fc_func_t cb, | |
118 | void *context); | |
119 | extern void _cupsFileCheckFilter(void *context, | |
120 | _cups_fc_result_t result, | |
121 | const char *message); | |
122 | ||
123 | # ifdef __cplusplus | |
124 | } | |
125 | # endif /* __cplusplus */ | |
126 | ||
b9faaae1 | 127 | #endif /* !_CUPS_FILE_PRIVATE_H_ */ |