• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * PWG media API definitions for CUPS.
3  *
4  * Copyright 2009-2017 by Apple Inc.
5  *
6  * These coded instructions, statements, and computer programs are the
7  * property of Apple Inc. and are protected by Federal copyright
8  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
9  * which should have been included with this file.  If this file is
10  * missing or damaged, see the license at "http://www.cups.org/".
11  *
12  * This file is subject to the Apple OS-Developed Software exception.
13  */
14 
15 #ifndef _CUPS_PWG_H_
16 #  define _CUPS_PWG_H_
17 
18 
19 /*
20  * C++ magic...
21  */
22 
23 #  ifdef __cplusplus
24 extern "C" {
25 #  endif /* __cplusplus */
26 
27 
28 /*
29  * Macros...
30  */
31 
32 /* Convert from points to hundredths of millimeters */
33 #  define PWG_FROM_POINTS(n)	(int)(((n) * 2540 + 36) / 72)
34 /* Convert from hundredths of millimeters to points */
35 #  define PWG_TO_POINTS(n)	((n) * 72.0 / 2540.0)
36 
37 
38 /*
39  * Types and structures...
40  */
41 
42 typedef struct pwg_map_s		/**** Map element - PPD to/from PWG @exclude all@ */
43 {
44   char		*pwg,			/* PWG media keyword */
45 		*ppd;			/* PPD option keyword */
46 } pwg_map_t;
47 
48 typedef struct pwg_media_s		/**** Common media size data ****/
49 {
50   const char	*pwg,			/* PWG 5101.1 "self describing" name */
51 		*legacy,		/* IPP/ISO legacy name */
52 		*ppd;			/* Standard Adobe PPD name */
53   int		width,			/* Width in 2540ths */
54 		length;			/* Length in 2540ths */
55 } pwg_media_t;
56 
57 typedef struct pwg_size_s		/**** Size element - PPD to/from PWG @exclude all@ */
58 {
59   pwg_map_t	map;			/* Map element */
60   int		width,			/* Width in 2540ths */
61 		length,			/* Length in 2540ths */
62 		left,			/* Left margin in 2540ths */
63 		bottom,			/* Bottom margin in 2540ths */
64 		right,			/* Right margin in 2540ths */
65 		top;			/* Top margin in 2540ths */
66 } pwg_size_t;
67 
68 
69 /*
70  * Functions...
71  */
72 
73 extern int		pwgFormatSizeName(char *keyword, size_t keysize,
74 					  const char *prefix, const char *name,
75 					  int width, int length,
76 					  const char *units) _CUPS_API_1_7;
77 extern int		pwgInitSize(pwg_size_t *size, ipp_t *job,
78 				    int *margins_set) _CUPS_API_1_7;
79 extern pwg_media_t	*pwgMediaForLegacy(const char *legacy) _CUPS_API_1_7;
80 extern pwg_media_t	*pwgMediaForPPD(const char *ppd) _CUPS_API_1_7;
81 extern pwg_media_t	*pwgMediaForPWG(const char *pwg) _CUPS_API_1_7;
82 extern pwg_media_t	*pwgMediaForSize(int width, int length) _CUPS_API_1_7;
83 
84 #  ifdef __cplusplus
85 }
86 #  endif /* __cplusplus */
87 
88 #endif /* !_CUPS_PWG_H_ */
89