1 /* 2 * PWG media API definitions for CUPS. 3 * 4 * Copyright © 2020-2024 by OpenPrinting. 5 * Copyright 2009-2017 by Apple Inc. 6 * 7 * Licensed under Apache License v2.0. See the file "LICENSE" for more information. 8 */ 9 10 #ifndef _CUPS_PWG_H_ 11 # define _CUPS_PWG_H_ 12 13 14 /* 15 * C++ magic... 16 */ 17 18 # ifdef __cplusplus 19 extern "C" { 20 # endif /* __cplusplus */ 21 22 23 /* 24 * Macros... 25 */ 26 27 /* Convert from points to hundredths of millimeters */ 28 # define PWG_FROM_POINTS(n) (int)(((n) * 2540 + 36) / 72) 29 /* Convert from hundredths of millimeters to points */ 30 # define PWG_TO_POINTS(n) ((n) * 72.0 / 2540.0) 31 32 33 /* 34 * Types and structures... 35 */ 36 37 typedef struct pwg_map_s /**** Map element - PPD to/from PWG @exclude all@ */ 38 { 39 char *pwg, /* PWG media keyword */ 40 *ppd; /* PPD option keyword */ 41 } pwg_map_t; 42 43 typedef struct pwg_media_s /**** Common media size data ****/ 44 { 45 const char *pwg, /* PWG 5101.1 "self describing" name */ 46 *legacy, /* IPP/ISO legacy name */ 47 *ppd; /* Standard Adobe PPD name */ 48 int width, /* Width in 2540ths */ 49 length; /* Length in 2540ths */ 50 } pwg_media_t; 51 52 typedef struct pwg_size_s /**** Size element - PPD to/from PWG @exclude all@ */ 53 { 54 pwg_map_t map; /* Map element */ 55 int width, /* Width in 2540ths */ 56 length, /* Length in 2540ths */ 57 left, /* Left margin in 2540ths */ 58 bottom, /* Bottom margin in 2540ths */ 59 right, /* Right margin in 2540ths */ 60 top; /* Top margin in 2540ths */ 61 } pwg_size_t; 62 63 64 /* 65 * Functions... 66 */ 67 68 extern int pwgFormatSizeName(char *keyword, size_t keysize, 69 const char *prefix, const char *name, 70 int width, int length, 71 const char *units) _CUPS_API_1_7; 72 extern int pwgInitSize(pwg_size_t *size, ipp_t *job, 73 int *margins_set) _CUPS_API_1_7; 74 extern pwg_media_t *pwgMediaForLegacy(const char *legacy) _CUPS_API_1_7; 75 extern pwg_media_t *pwgMediaForPPD(const char *ppd) _CUPS_API_1_7; 76 extern pwg_media_t *pwgMediaForPWG(const char *pwg) _CUPS_API_1_7; 77 extern pwg_media_t *pwgMediaForSize(int width, int length) _CUPS_API_1_7; 78 79 # ifdef __cplusplus 80 } 81 # endif /* __cplusplus */ 82 83 #endif /* !_CUPS_PWG_H_ */ 84