/*
* "$Id: serial.c 7647 2008-06-16 17:39:40Z mike $"
*
- * Serial port backend for the Common UNIX Printing System (CUPS).
+ * Serial port backend for CUPS.
*
- * Copyright 2007-2010 by Apple Inc.
+ * Copyright 2007-2011 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
else if (argc < 6 || argc > 7)
{
_cupsLangPrintf(stderr,
- _("Usage: %s job-id user title copies options [file]\n"),
+ _("Usage: %s job-id user title copies options [file]"),
argv[0]);
return (CUPS_BACKEND_FAILED);
}
if ((print_fd = open(argv[6], O_RDONLY)) < 0)
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to open print file \"%s\": %s\n"),
- argv[6], strerror(errno));
+ _cupsLangPrintError("ERROR", _("Unable to open print file"));
return (CUPS_BACKEND_FAILED);
}
* available printer in the class.
*/
- _cupsLangPuts(stderr,
- _("INFO: Unable to contact printer, queuing on next "
- "printer in class...\n"));
+ _cupsLangPrintFilter(stderr, "INFO",
+ _("Unable to contact printer, queuing on next "
+ "printer in class."));
/*
* Sleep 5 seconds to keep the job from requeuing too rapidly...
if (errno == EBUSY)
{
- _cupsLangPuts(stderr,
- _("INFO: Printer busy; will retry in 30 seconds...\n"));
+ _cupsLangPrintFilter(stderr, "INFO",
+ _("Printer busy; will retry in 30 seconds."));
sleep(30);
}
else
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to open device file \"%s\": %s\n"),
- resource, strerror(errno));
+ _cupsLangPrintError("ERROR", _("Unable to open device file"));
return (CUPS_BACKEND_FAILED);
}
}
* Process the option...
*/
- if (!strcasecmp(name, "baud"))
+ if (!_cups_strcasecmp(name, "baud"))
{
/*
* Set the baud rate...
break;
# endif /* B230400 */
default :
- _cupsLangPrintf(stderr, _("WARNING: Unsupported baud rate %s\n"),
- value);
+ _cupsLangPrintFilter(stderr, "WARNING",
+ _("Unsupported baud rate: %s"), value);
break;
}
#endif /* B19200 == 19200 */
}
- else if (!strcasecmp(name, "bits"))
+ else if (!_cups_strcasecmp(name, "bits"))
{
/*
* Set number of data bits...
break;
}
}
- else if (!strcasecmp(name, "parity"))
+ else if (!_cups_strcasecmp(name, "parity"))
{
/*
* Set parity checking...
*/
- if (!strcasecmp(value, "even"))
+ if (!_cups_strcasecmp(value, "even"))
{
opts.c_cflag |= PARENB;
opts.c_cflag &= ~PARODD;
}
- else if (!strcasecmp(value, "odd"))
+ else if (!_cups_strcasecmp(value, "odd"))
{
opts.c_cflag |= PARENB;
opts.c_cflag |= PARODD;
}
- else if (!strcasecmp(value, "none"))
+ else if (!_cups_strcasecmp(value, "none"))
opts.c_cflag &= ~PARENB;
- else if (!strcasecmp(value, "space"))
+ else if (!_cups_strcasecmp(value, "space"))
{
/*
* Note: we only support space parity with 7 bits per character...
opts.c_cflag |= CS8;
opts.c_cflag &= ~PARENB;
}
- else if (!strcasecmp(value, "mark"))
+ else if (!_cups_strcasecmp(value, "mark"))
{
/*
* Note: we only support mark parity with 7 bits per character
opts.c_cflag |= CSTOPB;
}
}
- else if (!strcasecmp(name, "flow"))
+ else if (!_cups_strcasecmp(name, "flow"))
{
/*
* Set flow control...
*/
- if (!strcasecmp(value, "none"))
+ if (!_cups_strcasecmp(value, "none"))
{
opts.c_iflag &= ~(IXON | IXOFF);
opts.c_cflag &= ~CRTSCTS;
}
- else if (!strcasecmp(value, "soft"))
+ else if (!_cups_strcasecmp(value, "soft"))
{
opts.c_iflag |= IXON | IXOFF;
opts.c_cflag &= ~CRTSCTS;
}
- else if (!strcasecmp(value, "hard") ||
- !strcasecmp(value, "rtscts"))
+ else if (!_cups_strcasecmp(value, "hard") ||
+ !_cups_strcasecmp(value, "rtscts"))
{
opts.c_iflag &= ~(IXON | IXOFF);
opts.c_cflag |= CRTSCTS;
}
- else if (!strcasecmp(value, "dtrdsr"))
+ else if (!_cups_strcasecmp(value, "dtrdsr"))
{
opts.c_iflag &= ~(IXON | IXOFF);
opts.c_cflag &= ~CRTSCTS;
dtrdsr = 1;
}
}
- else if (!strcasecmp(name, "stop"))
+ else if (!_cups_strcasecmp(name, "stop"))
{
switch (atoi(value))
{
if (print_fd != 0)
close(print_fd);
- return (total_bytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK);
+ return (CUPS_BACKEND_OK);
}
/* Check if hidden... */
- hiddenVal = IORegistryEntrySearchCFProperty(serialService,
+ hiddenVal = IORegistryEntrySearchCFProperty(serialService,
kIOServicePlane,
CFSTR("HiddenPort"),
kCFAllocatorDefault,
- kIORegistryIterateRecursively |
+ kIORegistryIterateRecursively |
kIORegistryIterateParents);
if (hiddenVal)
CFRelease(hiddenVal); /* This interface should not be used */
sizeof(serialName),
kCFStringEncodingASCII);
CFRelease(serialNameAsCFString);
-
+
if (result)
{
bsdPathAsCFString =
sizeof(bsdPath),
kCFStringEncodingASCII);
CFRelease(bsdPathAsCFString);
-
+
if (result)
printf("serial serial:%s?baud=115200 \"Unknown\" \"%s\"\n",
bsdPath, serialName);