Net-CUPS
view release on metacpan or search on metacpan
NETCUPS_getPassword( prompt )
const char* prompt;
CODE:
RETVAL = cupsGetPassword( prompt );
OUTPUT:
RETVAL
void
NETCUPS_getDestination( name )
char* name;
PPCODE:
cups_dest_t * destinations = NULL;
cups_dest_t * destination = NULL;
int count = 0;
SV* rv = NULL;
count = cupsGetDests( &destinations );
/* If we have a NULL for destination name, then we are going
to assume we want the default. */
if( !strlen( name ) )
{
name = cupsGetDefault();
}
destination = cupsGetDest( name, NULL, count, destinations );
rv = sv_newmortal();
sv_setref_pv( rv, "Net::CUPS::Destination", destination );
XPUSHs( rv );
XSRETURN( 1 );
void
NETCUPS_getDestinations()
PPCODE:
cups_dest_t * destinations = NULL;
int count = 0;
int loop = 0;
SV* rv = NULL;
count = cupsGetDests( &destinations );
for( loop = 0; loop < count; loop++ )
{
rv = sv_newmortal();
/* FIXME cloning is probably not the best way to go at this.
It's at best a band aid for incorrect memory management
filename = cupsGetPPD( name );
RETVAL = ppdOpenFile( filename );
OUTPUT:
RETVAL
void
NETCUPS_requestData( request, resource, filename )
ipp_t* request;
const char* resource;
const char* filename;
PPCODE:
http_t* http = NULL;
ipp_t* response = NULL;
const char* server = NULL;
SV* rv = NULL;
int port;
server = cupsServer();
port = ippPort();
httpInitialize();
http = httpConnect( server, port );
if( strlen( filename ) == 0 )
httpClose( http );
XSRETURN( 1 );
void
NETCUPS_getPPDMakes()
http_t *http; /* HTTP object */
ipp_t *request; /* IPP request object */
ipp_t *response; /* IPP response object */
ipp_attribute_t *attr; /* Current IPP attribute */
PPCODE:
SV* rv = NULL;
int count = 0;
cups_lang_t *language;
language = cupsLangDefault();
http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
request = ippNewRequest(CUPS_GET_PPDS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
"attributes-charset", NULL, "utf-8");
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
"attributes-natural-language", NULL, language->language);
XSRETURN( count );
void
NETCUPS_getAllPPDs ()
http_t *http; /* HTTP object */
ipp_t *request; /* IPP request object */
ipp_t *response; /* IPP response object */
ipp_attribute_t *attr; /* Current IPP attribute */
PPCODE:
SV* rv = NULL;
int count = 0;
cups_lang_t *language;
language = cupsLangDefault();
http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
request = ippNewRequest(CUPS_GET_PPDS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
"attributes-charset", NULL, "utf-8");
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
"attributes-natural-language", NULL, language->language);
}
else {
XSRETURN ( 0 );
}
XSRETURN( count );
void
NETCUPS_deleteDestination( destination );
const char* destination;
PPCODE:
ipp_t *request;
http_t *http;
char uri[HTTP_MAX_URI];
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
cupsServer(), 0, "/printers/%s", destination);
http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
request = ippNewRequest(CUPS_DELETE_PRINTER);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
ippDelete(cupsDoRequest(http, request, "/admin/"));
void
NETCUPS_addDestination(name, location, printer_info, ppd_name, device_uri);
const char* name;
const char* location;
const char* printer_info;
const char* ppd_name;
const char* device_uri;
PPCODE:
http_t *http = NULL; /* HTTP object */
ipp_t *request = NULL; /* IPP request object */
char uri[HTTP_MAX_URI]; /* Job URI */
http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
request = ippNewRequest(CUPS_ADD_PRINTER);
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
cupsServer(), 0, "/printers/%s", name);
NULL, uri);
ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1);
ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state",
IPP_PRINTER_IDLE);
ippDelete(cupsDoRequest(http, request, "/admin/"));
void
NETCUPS_getPPDFileName(ppdfilename);
const char* ppdfilename;
PPCODE:
http_t *http; /* HTTP object */
ipp_t *request; /* IPP request object */
ipp_t *response; /* IPP response object */
ipp_attribute_t *attr; /* Current IPP attribute */
int i = 0;
char* tmpppd;
char test[1024];
SV* rv = NULL;
http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
PROTOTYPES: DISABLE
INCLUDE: const-xs.inc
void
NETCUPS_getDeviceAttribute( device, attribute, attribute_type )
const char* device;
const char* attribute;
int attribute_type;
PPCODE:
http_t *http = NULL; /* HTTP object */
ipp_t *request = NULL; /* IPP request */
ipp_t *response = NULL; /* IPP response */
ipp_attribute_t *attr = NULL; /* IPP attribute */
SV* rv = NULL;
char *description = NULL;
http = httpConnectEncrypt( cupsServer(), ippPort(), cupsEncryption() );
if (http == NULL) {
RETVAL
void
NETCUPS_getDestinationOptions( self )
cups_dest_t* self
INIT:
int count = 0;
int loop = 0;
SV* rv = NULL;
cups_option_t* options = NULL;
PPCODE:
count = self->num_options;
options = self->options;
for( loop = 0; loop < count; loop++ )
{
rv = newSV(0);
sv_setpv( rv, options[loop].name );
XPUSHs( rv );
}
XSRETURN( count );
}
}
OUTPUT:
RETVAL
void
NETCUPS_getJobs( dest, whose, scope )
const char* dest;
int whose;
int scope;
PPCODE:
int loop = 0;
int count = 0;
SV* rv = NULL;
cups_job_t* jobs = NULL;
count = cupsGetJobs( &jobs, dest, whose, scope );
for( loop = 0; loop < count; loop++ )
{
rv = newSV(0);
sv_setiv( rv, jobs[loop].id );
XPUSHs( rv );
ipp_attribute_t* attribute = NULL;
attribute = ippAddString( ipp, group, type, name, charset, value );
RETVAL = 1;
OUTPUT:
RETVAL
void
NETCUPS_getAttributes( ipp )
ipp_t* ipp;
PPCODE:
SV* rv = NULL;
int count = 0;
ipp_attribute_t* attr = NULL;
for (attr = ippFirstAttribute(ipp); attr != NULL; attr = ippNextAttribute(ipp))
{
while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_JOB)
attr = ippNextAttribute(ipp);
if (attr == NULL)
break;
sv_setpv( rv, ippGetName(attr) );
XPUSHs( rv );
count++;
}
XSRETURN( count );
void
NETCUPS_getAttributeValue( ipp, name )
ipp_t* ipp;
const char* name;
PPCODE:
SV* rv = NULL;
int count = 0;
ipp_attribute_t* attr = NULL;
for (attr = ippFirstAttribute(ipp); attr != NULL; attr = ippNextAttribute(ipp))
{
while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_JOB)
attr = ippNextAttribute(ipp);
if (attr == NULL)
break;
size_t
NETCUPS_getSize( ipp )
ipp_t* ipp;
CODE:
RETVAL = ippLength( ipp );
OUTPUT:
RETVAL
void
NETCUPS_newIPP()
PPCODE:
ipp_t * ipp = NULL;
SV* rv = NULL;
ipp = ippNew();
rv = sv_newmortal();
sv_setref_pv( rv, "Net::CUPS::IPP", ipp );
XPUSHs( rv );
XSRETURN( 1 );
void
NETCUPS_newIPPRequest( op )
ipp_op_t op;
PPCODE:
ipp_t * ipp = NULL;
SV* rv = NULL;
ipp = ippNewRequest( op );
rv = sv_newmortal();
sv_setref_pv( rv, "Net::CUPS::IPP", ipp );
XPUSHs( rv );
XSRETURN( 1 );
int
NETCUPS_setPort( port )
const-xs.inc view on Meta::CPAN
dTARGET;
#endif
STRLEN len;
int type;
IV iv = 0; /* avoid uninit var warning */
/* NV nv; Uncomment this if you need to return NVs */
/* const char *pv; Uncomment this if you need to return PVs */
INPUT:
SV * sv;
const char * s = SvPV(sv, len);
PPCODE:
/* Change this to constant(aTHX_ s, len, &iv, &nv);
if you need to return both NVs and IVs */
type = constant(aTHX_ s, len, &iv);
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
sv =
sv_2mortal(newSVpvf("%s is not a valid Net::CUPS macro", s));
PUSHs(sv);
fallback/const-xs.inc view on Meta::CPAN
dTARGET;
#endif
STRLEN len;
int type;
IV iv;
/* NV nv; Uncomment this if you need to return NVs */
/* const char *pv; Uncomment this if you need to return PVs */
INPUT:
SV * sv;
const char * s = SvPV(sv, len);
PPCODE:
/* Change this to constant(aTHX_ s, len, &iv, &nv);
if you need to return both NVs and IVs */
type = constant(aTHX_ s, len, &iv);
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
sv = sv_2mortal(newSVpvf("%s is not a valid Net::CUPS macro", s));
PUSHs(sv);
break;
( run in 0.621 second using v1.01-cache-2.11-cpan-5511b514fd6 )