本文整理汇总了C++中cupsdLogMessage函数的典型用法代码示例。如果您正苦于以下问题:C++ cupsdLogMessage函数的具体用法?C++ cupsdLogMessage怎么用?C++ cupsdLogMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cupsdLogMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cupsdExpireSubscriptions
void
cupsdExpireSubscriptions(
cupsd_printer_t *dest, /* I - Printer, if any */
cupsd_job_t *job) /* I - Job, if any */
{
cupsd_subscription_t *sub; /* Current subscription */
int update; /* Update subscriptions.conf? */
time_t curtime; /* Current time */
curtime = time(NULL);
update = 0;
cupsdLogMessage(CUPSD_LOG_INFO, "Expiring subscriptions...");
for (sub = (cupsd_subscription_t *)cupsArrayFirst(Subscriptions);
sub;
sub = (cupsd_subscription_t *)cupsArrayNext(Subscriptions))
if ((!sub->job && !dest && sub->expire && sub->expire <= curtime) ||
(dest && sub->dest == dest) ||
(job && sub->job == job))
{
cupsdLogMessage(CUPSD_LOG_INFO, "Subscription %d has expired...",
sub->id);
cupsdDeleteSubscription(sub, 0);
update = 1;
}
if (update)
cupsdMarkDirty(CUPSD_DIRTY_SUBSCRIPTIONS);
}
示例2: cupsdPauseListening
void
cupsdPauseListening(void)
{
cupsd_listener_t *lis; /* Current listening socket */
if (cupsArrayCount(Listeners) < 1)
return;
if (cupsArrayCount(Clients) == MaxClients)
cupsdLogMessage(CUPSD_LOG_WARN,
"Max clients reached, holding new connections...");
else if (errno == ENFILE || errno == EMFILE)
cupsdLogMessage(CUPSD_LOG_WARN,
"Too many open files, holding new connections for "
"30 seconds...");
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdPauseListening: Clearing input bits...");
for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
lis;
lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
cupsdRemoveSelect(lis->fd);
ListeningPaused = time(NULL) + 30;
}
示例3: service_checkout
static void
service_checkout(void)
{
int fd; /* File descriptor */
/*
* Create or remove the "keep-alive" file based on whether there are active
* jobs or shared printers to advertise...
*/
if (cupsArrayCount(ActiveJobs) || /* Active jobs */
WebInterface || /* Web interface enabled */
NeedReload || /* Doing a reload */
(Browsing && BrowseLocalProtocols && cupsArrayCount(Printers)))
/* Printers being shared */
{
cupsdLogMessage(CUPSD_LOG_DEBUG, "Creating keep-alive file \"" CUPS_KEEPALIVE "\".");
if ((fd = open(CUPS_KEEPALIVE, O_RDONLY | O_CREAT | O_EXCL, S_IRUSR)) >= 0)
close(fd);
}
else
{
cupsdLogMessage(CUPSD_LOG_DEBUG, "Removing keep-alive file \"" CUPS_KEEPALIVE "\".");
unlink(CUPS_KEEPALIVE);
}
}
示例4: cupsdEndTLS
int /* O - 1 on success, 0 on error */
cupsdEndTLS(cupsd_client_t *con) /* I - Client connection */
{
int error; /* Error code */
gnutls_certificate_server_credentials *credentials;
/* TLS credentials */
credentials = (gnutls_certificate_server_credentials *)
(con->http.tls_credentials);
error = gnutls_bye(con->http.tls, GNUTLS_SHUT_WR);
switch (error)
{
case GNUTLS_E_SUCCESS:
cupsdLogMessage(CUPSD_LOG_DEBUG,
"SSL shutdown successful!");
break;
default:
cupsdLogMessage(CUPSD_LOG_ERROR,
"SSL shutdown failed: %s", gnutls_strerror(error));
break;
}
gnutls_deinit(con->http.tls);
con->http.tls = NULL;
gnutls_certificate_free_credentials(*credentials);
free(credentials);
return (1);
}
示例5: dnssdAddAlias
static void
dnssdAddAlias(const void *key, /* I - Key */
const void *value, /* I - Value (domain) */
void *context) /* I - Unused */
{
char valueStr[1024], /* Domain string */
hostname[1024], /* Complete hostname */
*hostptr; /* Pointer into hostname */
(void)key;
(void)context;
if (CFGetTypeID((CFStringRef)value) == CFStringGetTypeID() &&
CFStringGetCString((CFStringRef)value, valueStr, sizeof(valueStr),
kCFStringEncodingUTF8))
{
snprintf(hostname, sizeof(hostname), "%s.%s", DNSSDHostName, valueStr);
hostptr = hostname + strlen(hostname) - 1;
if (*hostptr == '.')
*hostptr = '\0'; /* Strip trailing dot */
if (!DNSSDAlias)
DNSSDAlias = cupsArrayNew(NULL, NULL);
cupsdAddAlias(DNSSDAlias, hostname);
cupsdLogMessage(CUPSD_LOG_DEBUG, "Added Back to My Mac ServerAlias %s",
hostname);
}
else
cupsdLogMessage(CUPSD_LOG_ERROR,
"Bad Back to My Mac domain in dynamic store!");
}
示例6: launchd_checkout
static void
launchd_checkout(void)
{
int fd; /* File descriptor */
/*
* Create or remove the launchd KeepAlive file based on whether
* there are active jobs, polling, browsing for remote printers or
* shared printers to advertise...
*/
if (cupsArrayCount(ActiveJobs) ||
(Browsing && BrowseLocalProtocols && cupsArrayCount(Printers)))
{
cupsdLogMessage(CUPSD_LOG_DEBUG,
"Creating launchd keepalive file \"" CUPS_KEEPALIVE
"\"...");
if ((fd = open(CUPS_KEEPALIVE, O_RDONLY | O_CREAT | O_EXCL, S_IRUSR)) >= 0)
close(fd);
}
else
{
cupsdLogMessage(CUPSD_LOG_DEBUG,
"Removing launchd keepalive file \"" CUPS_KEEPALIVE
"\"...");
unlink(CUPS_KEEPALIVE);
}
}
示例7: colord_delete_device
static void
colord_delete_device(
const char *device_id) /* I - Device ID string */
{
DBusMessage *message = NULL; /* D-Bus request */
DBusMessage *reply = NULL; /* D-Bus reply */
DBusMessageIter args; /* D-Bus method arguments */
DBusError error; /* D-Bus error */
char *device_path; /* Device object path */
/*
* Find the device...
*/
if ((device_path = colord_find_device(device_id)) == NULL)
goto out;
/*
* Delete the device...
*/
message = dbus_message_new_method_call(COLORD_DBUS_SERVICE,
COLORD_DBUS_PATH,
COLORD_DBUS_INTERFACE,
"DeleteDevice");
dbus_message_iter_init_append(message, &args);
dbus_message_iter_append_basic(&args, DBUS_TYPE_OBJECT_PATH, &device_path);
/*
* Send the DeleteDevice request synchronously...
*/
dbus_error_init(&error);
cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling DeleteDevice(%s)", device_path);
reply = dbus_connection_send_with_reply_and_block(colord_con, message,
COLORD_DBUS_TIMEOUT,
&error);
if (!reply)
{
cupsdLogMessage(CUPSD_LOG_DEBUG, "DeleteDevice failed: %s:%s", error.name,
error.message);
dbus_error_free(&error);
goto out;
}
out:
if (device_path)
free(device_path);
if (message)
dbus_message_unref(message);
if (reply)
dbus_message_unref(reply);
}
示例8: cupsdSetEnv
void
cupsdSetEnv(const char *name, /* I - Name of variable */
const char *value) /* I - Value of variable */
{
int i; /* Index into environent array */
/*
* If "value" is NULL, try getting value from current environment...
*/
if (!value)
value = getenv(name);
if (!value)
return;
/*
* Do not allow dynamic linker variables when running as root...
*/
if (!RunUser && (!strncmp(name, "DYLD_", 5) || !strncmp(name, "LD_", 3)))
return;
/*
* See if this variable has already been defined...
*/
if ((i = find_env(name)) < 0)
{
/*
* Check for room...
*/
if (num_common_env >= (int)(sizeof(common_env) / sizeof(common_env[0])))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"cupsdSetEnv: Too many environment variables set!");
return;
}
i = num_common_env;
num_common_env ++;
}
/*
* Set the new environment variable...
*/
cupsdSetStringf(common_env + i, "%s=%s", name, value);
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSetEnv: %s", common_env[i]);
}
示例9: colord_device_add_profile
static void
colord_device_add_profile(
const char *device_path, /* I - Device object path */
const char *profile_path, /* I - Profile object path */
const char *relation) /* I - Device relation, either
'soft' or 'hard' */
{
DBusMessage *message = NULL; /* D-Bus request */
DBusMessage *reply = NULL; /* D-Bus reply */
DBusMessageIter args; /* D-Bus method arguments */
DBusError error; /* D-Bus error */
message = dbus_message_new_method_call(COLORD_DBUS_SERVICE,
device_path,
COLORD_DBUS_INTERFACE_DEVICE,
"AddProfile");
dbus_message_iter_init_append(message, &args);
dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &relation);
dbus_message_iter_append_basic(&args, DBUS_TYPE_OBJECT_PATH, &profile_path);
cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling %s:AddProfile(%s) [%s]",
device_path, profile_path, relation);
/*
* Send the AddProfile request synchronously...
*/
dbus_error_init(&error);
reply = dbus_connection_send_with_reply_and_block(colord_con, message,
COLORD_DBUS_TIMEOUT,
&error);
if (!reply)
{
cupsdLogMessage(CUPSD_LOG_WARN, "AddProfile failed: %s:%s", error.name,
error.message);
dbus_error_free(&error);
goto out;
}
out:
if (message)
dbus_message_unref(message);
if (reply)
dbus_message_unref(reply);
}
示例10: 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);
}
示例11: cupsdEndProcess
int /* O - 0 on success, -1 on failure */
cupsdEndProcess(int pid, /* I - Process ID */
int force) /* I - Force child to die */
{
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdEndProcess(pid=%d, force=%d)", pid,
force);
if (!pid)
return (0);
if (!RunUser)
{
/*
* When running as root, cupsd puts child processes in their own process
* group. Using "-pid" sends a signal to all processes in the group.
*/
pid = -pid;
}
if (force)
return (kill(pid, SIGKILL));
else
return (kill(pid, SIGTERM));
}
示例12: cupsdStopListening
void
cupsdStopListening(void)
{
cupsd_listener_t *lis; /* Current listening socket */
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdStopListening: closing all listen sockets.");
cupsdPauseListening();
for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
lis;
lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
{
if (lis->fd != -1)
{
#ifdef HAVE_LAUNCH_H
httpAddrClose(NULL, lis->fd);
#else
httpAddrClose(&(lis->address), lis->fd);
#endif /* HAVE_LAUNCH */
lis->fd = -1;
}
}
}
示例13: cupsdStartSystemMonitor
void
cupsdStartSystemMonitor(void)
{
int flags; /* fcntl flags on pipe */
if (cupsdOpenPipe(SysEventPipes))
{
cupsdLogMessage(CUPSD_LOG_ERROR, "System event monitor pipe() failed - %s!",
strerror(errno));
return;
}
cupsdAddSelect(SysEventPipes[0], (cupsd_selfunc_t)sysUpdate, NULL, NULL);
/*
* Set non-blocking mode on the descriptor we will be receiving notification
* events on.
*/
flags = fcntl(SysEventPipes[0], F_GETFL, 0);
fcntl(SysEventPipes[0], F_SETFL, flags | O_NONBLOCK);
/*
* Start the thread that runs the runloop...
*/
pthread_mutex_init(&SysEventThreadMutex, NULL);
pthread_cond_init(&SysEventThreadCond, NULL);
pthread_create(&SysEventThread, NULL, (void *(*)())sysEventThreadEntry, NULL);
}
示例14: cupsdDeleteAllCerts
void
cupsdDeleteAllCerts(void)
{
cupsd_cert_t *cert, /* Current certificate */
*next; /* Next certificate */
char filename[1024]; /* Certificate file */
/*
* Loop through each certificate, deleting them...
*/
for (cert = Certs; cert != NULL; cert = next)
{
/*
* Delete the file...
*/
snprintf(filename, sizeof(filename), "%s/certs/%d", StateDir, cert->pid);
if (unlink(filename))
cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to remove %s!", filename);
/*
* Free memory...
*/
next = cert->next;
free(cert);
}
Certs = NULL;
RootCertTime = 0;
}
示例15: cupsdStopListening
void
cupsdStopListening(void)
{
cupsd_listener_t *lis; /* Current listening socket */
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdStopListening: closing all listen sockets.");
cupsdPauseListening();
for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
lis;
lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
{
#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
if (!lis->on_demand && lis->fd != -1)
{
httpAddrClose(&(lis->address), lis->fd);
lis->fd = -1;
}
#else
if (lis->fd != -1)
{
httpAddrClose(&(lis->address), lis->fd);
lis->fd = -1;
}
#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
}
}