]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/quotas.c
Load cups into easysw/current.
[thirdparty/cups.git] / scheduler / quotas.c
index db10d8677397f084ec9a3c087cb3e7b82b55d040..a9bfd01639303d77fbb5f30a692c63758f4bc29b 100644 (file)
@@ -1,33 +1,24 @@
 /*
- * "$Id: quotas.c 5305 2006-03-18 03:05:12Z mike $"
+ * "$Id: quotas.c 6649 2007-07-11 21:46:42Z mike $"
  *
  *   Quota routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 1997-2006 by Easy Software Products.
+ *   Copyright 2007 by Apple Inc.
+ *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products 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 missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   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:
  *
+ *   cupsdFindQuota()   - Find a quota record.
  *   cupsdFreeQuotas()  - Free quotas for a printer.
  *   cupsdUpdateQuota() - Update quota data for the specified printer and user.
  *   add_quota()        - Add a quota record for this printer and user.
  *   compare_quotas()   - Compare two quota records...
- *   find_quota()       - Find a quota record.
  */
 
 /*
 static cupsd_quota_t   *add_quota(cupsd_printer_t *p, const char *username);
 static int             compare_quotas(const cupsd_quota_t *q1,
                                       const cupsd_quota_t *q2);
-static cupsd_quota_t   *find_quota(cupsd_printer_t *p, const char *username);
+
+
+/*
+ * 'cupsdFindQuota()' - Find a quota record.
+ */
+
+cupsd_quota_t *                                /* O - Quota data */
+cupsdFindQuota(
+    cupsd_printer_t *p,                        /* I - Printer */
+    const char      *username)         /* I - User */
+{
+  cupsd_quota_t        *q,                     /* Quota data pointer */
+               match;                  /* Search data */
+
+
+  if (!p || !username)
+    return (NULL);
+
+  strlcpy(match.username, username, sizeof(match.username));
+
+  if ((q = (cupsd_quota_t *)cupsArrayFind(p->quotas, &match)) != NULL)
+    return (q);
+  else
+    return (add_quota(p, username));
+}
 
 
 /*
@@ -94,13 +109,26 @@ cupsdUpdateQuota(
   if (!p->k_limit && !p->page_limit)
     return (NULL);
 
-  if ((q = find_quota(p, username)) == NULL)
+  if ((q = cupsdFindQuota(p, username)) == NULL)
     return (NULL);
 
   cupsdLogMessage(CUPSD_LOG_DEBUG,
                   "cupsdUpdateQuota: p=%s username=%s pages=%d k=%d",
                   p->name, username, pages, k);
 
+#if defined(__APPLE__) && defined(HAVE_DLFCN_H)
+ /*
+  * Use Apple PrintService quota enforcement if installed (X Server only)
+  */
+
+  if (AppleQuotas && PSQUpdateQuotaProc)
+  { 
+    q->page_count = (*PSQUpdateQuotaProc)(p->name, p->info, username, pages, 0);
+
+    return (q);
+  }
+#endif /* __APPLE__ && HAVE_DLFCN_H */
+
   curtime = time(NULL);
 
   if (curtime < q->next_update)
@@ -141,7 +169,7 @@ cupsdUpdateQuota(
     if (attr->values[0].integer < curtime)
     {
       if (JobAutoPurge)
-        cupsdCancelJob(job, 1);
+        cupsdCancelJob(job, 1, IPP_JOB_CANCELED);
 
       continue;
     }
@@ -166,7 +194,7 @@ cupsdUpdateQuota(
  * 'add_quota()' - Add a quota record for this printer and user.
  */
 
-cupsd_quota_t *                                /* O - Quota data */
+static cupsd_quota_t *                 /* O - Quota data */
 add_quota(cupsd_printer_t *p,          /* I - Printer */
           const char      *username)   /* I - User */
 {
@@ -206,29 +234,5 @@ compare_quotas(const cupsd_quota_t *q1,    /* I - First quota record */
 
 
 /*
- * 'find_quota()' - Find a quota record.
- */
-
-cupsd_quota_t *                                /* O - Quota data */
-find_quota(cupsd_printer_t *p,         /* I - Printer */
-           const char      *username)  /* I - User */
-{
-  cupsd_quota_t        *q,                     /* Quota data pointer */
-               match;                  /* Search data */
-
-
-  if (!p || !username)
-    return (NULL);
-
-  strlcpy(match.username, username, sizeof(match.username));
-
-  if ((q = (cupsd_quota_t *)cupsArrayFind(p->quotas, &match)) != NULL)
-    return (q);
-  else
-    return (add_quota(p, username));
-}
-
-
-/*
- * End of "$Id: quotas.c 5305 2006-03-18 03:05:12Z mike $".
+ * End of "$Id: quotas.c 6649 2007-07-11 21:46:42Z mike $".
  */