resource[1024], /* Resource info (printer name) */
addrname[256], /* Address name */
*optptr, /* Pointer to URI options */
- name[255], /* Name of option */
- value[255], /* Value of option */
- *ptr; /* Pointer into name or value */
+ *name, /* Name of option */
+ *value, /* Value of option */
+ sep; /* Separator character */
int num_files; /* Number of files to print */
char **files, /* Files to print */
*filename; /* Pointer to single filename */
* Get the name...
*/
- for (ptr = name; *optptr && *optptr != '=';)
- if (ptr < (name + sizeof(name) - 1))
- *ptr++ = *optptr++;
- *ptr = '\0';
+ name = optptr;
- if (*optptr == '=')
+ while (*optptr && *optptr != '=' && *optptr != '+' && *optptr != '&')
+ optptr ++;
+
+ if ((sep = *optptr) != '\0')
+ *optptr++ = '\0';
+
+ if (sep == '=')
{
/*
* Get the value...
*/
- optptr ++;
+ value = optptr;
- for (ptr = value; *optptr && *optptr != '+' && *optptr != '&';)
- if (ptr < (value + sizeof(value) - 1))
- *ptr++ = *optptr++;
- *ptr = '\0';
-
- if (*optptr == '+' || *optptr == '&')
+ while (*optptr && *optptr != '+' && *optptr != '&')
optptr ++;
+
+ if (*optptr)
+ *optptr++ = '\0';
}
else
- value[0] = '\0';
+ value = (char *)"";
/*
* Process the option...
* Try loading authentication information from the environment.
*/
- if ((ptr = getenv("AUTH_USERNAME")) != NULL)
+ const char *ptr = getenv("AUTH_USERNAME");
+
+ if (ptr)
cupsSetUser(ptr);
password = getenv("AUTH_PASSWORD");
username[255], /* Username info */
resource[1024], /* Resource info (printer name) */
*options, /* Pointer to options */
- name[255], /* Name of option */
- value[255], /* Value of option */
- *ptr, /* Pointer into name or value */
+ *name, /* Name of option */
+ *value, /* Value of option */
+ sep, /* Separator character */
*filename, /* File to print */
title[256]; /* Title string */
int port; /* Port number */
* Get the name...
*/
- for (ptr = name; *options && *options != '=';)
- if (ptr < (name + sizeof(name) - 1))
- *ptr++ = *options++;
- *ptr = '\0';
+ name = options;
- if (*options == '=')
+ while (*options && *options != '=' && *options != '+' && *options != '&')
+ options ++;
+
+ if ((sep = *options) != '\0')
+ *options++ = '\0';
+
+ if (sep == '=')
{
/*
* Get the value...
*/
- options ++;
+ value = options;
- for (ptr = value; *options && *options != '+' && *options != '&';)
- if (ptr < (value + sizeof(value) - 1))
- *ptr++ = *options++;
- *ptr = '\0';
-
- if (*options == '+' || *options == '&')
+ while (*options && *options != '+' && *options != '&')
options ++;
+
+ if (*options)
+ *options++ = '\0';
}
else
- value[0] = '\0';
+ value = (char *)"";
/*
* Process the option...
* the remote end...
*/
+ char *ptr;
+
for (ptr = title; *ptr; ptr ++)
if (!isalnum(*ptr & 255) && !isspace(*ptr & 255))
*ptr = '_';
*resourcePtr,
*typePtr,
*options, /* Pointer to options */
- optionName[255], /* Name of option */
- value[255], /* Value of option */
- *ptr; /* Pointer into name or value */
+ *optionName, /* Name of option */
+ *value, /* Value of option */
+ sep; /* Separator character */
int port; /* Port number (not used) */
int statusInterval; /* */
while (*options != '\0')
{
- /*
+ /*
* Get the name...
*/
- for (ptr = optionName; *options && *options != '=' && *options != '+'; )
- *ptr++ = *options++;
- *ptr = '\0';
- value[0] = '\0';
+ optionName = options;
- if (*options == '=')
- {
- /*
- * Get the value...
- */
-
+ while (*options && *options != '=' && *options != '+' && *options != '&')
options ++;
-
- for (ptr = value; *options && *options != '+';)
- *ptr++ = *options++;
-
- *ptr = '\0';
-
- if (*options == '+')
- options ++;
- }
- else if (*options == '+')
+
+ if ((sep = *options) != '\0')
+ *options++ = '\0';
+
+ if (sep == '=')
{
- options ++;
+ /*
+ * Get the value...
+ */
+
+ value = options;
+
+ while (*options && *options != '+' && *options != '&')
+ options ++;
+
+ if (*options)
+ *options++ = '\0';
}
+ else
+ value = (char *)"";
- /*
+ /*
* Process the option...
*/
- if (strcasecmp(optionName, "waiteof") == 0)
+
+ if (!strcasecmp(optionName, "waiteof"))
{
- /*
- * Set the banner...
+ /*
+ * Wait for the end of the print file?
*/
- if (strcasecmp(value, "on") == 0 ||
- strcasecmp(value, "yes") == 0 ||
- strcasecmp(value, "true") == 0)
+
+ if (!strcasecmp(value, "on") ||
+ !strcasecmp(value, "yes") ||
+ !strcasecmp(value, "true"))
{
gWaitEOF = true;
}
- else if (strcasecmp(value, "off") == 0 ||
- strcasecmp(value, "no") == 0 ||
- strcasecmp(value, "false") == 0)
+ else if (!strcasecmp(value, "off") ||
+ !strcasecmp(value, "no") ||
+ !strcasecmp(value, "false"))
{
gWaitEOF = false;
}
fprintf(stderr, "WARNING: Boolean expected for waiteof option \"%s\"\n", value);
}
}
- else if (strcasecmp(optionName, "status") == 0)
+ else if (!strcasecmp(optionName, "status"))
{
+ /*
+ * Set status reporting interval...
+ */
+
statusInterval = atoi(value);
- if (value[0] < '0' || value[0] > '9' ||
- statusInterval < 0)
+ if (value[0] < '0' || value[0] > '9' || statusInterval < 0)
{
- fprintf(stderr, "WARNING: number expected for status option \"%s\"\n", value);
+ fprintf(stderr, "WARNING: number expected for status option \"%s\"\n",
+ value);
}
else
{
if (*resourcePtr == '/')
resourcePtr++;
- /* If the resource has a slash we assume the slash seperates the AppleTalk object
- * name from the AppleTalk type. If the slash is not present we assume the AppleTalk
- * type is LaserWriter.
- */
- typePtr = strchr(resourcePtr, '/');
- if (typePtr != NULL) {
- *typePtr++ = '\0';
- } else {
- typePtr = "LaserWriter";
- }
+ /* If the resource has a slash we assume the slash seperates the AppleTalk object
+ * name from the AppleTalk type. If the slash is not present we assume the AppleTalk
+ * type is LaserWriter.
+ */
+
+ typePtr = strchr(resourcePtr, '/');
+ if (typePtr != NULL)
+ {
+ *typePtr++ = '\0';
+ }
+ else
+ {
+ typePtr = "LaserWriter";
+ }
- removePercentEscapes(hostname, zone, NBP_NVE_STR_SIZE + 1);
- removePercentEscapes(resourcePtr, name, NBP_NVE_STR_SIZE + 1);
- removePercentEscapes(typePtr, type, NBP_NVE_STR_SIZE + 1);
+ removePercentEscapes(hostname, zone, NBP_NVE_STR_SIZE + 1);
+ removePercentEscapes(resourcePtr, name, NBP_NVE_STR_SIZE + 1);
+ removePercentEscapes(typePtr, type, NBP_NVE_STR_SIZE + 1);
return 0;
}
username[255], /* Username info (not used) */
resource[1024], /* Resource info (device and options) */
*options, /* Pointer to options */
- name[255], /* Name of option */
- value[255], /* Value of option */
- *ptr; /* Pointer into name or value */
+ *name, /* Name of option */
+ *value, /* Value of option */
+ sep; /* Option separator */
int port; /* Port number (not used) */
int copies; /* Number of copies to print */
int print_fd, /* Print file */
* Get the name...
*/
- for (ptr = name; *options && *options != '=';)
- if (ptr < (name + sizeof(name) - 1))
- *ptr++ = *options++;
- *ptr = '\0';
+ name = options;
- if (*options == '=')
+ while (*options && *options != '=' && *options != '+' && *options != '&')
+ options ++;
+
+ if ((sep = *options) != '\0')
+ *options++ = '\0';
+
+ if (sep == '=')
{
/*
* Get the value...
*/
- options ++;
-
- for (ptr = value; *options && *options != '+' && *options != '&';)
- if (ptr < (value + sizeof(value) - 1))
- *ptr++ = *options++;
- *ptr = '\0';
+ value = options;
- if (*options == '+' || *options == '&')
+ while (*options && *options != '+' && *options != '&')
options ++;
+
+ if (*options)
+ *options++ = '\0';
}
else
- value[0] = '\0';
+ value = (char *)"";
/*
* Process the option...
username[255], /* Username info (not used) */
resource[1024], /* Resource info (not used) */
*options, /* Pointer to options */
- name[255], /* Name of option */
- value[255], /* Value of option */
- *ptr; /* Pointer into name or value */
+ *name, /* Name of option */
+ *value, /* Value of option */
+ sep; /* Option separator */
int print_fd; /* Print file */
int copies; /* Number of copies to print */
time_t start_time; /* Time of first connect */
int device_fd; /* AppSocket */
int error; /* Error code (if any) */
http_addrlist_t *addrlist, /* Address list */
- *addr; /* Connected address */
+ *addr; /* Connected address */
char addrname[256]; /* Address name */
ssize_t tbytes; /* Total number of bytes written */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
* Get the name...
*/
- for (ptr = name; *options && *options != '=';)
- if (ptr < (name + sizeof(name) - 1))
- *ptr++ = *options++;
- *ptr = '\0';
+ name = options;
- if (*options == '=')
+ while (*options && *options != '=' && *options != '+' && *options != '&')
+ options ++;
+
+ if ((sep = *options) != '\0')
+ *options++ = '\0';
+
+ if (sep == '=')
{
/*
* Get the value...
*/
- options ++;
-
- for (ptr = value; *options && *options != '+' && *options != '&';)
- if (ptr < (value + sizeof(value) - 1))
- *ptr++ = *options++;
- *ptr = '\0';
+ value = options;
- if (*options == '+' || *options == '&')
+ while (*options && *options != '+' && *options != '&')
options ++;
+
+ if (*options)
+ *options++ = '\0';
}
else
- value[0] = '\0';
+ value = (char *)"";
/*
* Process the option...
static void device_added(void *userdata, io_iterator_t iterator);
static void get_device_id(cups_sc_status_t *status, char *data, int *datalen);
static void iterate_printers(iterator_callback_t callBack, void *userdata);
-static void parse_options(const char *options, char *serial, int serial_size, UInt32 *location, Boolean *wait_eof);
+static void parse_options(char *options, char *serial, int serial_size, UInt32 *location, Boolean *wait_eof);
static void release_deviceinfo(CFStringRef *make, CFStringRef *model, CFStringRef *serial);
static void setup_cfLanguage(void);
static void soft_reset();
print_device(const char *uri, /* I - Device URI */
const char *hostname, /* I - Hostname/manufacturer */
const char *resource, /* I - Resource/modelname */
- const char *options, /* I - Device options/serial number */
+ char *options, /* I - Device options/serial number */
int print_fd, /* I - File descriptor to print */
int copies, /* I - Copies to print */
int argc, /* I - Number of command-line arguments (6 or 7) */
#pragma mark -
/*
- * 'parse_options()' - Parse uri options.
+ * 'parse_options()' - Parse URI options.
*/
-static void parse_options(const char *options,
+static void parse_options(char *options,
char *serial,
int serial_size,
UInt32 *location,
Boolean *wait_eof)
{
- char optionName[255], /* Name of option */
- value[255], /* Value of option */
- *ptr; /* Pointer into name or value */
+ char sep, /* Separator character */
+ *name, /* Name of option */
+ *value; /* Value of option */
+
if (serial)
*serial = '\0';
if (!options)
return;
- while (*options != '\0')
+ while (*options)
{
- /* Get the name... */
- for (ptr = optionName; *options && *options != '=' && *options != '+';)
- *ptr++ = *options++;
+ /*
+ * Get the name...
+ */
- *ptr = '\0';
- value[0] = '\0';
+ name = options;
- if (*options == '=')
- {
- /* Get the value... */
+ while (*options && *options != '=' && *options != '+' && *options != '&')
options ++;
- for (ptr = value; *options && *options != '+';)
- *ptr++ = *options++;
+ if ((sep = *options) != '\0')
+ *options++ = '\0';
+
+ if (sep == '=')
+ {
+ /*
+ * Get the value...
+ */
- *ptr = '\0';
+ value = options;
- if (*options == '+')
+ while (*options && *options != '+' && *options != '&')
options ++;
+
+ if (*options)
+ *options++ = '\0';
}
- else if (*options == '+')
- options ++;
+ else
+ value = (char *)"";
- /*
- * Process the option...
- */
- if (strcasecmp(optionName, "waiteof") == 0)
+ /*
+ * Process the option...
+ */
+
+ if (!strcasecmp(name, "waiteof"))
{
- if (strcasecmp(value, "on") == 0 ||
- strcasecmp(value, "yes") == 0 ||
- strcasecmp(value, "true") == 0)
+ if (!strcasecmp(value, "on") ||
+ !strcasecmp(value, "yes") ||
+ !strcasecmp(value, "true"))
*wait_eof = true;
- else if (strcasecmp(value, "off") == 0 ||
- strcasecmp(value, "no") == 0 ||
- strcasecmp(value, "false") == 0)
+ else if (!strcasecmp(value, "off") ||
+ !strcasecmp(value, "no") ||
+ !strcasecmp(value, "false"))
*wait_eof = false;
else
_cupsLangPrintf(stderr,
_("WARNING: Boolean expected for waiteof option "
"\"%s\"\n"), value);
}
- else if (strcasecmp(optionName, "serial") == 0)
- {
+ else if (!strcasecmp(name, "serial"))
strlcpy(serial, value, serial_size);
- }
- else if (strcasecmp(optionName, "location") == 0 && location)
+ else if (!strcasecmp(name, "location") && location)
*location = strtol(value, NULL, 16);
}
-
- return;
}
print_device(const char *uri, /* I - Device URI */
const char *hostname, /* I - Hostname/manufacturer */
const char *resource, /* I - Resource/modelname */
- const char *options, /* I - Device options/serial number */
+ char *options, /* I - Device options/serial number */
int print_fd, /* I - File descriptor to print */
int copies, /* I - Copies to print */
int argc, /* I - Number of command-line arguments (6 or 7) */
void list_devices(void);
int print_device(const char *uri, const char *hostname,
- const char *resource, const char *options,
+ const char *resource, char *options,
int print_fd, int copies, int argc, char *argv[]);
print_device(const char *uri, /* I - Device URI */
const char *hostname, /* I - Hostname/manufacturer */
const char *resource, /* I - Resource/modelname */
- const char *options, /* I - Device options/serial number */
+ char *options, /* I - Device options/serial number */
int print_fd, /* I - File descriptor to print */
int copies, /* I - Copies to print */
int argc, /* I - Number of command-line arguments (6 or 7) */