MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsGetNamedDest

Function cupsGetNamedDest

cups/dest.c:1743–1922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1741 */
1742
1743cups_dest_t * /* O - Destination or @code NULL@ */
1744cupsGetNamedDest(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
1745 const char *name, /* I - Destination name or @code NULL@ for the default destination */
1746 const char *instance) /* I - Instance name or @code NULL@ */
1747{
1748 const char *dest_name; /* Working destination name */
1749 cups_dest_t *dest; /* Destination */
1750 char filename[1024], /* Path to lpoptions */
1751 defname[256]; /* Default printer name */
1752 int set_as_default = 0; /* Set returned destination as default */
1753 ipp_op_t op = IPP_OP_GET_PRINTER_ATTRIBUTES;
1754 /* IPP operation to get server ops */
1755 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
1756
1757
1758 DEBUG_printf(("cupsGetNamedDest(http=%p, name=\"%s\", instance=\"%s\")", (void *)http, name, instance));
1759
1760 /*
1761 * If "name" is NULL, find the default destination...
1762 */
1763
1764 dest_name = name;
1765
1766 if (!dest_name)
1767 {
1768 set_as_default = 1;
1769 dest_name = _cupsUserDefault(defname, sizeof(defname));
1770
1771 if (dest_name)
1772 {
1773 char *ptr; /* Temporary pointer... */
1774
1775 if ((ptr = strchr(defname, '/')) != NULL)
1776 {
1777 *ptr++ = '\0';
1778 instance = ptr;
1779 }
1780 else
1781 instance = NULL;
1782 }
1783#if _WIN32
1784 else if (cg->home)
1785#else
1786 else if (cg->home && getuid() != 0)
1787#endif
1788 {
1789 /*
1790 * No default in the environment, try the user's lpoptions files...
1791 */
1792
1793#if _WIN32
1794 snprintf(filename, sizeof(filename), "%s/AppData/Local/cups/lpoptions", cg->home);
1795#else
1796 snprintf(filename, sizeof(filename), "%s/.cups/lpoptions", cg->home);
1797#endif // _WIN32
1798
1799 dest_name = cups_get_default(filename, defname, sizeof(defname), &instance);
1800

Callers 10

exec_filtersFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
check_destFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
cupsCreateJobFunction · 0.85

Calls 8

_cupsGlobalsFunction · 0.85
_cupsUserDefaultFunction · 0.85
cups_get_defaultFunction · 0.85
_cupsGetDestsFunction · 0.85
cupsEnumDestsFunction · 0.85
_cupsSetErrorFunction · 0.85
_cupsStrAllocFunction · 0.85
cups_get_destsFunction · 0.85

Tested by 2

mainFunction · 0.68
mainFunction · 0.68