/*
- * "$Id: dest.c 5138 2006-02-21 10:49:06Z mike $"
+ * "$Id: dest.c 5182 2006-02-26 04:10:27Z mike $"
*
* User-defined destination (and option) support for the Common UNIX
* Printing System (CUPS).
#include "globals.h"
#include <stdlib.h>
#include <ctype.h>
+#include <sys/stat.h>
#ifdef HAVE_NOTIFY_H
# include <notify.h>
for (i = num_dests; i > 0; i --, dest ++)
if (strcasecmp(name, dest->name) < 0)
break;
- else if (strcasecmp(name, dest->name) == 0 &&
+ else if (!strcasecmp(name, dest->name) &&
instance != NULL && dest->instance != NULL &&
strcasecmp(instance, dest->instance) < 0)
break;
int num_dests; /* Number of destinations */
cups_dest_t *dest; /* Destination pointer */
const char *home; /* HOME environment variable */
- char filename[1024]; /* Local ~/.lpoptions file */
+ char filename[1024]; /* Local ~/.cups/lpoptions file */
const char *defprinter; /* Default printer */
char name[1024], /* Copy of printer name */
*instance; /* Pointer to instance name */
}
/*
- * Load the /etc/cups/lpoptions and ~/.lpoptions files...
+ * Load the /etc/cups/lpoptions and ~/.cups/lpoptions files...
*/
snprintf(filename, sizeof(filename), "%s/lpoptions", cg->cups_serverroot);
if ((home = getenv("HOME")) != NULL)
{
- snprintf(filename, sizeof(filename), "%s/.lpoptions", home);
+ snprintf(filename, sizeof(filename), "%s/.cups/lpoptions", home);
+ if (access(filename, 0))
+ snprintf(filename, sizeof(filename), "%s/.lpoptions", home);
+
num_dests = cups_get_dests(filename, num_dests, dests);
}
/*
* Validate the current default destination - this prevents old
- * Default lines in /etc/cups/lpoptions and ~/.lpoptions from
+ * Default lines in /etc/cups/lpoptions and ~/.cups/lpoptions from
* pointing to a non-existent printer or class...
*/
* 'cupsSetDests()' - Save the list of destinations for the default server.
*
* This function saves the destinations to /etc/cups/lpoptions when run
- * as root and ~/.lpoptions when run as a normal user.
+ * as root and ~/.cups/lpoptions when run as a normal user.
*/
void
* 'cupsSetDests2()' - Save the list of destinations for the specified server.
*
* This function saves the destinations to /etc/cups/lpoptions when run
- * as root and ~/.lpoptions when run as a normal user.
+ * as root and ~/.cups/lpoptions when run as a normal user.
*
* @since CUPS 1.1.21@
*/
*/
if ((home = getenv("HOME")) != NULL)
+ {
+ /*
+ * Remove the old ~/.lpoptions file...
+ */
+
snprintf(filename, sizeof(filename), "%s/.lpoptions", home);
+ unlink(filename);
+
+ /*
+ * Create ~/.cups subdirectory...
+ */
+
+ snprintf(filename, sizeof(filename), "%s/.cups", home);
+ if (access(filename, 0))
+ mkdir(filename, 0700);
+
+ snprintf(filename, sizeof(filename), "%s/.cups/lpoptions", home);
+ }
}
#endif /* !WIN32 */
if (temp && (val = cupsGetOption(option->name, temp->num_options,
temp->options)) != NULL)
{
- if (strcasecmp(val, option->value) == 0)
+ if (!strcasecmp(val, option->value))
continue;
}
/*
- * End of "$Id: dest.c 5138 2006-02-21 10:49:06Z mike $".
+ * End of "$Id: dest.c 5182 2006-02-26 04:10:27Z mike $".
*/