]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/mark.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / mark.c
index 274e13745535ce81c075c85f2d46e5e3b7d02b46..20a94fd4a0282a589dd06eb57bfb95c8d959bb0c 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: mark.c 177 2006-06-21 00:20:03Z jlovell $"
+ * "$Id: mark.c 6187 2007-01-10 16:20:42Z mike $"
  *
  *   Option marking routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Easy Software Products and are protected by Federal
@@ -62,15 +62,14 @@ static void ppd_defaults(ppd_file_t *ppd, ppd_group_t *g);
 int                            /* O - Number of conflicts found */
 ppdConflicts(ppd_file_t *ppd)  /* I - PPD to check */
 {
-  int          i, j, k,        /* Looping variables */
+  int          i, j,           /* Looping variables */
                conflicts;      /* Number of conflicts */
   ppd_const_t  *c;             /* Current constraint */
-  ppd_group_t  *g, *sg;        /* Groups */
   ppd_option_t *o1, *o2;       /* Options */
   ppd_choice_t *c1, *c2;       /* Choices */
 
 
-  if (ppd == NULL)
+  if (!ppd)
     return (0);
 
  /*
@@ -79,15 +78,8 @@ ppdConflicts(ppd_file_t *ppd)        /* I - PPD to check */
 
   conflicts = 0;
 
-  for (i = ppd->num_groups, g = ppd->groups; i > 0; i --, g ++)
-  {
-    for (j = g->num_options, o1 = g->options; j > 0; j --, o1 ++)
-      o1->conflicted = 0;
-
-    for (j = g->num_subgroups, sg = g->subgroups; j > 0; j --, sg ++)
-      for (k = sg->num_options, o1 = sg->options; k > 0; k --, o1 ++)
-        o1->conflicted = 0;
-  }
+  for (o1 = ppdFirstOption(ppd); o1; o1 = ppdNextOption(ppd))
+    o1->conflicted = 0;
 
  /*
   * Loop through all of the UI constraints and flag any options
@@ -102,9 +94,9 @@ ppdConflicts(ppd_file_t *ppd)        /* I - PPD to check */
 
     o1 = ppdFindOption(ppd, c->option1);
 
-    if (o1 == NULL)
+    if (!o1)
       continue;
-    else if (c->choice1[0] != '\0')
+    else if (c->choice1[0])
     {
      /*
       * This constraint maps to a specific choice.
@@ -122,10 +114,10 @@ ppdConflicts(ppd_file_t *ppd)     /* I - PPD to check */
         if (c1->marked)
          break;
 
-      if (j == 0 ||
-          strcasecmp(c1->choice, "None") == 0 ||
-          strcasecmp(c1->choice, "Off") == 0 ||
-          strcasecmp(c1->choice, "False") == 0)
+      if (!j ||
+          !strcasecmp(c1->choice, "None") ||
+          !strcasecmp(c1->choice, "Off") ||
+          !strcasecmp(c1->choice, "False"))
         c1 = NULL;
     }
 
@@ -135,9 +127,9 @@ ppdConflicts(ppd_file_t *ppd)       /* I - PPD to check */
 
     o2 = ppdFindOption(ppd, c->option2);
 
-    if (o2 == NULL)
+    if (!o2)
       continue;
-    else if (c->choice2[0] != '\0')
+    else if (c->choice2[0])
     {
      /*
       * This constraint maps to a specific choice.
@@ -155,10 +147,10 @@ ppdConflicts(ppd_file_t *ppd)     /* I - PPD to check */
         if (c2->marked)
          break;
 
-      if (j == 0 ||
-          strcasecmp(c2->choice, "None") == 0 ||
-          strcasecmp(c2->choice, "Off") == 0 ||
-          strcasecmp(c2->choice, "False") == 0)
+      if (!j ||
+          !strcasecmp(c2->choice, "None") ||
+          !strcasecmp(c2->choice, "Off") ||
+          !strcasecmp(c2->choice, "False"))
         c2 = NULL;
     }
 
@@ -166,8 +158,7 @@ ppdConflicts(ppd_file_t *ppd)       /* I - PPD to check */
     * If both options are marked then there is a conflict...
     */
 
-    if (c1 != NULL && c1->marked &&
-        c2 != NULL && c2->marked)
+    if (c1 && c1->marked && c2 && c2->marked)
     {
       DEBUG_printf(("%s->%s conflicts with %s->%s (%s %s %s %s)\n",
                     o1->keyword, c1->choice, o2->keyword, c2->choice,
@@ -407,6 +398,7 @@ ppdMarkOption(ppd_file_t *ppd,              /* I - PPD file record */
       ppd_cparam_t     *cparam;        /* Custom parameter */
       char             *units;         /* Custom points units */
 
+
       if ((coption = ppdFindCustomOption(ppd, option)) != NULL)
       {
         if ((cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params)) == NULL)
@@ -417,26 +409,27 @@ ppdMarkOption(ppd_file_t *ppd,            /* I - PPD file record */
          case PPD_CUSTOM_CURVE :
          case PPD_CUSTOM_INVCURVE :
          case PPD_CUSTOM_REAL :
-             cparam->current.custom_real = _cupsStrScand(choice + 7, NULL,
-                                                         loc);
+             cparam->current.custom_real = (float)_cupsStrScand(choice + 7,
+                                                                NULL, loc);
              break;
 
          case PPD_CUSTOM_POINTS :
-             cparam->current.custom_points = _cupsStrScand(choice + 7,
-                                                           &units, loc);
+             cparam->current.custom_points = (float)_cupsStrScand(choice + 7,
+                                                                  &units,
+                                                                  loc);
 
               if (units)
              {
                if (!strcasecmp(units, "cm"))
-                 cparam->current.custom_points *= 72.0 / 2.54;       
+                 cparam->current.custom_points *= 72.0f / 2.54f;             
                else if (!strcasecmp(units, "mm"))
-                 cparam->current.custom_points *= 72.0 / 25.4;       
+                 cparam->current.custom_points *= 72.0f / 25.4f;             
                else if (!strcasecmp(units, "m"))
-                 cparam->current.custom_points *= 72.0 / 0.0254;             
+                 cparam->current.custom_points *= 72.0f / 0.0254f;           
                else if (!strcasecmp(units, "in"))
-                 cparam->current.custom_points *= 72.0             
+                 cparam->current.custom_points *= 72.0f;             
                else if (!strcasecmp(units, "ft"))
-                 cparam->current.custom_points *= 12 * 72.0;         
+                 cparam->current.custom_points *= 12.0f * 72.0f;             
               }
              break;
 
@@ -455,6 +448,12 @@ ppdMarkOption(ppd_file_t *ppd,             /* I - PPD file record */
        }
       }
     }
+
+   /*
+    * Make sure that we keep the option marked below...
+    */
+
+    choice = "Custom";
   }
   else if (choice[0] == '{')
   {
@@ -487,26 +486,27 @@ ppdMarkOption(ppd_file_t *ppd,            /* I - PPD file record */
          case PPD_CUSTOM_CURVE :
          case PPD_CUSTOM_INVCURVE :
          case PPD_CUSTOM_REAL :
-             cparam->current.custom_real = _cupsStrScand(val->value, NULL,
-                                                         loc);
+             cparam->current.custom_real = (float)_cupsStrScand(val->value,
+                                                                NULL, loc);
              break;
 
          case PPD_CUSTOM_POINTS :
-             cparam->current.custom_points = _cupsStrScand(val->value, &units,
-                                                           loc);
+             cparam->current.custom_points = (float)_cupsStrScand(val->value,
+                                                                  &units,
+                                                                  loc);
 
              if (units)
              {
                if (!strcasecmp(units, "cm"))
-                 cparam->current.custom_points *= 72.0 / 2.54;       
+                 cparam->current.custom_points *= 72.0f / 2.54f;
                else if (!strcasecmp(units, "mm"))
-                 cparam->current.custom_points *= 72.0 / 25.4;       
+                 cparam->current.custom_points *= 72.0f / 25.4f;
                else if (!strcasecmp(units, "m"))
-                 cparam->current.custom_points *= 72.0 / 0.0254;             
+                 cparam->current.custom_points *= 72.0f / 0.0254f;
                else if (!strcasecmp(units, "in"))
-                 cparam->current.custom_points *= 72.0;              
+                 cparam->current.custom_points *= 72.0f;
                else if (!strcasecmp(units, "ft"))
-                 cparam->current.custom_points *= 12 * 72.0;         
+                 cparam->current.custom_points *= 12.0f * 72.0f;
              }
              break;
 
@@ -679,5 +679,5 @@ ppd_defaults(ppd_file_t  *ppd,      /* I - PPD file */
 
 
 /*
- * End of "$Id: mark.c 177 2006-06-21 00:20:03Z jlovell $".
+ * End of "$Id: mark.c 6187 2007-01-10 16:20:42Z mike $".
  */