* cupsdUpdateLDAPBrowse() - Scan for new printers via LDAP...
* cupsdUpdateSLPBrowse() - Get browsing information via SLP.
* dequote() - Remote quotes from a string.
+ * get_hostconfig() - Get an /etc/hostconfig service setting.
* is_local_queue() - Determine whether the URI points at a local
* queue.
* process_browse_data() - Process new browse data.
*/
static char *dequote(char *d, const char *s, int dlen);
+#ifdef __APPLE__
+static int get_hostconfig(const char *name);
+#endif /* __APPLE__ */
static int is_local_queue(const char *uri, char *host, int hostlen,
char *resource, int resourcelen);
static void process_browse_data(const char *uri, const char *host,
}
+#ifdef __APPLE__
+/*
+ * 'get_hostconfig()' - Get an /etc/hostconfig service setting.
+ */
+
+static int /* O - 1 for YES or AUTOMATIC, 0 for NO */
+get_hostconfig(const char *name) /* I - Name of service */
+{
+ cups_file_t *fp; /* Hostconfig file */
+ char line[1024], /* Line from file */
+ *ptr; /* Pointer to value */
+ int state = 1; /* State of service */
+
+
+ /*
+ * Try opening the /etc/hostconfig file; if we can't open it, assume that
+ * the service is enabled/auto.
+ */
+
+ if ((fp = cupsFileOpen("/etc/hostconfig", "r")) != NULL)
+ {
+ /*
+ * Read lines from the file until we find the service...
+ */
+
+ while (cupsFileGets(fp, line, sizeof(line)))
+ {
+ if (line[0] == '#' || (ptr = strchr(line, '=')) == NULL)
+ continue;
+
+ *ptr++ = '\0';
+
+ if (!strcasecmp(line, name))
+ {
+ /*
+ * Found the service, see if it is set to "-NO-"...
+ */
+
+ if (!strncasecmp(ptr, "-NO-", 4))
+ state = 0;
+ break;
+ }
+ }
+
+ cupsFileClose(fp);
+ }
+
+ return (state);
+}
+#endif /* __APPLE__ */
+
+
/*
* 'is_local_queue()' - Determine whether the URI points at a local queue.
*/
const char *domain, /* I - Domain. ".local" for now */
void *context) /* I - User-defined context */
{
- (void)context;
+ cupsd_printer_t *p = (cupsd_printer_t *)context;
+ /* Current printer */
+
- cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "dnssdRegisterCallback(%s, %s)", name, regtype);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterCallback(%s, %s) for %s",
+ name, regtype, p->name);
if (errorCode)
{
"DNSServiceRegister failed with error %d", (int)errorCode);
return;
}
+ else if (strcasecmp(name, p->reg_name))
+ {
+ cupsdLogMessage(CUPSD_LOG_INFO, "Using service name \"%s\" for \"%s\"",
+ name, p->name);
+
+ cupsdSetString(&p->reg_name, name);
+ LastEvent |= CUPSD_EVENT_PRINTER_MODIFIED;
+ }
}
cupsdLogMessage(CUPSD_LOG_DEBUG,
- "dnssdRegisterPrinter(%s) type, domain is \"%s\", \"%s\"",
- p->name, regtype, domain ? domain : "(null)");
+ "dnssdRegisterPrinter(%s) type, domain is \"%s\", \"%s\"",
+ p->name, regtype, domain ? domain : "(null)");
se = DNSServiceRegister(&p->dnssd_ipp_ref, 0, 0, name, regtype,
domain, NULL, htons(port), txt_len, txt_record,
if (!LPDConfigFile)
return;
+#ifdef __APPLE__
+ /*
+ * Allow /etc/hostconfig CUPS_LPD service setting to override cupsd.conf
+ * setting for backwards-compatibility.
+ */
+
+ if (onoff && !get_hostconfig("CUPS_LPD"))
+ onoff = 0;
+#endif /* __APPLE__ */
+
if (!strncmp(LPDConfigFile, "xinetd:///", 10))
{
/*
snprintf(line, sizeof(line), "\tdisable = %s",
onoff ? "no" : "yes");
}
- else if (strstr(line, "disable ="))
- continue;
-
- cupsFilePrintf(nfp, "%s\n", line);
+ else if (!strstr(line, "disable ="))
+ cupsFilePrintf(nfp, "%s\n", line);
}
cupsFileClose(nfp);
cupsFileClose(ofp);
rename(newfile, LPDConfigFile + 9);
}
+#ifdef __APPLE__
else if (!strncmp(LPDConfigFile, "launchd:///", 11))
{
/*
cupsdStartProcess("/bin/launchctl", argv, envp, -1, -1, -1, -1, -1, 1,
NULL, &pid);
}
+#endif /* __APPLE__ */
+ else
+ cupsdLogMessage(CUPSD_LOG_INFO, "Unknown LPDConfigFile scheme!");
}
cupsFileClose(ofp);
rename(newfile, SMBConfigFile + 8);
}
- else if (!strncmp(SMBConfigFile, "launchd:///", 11))
- {
- /*
- * Enable/disable SMB via the launchctl command...
- */
-
- char *argv[5], /* Arguments for command */
- *envp[MAX_ENV]; /* Environment for command */
- int pid; /* Process ID */
-
-
- cupsdLoadEnv(envp, (int)(sizeof(envp) / sizeof(envp[0])));
- argv[0] = (char *)"launchctl";
- argv[1] = (char *)(onoff ? "load" : "unload");
- argv[2] = (char *)"-w";
- argv[3] = SMBConfigFile + 10;
- argv[4] = NULL;
-
- cupsdStartProcess("/bin/launchctl", argv, envp, -1, -1, -1, -1, -1, 1,
- NULL, &pid);
- }
+ else
+ cupsdLogMessage(CUPSD_LOG_INFO, "Unknown SMBConfigFile scheme!");
}