/*
- * "$Id: subscriptions.c 7824 2008-08-01 21:11:55Z mike $"
+ * Subscription routines for the CUPS scheduler.
*
- * Subscription routines for the CUPS scheduler.
+ * Copyright 2007-2019 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cupsdAddEvent() - Add an event to the global event cache.
- * cupsdAddSubscription() - Add a new subscription object.
- * cupsdDeleteAllSubscriptions() - Delete all subscriptions.
- * cupsdDeleteSubscription() - Delete a subscription object.
- * cupsdEventName() - Return a single event name.
- * cupsdEventValue() - Return the event mask value for a name.
- * cupsdExpireSubscriptions() - Expire old subscription objects.
- * cupsdFindSubscription() - Find a subscription by ID.
- * cupsdLoadAllSubscriptions() - Load all subscriptions from the .conf file.
- * cupsdSaveAllSubscriptions() - Save all subscriptions to the .conf file.
- * cupsdStopAllNotifiers() - Stop all notifier processes.
- * cupsd_compare_subscriptions() - Compare two subscriptions.
- * cupsd_delete_event() - Delete a single event...
- * cupsd_send_dbus() - Send a DBUS notification...
- * cupsd_send_notification() - Send a notification for the specified
- * event.
- * cupsd_start_notifier() - Start a notifier subprocess...
- * cupsd_update_notifier() - Read messages from notifiers.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
*/
/*
* Check if this subscription requires this event...
*/
- if ((sub->mask & event) != 0 &&
- (sub->dest == dest || !sub->dest) &&
- (sub->job == job || !sub->job))
+ if ((sub->mask & event) != 0 && (sub->dest == dest || !sub->dest || sub->job == job))
{
/*
* Need this event, so create a new event record...
temp->time = time(NULL);
temp->attrs = ippNew();
temp->job = job;
- temp->dest = dest;
+
+ if (dest)
+ temp->dest = dest;
+ else if (job)
+ temp->dest = dest = cupsdFindPrinter(job->dest);
/*
* Add common event notification attributes...
(const char * const *)dest->reasons);
ippAddBoolean(temp->attrs, IPP_TAG_EVENT_NOTIFICATION,
- "printer-is-accepting-jobs", dest->accepting);
+ "printer-is-accepting-jobs", (char)dest->accepting);
}
if (job)
time_t curtime; /* Current time */
+ if (cupsArrayCount(Subscriptions) == 0)
+ return;
+
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 (isxdigit(valueptr[0]) && isxdigit(valueptr[1]))
{
if (isdigit(valueptr[0]))
- sub->user_data[i] = (valueptr[0] - '0') << 4;
+ sub->user_data[i] = (unsigned char)((valueptr[0] - '0') << 4);
else
- sub->user_data[i] = (tolower(valueptr[0]) - 'a' + 10) << 4;
+ sub->user_data[i] = (unsigned char)((tolower(valueptr[0]) - 'a' + 10) << 4);
if (isdigit(valueptr[1]))
sub->user_data[i] |= valueptr[1] - '0';
break;
}
else
- sub->user_data[i] = *valueptr++;
+ sub->user_data[i] = (unsigned char)*valueptr++;
}
if (*valueptr)
break;
}
}
-
-
-/*
- * End of "$Id: subscriptions.c 7824 2008-08-01 21:11:55Z mike $".
- */