]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/banners.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / scheduler / banners.c
index 5ce485673efbd9c2965b7f0a91551039a39d4e85..e9399230209ab1475c729d7b7f5fe5167acf14f2 100644 (file)
@@ -1,32 +1,10 @@
 /*
- * "$Id: banners.c 5062 2006-02-03 16:36:24Z mike $"
+ * Banner routines for the CUPS scheduler.
  *
- *   Banner routines for the Common UNIX Printing System (CUPS).
+ * Copyright 2007-2011 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
  *
- *   Copyright 1997-2006 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
- *
- * Contents:
- *
- *   cupsdAddBanner()   - Add a banner to the array.
- *   cupsdFindBanner()  - Find a named banner.
- *   cupsdLoadBanners() - Load all available banner files...
- *   compare_banners()  - Compare two banners.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
  * Local functions...
  */
 
+static void    add_banner(const char *name, const char *filename);
 static int     compare_banners(const cupsd_banner_t *b0,
                                const cupsd_banner_t *b1);
-
-
-/*
- * 'cupsdAddBanner()' - Add a banner to the array.
- */
-
-void
-cupsdAddBanner(const char *name,       /* I - Name of banner */
-               const char *filename)   /* I - Filename for banner */
-{
-  mime_type_t          *filetype;      /* Filetype */
-  cupsd_banner_t       *temp;          /* New banner data */
-
-
- /*
-  * See what the filetype is...
-  */
-
-  if ((filetype = mimeFileType(MimeDatabase, filename, NULL, NULL)) == NULL)
-  {
-    cupsdLogMessage(CUPSD_LOG_WARN,
-                    "cupsdAddBanner: Banner \"%s\" (\"%s\") is of an unknown file type - skipping!",
-                    name, filename);
-    return;
-  }
-
- /*
-  * Allocate memory...
-  */
-
-  temp = calloc(1, sizeof(cupsd_banner_t));
-
- /*
-  * Copy the new banner data over...
-  */
-
-  temp->name     = strdup(name);
-  temp->filetype = filetype;
-
-  cupsArrayAdd(Banners, temp);
-}
+static void    free_banners(void);
 
 
 /*
@@ -102,29 +41,6 @@ cupsdFindBanner(const char *name)   /* I - Name of banner */
 }
 
 
-/*
- * 'cupsdFreeBanners()' - Free all banners.
- */
-
-void
-cupsdFreeBanners(void)
-{
-  cupsd_banner_t       *temp;          /* Current banner */
-
-
-  for (temp = (cupsd_banner_t *)cupsArrayFirst(Banners);
-       temp;
-       temp = (cupsd_banner_t *)cupsArrayNext(Banners))
-  {
-    free(temp->name);
-    free(temp);
-  }
-
-  cupsArrayDelete(Banners);
-  Banners = NULL;
-}
-
-
 /*
  * 'cupsdLoadBanners()' - Load all available banner files...
  */
@@ -142,7 +58,7 @@ cupsdLoadBanners(const char *d)              /* I - Directory to search */
   * Free old banner info...
   */
 
-  cupsdFreeBanners();
+  free_banners();
 
  /*
   * Try opening the banner directory...
@@ -187,7 +103,7 @@ cupsdLoadBanners(const char *d)             /* I - Directory to search */
     * Must be a valid file; add it!
     */
 
-    cupsdAddBanner(dent->filename, filename);
+    add_banner(dent->filename, filename);
   }
 
  /*
@@ -198,6 +114,61 @@ cupsdLoadBanners(const char *d)            /* I - Directory to search */
 }
 
 
+/*
+ * 'add_banner()' - Add a banner to the array.
+ */
+
+static void
+add_banner(const char *name,           /* I - Name of banner */
+           const char *filename)       /* I - Filename for banner */
+{
+  mime_type_t          *filetype;      /* Filetype */
+  cupsd_banner_t       *temp;          /* New banner data */
+
+
+ /*
+  * See what the filetype is...
+  */
+
+  if ((filetype = mimeFileType(MimeDatabase, filename, NULL, NULL)) == NULL)
+  {
+    cupsdLogMessage(CUPSD_LOG_WARN,
+                    "add_banner: Banner \"%s\" (\"%s\") is of an unknown file "
+                   "type - skipping!", name, filename);
+    return;
+  }
+
+ /*
+  * Allocate memory...
+  */
+
+  if ((temp = calloc(1, sizeof(cupsd_banner_t))) == NULL)
+  {
+    cupsdLogMessage(CUPSD_LOG_WARN,
+                    "add_banner: Unable to allocate memory for banner \"%s\" - "
+                   "skipping!", name);
+    return;
+  }
+
+ /*
+  * Copy the new banner data over...
+  */
+
+  if ((temp->name = strdup(name)) == NULL)
+  {
+    cupsdLogMessage(CUPSD_LOG_WARN,
+                    "add_banner: Unable to allocate memory for banner \"%s\" - "
+                   "skipping!", name);
+    free(temp);
+    return;
+  }
+
+  temp->filetype = filetype;
+
+  cupsArrayAdd(Banners, temp);
+}
+
+
 /*
  * 'compare_banners()' - Compare two banners.
  */
@@ -207,10 +178,28 @@ compare_banners(
     const cupsd_banner_t *b0,          /* I - First banner */
     const cupsd_banner_t *b1)          /* I - Second banner */
 {
-  return (strcasecmp(b0->name, b1->name));
+  return (_cups_strcasecmp(b0->name, b1->name));
 }
 
 
 /*
- * End of "$Id: banners.c 5062 2006-02-03 16:36:24Z mike $".
+ * 'free_banners()' - Free all banners.
  */
+
+static void
+free_banners(void)
+{
+  cupsd_banner_t       *temp;          /* Current banner */
+
+
+  for (temp = (cupsd_banner_t *)cupsArrayFirst(Banners);
+       temp;
+       temp = (cupsd_banner_t *)cupsArrayNext(Banners))
+  {
+    free(temp->name);
+    free(temp);
+  }
+
+  cupsArrayDelete(Banners);
+  Banners = NULL;
+}