X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fcups.git;a=blobdiff_plain;f=scheduler%2Fquotas.c;h=db10d8677397f084ec9a3c087cb3e7b82b55d040;hp=8cd8fc9c21a8bc25dbe40f0c038bf8c78837a7fb;hb=e1d6a77454308ff30d6da778be9d7b570e4f00b0;hpb=480ef0fe29ab803f49dd87a7a21a6c61648539b8 diff --git a/scheduler/quotas.c b/scheduler/quotas.c index 8cd8fc9c2..db10d8677 100644 --- a/scheduler/quotas.c +++ b/scheduler/quotas.c @@ -1,5 +1,5 @@ /* - * "$Id: quotas.c 4970 2006-01-24 14:05:45Z mike $" + * "$Id: quotas.c 5305 2006-03-18 03:05:12Z mike $" * * Quota routines for the Common UNIX Printing System (CUPS). * @@ -23,11 +23,11 @@ * * Contents: * - * cupsdAddQuota() - Add a quota record for this printer and user. - * 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. */ /* @@ -41,64 +41,10 @@ * Local functions... */ -static int compare_quotas(const cupsd_quota_t *q1, - const cupsd_quota_t *q2); - - -/* - * 'cupsdAddQuota()' - Add a quota record for this printer and user. - */ - -cupsd_quota_t * /* O - Quota data */ -cupsdAddQuota(cupsd_printer_t *p, /* I - Printer */ - const char *username)/* I - User */ -{ - cupsd_quota_t *q; /* New quota data */ - - - if (!p || !username) - return (NULL); - - if (!p->quotas) - p->quotas = cupsArrayNew((cups_array_func_t)compare_quotas, NULL); - - if (!p->quotas) - return (NULL); - - if ((q = calloc(1, sizeof(cupsd_quota_t))) == NULL) - return (NULL); - - strlcpy(q->username, username, sizeof(q->username)); - - cupsArrayAdd(p->quotas, q); - - return (q); -} - - -/* - * '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 (cupsdAddQuota(p, username)); -} +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); /* @@ -148,7 +94,7 @@ cupsdUpdateQuota( if (!p->k_limit && !p->page_limit) return (NULL); - if ((q = cupsdFindQuota(p, username)) == NULL) + if ((q = find_quota(p, username)) == NULL) return (NULL); cupsdLogMessage(CUPSD_LOG_DEBUG, @@ -216,6 +162,37 @@ cupsdUpdateQuota( } +/* + * 'add_quota()' - Add a quota record for this printer and user. + */ + +cupsd_quota_t * /* O - Quota data */ +add_quota(cupsd_printer_t *p, /* I - Printer */ + const char *username) /* I - User */ +{ + cupsd_quota_t *q; /* New quota data */ + + + if (!p || !username) + return (NULL); + + if (!p->quotas) + p->quotas = cupsArrayNew((cups_array_func_t)compare_quotas, NULL); + + if (!p->quotas) + return (NULL); + + if ((q = calloc(1, sizeof(cupsd_quota_t))) == NULL) + return (NULL); + + strlcpy(q->username, username, sizeof(q->username)); + + cupsArrayAdd(p->quotas, q); + + return (q); +} + + /* * 'compare_quotas()' - Compare two quota records... */ @@ -229,5 +206,29 @@ compare_quotas(const cupsd_quota_t *q1, /* I - First quota record */ /* - * End of "$Id: quotas.c 4970 2006-01-24 14:05:45Z mike $". + * '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 $". */