]>
git.ipfire.org Git - thirdparty/cups.git/blob - cgi-bin/ipp-var.c
2 * "$Id: ipp-var.c,v 1.1 2000/02/01 02:52:23 mike Exp $"
4 * IPP variable routines for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-1999 by Easy Software Products.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
26 * ippSetCGIVars() - Set CGI variables from an IPP response.
30 * Include necessary headers...
37 * 'ippSetCGIVars()' - Set CGI variables from an IPP response.
41 ippSetCGIVars(ipp_t
*response
) /* I - Response data to be copied... */
43 int element
; /* Element in CGI array */
44 ipp_attribute_t
*attr
; /* Attribute in response... */
45 int i
; /* Looping var */
46 char name
[1024], /* Name of attribute */
47 value
[16384], /* Value(s) */
48 *valptr
; /* Pointer into value */
51 cgiSetVariable("SERVER_NAME", getenv("SERVER_NAME"));
52 cgiSetVariable("REMOTE_USER", getenv("REMOTE_USER"));
53 cgiSetVariable("CUPS_VERSION", CUPS_SVERSION
);
55 for (element
= 0, attr
= response
->attrs
;
57 attr
= attr
->next
, element
++)
60 * Copy attributes to a separator...
63 for (; attr
!= NULL
&& attr
->group_tag
!= IPP_TAG_ZERO
; attr
= attr
->next
)
66 * Copy the attribute name, substituting "_" for "-"...
69 if (attr
->name
== NULL
)
72 for (i
= 0; attr
->name
[i
]; i
++)
73 if (attr
->name
[i
] == '-')
76 name
[i
] = attr
->name
[i
];
87 for (i
= 0; i
< attr
->num_values
; i
++)
92 valptr
+= strlen(valptr
);
94 switch (attr
->value_tag
)
96 case IPP_TAG_INTEGER
:
98 sprintf(valptr
, "%d", attr
->values
[i
].integer
);
101 case IPP_TAG_BOOLEAN
:
102 if (!attr
->values
[i
].boolean
)
103 strcat(valptr
, "no");
105 case IPP_TAG_NOVALUE
:
106 strcat(valptr
, attr
->name
);
110 sprintf(valptr
, "%d-%d", attr
->values
[i
].range
.lower
,
111 attr
->values
[i
].range
.upper
);
114 case IPP_TAG_RESOLUTION
:
115 sprintf(valptr
, "%dx%d%s", attr
->values
[i
].resolution
.xres
,
116 attr
->values
[i
].resolution
.yres
,
117 attr
->values
[i
].resolution
.units
== IPP_RES_PER_INCH
?
121 case IPP_TAG_STRING
:
124 case IPP_TAG_KEYWORD
:
125 case IPP_TAG_CHARSET
:
126 case IPP_TAG_LANGUAGE
:
127 strcat(valptr
, attr
->values
[i
].string
.text
);
136 cgiSetArray(name
, element
, value
);
146 * End of "$Id: ipp-var.c,v 1.1 2000/02/01 02:52:23 mike Exp $".