summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1999-11-30 16:15:22 +0000
committerache <ache@FreeBSD.org>1999-11-30 16:15:22 +0000
commit7fecd4994597b3ca71fd3d28dafd18b8f04895b3 (patch)
treeae027dba924139e3acab01c99a515f4253d04917 /usr.sbin/lpr
parent6bb6d94196a5509b8054bd3fa893cdd6f389c639 (diff)
downloadFreeBSD-src-7fecd4994597b3ca71fd3d28dafd18b8f04895b3.zip
FreeBSD-src-7fecd4994597b3ca71fd3d28dafd18b8f04895b3.tar.gz
Add support for pr's locale
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r--usr.sbin/lpr/lpd/lpd.83
-rw-r--r--usr.sbin/lpr/lpd/printjob.c30
-rw-r--r--usr.sbin/lpr/lpr/lpr.16
-rw-r--r--usr.sbin/lpr/lpr/lpr.c18
4 files changed, 46 insertions, 11 deletions
diff --git a/usr.sbin/lpr/lpd/lpd.8 b/usr.sbin/lpr/lpd/lpd.8
index 5f34030..cde575f 100644
--- a/usr.sbin/lpr/lpd/lpd.8
+++ b/usr.sbin/lpr/lpd/lpd.8
@@ -190,6 +190,9 @@ File name. The name of the file which is being printed, or a blank
for the standard input (when
.Xr lpr
is invoked in a pipeline).
+.It Z
+Locale. String to be used as the locale for
+.Xr pr 1 .
.El
.Pp
If a file cannot be opened, a message will be logged via
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index 37cc960..a3e3f28 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -103,6 +103,7 @@ static int pfd; /* prstatic inter file descriptor */
static int pid; /* pid of lpd process */
static int prchild; /* id of pr process */
static char title[80]; /* ``pr'' title */
+static char locale[80]; /* ``pr'' locale */
static char class[32]; /* classification field */
static char fromhost[32]; /* user's host machine */
@@ -388,6 +389,7 @@ printit(pp, file)
* U -- "unlink" name of file to remove
* (after we print it. (Pass 2 only)).
* M -- "mail" to user when done printing
+ * Z -- "locale" for pr
*
* getline reads a line and expands tabs to blanks
*/
@@ -477,6 +479,11 @@ printit(pp, file)
indent[2+sizeof(indent) - 3] = '\0';
continue;
+ case 'Z': /* locale for pr */
+ strncpy(locale, line+1, sizeof(locale) - 1);
+ locale[sizeof(locale) - 1] = '\0';
+ continue;
+
default: /* some file to print */
switch (i = print(pp, line[0], line+1)) {
case ERROR:
@@ -546,7 +553,7 @@ print(pp, format, file)
int format;
char *file;
{
- register int n;
+ register int n, i;
register char *prog;
int fi, fo;
FILE *fp;
@@ -584,13 +591,16 @@ print(pp, format, file)
case 'p': /* print file using 'pr' */
if (pp->filters[LPF_INPUT] == NULL) { /* use output filter */
prog = _PATH_PR;
- av[0] = "pr";
- av[1] = width;
- av[2] = length;
- av[3] = "-h";
- av[4] = *title ? title : " ";
- av[5] = "-F";
- av[6] = 0;
+ i = 0;
+ av[i++] = "pr";
+ av[i++] = width;
+ av[i++] = length;
+ av[i++] = "-h";
+ av[i++] = *title ? title : " ";
+ av[i++] = "-L";
+ av[i++] = *locale ? locale : "C";
+ av[i++] = "-F";
+ av[i] = 0;
fo = ofd;
goto start;
}
@@ -601,7 +611,9 @@ print(pp, format, file)
closelog();
closeallfds(3);
execl(_PATH_PR, "pr", width, length,
- "-h", *title ? title : " ", "-F", 0);
+ "-h", *title ? title : " ",
+ "-L", *locale ? locale : "C",
+ "-F", 0);
syslog(LOG_ERR, "cannot execl %s", _PATH_PR);
exit(2);
}
diff --git a/usr.sbin/lpr/lpr/lpr.1 b/usr.sbin/lpr/lpr/lpr.1
index 6295042..396fa2d 100644
--- a/usr.sbin/lpr/lpr/lpr.1
+++ b/usr.sbin/lpr/lpr/lpr.1
@@ -44,6 +44,7 @@
.Op Fl \&# Ns Ar num
.Op Fl C Ar class
.Op Fl J Ar job
+.Op Fl L Ar locale
.Op Fl T Ar title
.Op Fl U Ar user
.Op Fl i Ar numcols
@@ -173,6 +174,11 @@ and the file foo.c to be printed.
.It Fl J Ar job
Job name to print on the burst page.
Normally, the first file's name is used.
+.It Fl L Ar locale
+Use
+.Ar locale
+specified as argument instead of one found in environment.
+Use "C" to reset locale to default.
.It Fl T Ar title
Title name for
.Xr pr 1 ,
diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c
index 9a19606..6a1a099 100644
--- a/usr.sbin/lpr/lpr/lpr.c
+++ b/usr.sbin/lpr/lpr/lpr.c
@@ -65,6 +65,7 @@ static const char rcsid[] =
#include <fcntl.h>
#include <a.out.h>
#include <err.h>
+#include <locale.h>
#include <signal.h>
#include <syslog.h>
#include <pwd.h>
@@ -98,6 +99,7 @@ static int sflag; /* symbolic link flag */
static int tfd; /* control file descriptor */
static char *tfname; /* tmp copy of cf before linking */
static char *title; /* pr'ing title */
+static char *locale; /* pr'ing locale */
static int userid; /* user id */
static char *Uflag; /* user name specified with -U flag */
static char *width; /* width for versatec printing */
@@ -152,7 +154,7 @@ main(argc, argv)
errs = 0;
while ((c = getopt(argc, argv,
- ":#:1:2:3:4:C:J:P:T:U:cdfghi:lnmprstvw:")) != -1)
+ ":#:1:2:3:4:C:J:L:P:T:U:cdfghi:lnmprstvw:")) != -1)
switch (c) {
case '#': /* n copies */
i = strtol(optarg, &p, 10);
@@ -183,6 +185,10 @@ main(argc, argv)
printer = optarg;
break;
+ case 'L': /* pr's locale */
+ locale = optarg;
+ break;
+
case 'T': /* pr's title line */
title = optarg;
break;
@@ -336,6 +342,14 @@ main(argc, argv)
card('1'+i, fonts[i]);
if (width != NULL)
card('W', width);
+ if (format == 'p') {
+ char *s;
+
+ if (locale)
+ card('Z', locale);
+ else if ((s = setlocale(LC_TIME, "")) != NULL)
+ card('Z', s);
+ }
/*
* Read the files and spool them.
@@ -722,7 +736,7 @@ usage()
{
fprintf(stderr, "%s\n%s\n",
"usage: lpr [-Pprinter] [-#num] [-C class] [-J job] [-T title] [-U user]",
-"[-i[numcols]] [-1234 font] [-wnum] [-cdfghlnmprstv] [name ...]");
+"[-i[numcols]] [-1234 font] [-L locale] [-wnum] [-cdfghlnmprstv] [name ...]");
exit(1);
}
OpenPOWER on IntegriCloud