Codebase list libnet-cups-perl / 6ba9344
New upstream version 0.64 gregor herrmann 6 years ago
6 changed file(s) with 62 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
2929 #ifndef HAVE_CUPS_1_6
3030 #define ippGetGroupTag(attr) attr->group_tag
3131 #define ippGetName(attr) attr->name
32 #define ippGetCount(attr) attr->num_values
3233 #define ippGetValueTag(attr) attr->value_tag
3334 #define ippGetInteger(attr, element) attr->values[element].integer
35 #define ippGetBoolean(attr, element) attr->values[element].boolean
3436 #define ippGetString(attr, element, language) attr->values[element].string.text
3537 #define ippGetStatusCode(ipp) ipp->request.status.status_code
3638 #define ippFirstAttribute(ipp) ipp->current = ipp->attrs
450452 request = ippNewRequest (CUPS_GET_PRINTERS);
451453
452454 if ((response = cupsDoRequest (http, request, "/")) != NULL) {
453 attr = ippFindNextAttribute(response, "printer-name", IPP_TAG_NAME);
454
455 while (attr != NULL) {
456 if (strcmp(ippGetString(attr, 0, NULL), device) == 0) {
457 attr = ippFindNextAttribute( response,
458 attribute,
459 attribute_type);
460 rv = sv_newmortal();
461 sv_setpv( rv, ippGetString(attr, 0, NULL));
462 XPUSHs( rv );
463 break;
464 }
465 attr = ippFindNextAttribute( response,
466 "printer-name",
467 IPP_TAG_NAME);
468 if (attr == NULL) {
469 break;
470 }
455 rv = sv_newmortal();
456 int match = 0;
457 for (attr = ippFirstAttribute(response); attr != NULL; attr = ippNextAttribute(response)) {
458 if (ippGetName(attr) == NULL) {
459 if (match) break; else continue;
460 }
461 if (!strcmp(ippGetName(attr), "printer-name") && ippGetValueTag(attr) == IPP_TAG_NAME) {
462 match = !strcmp(ippGetString(attr, 0, NULL), device);
463 } else if (!strcmp(ippGetName(attr), attribute) && ippGetValueTag(attr) == attribute_type) {
464 if (ippGetCount(attr) == 1) {
465 switch (attribute_type) {
466 case IPP_TAG_TEXT:
467 case IPP_TAG_NAME:
468 case IPP_TAG_KEYWORD:
469 case IPP_TAG_URI:
470 case IPP_TAG_CHARSET:
471 case IPP_TAG_LANGUAGE:
472 sv_setpv(rv, ippGetString(attr, 0, NULL));
473 break;
474 case IPP_TAG_BOOLEAN:
475 sv_setiv(rv, ippGetBoolean(attr, 0));
476 break;
477 case IPP_TAG_INTEGER:
478 case IPP_TAG_ENUM:
479 sv_setiv(rv, ippGetInteger(attr, 0));
480 break;
481 }
482 } else {
483 /* XXX */
484 }
485 }
471486 }
487 if (match) XPUSHs(rv);
472488 }
473489 ippDelete( response );
474490 httpClose( http );
00 Revision history for Perl extension Net::CUPS.
1
2 0.64 Thu Jun 08 20:10:00 2017
3 - Report the printer-state attribute and support non-string device
4 attributes in general by Edgar Fuß
15
26 0.63 Thu Oct 31 09:15:00 2016
37 - Fix segfaults in Net::CUPS::PPD::getNextOption when enumerating
4343 "x_git" : "https://github.com/niner/perl-Net-CUPS.git"
4444 }
4545 },
46 "version" : "0.63",
46 "version" : "0.64",
4747 "x_serialization_backend" : "JSON::PP version 2.27300"
4848 }
2020 Test::More: '0'
2121 resources:
2222 repository: https://github.com/niner/perl-Net-CUPS
23 version: '0.63'
23 version: '0.64'
2424 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
11421142 {
11431143 my $self = shift;
11441144
1145 return( NETCUPS_getDeviceAttribute( $self->getName(),
1145 return( NETCUPS_getDeviceAttribute( $self->getName(),
11461146 "device-uri",
11471147 IPP_TAG_URI() ) );
1148 }
1149
1150 ##----------------------------------------------##
1151 ## getState ##
1152 ##----------------------------------------------##
1153 sub getState
1154 {
1155 my $self = shift;
1156
1157 return( NETCUPS_getDeviceAttribute( $self->getName(),
1158 "printer-state",
1159 IPP_TAG_ENUM() ) );
11481160 }
11491161
11501162 ##----------------------------------------------##
12741286 This function returns the device URI of a destination.
12751287 For example, a network printer might appear as socket://192.168.1.1
12761288
1289 =item B<getState>
1290
1291 my $state = $dest->getState();
1292
1293 This function returns the state of a destination.
1294 The value is an enumeration type with 3 meaning 'idle', 4 'processing'
1295 and 5 'stopped'.
1296
12771297 =back
12781298
12791299 =head1 SEE ALSO
958958 PPD_VERSION
959959 );
960960
961 our $VERSION = '0.63';
961 our $VERSION = '0.64';
962962
963963 sub AUTOLOAD {
964964 # This AUTOLOAD is used to 'autoload' constants from the constant()