diff options
Diffstat (limited to 'printutils/parse_prt.c')
-rw-r--r-- | printutils/parse_prt.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/printutils/parse_prt.c b/printutils/parse_prt.c new file mode 100644 index 000000000..2de0a9215 --- /dev/null +++ b/printutils/parse_prt.c | |||
@@ -0,0 +1,27 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Copyright 2008 Walter Harms (WHarms@bfs.de) | ||
4 | * | ||
5 | * Licensed under the GPL v2, see the file LICENSE in this tarball. | ||
6 | */ | ||
7 | #include "libbb.h" | ||
8 | #include "lpr.h" | ||
9 | |||
10 | void parse_prt(const char *buf, struct netprint *netprint) | ||
11 | { | ||
12 | const char *p; | ||
13 | |||
14 | if (!buf) { | ||
15 | buf = getenv("PRINTER"); | ||
16 | if (!buf) | ||
17 | buf = "lp"; /* "...@localhost:515" is implied */ | ||
18 | } | ||
19 | p = strchrnul(buf, '@'); | ||
20 | netprint->queue = xstrndup(buf, p - buf); | ||
21 | if (!*p) /* just queue? example: "lpq -Pcopie" */ | ||
22 | p = "localhost"; | ||
23 | netprint->server = xstrdup(p); | ||
24 | |||
25 | netprint->lsa = xhost2sockaddr(netprint->server, | ||
26 | bb_lookup_port(NULL, "tcp", 515)); | ||
27 | } | ||