xref: /aosp_15_r20/external/libcups/cups/file-private.h (revision 5e7646d21f1134fb0638875d812ef646c12ab91e)
1*5e7646d2SAndroid Build Coastguard Worker /*
2*5e7646d2SAndroid Build Coastguard Worker  * Private file definitions for CUPS.
3*5e7646d2SAndroid Build Coastguard Worker  *
4*5e7646d2SAndroid Build Coastguard Worker  * Since stdio files max out at 256 files on many systems, we have to
5*5e7646d2SAndroid Build Coastguard Worker  * write similar functions without this limit.  At the same time, using
6*5e7646d2SAndroid Build Coastguard Worker  * our own file functions allows us to provide transparent support of
7*5e7646d2SAndroid Build Coastguard Worker  * different line endings, gzip'd print files, PPD files, etc.
8*5e7646d2SAndroid Build Coastguard Worker  *
9*5e7646d2SAndroid Build Coastguard Worker  * Copyright © 2007-2018 by Apple Inc.
10*5e7646d2SAndroid Build Coastguard Worker  * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
11*5e7646d2SAndroid Build Coastguard Worker  *
12*5e7646d2SAndroid Build Coastguard Worker  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
13*5e7646d2SAndroid Build Coastguard Worker  * information.
14*5e7646d2SAndroid Build Coastguard Worker  */
15*5e7646d2SAndroid Build Coastguard Worker 
16*5e7646d2SAndroid Build Coastguard Worker #ifndef _CUPS_FILE_PRIVATE_H_
17*5e7646d2SAndroid Build Coastguard Worker #  define _CUPS_FILE_PRIVATE_H_
18*5e7646d2SAndroid Build Coastguard Worker 
19*5e7646d2SAndroid Build Coastguard Worker /*
20*5e7646d2SAndroid Build Coastguard Worker  * Include necessary headers...
21*5e7646d2SAndroid Build Coastguard Worker  */
22*5e7646d2SAndroid Build Coastguard Worker 
23*5e7646d2SAndroid Build Coastguard Worker #  include "cups-private.h"
24*5e7646d2SAndroid Build Coastguard Worker #  include <stdio.h>
25*5e7646d2SAndroid Build Coastguard Worker #  include <stdlib.h>
26*5e7646d2SAndroid Build Coastguard Worker #  include <stdarg.h>
27*5e7646d2SAndroid Build Coastguard Worker #  include <fcntl.h>
28*5e7646d2SAndroid Build Coastguard Worker 
29*5e7646d2SAndroid Build Coastguard Worker #  ifdef _WIN32
30*5e7646d2SAndroid Build Coastguard Worker #    include <io.h>
31*5e7646d2SAndroid Build Coastguard Worker #    include <sys/locking.h>
32*5e7646d2SAndroid Build Coastguard Worker #  endif /* _WIN32 */
33*5e7646d2SAndroid Build Coastguard Worker 
34*5e7646d2SAndroid Build Coastguard Worker 
35*5e7646d2SAndroid Build Coastguard Worker /*
36*5e7646d2SAndroid Build Coastguard Worker  * Some operating systems support large files via open flag O_LARGEFILE...
37*5e7646d2SAndroid Build Coastguard Worker  */
38*5e7646d2SAndroid Build Coastguard Worker 
39*5e7646d2SAndroid Build Coastguard Worker #  ifndef O_LARGEFILE
40*5e7646d2SAndroid Build Coastguard Worker #    define O_LARGEFILE 0
41*5e7646d2SAndroid Build Coastguard Worker #  endif /* !O_LARGEFILE */
42*5e7646d2SAndroid Build Coastguard Worker 
43*5e7646d2SAndroid Build Coastguard Worker 
44*5e7646d2SAndroid Build Coastguard Worker /*
45*5e7646d2SAndroid Build Coastguard Worker  * Some operating systems don't define O_BINARY, which is used by Microsoft
46*5e7646d2SAndroid Build Coastguard Worker  * and IBM to flag binary files...
47*5e7646d2SAndroid Build Coastguard Worker  */
48*5e7646d2SAndroid Build Coastguard Worker 
49*5e7646d2SAndroid Build Coastguard Worker #  ifndef O_BINARY
50*5e7646d2SAndroid Build Coastguard Worker #    define O_BINARY 0
51*5e7646d2SAndroid Build Coastguard Worker #  endif /* !O_BINARY */
52*5e7646d2SAndroid Build Coastguard Worker 
53*5e7646d2SAndroid Build Coastguard Worker 
54*5e7646d2SAndroid Build Coastguard Worker #  ifdef __cplusplus
55*5e7646d2SAndroid Build Coastguard Worker extern "C" {
56*5e7646d2SAndroid Build Coastguard Worker #  endif /* __cplusplus */
57*5e7646d2SAndroid Build Coastguard Worker 
58*5e7646d2SAndroid Build Coastguard Worker 
59*5e7646d2SAndroid Build Coastguard Worker /*
60*5e7646d2SAndroid Build Coastguard Worker  * Types and structures...
61*5e7646d2SAndroid Build Coastguard Worker  */
62*5e7646d2SAndroid Build Coastguard Worker 
63*5e7646d2SAndroid Build Coastguard Worker typedef enum				/**** _cupsFileCheck return values ****/
64*5e7646d2SAndroid Build Coastguard Worker {
65*5e7646d2SAndroid Build Coastguard Worker   _CUPS_FILE_CHECK_OK = 0,		/* Everything OK */
66*5e7646d2SAndroid Build Coastguard Worker   _CUPS_FILE_CHECK_MISSING = 1,		/* File is missing */
67*5e7646d2SAndroid Build Coastguard Worker   _CUPS_FILE_CHECK_PERMISSIONS = 2,	/* File (or parent dir) has bad perms */
68*5e7646d2SAndroid Build Coastguard Worker   _CUPS_FILE_CHECK_WRONG_TYPE = 3,	/* File has wrong type */
69*5e7646d2SAndroid Build Coastguard Worker   _CUPS_FILE_CHECK_RELATIVE_PATH = 4	/* File contains a relative path */
70*5e7646d2SAndroid Build Coastguard Worker } _cups_fc_result_t;
71*5e7646d2SAndroid Build Coastguard Worker 
72*5e7646d2SAndroid Build Coastguard Worker typedef enum				/**** _cupsFileCheck file type values ****/
73*5e7646d2SAndroid Build Coastguard Worker {
74*5e7646d2SAndroid Build Coastguard Worker   _CUPS_FILE_CHECK_FILE = 0,		/* Check the file and parent directory */
75*5e7646d2SAndroid Build Coastguard Worker   _CUPS_FILE_CHECK_PROGRAM = 1,		/* Check the program and parent directory */
76*5e7646d2SAndroid Build Coastguard Worker   _CUPS_FILE_CHECK_FILE_ONLY = 2,	/* Check the file only */
77*5e7646d2SAndroid Build Coastguard Worker   _CUPS_FILE_CHECK_DIRECTORY = 3	/* Check the directory */
78*5e7646d2SAndroid Build Coastguard Worker } _cups_fc_filetype_t;
79*5e7646d2SAndroid Build Coastguard Worker 
80*5e7646d2SAndroid Build Coastguard Worker typedef void (*_cups_fc_func_t)(void *context, _cups_fc_result_t result,
81*5e7646d2SAndroid Build Coastguard Worker 				const char *message);
82*5e7646d2SAndroid Build Coastguard Worker 
83*5e7646d2SAndroid Build Coastguard Worker /*
84*5e7646d2SAndroid Build Coastguard Worker  * Prototypes...
85*5e7646d2SAndroid Build Coastguard Worker  */
86*5e7646d2SAndroid Build Coastguard Worker 
87*5e7646d2SAndroid Build Coastguard Worker extern _cups_fc_result_t	_cupsFileCheck(const char *filename, _cups_fc_filetype_t filetype, int dorootchecks, _cups_fc_func_t cb, void *context) _CUPS_PRIVATE;
88*5e7646d2SAndroid Build Coastguard Worker extern void			_cupsFileCheckFilter(void *context, _cups_fc_result_t result, const char *message) _CUPS_PRIVATE;
89*5e7646d2SAndroid Build Coastguard Worker extern int			_cupsFilePeekAhead(cups_file_t *fp, int ch);
90*5e7646d2SAndroid Build Coastguard Worker 
91*5e7646d2SAndroid Build Coastguard Worker #  ifdef __cplusplus
92*5e7646d2SAndroid Build Coastguard Worker }
93*5e7646d2SAndroid Build Coastguard Worker #  endif /* __cplusplus */
94*5e7646d2SAndroid Build Coastguard Worker 
95*5e7646d2SAndroid Build Coastguard Worker #endif /* !_CUPS_FILE_PRIVATE_H_ */
96