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

Function exec_program

tools/ippfind.c:1858–2108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1856 */
1857
1858static int /* O - 1 if program terminated
1859 successfully, 0 otherwise. */
1860exec_program(ippfind_srv_t *service, /* I - Service */
1861 int num_args, /* I - Number of command-line args */
1862 char **args) /* I - Command-line arguments */
1863{
1864 char **myargv, /* Command-line arguments */
1865 **myenvp, /* Environment variables */
1866 *ptr, /* Pointer into variable */
1867 domain[1024], /* IPPFIND_SERVICE_DOMAIN */
1868 hostname[1024], /* IPPFIND_SERVICE_HOSTNAME */
1869 name[256], /* IPPFIND_SERVICE_NAME */
1870 port[32], /* IPPFIND_SERVICE_PORT */
1871 regtype[256], /* IPPFIND_SERVICE_REGTYPE */
1872 scheme[128], /* IPPFIND_SERVICE_SCHEME */
1873 uri[1024], /* IPPFIND_SERVICE_URI */
1874 txt[100][256]; /* IPPFIND_TXT_foo */
1875 int i, /* Looping var */
1876 myenvc, /* Number of environment variables */
1877 status; /* Exit status of program */
1878#ifndef _WIN32
1879 char program[1024]; /* Program to execute */
1880 int pid; /* Process ID */
1881#endif /* !_WIN32 */
1882
1883
1884 /*
1885 * Environment variables...
1886 */
1887
1888 snprintf(domain, sizeof(domain), "IPPFIND_SERVICE_DOMAIN=%s",
1889 service->domain);
1890 snprintf(hostname, sizeof(hostname), "IPPFIND_SERVICE_HOSTNAME=%s",
1891 service->host);
1892 snprintf(name, sizeof(name), "IPPFIND_SERVICE_NAME=%s", service->name);
1893 snprintf(port, sizeof(port), "IPPFIND_SERVICE_PORT=%d", service->port);
1894 snprintf(regtype, sizeof(regtype), "IPPFIND_SERVICE_REGTYPE=%s",
1895 service->regtype);
1896 snprintf(scheme, sizeof(scheme), "IPPFIND_SERVICE_SCHEME=%s",
1897 !strncmp(service->regtype, "_http._tcp", 10) ? "http" :
1898 !strncmp(service->regtype, "_https._tcp", 11) ? "https" :
1899 !strncmp(service->regtype, "_ipp._tcp", 9) ? "ipp" :
1900 !strncmp(service->regtype, "_ipps._tcp", 10) ? "ipps" : "lpd");
1901 snprintf(uri, sizeof(uri), "IPPFIND_SERVICE_URI=%s", service->uri);
1902 for (i = 0; i < service->num_txt && i < 100; i ++)
1903 {
1904 snprintf(txt[i], sizeof(txt[i]), "IPPFIND_TXT_%s=%s", service->txt[i].name,
1905 service->txt[i].value);
1906 for (ptr = txt[i] + 12; *ptr && *ptr != '='; ptr ++)
1907 *ptr = (char)_cups_toupper(*ptr);
1908 }
1909
1910 for (i = 0, myenvc = 7 + service->num_txt; environ[i]; i ++)
1911 if (strncmp(environ[i], "IPPFIND_", 8))
1912 myenvc ++;
1913
1914 if ((myenvp = calloc((size_t)(myenvc + 1), sizeof(char *))) == NULL)
1915 {

Callers 1

eval_exprFunction · 0.85

Calls 5

_cups_toupperFunction · 0.85
_cupsLangPutsFunction · 0.85
cupsGetOptionFunction · 0.85
_cupsLangPrintfFunction · 0.85
cupsFileFindFunction · 0.85

Tested by

no test coverage detected