Properly pass multi-value options to cups. (#355350, Jürg Billeter)
2006-12-10 Matthias Clasen <mclasen@redhat.com> * modules/printbackends/cups/gtkcupsutils.c (gtk_cups_request_encode_option): Properly pass multi-value options to cups. (#355350, Jürg Billeter)
This commit is contained in:
committed by
Matthias Clasen
parent
1cd7347a54
commit
d503f5d028
@ -1,3 +1,8 @@
|
||||
2006-12-10 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* modules/printbackends/cups/gtkcupsutils.c (gtk_cups_request_encode_option):
|
||||
Properly pass multi-value options to cups. (#355350, Jürg Billeter)
|
||||
|
||||
2006-12-10 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_focus_out_event):
|
||||
|
||||
@ -60,17 +60,21 @@ struct _GtkCupsResult
|
||||
#define _GTK_CUPS_MAX_ATTEMPTS 10
|
||||
#define _GTK_CUPS_MAX_CHUNK_SIZE 8192
|
||||
|
||||
GtkCupsRequestStateFunc post_states[] = {_connect,
|
||||
static GtkCupsRequestStateFunc post_states[] = {
|
||||
_connect,
|
||||
_post_send,
|
||||
_post_write_request,
|
||||
_post_write_data,
|
||||
_post_check,
|
||||
_post_read_response};
|
||||
_post_read_response
|
||||
};
|
||||
|
||||
GtkCupsRequestStateFunc get_states[] = {_connect,
|
||||
static GtkCupsRequestStateFunc get_states[] = {
|
||||
_connect,
|
||||
_get_send,
|
||||
_get_check,
|
||||
_get_read_data};
|
||||
_get_read_data
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_cups_result_set_error (GtkCupsResult *result,
|
||||
@ -278,8 +282,7 @@ typedef struct
|
||||
ipp_tag_t value_tag;
|
||||
} ipp_option_t;
|
||||
|
||||
static const ipp_option_t ipp_options[] =
|
||||
{
|
||||
static const ipp_option_t ipp_options[] = {
|
||||
{ "blackplot", IPP_TAG_BOOLEAN },
|
||||
{ "brightness", IPP_TAG_INTEGER },
|
||||
{ "columns", IPP_TAG_INTEGER },
|
||||
@ -474,12 +477,80 @@ gtk_cups_request_encode_option (GtkCupsRequest *request,
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
char *values;
|
||||
char *s;
|
||||
int in_quotes;
|
||||
char *next;
|
||||
GPtrArray *strings;
|
||||
|
||||
values = g_strdup (value);
|
||||
strings = NULL;
|
||||
in_quotes = 0;
|
||||
|
||||
for (s = values, next = s; *s != '\0'; s++)
|
||||
{
|
||||
if (in_quotes != 2 && *s == '\'')
|
||||
{
|
||||
/* skip quoted value */
|
||||
if (in_quotes == 0)
|
||||
in_quotes = 1;
|
||||
else
|
||||
in_quotes = 0;
|
||||
}
|
||||
else if (in_quotes != 1 && *s == '\"')
|
||||
{
|
||||
/* skip quoted value */
|
||||
if (in_quotes == 0)
|
||||
in_quotes = 2;
|
||||
else
|
||||
in_quotes = 0;
|
||||
}
|
||||
else if (in_quotes == 0 && *s == ',')
|
||||
{
|
||||
/* found delimiter, add to value array */
|
||||
*s = '\0';
|
||||
if (strings == NULL)
|
||||
strings = g_ptr_array_new ();
|
||||
g_ptr_array_add (strings, next);
|
||||
next = s + 1;
|
||||
}
|
||||
else if (in_quotes == 0 && *s == '\\' && s[1] != '\0')
|
||||
{
|
||||
/* skip escaped character */
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
if (strings == NULL)
|
||||
{
|
||||
/* single value */
|
||||
ippAddString (request->ipp_request,
|
||||
IPP_TAG_OPERATION,
|
||||
option_tag,
|
||||
option,
|
||||
NULL,
|
||||
value);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* multiple values */
|
||||
|
||||
/* add last value */
|
||||
g_ptr_array_add (strings, next);
|
||||
|
||||
ippAddStrings (request->ipp_request,
|
||||
IPP_TAG_OPERATION,
|
||||
option_tag,
|
||||
option,
|
||||
strings->len,
|
||||
NULL,
|
||||
(const char **) strings->pdata);
|
||||
g_ptr_array_free (strings, TRUE);
|
||||
}
|
||||
|
||||
g_free (values);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user