本文整理汇总了C++中cupsLangDefault函数的典型用法代码示例。如果您正苦于以下问题:C++ cupsLangDefault函数的具体用法?C++ cupsLangDefault怎么用?C++ cupsLangDefault使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cupsLangDefault函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:AndychenCL,项目名称:cups,代码行数:25,代码来源:string.c
示例2: cups_get_language
const char * cups_get_language (void)
{
cups_lang_t *language;
language = cupsLangDefault(); /* needed for conversion */
return cupsLangEncoding(language);
}
开发者ID:BrianHoldsworth,项目名称:netatalk2,代码行数:7,代码来源:print_cups.c
示例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);
}
开发者ID:jschwender,项目名称:cups,代码行数:56,代码来源:cupsaddsmb.c
示例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);
}
开发者ID:jianglei12138,项目名称:cups,代码行数:53,代码来源:langprintf.c
示例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;
}
开发者ID:Magister,项目名称:bjcups-2.50,代码行数:23,代码来源:bjcupsmon_cups.c
示例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);
}
开发者ID:CODECOMMUNITY,项目名称:cups,代码行数:46,代码来源:ppd-localize.c
示例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));
}
开发者ID:jelmer,项目名称:cups,代码行数:45,代码来源:request.c
示例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);
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:42,代码来源:langprintf.c
示例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);
//.........这里部分代码省略.........
开发者ID:ystk,项目名称:debian-cups,代码行数:101,代码来源:lppasswd.c
示例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);
}
//.........这里部分代码省略.........
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:101,代码来源:lpd.c
示例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;
}
}
//.........这里部分代码省略.........
开发者ID:gojdic,项目名称:samba,代码行数:101,代码来源:print_cups.c
示例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;
开发者ID:arthur-zhang,项目名称:android_samba,代码行数:67,代码来源:print_iprint.c
示例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);
}
开发者ID:AnotherView,项目名称:cups,代码行数:77,代码来源:testlang.c
示例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);
//.........这里部分代码省略.........
开发者ID:arthur-zhang,项目名称:android_samba,代码行数:101,代码来源:print_iprint.c
示例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);
//.........这里部分代码省略.........
开发者ID:Cacauu,项目名称:cups,代码行数:101,代码来源:cupsfilter.c
示例16: iprint_cache_reload
bool iprint_cache_reload(void)
{
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 */
int i;
bool ret = False;
DEBUG(5, ("reloading iprint printcap cache\n"));
/*
* 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 a OPERATION_NOVELL_LIST_PRINTERS request, which requires the following attributes:
*
* attributes-charset
* attributes-natural-language
*/
request = ippNew();
ippSetOperation(request, (ipp_op_t)OPERATION_NOVELL_LIST_PRINTERS);
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);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"ipp-server", NULL, "ippSrvr");
/*
* Do the request and get back a response...
*/
if ((response = cupsDoRequest(http, request, "/ipp")) == NULL) {
DEBUG(0,("Unable to get printer list - %s\n",
ippErrorString(cupsLastError())));
goto out;
}
for (attr = ippFirstAttribute(response); attr != NULL;) {
/*
* Skip leading attributes until we hit a printer...
*/
while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_PRINTER)
attr = ippNextAttribute(response);
if (attr == NULL)
break;
/*
* Pull the needed attributes from this printer...
*/
while (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_PRINTER)
{
if (strcmp(ippGetName(attr), "printer-name") == 0 &&
(ippGetValueTag(attr) == IPP_TAG_URI ||
ippGetValueTag(attr) == IPP_TAG_NAME ||
ippGetValueTag(attr) == IPP_TAG_TEXT ||
ippGetValueTag(attr) == IPP_TAG_NAMELANG ||
ippGetValueTag(attr) == IPP_TAG_TEXTLANG))
{
for (i = 0; i<ippGetCount(attr); i++)
{
char *url = ippGetString(attr, i, NULL);
if (!url || !strlen(url))
continue;
iprint_cache_add_printer(http, i+2, url);
}
}
attr = ippNextAttribute(response);
}
}
ret = True;
out:
//.........这里部分代码省略.........
开发者ID:arthur-zhang,项目名称:android_samba,代码行数:101,代码来源:print_iprint.c
示例17: gtk_cups_request_new_with_username
GtkCupsRequest *
gtk_cups_request_new_with_username (http_t *connection,
GtkCupsRequestType req_type,
gint operation_id,
GIOChannel *data_io,
const char *server,
const char *resource,
const char *username)
{
GtkCupsRequest *request;
cups_lang_t *language;
request = g_new0 (GtkCupsRequest, 1);
request->result = g_new0 (GtkCupsResult, 1);
request->result->error_msg = NULL;
request->result->ipp_response = NULL;
request->result->is_error = FALSE;
request->result->is_ipp_response = FALSE;
request->type = req_type;
request->state = GTK_CUPS_REQUEST_START;
request->password_state = GTK_CUPS_PASSWORD_NONE;
if (server)
request->server = g_strdup (server);
else
request->server = g_strdup (cupsServer ());
if (resource)
request->resource = g_strdup (resource);
else
request->resource = g_strdup ("/");
if (connection != NULL)
{
request->http = connection;
request->own_http = FALSE;
}
else
{
request->http = NULL;
request->http = httpConnectEncrypt (request->server,
ippPort (),
cupsEncryption ());
if (request->http)
httpBlocking (request->http, 0);
request->own_http = TRUE;
}
request->last_status = HTTP_CONTINUE;
request->attempts = 0;
request->data_io = data_io;
request->ipp_request = ippNew ();
ippSetOperation (request->ipp_request, operation_id);
ippSetRequestId (request->ipp_request, 1);
language = cupsLangDefault ();
gtk_cups_request_ipp_add_string (request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
"attributes-charset",
NULL, "utf-8");
gtk_cups_request_ipp_add_string (request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
"attributes-natural-language",
NULL, language->language);
if (username != NULL)
gtk_cups_request_ipp_add_string (request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name",
NULL, username);
else
gtk_cups_request_ipp_add_string (request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name",
NULL, cupsUser ());
request->auth_info_required = NULL;
request->auth_info = NULL;
request->need_auth_info = FALSE;
cupsLangFree (language);
return request;
}
开发者ID:Distrotech,项目名称:gtk,代码行数:91,代码来源:gtkcupsutils.c
示例18: get_cupsd_conf
static http_status_t /* O - Status of request */
get_cupsd_conf(
http_t *http, /* I - Connection to server */
_cups_globals_t *cg, /* I - Global data */
time_t last_update, /* I - Last update time for file */
char *name, /* I - Filename buffer */
size_t namesize, /* I - Size of filename buffer */
int *remote) /* O - Remote file? */
{
int fd; /* Temporary file descriptor */
#ifndef _WIN32
struct stat info; /* cupsd.conf file information */
#endif /* _WIN32 */
http_status_t status; /* Status of getting cupsd.conf */
char host[HTTP_MAX_HOST]; /* Hostname for connection */
/*
* See if we already have the data we need...
*/
httpGetHostname(http, host, sizeof(host));
if (_cups_strcasecmp(cg->cupsd_hostname, host))
invalidate_cupsd_cache(cg);
snprintf(name, namesize, "%s/cupsd.conf", cg->cups_serverroot);
*remote = 0;
#ifndef _WIN32
if (!_cups_strcasecmp(host, "localhost") && !access(name, R_OK))
{
/*
* Read the local file rather than using HTTP...
*/
if (stat(name, &info))
{
char message[1024]; /* Message string */
snprintf(message, sizeof(message),
_cupsLangString(cupsLangDefault(), _("stat of %s failed: %s")),
name, strerror(errno));
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, message, 0);
*name = '\0';
return (HTTP_STATUS_SERVER_ERROR);
}
else if (last_update && info.st_mtime <= last_update)
status = HTTP_STATUS_NOT_MODIFIED;
else
status = HTTP_STATUS_OK;
}
else
#endif /* !_WIN32 */
{
/*
* Read cupsd.conf via a HTTP GET request...
*/
if ((fd = cupsTempFd(name, (int)namesize)) < 0)
{
*name = '\0';
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, NULL, 0);
invalidate_cupsd_cache(cg);
return (HTTP_STATUS_SERVER_ERROR);
}
*remote = 1;
httpClearFields(http);
if (last_update)
httpSetField(http, HTTP_FIELD_IF_MODIFIED_SINCE,
httpGetDateString(last_update));
status = cupsGetFd(http, "/admin/conf/cupsd.conf", fd);
close(fd);
if (status != HTTP_STATUS_OK)
{
unlink(name);
*name = '\0';
}
}
return (status);
}
开发者ID:zdohnal,项目名称:cups,代码行数:94,代码来源:adminutil.c
示例19: cupsAdminGetServerSettings
//.........这里部分代码省略.........
http = cg->http;
}
if (!http || !num_settings || !settings)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
if (num_settings)
*num_settings = 0;
if (settings)
*settings = NULL;
return (0);
}
*num_settings = 0;
*settings = NULL;
/*
* Get the cupsd.conf file...
*/
if ((status = get_cupsd_conf(http, cg, cg->cupsd_update, cupsdconf,
sizeof(cupsdconf), &remote)) == HTTP_STATUS_OK)
{
if ((cupsd = cupsFileOpen(cupsdconf, "r")) == NULL)
{
char message[1024]; /* Message string */
snprintf(message, sizeof(message),
_cupsLangString(cupsLangDefault(), _("Open of %s failed: %s")),
cupsdconf, strerror(errno));
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, message, 0);
}
}
else
cupsd = NULL;
if (cupsd)
{
/*
* Read the file, keeping track of what settings are enabled...
*/
int remote_access = 0, /* Remote access allowed? */
remote_admin = 0, /* Remote administration allowed? */
remote_any = 0, /* Remote access from anywhere allowed? */
browsing = 1, /* Browsing enabled? */
cancel_policy = 1, /* Cancel-job policy set? */
debug_logging = 0; /* LogLevel debug set? */
int linenum = 0, /* Line number in file */
in_location = 0, /* In a location section? */
in_policy = 0, /* In a policy section? */
in_cancel_job = 0, /* In a cancel-job section? */
in_admin_location = 0; /* In the /admin location? */
invalidate_cupsd_cache(cg);
cg->cupsd_update = time(NULL);
httpGetHostname(http, cg->cupsd_hostname, sizeof(cg->cupsd_hostname));
wh
|
请发表评论