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