本文整理汇总了C++中cupsLangDefault函数的典型用法代码示例。如果您正苦于以下问题:C++ cupsLangDefault函数的具体用法?C++ cupsLangDefault怎么用?C++ cupsLangDefault使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cupsLangDefault函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _cupsStrDate
char * /* O - Buffer */
_cupsStrDate(char *buf, /* I - Buffer */
size_t bufsize, /* I - Size of buffer */
time_t timeval) /* I - Time value */
{
struct tm *dateval; /* Local date/time */
char temp[1024]; /* Temporary buffer */
_cups_globals_t *cg = _cupsGlobals(); /* Per-thread globals */
if (!cg->lang_default)
cg->lang_default = cupsLangDefault();
dateval = localtime(&timeval);
if (cg->lang_default->encoding != CUPS_UTF8)
{
strftime(temp, sizeof(temp), "%c", dateval);
cupsCharsetToUTF8((cups_utf8_t *)buf, temp, (int)bufsize, cg->lang_default->encoding);
}
else
strftime(buf, bufsize, "%c", dateval);
return (buf);
}
示例2: cups_get_language
const char * cups_get_language (void)
{
cups_lang_t *language;
language = cupsLangDefault(); /* needed for conversion */
return cupsLangEncoding(language);
}
示例3: 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);
}
示例4: _cupsLangPrintFilter
int /* O - Number of bytes written */
_cupsLangPrintFilter(
FILE *fp, /* I - File to write to */
const char *prefix, /* I - Non-localized message prefix */
const char *message, /* I - Message string to use */
...) /* I - Additional arguments as needed */
{
ssize_t bytes; /* Number of bytes formatted */
char temp[2048], /* Temporary format buffer */
buffer[2048], /* Message buffer */
output[8192]; /* Output buffer */
va_list ap; /* Pointer to additional arguments */
_cups_globals_t *cg; /* Global data */
/*
* Range check...
*/
if (!fp || !message)
return (-1);
cg = _cupsGlobals();
if (!cg->lang_default)
cg->lang_default = cupsLangDefault();
/*
* Format the string...
*/
va_start(ap, message);
snprintf(temp, sizeof(temp), "%s: %s\n", prefix,
_cupsLangString(cg->lang_default, message));
vsnprintf(buffer, sizeof(buffer), temp, ap);
va_end(ap);
/*
* Transcode to the destination charset...
*/
bytes = cupsUTF8ToCharset(output, (cups_utf8_t *)buffer, sizeof(output),
cg->lang_default->encoding);
/*
* Write the string and return the number of bytes written...
*/
if (bytes > 0)
return ((int)fwrite(output, 1, (size_t)bytes, fp));
else
return ((int)bytes);
}
示例5: bjcupsLangDefault
//////////////////////////////////////////////////////////////
//
// CS : PRIVATE cups_lang_t * bjcupsLangDefault()
// IN : none
// OUT : LC_ALL(locale)
// RETURN : pointer to cupa_lang_t structure
//
// This routine written for cups-1.1.19 Turbolinux10(Suzuka)
// Replace to cupsLangDefault()
//
PRIVATE cups_lang_t * bjcupsLangDefault( )
{
cups_lang_t *pLanguage;
char *tLang;
if( (tLang = getenv("LC_ALL"))==NULL)
tLang = getenv("LANG");
pLanguage = cupsLangDefault();
setlocale(LC_ALL,tLang);
return pLanguage;
}
示例6: ppd_ll_CC
static cups_lang_t * /* O - Current language */
ppd_ll_CC(char *ll_CC, /* O - Country-specific locale name */
size_t ll_CC_size) /* I - Size of country-specific name */
{
cups_lang_t *lang; /* Current language */
/*
* Get the current locale...
*/
if ((lang = cupsLangDefault()) == NULL)
{
strlcpy(ll_CC, "en_US", ll_CC_size);
return (NULL);
}
/*
* Copy the locale name...
*/
strlcpy(ll_CC, lang->language, ll_CC_size);
if (strlen(ll_CC) == 2)
{
/*
* Map "ll" to primary/origin country locales to have the best
* chance of finding a match...
*/
if (!strcmp(ll_CC, "cs"))
strlcpy(ll_CC, "cs_CZ", ll_CC_size);
else if (!strcmp(ll_CC, "en"))
strlcpy(ll_CC, "en_US", ll_CC_size);
else if (!strcmp(ll_CC, "ja"))
strlcpy(ll_CC, "ja_JP", ll_CC_size);
else if (!strcmp(ll_CC, "sv"))
strlcpy(ll_CC, "sv_SE", ll_CC_size);
else if (!strcmp(ll_CC, "zh")) /* Simplified Chinese */
strlcpy(ll_CC, "zh_CN", ll_CC_size);
}
DEBUG_printf(("8ppd_ll_CC: lang->language=\"%s\", ll_CC=\"%s\"...",
lang->language, ll_CC));
return (lang);
}
示例7: _cupsSetError
void
_cupsSetError(ipp_status_t status, /* I - IPP status code */
const char *message, /* I - status-message value */
int localize) /* I - Localize the message? */
{
_cups_globals_t *cg; /* Global data */
if (!message && errno)
{
message = strerror(errno);
localize = 0;
}
cg = _cupsGlobals();
cg->last_error = status;
if (cg->last_status_message)
{
_cupsStrFree(cg->last_status_message);
cg->last_status_message = NULL;
}
if (message)
{
if (localize)
{
/*
* Get the message catalog...
*/
if (!cg->lang_default)
cg->lang_default = cupsLangDefault();
cg->last_status_message = _cupsStrAlloc(_cupsLangString(cg->lang_default,
message));
}
else
cg->last_status_message = _cupsStrAlloc(message);
}
DEBUG_printf(("4_cupsSetError: last_error=%s, last_status_message=\"%s\"",
ippErrorString(cg->last_error), cg->last_status_message));
}
示例8: _cupsLangPuts
int /* O - Number of bytes written */
_cupsLangPuts(FILE *fp, /* I - File to write to */
const char *message) /* I - Message string to use */
{
int bytes; /* Number of bytes formatted */
char output[8192]; /* Message buffer */
_cups_globals_t *cg; /* Global data */
/*
* Range check...
*/
if (!fp || !message)
return (-1);
cg = _cupsGlobals();
if (!cg->lang_default)
cg->lang_default = cupsLangDefault();
/*
* Transcode to the destination charset...
*/
bytes = cupsUTF8ToCharset(output,
(cups_utf8_t *)_cupsLangString(cg->lang_default,
message),
sizeof(output) - 4, cg->lang_default->encoding);
bytes += cupsUTF8ToCharset(output + bytes, (cups_utf8_t *)"\n",
sizeof(output) - bytes,
cg->lang_default->encoding);
/*
* Write the string and return the number of bytes written...
*/
if (bytes > 0)
return ((int)fwrite(output, 1, bytes, fp));
else
return (bytes);
}
示例9: main
int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
int i; /* Looping var */
char *opt; /* Option pointer */
const char *username; /* Pointer to username */
const char *groupname; /* Pointer to group name */
int op; /* Operation (add, change, delete) */
const char *passwd; /* Password string */
FILE *infile, /* Input file */
*outfile; /* Output file */
char line[256], /* Line from file */
userline[17], /* User from line */
groupline[17], /* Group from line */
md5line[33], /* MD5-sum from line */
md5new[33]; /* New MD5 sum */
char passwdmd5[1024], /* passwd.md5 file */
passwdold[1024], /* passwd.old file */
passwdnew[1024]; /* passwd.tmp file */
char *newpass, /* new password */
*oldpass; /* old password */
int flag; /* Password check flags... */
int fd; /* Password file descriptor */
int error; /* Write error */
_cups_globals_t *cg = _cupsGlobals(); /* Global data */
cups_lang_t *lang; /* Language info */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Signal action */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET*/
_cupsSetLocale(argv);
lang = cupsLangDefault();
/*
* Check to see if stdin, stdout, and stderr are still open...
*/
if (fcntl(0, F_GETFD, &i) ||
fcntl(1, F_GETFD, &i) ||
fcntl(2, F_GETFD, &i))
{
/*
* No, return exit status 2 and don't try to send any output since
* someone is trying to bypass the security on the server.
*/
return (2);
}
/*
* Find the server directory...
*/
snprintf(passwdmd5, sizeof(passwdmd5), "%s/passwd.md5", cg->cups_serverroot);
snprintf(passwdold, sizeof(passwdold), "%s/passwd.old", cg->cups_serverroot);
snprintf(passwdnew, sizeof(passwdnew), "%s/passwd.new", cg->cups_serverroot);
/*
* Find the default system group...
*/
if (getgrnam(CUPS_DEFAULT_GROUP))
groupname = CUPS_DEFAULT_GROUP;
else
groupname = "unknown";
endgrent();
username = NULL;
op = CHANGE;
/*
* Parse command-line options...
*/
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-')
for (opt = argv[i] + 1; *opt; opt ++)
switch (*opt)
{
case 'a' : /* Add */
op = ADD;
break;
case 'x' : /* Delete */
op = DELETE;
break;
case 'g' : /* Group */
i ++;
if (i >= argc)
usage(stderr);
groupname = argv[i];
break;
case 'h' : /* Help */
usage(stdout);
break;
default : /* Bad option */
usage(stderr);
//.........这里部分代码省略.........
示例10: main
int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments (6 or 7) */
char *argv[]) /* I - Command-line arguments */
{
const char *device_uri; /* Device URI */
char scheme[255], /* Scheme in URI */
hostname[1024], /* Hostname */
username[255], /* Username info */
resource[1024], /* Resource info (printer name) */
*options, /* Pointer to options */
*name, /* Name of option */
*value, /* Value of option */
sep, /* Separator character */
*filename, /* File to print */
title[256]; /* Title string */
int port; /* Port number */
char portname[256]; /* Port name (string) */
http_addrlist_t *addrlist; /* List of addresses for printer */
int snmp_enabled = 1; /* Is SNMP enabled? */
int snmp_fd; /* SNMP socket */
int fd; /* Print file */
int status; /* Status of LPD job */
int mode; /* Print mode */
int banner; /* Print banner page? */
int format; /* Print format */
int order; /* Order of control/data files */
int reserve; /* Reserve priviledged port? */
int sanitize_title; /* Sanitize title string? */
int manual_copies, /* Do manual copies? */
timeout, /* Timeout */
contimeout, /* Connection timeout */
copies; /* Number of copies */
ssize_t bytes = 0; /* Initial bytes read */
char buffer[16384]; /* Initial print buffer */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
int num_jobopts; /* Number of job options */
cups_option_t *jobopts = NULL; /* Job options */
/*
* Make sure status messages are not buffered...
*/
setbuf(stderr, NULL);
/*
* Ignore SIGPIPE and catch SIGTERM signals...
*/
#ifdef HAVE_SIGSET
sigset(SIGPIPE, SIG_IGN);
sigset(SIGTERM, sigterm_handler);
#elif defined(HAVE_SIGACTION)
memset(&action, 0, sizeof(action));
action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &action, NULL);
sigemptyset(&action.sa_mask);
sigaddset(&action.sa_mask, SIGTERM);
action.sa_handler = sigterm_handler;
sigaction(SIGTERM, &action, NULL);
#else
signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, sigterm_handler);
#endif /* HAVE_SIGSET */
/*
* Check command-line...
*/
if (argc == 1)
{
printf("network lpd \"Unknown\" \"%s\"\n",
_cupsLangString(cupsLangDefault(), _("LPD/LPR Host or Printer")));
return (CUPS_BACKEND_OK);
}
else if (argc < 6 || argc > 7)
{
_cupsLangPrintf(stderr,
_("Usage: %s job-id user title copies options [file]"),
argv[0]);
return (CUPS_BACKEND_FAILED);
}
num_jobopts = cupsParseOptions(argv[5], 0, &jobopts);
/*
* Extract the hostname and printer name from the URI...
*/
while ((device_uri = cupsBackendDeviceURI(argv)) == NULL)
{
_cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer."));
sleep(10);
if (getenv("CLASS") != NULL)
return (CUPS_BACKEND_FAILED);
}
//.........这里部分代码省略.........
示例11: cups_cache_reload_async
static bool cups_cache_reload_async(int fd)
{
TALLOC_CTX *frame = talloc_stackframe();
struct pcap_cache *tmp_pcap_cache = NULL;
http_t *http = NULL; /* HTTP connection to server */
ipp_t *request = NULL, /* IPP Request */
*response = NULL; /* IPP Response */
ipp_attribute_t *attr; /* Current attribute */
cups_lang_t *language = NULL; /* Default language */
char *name, /* printer-name attribute */
*info; /* printer-info attribute */
static const char *requested[] =/* Requested attributes */
{
"printer-name",
"printer-info"
};
bool ret = False;
size_t size;
DEBUG(5, ("reloading cups printcap cache\n"));
/*
* Make sure we don't ask for passwords...
*/
cupsSetPasswordCB(cups_passwd_cb);
/*
* Try to connect to the server...
*/
if ((http = cups_connect(frame)) == NULL) {
goto out;
}
/*
* Build a CUPS_GET_PRINTERS request, which requires the following
* attributes:
*
* attributes-charset
* attributes-natural-language
* requested-attributes
*/
request = ippNew();
request->request.op.operation_id = CUPS_GET_PRINTERS;
request->request.op.request_id = 1;
language = cupsLangDefault();
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);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requested-attributes",
(sizeof(requested) / sizeof(requested[0])),
NULL, requested);
/*
* Do the request and get back a response...
*/
if ((response = cupsDoRequest(http, request, "/")) == NULL) {
DEBUG(0,("Unable to get printer list - %s\n",
ippErrorString(cupsLastError())));
goto out;
}
for (attr = response->attrs; attr != NULL;) {
/*
* Skip leading attributes until we hit a printer...
*/
while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
attr = attr->next;
if (attr == NULL)
break;
/*
* Pull the needed attributes from this printer...
*/
name = NULL;
info = NULL;
while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) {
if (strcmp(attr->name, "printer-name") == 0 &&
attr->value_tag == IPP_TAG_NAME) {
if (!pull_utf8_talloc(frame,
&name,
attr->values[0].string.text,
&size)) {
goto out;
}
}
//.........这里部分代码省略.........
示例12: iprint_queue_get
//.........这里部分代码省略.........
if ((http = httpConnect(iprint_server(), ippPort())) == NULL) {
DEBUG(0,("Unable to connect to iPrint server %s - %s\n",
iprint_server(), strerror(errno)));
goto out;
}
/*
* Generate the printer URI and the service URI that goes with it...
*/
slprintf(uri, sizeof(uri) - 1, "ipp://%s/ipp/%s", iprint_server(), printername);
slprintf(serviceUri, sizeof(serviceUri) - 1, "ipp://%s/ipp/", iprint_server());
/*
* For Linux iPrint servers from OES SP1 on, the iPrint server
* uses Unix time for job start times unless it detects the iPrint
* client in an http User-Agent header. (This was done to accomodate
* CUPS broken behavior. According to RFC 2911, section 4.3.14, job
* start times are supposed to be relative to how long the printer has
* been up.) Since libcups doesn't allow us to set that header before
* the request is sent, this ugly hack allows us to detect the server
* version and decide how to interpret the job time.
*/
if (iprint_get_server_version(http, serviceUri) >=
NOVELL_SERVER_VERSION_OES_SP1)
jobUseUnixTime = 1;
request = ippNew();
ippSetOperation(request, IPP_GET_PRINTER_ATTRIBUTES);
ippSetRequestId(request, 2);
language = cupsLangDefault();
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);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes",
(sizeof(pattrs) / sizeof(pattrs[0])),
NULL, pattrs);
/*
* Do the request and get back a response...
*/
slprintf(httpPath, sizeof(httpPath) - 1, "/ipp/%s", printername);
if ((response = cupsDoRequest(http, request, httpPath)) == NULL) {
DEBUG(0,("Unable to get printer status for %s - %s\n", printername,
ippErrorString(cupsLastError())));
*q = queue;
goto out;
}
if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
DEBUG(0,("Unable to get printer status for %s - %s\n", printername,
ippErrorString(ippGetStatusCode(response))));
*q = queue;
示例13: main
int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
int i; /* Looping var */
int errors = 0; /* Number of errors */
cups_lang_t *language; /* Message catalog */
cups_lang_t *language2; /* Message catalog */
struct lconv *loc; /* Locale data */
char buffer[1024]; /* String buffer */
double number; /* Number */
static const char * const tests[] = /* Test strings */
{
"1",
"-1",
"3",
"5.125"
};
_cupsSetLocale(argv);
if (argc == 1)
{
language = cupsLangDefault();
language2 = cupsLangDefault();
}
else
{
language = cupsLangGet(argv[1]);
language2 = cupsLangGet(argv[1]);
}
if (language != language2)
{
errors ++;
puts("**** ERROR: Language cache did not work! ****");
puts("First result from cupsLangGet:");
}
printf("Language = \"%s\"\n", language->language);
printf("Encoding = \"%s\"\n", _cupsEncodingName(language->encoding));
printf("No = \"%s\"\n", _cupsLangString(language, "No"));
printf("Yes = \"%s\"\n", _cupsLangString(language, "Yes"));
if (language != language2)
{
puts("Second result from cupsLangGet:");
printf("Language = \"%s\"\n", language2->language);
printf("Encoding = \"%s\"\n", _cupsEncodingName(language2->encoding));
printf("No = \"%s\"\n", _cupsLangString(language2, "No"));
printf("Yes = \"%s\"\n", _cupsLangString(language2, "Yes"));
}
loc = localeconv();
for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i ++)
{
number = _cupsStrScand(tests[i], NULL, loc);
printf("_cupsStrScand(\"%s\") number=%f\n", tests[i], number);
_cupsStrFormatd(buffer, buffer + sizeof(buffer), number, loc);
printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number, buffer);
if (strcmp(buffer, tests[i]))
{
errors ++;
puts("**** ERROR: Bad formatted number! ****");
}
}
return (errors > 0);
}
示例14: iprint_job_submit
static int iprint_job_submit(int snum, struct printjob *pjob,
enum printing_types printing_type,
char *lpq_cmd)
{
int ret = 1; /* Return value */
http_t *http = NULL; /* HTTP connection to server */
ipp_t *request = NULL, /* IPP Request */
*response = NULL; /* IPP Response */
ipp_attribute_t *attr; /* Current attribute */
cups_lang_t *language = NULL; /* Default language */
char uri[HTTP_MAX_URI]; /* printer-uri attribute */
DEBUG(5,("iprint_job_submit(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
/*
* Make sure we don't ask for passwords...
*/
cupsSetPasswordCB(iprint_passwd_cb);
/*
* Try to connect to the server...
*/
if ((http = httpConnect(iprint_server(), ippPort())) == NULL) {
DEBUG(0,("Unable to connect to iPrint server %s - %s\n",
iprint_server(), strerror(errno)));
goto out;
}
/*
* Build an IPP_PRINT_JOB request, which requires the following
* attributes:
*
* attributes-charset
* attributes-natural-language
* printer-uri
* requesting-user-name
* [document-data]
*/
request = ippNew();
ippSetOperation(request, IPP_PRINT_JOB);
ippSetRequestId(request, 1);
language = cupsLangDefault();
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);
slprintf(uri, sizeof(uri) - 1, "ipp://%s/ipp/%s", iprint_server(),
lp_printername(snum));
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
NULL, pjob->user);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"job-originating-host-name", NULL,
pjob->clientmachine);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL,
pjob->jobname);
/*
* Do the request and get back a response...
*/
slprintf(uri, sizeof(uri) - 1, "/ipp/%s", lp_printername(snum));
if ((response = cupsDoFileRequest(http, request, uri, pjob->filename)) != NULL) {
if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
DEBUG(0,("Unable to print file to %s - %s\n",
lp_printername(snum),
ippErrorString(cupsLastError())));
} else {
ret = 0;
}
} else {
DEBUG(0,("Unable to print file to `%s' - %s\n",
lp_printername(snum),
ippErrorString(cupsLastError())));
}
if ( ret == 0 )
unlink(pjob->filename);
/* else print_job_end will do it for us */
if ( ret == 0 ) {
attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER);
if (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_JOB)
{
pjob->sysjob = ippGetInteger(attr, 0);
//.........这里部分代码省略.........
示例15: exec_filters
static int /* O - 0 on success, 1 on error */
exec_filters(mime_type_t *srctype, /* I - Source type */
cups_array_t *filters, /* I - Array of filters to run */
const char *infile, /* I - File to filter */
const char *outfile, /* I - File to create */
const char *ppdfile, /* I - PPD file, if any */
const char *printer, /* I - Printer name */
const char *user, /* I - Username */
const char *title, /* I - Job title */
int num_options, /* I - Number of filter options */
cups_option_t *options) /* I - Filter options */
{
int i; /* Looping var */
const char *argv[8], /* Command-line arguments */
*envp[17], /* Environment variables */
*temp; /* Temporary string */
char *optstr, /* Filter options */
content_type[1024], /* CONTENT_TYPE */
cups_datadir[1024], /* CUPS_DATADIR */
cups_fontpath[1024], /* CUPS_FONTPATH */
cups_serverbin[1024], /* CUPS_SERVERBIN */
cups_serverroot[1024], /* CUPS_SERVERROOT */
final_content_type[1024] = "",
/* FINAL_CONTENT_TYPE */
lang[1024], /* LANG */
path[1024], /* PATH */
ppd[1024], /* PPD */
printer_info[255], /* PRINTER_INFO env variable */
printer_location[255], /* PRINTER_LOCATION env variable */
printer_name[255], /* PRINTER env variable */
rip_max_cache[1024], /* RIP_MAX_CACHE */
userenv[1024], /* USER */
program[1024]; /* Program to run */
mime_filter_t *filter, /* Current filter */
*next; /* Next filter */
int current, /* Current filter */
filterfds[2][2], /* Pipes for filters */
pid, /* Process ID of filter */
status, /* Exit status */
retval; /* Return value */
cups_array_t *pids; /* Executed filters array */
mime_filter_t key; /* Search key for filters */
cups_lang_t *language; /* Current language */
cups_dest_t *dest; /* Destination information */
/*
* Figure out the final content type...
*/
for (filter = (mime_filter_t *)cupsArrayLast(filters);
filter && filter->dst;
filter = (mime_filter_t *)cupsArrayPrev(filters))
if (strcmp(filter->dst->super, "printer"))
break;
if (filter && filter->dst)
{
const char *ptr; /* Pointer in type name */
if ((ptr = strchr(filter->dst->type, '/')) != NULL)
snprintf(final_content_type, sizeof(final_content_type),
"FINAL_CONTENT_TYPE=%s", ptr + 1);
else
snprintf(final_content_type, sizeof(final_content_type),
"FINAL_CONTENT_TYPE=%s/%s", filter->dst->super,
filter->dst->type);
}
/*
* Remove NULL ("-") filters...
*/
for (filter = (mime_filter_t *)cupsArrayFirst(filters);
filter;
filter = (mime_filter_t *)cupsArrayNext(filters))
if (!strcmp(filter->filter, "-"))
cupsArrayRemove(filters, filter);
/*
* Setup the filter environment and command-line...
*/
optstr = escape_options(num_options, options);
snprintf(content_type, sizeof(content_type), "CONTENT_TYPE=%s/%s",
srctype->super, srctype->type);
snprintf(cups_datadir, sizeof(cups_datadir), "CUPS_DATADIR=%s", DataDir);
snprintf(cups_fontpath, sizeof(cups_fontpath), "CUPS_FONTPATH=%s", FontPath);
snprintf(cups_serverbin, sizeof(cups_serverbin), "CUPS_SERVERBIN=%s",
ServerBin);
snprintf(cups_serverroot, sizeof(cups_serverroot), "CUPS_SERVERROOT=%s",
ServerRoot);
language = cupsLangDefault();
snprintf(lang, sizeof(lang), "LANG=%s.UTF8", language->language);
snprintf(path, sizeof(path), "PATH=%s", Path);
if (ppdfile)
snprintf(ppd, sizeof(ppd), "PPD=%s", ppdfile);
else if ((temp = getenv("PPD")) != NULL)
snprintf(ppd, sizeof(ppd), "PPD=%s", temp);
//.........这里部分代码省略.........