• 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  * 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 _WIN32
35 #    include <io.h>
36 #    include <sys/locking.h>
37 #  endif /* _WIN32 */
38 
39 
40 /*
41  * Some operating systems support large files via open flag O_LARGEFILE...
42  */
43 
44 #  ifndef O_LARGEFILE
45 #    define O_LARGEFILE 0
46 #  endif /* !O_LARGEFILE */
47 
48 
49 /*
50  * Some operating systems don't define O_BINARY, which is used by Microsoft
51  * and IBM to flag binary files...
52  */
53 
54 #  ifndef O_BINARY
55 #    define O_BINARY 0
56 #  endif /* !O_BINARY */
57 
58 
59 #  ifdef __cplusplus
60 extern "C" {
61 #  endif /* __cplusplus */
62 
63 
64 /*
65  * Types and structures...
66  */
67 
68 typedef enum				/**** _cupsFileCheck return values ****/
69 {
70   _CUPS_FILE_CHECK_OK = 0,		/* Everything OK */
71   _CUPS_FILE_CHECK_MISSING = 1,		/* File is missing */
72   _CUPS_FILE_CHECK_PERMISSIONS = 2,	/* File (or parent dir) has bad perms */
73   _CUPS_FILE_CHECK_WRONG_TYPE = 3,	/* File has wrong type */
74   _CUPS_FILE_CHECK_RELATIVE_PATH = 4	/* File contains a relative path */
75 } _cups_fc_result_t;
76 
77 typedef enum				/**** _cupsFileCheck file type values ****/
78 {
79   _CUPS_FILE_CHECK_FILE = 0,		/* Check the file and parent directory */
80   _CUPS_FILE_CHECK_PROGRAM = 1,		/* Check the program and parent directory */
81   _CUPS_FILE_CHECK_FILE_ONLY = 2,	/* Check the file only */
82   _CUPS_FILE_CHECK_DIRECTORY = 3	/* Check the directory */
83 } _cups_fc_filetype_t;
84 
85 typedef void (*_cups_fc_func_t)(void *context, _cups_fc_result_t result,
86 				const char *message);
87 
88 
89 /*
90  * Prototypes...
91  */
92 
93 extern _cups_fc_result_t	_cupsFileCheck(const char *filename,
94 					       _cups_fc_filetype_t filetype,
95 				               int dorootchecks,
96 					       _cups_fc_func_t cb,
97 					       void *context);
98 extern void			_cupsFileCheckFilter(void *context,
99 						     _cups_fc_result_t result,
100 						     const char *message);
101 extern int			_cupsFilePeekAhead(cups_file_t *fp, int ch);
102 
103 #  ifdef __cplusplus
104 }
105 #  endif /* __cplusplus */
106 
107 #endif /* !_CUPS_FILE_PRIVATE_H_ */
108