本文整理汇总了C++中cupsArrayFind函数的典型用法代码示例。如果您正苦于以下问题:C++ cupsArrayFind函数的具体用法?C++ cupsArrayFind怎么用?C++ cupsArrayFind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cupsArrayFind函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cupsLocalizeDestValue
const char * /* O - Localized string */
cupsLocalizeDestValue(
http_t *http, /* I - Connection to destination */
cups_dest_t *dest, /* I - Destination */
cups_dinfo_t *dinfo, /* I - Destination information */
const char *option, /* I - Option to localize */
const char *value) /* I - Value to localize */
{
_cups_message_t key, /* Search key */
*match; /* Matching entry */
char pair[256]; /* option.value pair */
if (!http || !dest || !dinfo)
return (value);
if (!dinfo->localizations)
cups_create_localizations(http, dinfo);
if (cupsArrayCount(dinfo->localizations) == 0)
return (value);
snprintf(pair, sizeof(pair), "%s.%s", option, value);
key.id = pair;
if ((match = (_cups_message_t *)cupsArrayFind(dinfo->localizations,
&key)) != NULL)
return (match->str);
else
return (value);
}
示例2: cupsLocalizeDestOption
const char * /* O - Localized string */
cupsLocalizeDestOption(
http_t *http, /* I - Connection to destination */
cups_dest_t *dest, /* I - Destination */
cups_dinfo_t *dinfo, /* I - Destination information */
const char *option) /* I - Option to localize */
{
_cups_message_t key, /* Search key */
*match; /* Matching entry */
if (!http || !dest || !dinfo)
return (option);
if (!dinfo->localizations)
cups_create_localizations(http, dinfo);
if (cupsArrayCount(dinfo->localizations) == 0)
return (option);
key.id = (char *)option;
if ((match = (_cups_message_t *)cupsArrayFind(dinfo->localizations,
&key)) != NULL)
return (match->str);
else
return (option);
}
示例3: mimeType
mime_type_t * /* O - Matching file type definition */
mimeType(mime_t *mime, /* I - MIME database */
const char *super, /* I - Super-type name */
const char *type) /* I - Type name */
{
mime_type_t key, /* MIME type search key */
*mt; /* Matching type */
DEBUG_printf(("mimeType(mime=%p, super=\"%s\", type=\"%s\")", mime, super,
type));
/*
* Range check input...
*/
if (!mime || !super || !type)
{
DEBUG_puts("1mimeType: Returning NULL.");
return (NULL);
}
/*
* Lookup the type in the array...
*/
strlcpy(key.super, super, sizeof(key.super));
strlcpy(key.type, type, sizeof(key.type));
mt = (mime_type_t *)cupsArrayFind(mime->types, &key);
DEBUG_printf(("1mimeType: Returning %p.", mt));
return (mt);
}
示例4: cupsdFinishProcess
const char * /* O - Process name */
cupsdFinishProcess(int pid, /* I - Process ID */
char *name, /* I - Name buffer */
size_t namelen, /* I - Size of name buffer */
int *job_id) /* O - Job ID pointer or NULL */
{
cupsd_proc_t key, /* Search key */
*proc; /* Matching process */
key.pid = pid;
if ((proc = (cupsd_proc_t *)cupsArrayFind(process_array, &key)) != NULL)
{
if (job_id)
*job_id = proc->job_id;
strlcpy(name, proc->name, namelen);
cupsArrayRemove(process_array, proc);
free(proc);
}
else
{
if (job_id)
*job_id = 0;
strlcpy(name, "unknown", namelen);
}
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFinishProcess(pid=%d, name=%p, namelen=" CUPS_LLFMT ", job_id=%p(%d)) = \"%s\"", pid, name, CUPS_LLCAST namelen, job_id, job_id ? *job_id : 0, name);
return (name);
}
示例5: serverFindPrinter
server_printer_t * /* O - Printer or NULL */
serverFindPrinter(const char *resource) /* I - Resource path */
{
server_printer_t key, /* Search key */
*match = NULL; /* Matching printer */
_cupsMutexLock(&printer_mutex);
if (cupsArrayCount(Printers) == 1 || !strcmp(resource, "/ipp/print"))
{
/*
* Just use the first printer...
*/
match = cupsArrayFirst(Printers);
if (strcmp(match->resource, resource) && strcmp(resource, "/ipp/print"))
match = NULL;
}
else
{
key.resource = (char *)resource;
match = (server_printer_t *)cupsArrayFind(Printers, &key);
}
_cupsMutexUnlock(&printer_mutex);
return (match);
}
示例6: helpFindNode
help_node_t * /* O - Node pointer or NULL */
helpFindNode(help_index_t *hi, /* I - Index */
const char *filename, /* I - Filename */
const char *anchor) /* I - Anchor */
{
help_node_t key; /* Search key */
DEBUG_printf(("helpFindNode(hi=%p, filename=\"%s\", anchor=\"%s\")",
hi, filename, anchor));
/*
* Range check input...
*/
if (!hi || !filename)
return (NULL);
/*
* Initialize the search key...
*/
key.filename = (char *)filename;
key.anchor = (char *)anchor;
/*
* Return any match...
*/
return ((help_node_t *)cupsArrayFind(hi->nodes, &key));
}
示例7: cupsdFindSubscription
cupsd_subscription_t * /* O - Subscription object */
cupsdFindSubscription(int id) /* I - Subscription ID */
{
cupsd_subscription_t sub; /* Subscription template */
sub.id = id;
return ((cupsd_subscription_t *)cupsArrayFind(Subscriptions, &sub));
}
示例8: cupsdFindPolicyOp
cupsd_location_t * /* O - Policy operation */
cupsdFindPolicyOp(cupsd_policy_t *p, /* I - Policy */
ipp_op_t op) /* I - IPP operation */
{
cupsd_location_t key, /* Search key... */
*po; /* Current policy operation */
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFindPolicyOp(p=%p, op=%x(%s))",
p, op, ippOpString(op));
/*
* Range check...
*/
if (!p)
return (NULL);
/*
* Check the operation against the available policies...
*/
key.op = op;
if ((po = (cupsd_location_t *)cupsArrayFind(p->ops, &key)) != NULL)
{
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdFindPolicyOp: Found exact match...");
return (po);
}
key.op = IPP_ANY_OPERATION;
if ((po = (cupsd_location_t *)cupsArrayFind(p->ops, &key)) != NULL)
{
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdFindPolicyOp: Found wildcard match...");
return (po);
}
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFindPolicyOp: No match found!");
return (NULL);
}
示例9: ppdFindCustomParam
ppd_cparam_t * /* O - Custom parameter or NULL */
ppdFindCustomParam(ppd_coption_t *opt, /* I - Custom option */
const char *name) /* I - Parameter name */
{
ppd_cparam_t key; /* Custom parameter search key */
if (!opt)
return (NULL);
strlcpy(key.name, name, sizeof(key.name));
return ((ppd_cparam_t *)cupsArrayFind(opt->params, &key));
}
示例10: ppdFindCustomOption
ppd_coption_t * /* O - Custom option or NULL */
ppdFindCustomOption(ppd_file_t *ppd, /* I - PPD file */
const char *keyword)/* I - Custom option name */
{
ppd_coption_t key; /* Custom option search key */
if (!ppd)
return (NULL);
strlcpy(key.keyword, keyword, sizeof(key.keyword));
return ((ppd_coption_t *)cupsArrayFind(ppd->coptions, &key));
}
示例11: help_add_word
static help_word_t * /* O - New word */
help_add_word(help_node_t *n, /* I - Node */
const char *text) /* I - Word text */
{
help_word_t *w, /* New word */
key; /* Search key */
DEBUG_printf(("2help_add_word(n=%p, text=\"%s\")", n, text));
/*
* Create the words array as needed...
*/
if (!n->words)
n->words = cupsArrayNew((cups_array_func_t)help_sort_words, NULL);
/*
* See if the word is already added...
*/
key.text = (char *)text;
if ((w = (help_word_t *)cupsArrayFind(n->words, &key)) == NULL)
{
/*
* Create a new word...
*/
if ((w = calloc(1, sizeof(help_word_t))) == NULL)
return (NULL);
if ((w->text = strdup(text)) == NULL)
{
free(w);
return (NULL);
}
cupsArrayAdd(n->words, w);
}
/*
* Bump the counter for this word and return it...
*/
w->count ++;
return (w);
}
示例12: ppdFindAttr
ppd_attr_t * /* O - Attribute or @code [email protected] if not found */
ppdFindAttr(ppd_file_t *ppd, /* I - PPD file data */
const char *name, /* I - Attribute name */
const char *spec) /* I - Specifier string or @code [email protected] */
{
ppd_attr_t key, /* Search key */
*attr; /* Current attribute */
DEBUG_printf(("2ppdFindAttr(ppd=%p, name=\"%s\", spec=\"%s\")", ppd, name,
spec));
/*
* Range check input...
*/
if (!ppd || !name || ppd->num_attrs == 0)
return (NULL);
/*
* Search for a matching attribute...
*/
memset(&key, 0, sizeof(key));
strlcpy(key.name, name, sizeof(key.name));
/*
* Return the first matching attribute, if any...
*/
if ((attr = (ppd_attr_t *)cupsArrayFind(ppd->sorted_attrs, &key)) != NULL)
{
if (spec)
{
/*
* Loop until we find the first matching attribute for "spec"...
*/
while (attr && _cups_strcasecmp(spec, attr->spec))
{
if ((attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs)) != NULL &&
_cups_strcasecmp(attr->name, name))
attr = NULL;
}
}
}
return (attr);
}
示例13: ppdFindOption
ppd_option_t * /* O - Pointer to option or @code [email protected] */
ppdFindOption(ppd_file_t *ppd, /* I - PPD file data */
const char *option) /* I - Option/Keyword name */
{
/*
* Range check input...
*/
if (!ppd || !option)
return (NULL);
if (ppd->options)
{
/*
* Search in the array...
*/
ppd_option_t key; /* Option search key */
strlcpy(key.keyword, option, sizeof(key.keyword));
return ((ppd_option_t *)cupsArrayFind(ppd->options, &key));
}
else
{
/*
* Search in each group...
*/
int i, j; /* Looping vars */
ppd_group_t *group; /* Current group */
ppd_option_t *optptr; /* Current option */
for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++)
for (j = group->num_options, optptr = group->options;
j > 0;
j --, optptr ++)
if (!_cups_strcasecmp(optptr->keyword, option))
return (optptr);
return (NULL);
}
}
示例14: serverFindJob
server_job_t * /* O - Job or NULL */
serverFindJob(
server_client_t *client, /* I - Client */
int job_id) /* I - Job ID to find or 0 to lookup */
{
ipp_attribute_t *attr; /* job-id or job-uri attribute */
server_job_t key, /* Job search key */
*job; /* Matching job, if any */
if (job_id > 0)
{
key.id = job_id;
}
else if ((attr = ippFindAttribute(client->request, "job-uri", IPP_TAG_URI)) != NULL)
{
const char *uri = ippGetString(attr, 0, NULL);
/* job-uri value */
char scheme[32], /* URI scheme */
userpass[256], /* username:password */
host[256], /* Hostname/IP */
resource[1024]; /* Resource path */
int port; /* Port number */
if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) >= HTTP_URI_STATUS_OK &&
!strncmp(resource, client->printer->resource, client->printer->resourcelen) &&
resource[client->printer->resourcelen] == '/')
key.id = atoi(resource + client->printer->resourcelen + 1);
else
return (NULL);
}
else if ((attr = ippFindAttribute(client->request, "job-id", IPP_TAG_INTEGER)) != NULL)
{
key.id = ippGetInteger(attr, 0);
}
_cupsRWLockRead(&(client->printer->rwlock));
job = (server_job_t *)cupsArrayFind(client->printer->jobs, &key);
_cupsRWUnlock(&(client->printer->rwlock));
return (job);
}
示例15: _pwgMediaForLegacy
_pwg_media_t * /* O - Matching size or NULL */
_pwgMediaForLegacy(
const char *legacy) /* I - Legacy size name */
{
_pwg_media_t key; /* Search key */
_cups_globals_t *cg = _cupsGlobals(); /* Global data */
/*
* Range check input...
*/
if (!legacy)
return (NULL);
/*
* Build the lookup table for PWG names as needed...
*/
if (!cg->leg_size_lut)
{
int i; /* Looping var */
_pwg_media_t *size; /* Current size */
cg->leg_size_lut = cupsArrayNew((cups_array_func_t)pwg_compare_legacy,
NULL);
for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
size = (_pwg_media_t *)cups_pwg_media;
i > 0;
i --, size ++)
if (size->legacy)
cupsArrayAdd(cg->leg_size_lut, size);
}
/*
* Lookup the name...
*/
key.legacy = legacy;
return ((_pwg_media_t *)cupsArrayFind(cg->leg_size_lut, &key));
}