| 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 |
| 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_H_ |
| 17 | # define _CUPS_FILE_H_ |
| 18 | |
| 19 | |
| 20 | /* |
| 21 | * Include necessary headers... |
| 22 | */ |
| 23 | |
| 24 | # include "versioning.h" |
| 25 | # include <stddef.h> |
| 26 | # include <sys/types.h> |
| 27 | # if defined(_WIN32) && !defined(__CUPS_SSIZE_T_DEFINED) |
| 28 | # define __CUPS_SSIZE_T_DEFINED |
| 29 | /* Windows does not support the ssize_t type, so map it to off_t... */ |
| 30 | typedef off_t ssize_t; /* @private@ */ |
| 31 | # endif /* _WIN32 && !__CUPS_SSIZE_T_DEFINED */ |
| 32 | |
| 33 | |
| 34 | /* |
| 35 | * C++ magic... |
| 36 | */ |
| 37 | |
| 38 | # ifdef __cplusplus |
| 39 | extern "C" { |
| 40 | # endif /* __cplusplus */ |
| 41 | |
| 42 | |
| 43 | /* |
| 44 | * CUPS file definitions... |
| 45 | */ |
| 46 | |
| 47 | # define CUPS_FILE_NONE 0 /* No compression */ |
| 48 | # define CUPS_FILE_GZIP 1 /* GZIP compression */ |
| 49 | |
| 50 | |
| 51 | /* |
| 52 | * Types and structures... |
| 53 | */ |
| 54 | |
| 55 | typedef struct _cups_file_s cups_file_t;/**** CUPS file type ****/ |
| 56 | |
| 57 | |
| 58 | /* |
| 59 | * Prototypes... |
| 60 | */ |
| 61 | |
| 62 | extern int cupsFileClose(cups_file_t *fp) _CUPS_API_1_2; |
| 63 | extern int cupsFileCompression(cups_file_t *fp) _CUPS_API_1_2; |
| 64 | extern int cupsFileEOF(cups_file_t *fp) _CUPS_API_1_2; |
| 65 | extern const char *cupsFileFind(const char *filename, const char *path, int executable, char *buffer, int bufsize) _CUPS_API_1_2; |
| 66 | extern int cupsFileFlush(cups_file_t *fp) _CUPS_API_1_2; |
| 67 | extern int cupsFileGetChar(cups_file_t *fp) _CUPS_API_1_2; |
| 68 | extern char *cupsFileGetConf(cups_file_t *fp, char *buf, size_t buflen, char **value, int *linenum) _CUPS_API_1_2; |
| 69 | extern size_t cupsFileGetLine(cups_file_t *fp, char *buf, size_t buflen) _CUPS_API_1_2; |
| 70 | extern char *cupsFileGets(cups_file_t *fp, char *buf, size_t buflen) _CUPS_API_1_2; |
| 71 | extern int cupsFileLock(cups_file_t *fp, int block) _CUPS_API_1_2; |
| 72 | extern int cupsFileNumber(cups_file_t *fp) _CUPS_API_1_2; |
| 73 | extern cups_file_t *cupsFileOpen(const char *filename, const char *mode) _CUPS_API_1_2; |
| 74 | extern cups_file_t *cupsFileOpenFd(int fd, const char *mode) _CUPS_API_1_2; |
| 75 | extern int cupsFilePeekChar(cups_file_t *fp) _CUPS_API_1_2; |
| 76 | extern int cupsFilePrintf(cups_file_t *fp, const char *format, ...) _CUPS_FORMAT(2, 3) _CUPS_API_1_2; |
| 77 | extern int cupsFilePutChar(cups_file_t *fp, int c) _CUPS_API_1_2; |
| 78 | extern ssize_t cupsFilePutConf(cups_file_t *fp, const char *directive, const char *value) _CUPS_API_1_4; |
| 79 | extern int cupsFilePuts(cups_file_t *fp, const char *s) _CUPS_API_1_2; |
| 80 | extern ssize_t cupsFileRead(cups_file_t *fp, char *buf, size_t bytes) _CUPS_API_1_2; |
| 81 | extern off_t cupsFileRewind(cups_file_t *fp) _CUPS_API_1_2; |
| 82 | extern off_t cupsFileSeek(cups_file_t *fp, off_t pos) _CUPS_API_1_2; |
| 83 | extern cups_file_t *cupsFileStderr(void) _CUPS_API_1_2; |
| 84 | extern cups_file_t *cupsFileStdin(void) _CUPS_API_1_2; |
| 85 | extern cups_file_t *cupsFileStdout(void) _CUPS_API_1_2; |
| 86 | extern off_t cupsFileTell(cups_file_t *fp) _CUPS_API_1_2; |
| 87 | extern int cupsFileUnlock(cups_file_t *fp) _CUPS_API_1_2; |
| 88 | extern ssize_t cupsFileWrite(cups_file_t *fp, const char *buf, size_t bytes) _CUPS_API_1_2; |
| 89 | |
| 90 | |
| 91 | # ifdef __cplusplus |
| 92 | } |
| 93 | # endif /* __cplusplus */ |
| 94 | #endif /* !_CUPS_FILE_H_ */ |
| 95 | |