• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-2018 by Apple Inc.
10  * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
11  *
12  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
13  * information.
14  */
15 
16 #ifndef _CUPS_FILE_PRIVATE_H_
17 #  define _CUPS_FILE_PRIVATE_H_
18 
19 /*
20  * Include necessary headers...
21  */
22 
23 #  include "cups-private.h"
24 #  include <stdio.h>
25 #  include <stdlib.h>
26 #  include <stdarg.h>
27 #  include <fcntl.h>
28 
29 #  ifdef _WIN32
30 #    include <io.h>
31 #    include <sys/locking.h>
32 #  endif /* _WIN32 */
33 
34 
35 /*
36  * Some operating systems support large files via open flag O_LARGEFILE...
37  */
38 
39 #  ifndef O_LARGEFILE
40 #    define O_LARGEFILE 0
41 #  endif /* !O_LARGEFILE */
42 
43 
44 /*
45  * Some operating systems don't define O_BINARY, which is used by Microsoft
46  * and IBM to flag binary files...
47  */
48 
49 #  ifndef O_BINARY
50 #    define O_BINARY 0
51 #  endif /* !O_BINARY */
52 
53 
54 #  ifdef __cplusplus
55 extern "C" {
56 #  endif /* __cplusplus */
57 
58 
59 /*
60  * Types and structures...
61  */
62 
63 typedef enum				/**** _cupsFileCheck return values ****/
64 {
65   _CUPS_FILE_CHECK_OK = 0,		/* Everything OK */
66   _CUPS_FILE_CHECK_MISSING = 1,		/* File is missing */
67   _CUPS_FILE_CHECK_PERMISSIONS = 2,	/* File (or parent dir) has bad perms */
68   _CUPS_FILE_CHECK_WRONG_TYPE = 3,	/* File has wrong type */
69   _CUPS_FILE_CHECK_RELATIVE_PATH = 4	/* File contains a relative path */
70 } _cups_fc_result_t;
71 
72 typedef enum				/**** _cupsFileCheck file type values ****/
73 {
74   _CUPS_FILE_CHECK_FILE = 0,		/* Check the file and parent directory */
75   _CUPS_FILE_CHECK_PROGRAM = 1,		/* Check the program and parent directory */
76   _CUPS_FILE_CHECK_FILE_ONLY = 2,	/* Check the file only */
77   _CUPS_FILE_CHECK_DIRECTORY = 3	/* Check the directory */
78 } _cups_fc_filetype_t;
79 
80 typedef void (*_cups_fc_func_t)(void *context, _cups_fc_result_t result,
81 				const char *message);
82 
83 /*
84  * Prototypes...
85  */
86 
87 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 extern void			_cupsFileCheckFilter(void *context, _cups_fc_result_t result, const char *message) _CUPS_PRIVATE;
89 extern int			_cupsFilePeekAhead(cups_file_t *fp, int ch);
90 
91 #  ifdef __cplusplus
92 }
93 #  endif /* __cplusplus */
94 
95 #endif /* !_CUPS_FILE_PRIVATE_H_ */
96