Philip P. Moltmann | 25aee82 | 2016-12-15 12:16:46 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Public 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 |
Philip P. Moltmann | 985548d | 2018-03-16 14:38:27 -0700 | [diff] [blame] | 7 | * different line endings, gzip'd print files, PPD files, etc. |
Philip P. Moltmann | 25aee82 | 2016-12-15 12:16:46 -0800 | [diff] [blame] | 8 | * |
Bryan Ferris | 7d91941 | 2019-07-17 12:18:10 -0700 | [diff] [blame] | 9 | * Copyright 2007-2018 by Apple Inc. |
Philip P. Moltmann | 25aee82 | 2016-12-15 12:16:46 -0800 | [diff] [blame] | 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 |
Philip P. Moltmann | 2447373 | 2017-05-11 09:37:47 -0700 | [diff] [blame] | 16 | * missing or damaged, see the license at "http://www.cups.org/". |
Philip P. Moltmann | 25aee82 | 2016-12-15 12:16:46 -0800 | [diff] [blame] | 17 | * |
| 18 | * This file is subject to the Apple OS-Developed Software exception. |
| 19 | */ |
| 20 | |
| 21 | #ifndef _CUPS_FILE_H_ |
| 22 | # define _CUPS_FILE_H_ |
| 23 | |
| 24 | |
| 25 | /* |
| 26 | * Include necessary headers... |
| 27 | */ |
| 28 | |
| 29 | # include "versioning.h" |
| 30 | # include <stddef.h> |
| 31 | # include <sys/types.h> |
Bryan Ferris | 7d91941 | 2019-07-17 12:18:10 -0700 | [diff] [blame] | 32 | # if defined(_WIN32) && !defined(__CUPS_SSIZE_T_DEFINED) |
Philip P. Moltmann | 25aee82 | 2016-12-15 12:16:46 -0800 | [diff] [blame] | 33 | # define __CUPS_SSIZE_T_DEFINED |
| 34 | /* Windows does not support the ssize_t type, so map it to off_t... */ |
| 35 | typedef off_t ssize_t; /* @private@ */ |
Bryan Ferris | 7d91941 | 2019-07-17 12:18:10 -0700 | [diff] [blame] | 36 | # endif /* _WIN32 && !__CUPS_SSIZE_T_DEFINED */ |
Philip P. Moltmann | 25aee82 | 2016-12-15 12:16:46 -0800 | [diff] [blame] | 37 | |
| 38 | |
| 39 | /* |
| 40 | * C++ magic... |
| 41 | */ |
| 42 | |
| 43 | # ifdef __cplusplus |
| 44 | extern "C" { |
| 45 | # endif /* __cplusplus */ |
| 46 | |
| 47 | |
| 48 | /* |
| 49 | * CUPS file definitions... |
| 50 | */ |
| 51 | |
| 52 | # define CUPS_FILE_NONE 0 /* No compression */ |
| 53 | # define CUPS_FILE_GZIP 1 /* GZIP compression */ |
| 54 | |
| 55 | |
| 56 | /* |
| 57 | * Types and structures... |
| 58 | */ |
| 59 | |
| 60 | typedef struct _cups_file_s cups_file_t;/**** CUPS file type ****/ |
| 61 | |
| 62 | |
| 63 | /* |
| 64 | * Prototypes... |
| 65 | */ |
| 66 | |
| 67 | extern int cupsFileClose(cups_file_t *fp) _CUPS_API_1_2; |
| 68 | extern int cupsFileCompression(cups_file_t *fp) _CUPS_API_1_2; |
| 69 | extern int cupsFileEOF(cups_file_t *fp) _CUPS_API_1_2; |
| 70 | extern const char *cupsFileFind(const char *filename, const char *path, |
| 71 | int executable, char *buffer, |
| 72 | int bufsize) _CUPS_API_1_2; |
| 73 | extern int cupsFileFlush(cups_file_t *fp) _CUPS_API_1_2; |
| 74 | extern int cupsFileGetChar(cups_file_t *fp) _CUPS_API_1_2; |
| 75 | extern char *cupsFileGetConf(cups_file_t *fp, char *buf, |
| 76 | size_t buflen, char **value, |
| 77 | int *linenum) _CUPS_API_1_2; |
| 78 | extern size_t cupsFileGetLine(cups_file_t *fp, char *buf, |
| 79 | size_t buflen) _CUPS_API_1_2; |
| 80 | extern char *cupsFileGets(cups_file_t *fp, char *buf, size_t buflen) |
| 81 | _CUPS_API_1_2; |
| 82 | extern int cupsFileLock(cups_file_t *fp, int block) _CUPS_API_1_2; |
| 83 | extern int cupsFileNumber(cups_file_t *fp) _CUPS_API_1_2; |
| 84 | extern cups_file_t *cupsFileOpen(const char *filename, const char *mode) |
| 85 | _CUPS_API_1_2; |
| 86 | extern cups_file_t *cupsFileOpenFd(int fd, const char *mode) _CUPS_API_1_2; |
| 87 | extern int cupsFilePeekChar(cups_file_t *fp) _CUPS_API_1_2; |
Bryan Ferris | 7d91941 | 2019-07-17 12:18:10 -0700 | [diff] [blame] | 88 | extern int cupsFilePrintf(cups_file_t *fp, const char *format, ...) _CUPS_FORMAT(2, 3) _CUPS_API_1_2; |
Philip P. Moltmann | 25aee82 | 2016-12-15 12:16:46 -0800 | [diff] [blame] | 89 | extern int cupsFilePutChar(cups_file_t *fp, int c) _CUPS_API_1_2; |
| 90 | extern ssize_t cupsFilePutConf(cups_file_t *fp, const char *directive, |
| 91 | const char *value) _CUPS_API_1_4; |
| 92 | extern int cupsFilePuts(cups_file_t *fp, const char *s) |
| 93 | _CUPS_API_1_2; |
| 94 | extern ssize_t cupsFileRead(cups_file_t *fp, char *buf, size_t bytes) |
| 95 | _CUPS_API_1_2; |
| 96 | extern off_t cupsFileRewind(cups_file_t *fp) _CUPS_API_1_2; |
| 97 | extern off_t cupsFileSeek(cups_file_t *fp, off_t pos) _CUPS_API_1_2; |
| 98 | extern cups_file_t *cupsFileStderr(void) _CUPS_API_1_2; |
| 99 | extern cups_file_t *cupsFileStdin(void) _CUPS_API_1_2; |
| 100 | extern cups_file_t *cupsFileStdout(void) _CUPS_API_1_2; |
| 101 | extern off_t cupsFileTell(cups_file_t *fp) _CUPS_API_1_2; |
| 102 | extern int cupsFileUnlock(cups_file_t *fp) _CUPS_API_1_2; |
| 103 | extern ssize_t cupsFileWrite(cups_file_t *fp, const char *buf, |
| 104 | size_t bytes) _CUPS_API_1_2; |
| 105 | |
| 106 | |
| 107 | # ifdef __cplusplus |
| 108 | } |
| 109 | # endif /* __cplusplus */ |
| 110 | #endif /* !_CUPS_FILE_H_ */ |