本文整理汇总了C++中cupsLastErrorString函数的典型用法代码示例。如果您正苦于以下问题:C++ cupsLastErrorString函数的具体用法?C++ cupsLastErrorString怎么用?C++ cupsLastErrorString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cupsLastErrorString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printer_cups_create_printjob
static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
{
rdpCupsPrinter* cups_printer = (rdpCupsPrinter*) printer;
rdpCupsPrintJob* cups_printjob;
if (cups_printer->printjob != NULL)
return NULL;
cups_printjob = (rdpCupsPrintJob*) malloc(sizeof(rdpCupsPrintJob));
ZeroMemory(cups_printjob, sizeof(rdpCupsPrintJob));
cups_printjob->printjob.id = id;
cups_printjob->printjob.printer = printer;
cups_printjob->printjob.Write = printer_cups_write_printjob;
cups_printjob->printjob.Close = printer_cups_close_printjob;
#ifndef _CUPS_API_1_4
cups_printjob->printjob_object = _strdup(tmpnam(NULL));
#else
{
char buf[100];
cups_printjob->printjob_object = httpConnectEncrypt(cupsServer(), ippPort(), HTTP_ENCRYPT_IF_REQUESTED);
if (cups_printjob->printjob_object == NULL)
{
DEBUG_WARN("httpConnectEncrypt: %s", cupsLastErrorString());
free(cups_printjob);
return NULL;
}
printer_cups_get_printjob_name(buf, sizeof(buf));
cups_printjob->printjob_id = cupsCreateJob((http_t*) cups_printjob->printjob_object,
printer->name, buf, 0, NULL);
if (cups_printjob->printjob_id == 0)
{
DEBUG_WARN("cupsCreateJob: %s", cupsLastErrorString());
httpClose((http_t*) cups_printjob->printjob_object);
free(cups_printjob);
return NULL;
}
cupsStartDocument((http_t*) cups_printjob->printjob_object,
printer->name, cups_printjob->printjob_id, buf, CUPS_FORMAT_AUTO, 1);
}
#endif
cups_printer->printjob = cups_printjob;
return (rdpPrintJob*)cups_printjob;
}
示例2: main
int /* O - Exit status */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line arguments */
{
int i, /* Looping var */
num_settings; /* Number of settings */
cups_option_t *settings; /* Settings */
http_t *http; /* Connection to server */
/*
* Connect to the server using the defaults...
*/
http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC,
cupsEncryption(), 1, 30000, NULL);
/*
* Set the current configuration if we have anything on the command-line...
*/
if (argc > 1)
{
for (i = 1, num_settings = 0, settings = NULL; i < argc; i ++)
num_settings = cupsParseOptions(argv[i], num_settings, &settings);
if (cupsAdminSetServerSettings(http, num_settings, settings))
{
puts("New server settings:");
cupsFreeOptions(num_settings, settings);
}
else
{
printf("Server settings not changed: %s\n", cupsLastErrorString());
return (1);
}
}
else
puts("Current server settings:");
/*
* Get the current configuration...
*/
if (cupsAdminGetServerSettings(http, &num_settings, &settings))
{
show_settings(num_settings, settings);
cupsFreeOptions(num_settings, settings);
return (0);
}
else
{
printf(" %s\n", cupsLastErrorString());
return (1);
}
}
示例3: printer_hw_create
uint32
printer_hw_create(IRP * irp, const char * path)
{
PRINTER_DEVICE_INFO * info;
info = (PRINTER_DEVICE_INFO *) irp->dev->info;
/* Server's print queue will ensure no two print jobs will be sent to the same printer.
However, we still want to do a simple locking just to ensure we are safe. */
if (info->printjob_object)
{
return RD_STATUS_DEVICE_BUSY;
}
#ifndef _CUPS_API_1_4
info->printjob_id++;
info->printjob_object = strdup(tmpnam(NULL));
#else
{
char buf[100];
info->printjob_object = httpConnectEncrypt(cupsServer(), ippPort(), HTTP_ENCRYPT_IF_REQUESTED);
if (info->printjob_object == NULL)
{
LLOGLN(0, ("printer_hw_create: httpConnectEncrypt: %s", cupsLastErrorString()));
return RD_STATUS_DEVICE_BUSY;
}
printer_hw_get_printjob_name(buf, sizeof(buf));
info->printjob_id = cupsCreateJob((http_t *) info->printjob_object,
info->printer_name, buf,
0, NULL);
if (info->printjob_id == 0)
{
LLOGLN(0, ("printer_hw_create: cupsCreateJob: %s", cupsLastErrorString()));
httpClose((http_t *) info->printjob_object);
info->printjob_object = NULL;
/* Should get the right return code based on printer status */
return RD_STATUS_DEVICE_BUSY;
}
cupsStartDocument((http_t *) info->printjob_object,
info->printer_name, info->printjob_id, buf,
CUPS_FORMAT_POSTSCRIPT, 1);
}
#endif
LLOGLN(10, ("printe_hw_create: %s id=%d", info->printer_name, info->printjob_id));
irp->fileID = info->printjob_id;
return RD_STATUS_SUCCESS;
}
示例4: getPrinterSharingStatus
int getPrinterSharingStatus() {
http_t* cups = nullptr;
int num_settings = 0;
cups_option_t* settings = nullptr;
const char* value = nullptr;
cups = httpConnect2(cupsServer(),
ippPort(),
nullptr,
AF_INET,
cupsEncryption(),
1,
30000,
nullptr);
if (cups == nullptr) {
return 0;
}
int ret = cupsAdminGetServerSettings(cups, &num_settings, &settings);
if (ret != 0) {
value = cupsGetOption("_share_printers", num_settings, settings);
cupsFreeOptions(num_settings, settings);
} else {
VLOG(1) << "Unable to get CUPS server settings: " << cupsLastErrorString();
}
httpClose(cups);
if (value != nullptr) {
return *value == '1' ? 1 : 0;
}
return 0;
}
示例5: cupsPrintFile
void ofxCUPS::printImage(string filename)
{
int num_options = 0;
cups_option_t *options = NULL;
string path = ofFilePath::getAbsolutePath("");
string currentFile = filename;
string printFile = path + currentFile;
//optionen = "media=DS_PC_size"; //ds40
//num_options = cupsParseOptions(optionen.c_str(), num_options, &options);
int last_job_id = cupsPrintFile(
printerName.c_str(),
printFile.c_str(),
jobTitle.c_str() ? jobTitle.c_str() : "print from ofxCUPS",
num_options,
options);
cout << "the job id is: " << last_job_id << endl;
if (last_job_id == 0)
{
cout << "print Error: " << cupsLastErrorString() << endl;
}
cupsFreeOptions(num_options,options);
}
示例6: list_options
static void
list_options(cups_dest_t *dest) /* I - Destination to list */
{
int i; /* Looping var */
const char *filename; /* PPD filename */
ppd_file_t *ppd; /* PPD data */
ppd_group_t *group; /* Current group */
if ((filename = cupsGetPPD(dest->name)) == NULL)
{
_cupsLangPrintf(stderr, _("lpoptions: Unable to get PPD file for %s: %s"),
dest->name, cupsLastErrorString());
return;
}
if ((ppd = ppdOpenFile(filename)) == NULL)
{
unlink(filename);
_cupsLangPrintf(stderr, _("lpoptions: Unable to open PPD file for %s."),
dest->name);
return;
}
ppdMarkDefaults(ppd);
cupsMarkOptions(ppd, dest->num_options, dest->options);
for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++)
list_group(ppd, group);
ppdClose(ppd);
unlink(filename);
}
示例7: printer_cups_close_printjob
static void printer_cups_close_printjob(rdpPrintJob* printjob)
{
rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*)printjob;
#ifndef _CUPS_API_1_4
{
char buf[100];
printer_cups_get_printjob_name(buf, sizeof(buf));
if (cupsPrintFile(printjob->printer->name, (const char *)cups_printjob->printjob_object, buf, 0, NULL) == 0)
{
DEBUG_WARN("cupsPrintFile: %s", cupsLastErrorString());
}
unlink(cups_printjob->printjob_object);
xfree(cups_printjob->printjob_object);
}
#else
cupsFinishDocument((http_t*)cups_printjob->printjob_object, printjob->printer->name);
cups_printjob->printjob_id = 0;
httpClose((http_t*)cups_printjob->printjob_object);
#endif
xfree(cups_printjob);
((rdpCupsPrinter*)printjob->printer)->printjob = NULL;
}
示例8: ofToDataPath
void ofxCUPS::printImage(string filename, bool isAbsolutePath) {
int num_options = 0;
cups_option_t *options = NULL;
string printFile;
if(isAbsolutePath) {
printFile = filename;
}
else {
printFile = ofToDataPath("./",true) + filename;
}
//optionen = "media=DS_PC_size"; //ds40
//num_options = cupsParseOptions(optionen.c_str(), num_options, &options);
int last_job_id = cupsPrintFile(
printerName.c_str(),
printFile.c_str(),
jobTitle.c_str() ? jobTitle.c_str() : "print from ofxCUPS",
num_options,
options);
cout << "the job id is: " << last_job_id << endl;
if (last_job_id == 0)
{
cout << "print Error: " << cupsLastErrorString() << endl;
}
cupsFreeOptions(num_options,options);
}
示例9: cupsFinishDestDocument
ipp_status_t /* O - Status of document submission */
cupsFinishDestDocument(
http_t *http, /* I - Connection to destination */
cups_dest_t *dest, /* I - Destination */
cups_dinfo_t *info) /* I - Destination information */
{
DEBUG_printf(("cupsFinishDestDocument(http=%p, dest=%p(%s/%s), info=%p)",
http, dest, dest ? dest->name : NULL,
dest ? dest->instance : NULL, info));
/*
* Range check input...
*/
if (!http || !dest || !info)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
DEBUG_puts("1cupsFinishDestDocument: Bad arguments.");
return (IPP_STATUS_ERROR_INTERNAL);
}
/*
* Get the response at the end of the document and return it...
*/
ippDelete(cupsGetResponse(http, info->resource));
DEBUG_printf(("1cupsFinishDestDocument: %s (%s)",
ippErrorString(cupsLastError()), cupsLastErrorString()));
return (cupsLastError());
}
示例10: list_options
static void
list_options(cups_dest_t *dest) /* I - Destination to list */
{
http_t *http; /* Connection to destination */
char resource[1024]; /* Resource path */
int i; /* Looping var */
const char *filename; /* PPD filename */
ppd_file_t *ppd; /* PPD data */
ppd_group_t *group; /* Current group */
if ((http = cupsConnectDest(dest, CUPS_DEST_FLAGS_NONE, 30000, NULL, resource, sizeof(resource), NULL, NULL)) == NULL)
{
_cupsLangPrintf(stderr, _("lpoptions: Unable to get PPD file for %s: %s"),
dest->name, cupsLastErrorString());
return;
}
if ((filename = cupsGetPPD2(http, dest->name)) == NULL)
{
httpClose(http);
_cupsLangPrintf(stderr, _("lpoptions: Unable to get PPD file for %s: %s"),
dest->name, cupsLastErrorString());
return;
}
httpClose(http);
if ((ppd = ppdOpenFile(filename)) == NULL)
{
unlink(filename);
_cupsLangPrintf(stderr, _("lpoptions: Unable to open PPD file for %s."),
dest->name);
return;
}
ppdMarkDefaults(ppd);
cupsMarkOptions(ppd, dest->num_options, dest->options);
for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++)
list_group(ppd, group);
ppdClose(ppd);
unlink(filename);
}
示例11: export_dest
int /* O - 0 on success, non-zero on error */
export_dest(http_t *http, /* I - Connection to server */
const char *dest) /* I - Destination to export */
{
int status; /* Status of export */
char ppdfile[1024], /* PPD file for printer drivers */
prompt[1024]; /* Password prompt */
int tries; /* Number of tries */
/*
* Get the Windows PPD file for the printer...
*/
if (!cupsAdminCreateWindowsPPD(http, dest, ppdfile, sizeof(ppdfile)))
{
_cupsLangPrintf(stderr,
_("cupsaddsmb: No PPD file for printer \"%s\" - %s"),
dest, cupsLastErrorString());
return (1);
}
/*
* Try to export it...
*/
for (status = 0, tries = 0; !status && tries < 3; tries ++)
{
/*
* Get the password, as needed...
*/
if (!SAMBAPassword)
{
snprintf(prompt, sizeof(prompt),
_cupsLangString(cupsLangDefault(),
_("Password for %s required to access %s via "
"SAMBA: ")),
SAMBAUser, SAMBAServer);
if ((SAMBAPassword = cupsGetPassword(prompt)) == NULL)
break;
}
status = cupsAdminExportSamba(dest, ppdfile, SAMBAServer,
SAMBAUser, SAMBAPassword,
Verbosity ? stderr : NULL);
if (!status && cupsLastError() == IPP_NOT_FOUND)
break;
}
unlink(ppdfile);
return (!status);
}
示例12: cups_get_error_reason
/*
* call-seq:
* print_job.error_reason -> String
*
* Get the last human-readable error string
*/
static VALUE cups_get_error_reason(VALUE self)
{
VALUE job_id = rb_iv_get(self, "@job_id");
if (NIL_P(job_id) || !NUM2INT(job_id) == 0) {
return Qnil;
} else {
VALUE error_exp = rb_str_new2(cupsLastErrorString());
return error_exp;
}
}
示例13: print_file
static int /* O - 0 on success, -1 on failure */
print_file(http_t *http, /* I - HTTP connection */
int id, /* I - Job ID */
const char *filename, /* I - File to print */
const char *docname, /* I - document-name */
const char *user, /* I - requesting-user-name */
const char *format, /* I - document-format */
int last) /* I - 1 = last file in job */
{
ipp_t *request; /* IPP request */
char uri[HTTP_MAX_URI]; /* Printer URI */
/*
* Setup the Send-Document request...
*/
request = ippNewRequest(IPP_SEND_DOCUMENT);
snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", id);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, user);
if (docname)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"document-name", NULL, docname);
if (format)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE,
"document-format", NULL, format);
ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", (char)last);
/*
* Do the request...
*/
snprintf(uri, sizeof(uri), "/jobs/%d", id);
ippDelete(cupsDoFileRequest(http, request, uri, filename));
if (cupsLastError() > IPP_OK_CONFLICT)
{
syslog(LOG_ERR, "Unable to send document - %s", cupsLastErrorString());
return (-1);
}
return (0);
}
示例14: enable_printer
static int /* O - 0 on success, 1 on fail */
enable_printer(http_t *http, /* I - Server connection */
char *printer) /* I - Printer to enable */
{
ipp_t *request; /* IPP Request */
char uri[HTTP_MAX_URI]; /* URI for printer/class */
DEBUG_printf(("enable_printer(%p, \"%s\")\n", http, printer));
/*
* Build a CUPS_ADD_MODIFY_PRINTER or CUPS_ADD_MODIFY_CLASS request, which
* require the following attributes:
*
* attributes-charset
* attributes-natural-language
* printer-uri
* requesting-user-name
* printer-state
* printer-is-accepting-jobs
*/
if (get_printer_type(http, printer, uri, sizeof(uri)) & CUPS_PRINTER_CLASS)
request = ippNewRequest(CUPS_ADD_MODIFY_CLASS);
else
request = ippNewRequest(CUPS_ADD_MODIFY_PRINTER);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, cupsUser());
ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state",
IPP_PRINTER_IDLE);
ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1);
/*
* Do the request and get back a response...
*/
ippDelete(cupsDoRequest(http, request, "/admin/"));
if (cupsLastError() > IPP_OK_CONFLICT)
{
_cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
return (1);
}
else
return (0);
}
示例15: delete_printer_option
static int /* O - 0 on success, 1 on fail */
delete_printer_option(http_t *http, /* I - Server connection */
char *printer, /* I - Printer */
char *option) /* I - Option to delete */
{
ipp_t *request; /* IPP request */
char uri[HTTP_MAX_URI]; /* URI for printer/class */
/*
* Build a CUPS_ADD_MODIFY_PRINTER or CUPS_ADD_MODIFY_CLASS request, which
* requires the following attributes:
*
* attributes-charset
* attributes-natural-language
* printer-uri
* requesting-user-name
* option with deleteAttr tag
*/
if (get_printer_type(http, printer, uri, sizeof(uri)) & CUPS_PRINTER_CLASS)
request = ippNewRequest(CUPS_ADD_MODIFY_CLASS);
else
request = ippNewRequest(CUPS_ADD_MODIFY_PRINTER);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, cupsUser());
ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_DELETEATTR, option, 0);
/*
* Do the request and get back a response...
*/
ippDelete(cupsDoRequest(http, request, "/admin/"));
if (cupsLastError() > IPP_OK_CONFLICT)
{
_cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
return (1);
}
else
return (0);
}