busybox/printutils/parse_prt.c
Denis Vlasenko 68444b9f0c lpr and lpq applets by Walter Harms.
text    data     bss     dec     hex filename
    392       0       0     392     188 lpq.o
   1378       0       0    1378     562 lpr.o
    142       0       0     142      8e parse_prt.o
2008-02-22 22:24:48 +00:00

28 lines
634 B
C

/* vi: set sw=4 ts=4: */
/*
* Copyright 2008 Walter Harms (WHarms@bfs.de)
*
* Licensed under the GPL v2, see the file LICENSE in this tarball.
*/
#include "libbb.h"
#include "lpr.h"
void parse_prt(const char *buf, struct netprint *netprint)
{
const char *p;
if (!buf) {
buf = getenv("PRINTER");
if (!buf)
buf = "lp"; /* "...@localhost:515" is implied */
}
p = strchrnul(buf, '@');
netprint->queue = xstrndup(buf, p - buf);
if (!*p) /* just queue? example: "lpq -Pcopie" */
p = "localhost";
netprint->server = xstrdup(p);
netprint->lsa = xhost2sockaddr(netprint->server,
bb_lookup_port(NULL, "tcp", 515));
}