source: trunk/athena/bin/lpr/ms.c @ 7907

Revision 7907, 990 bytes checked in by miki, 29 years ago (diff)
Initial revision
  • Property svn:executable set to *
Line 
1/*
2 * Implement ms capability.  Uses POSIX termios interface.
3 * James Clark (jjc@jclark.com) as part of lprps package.
4 */
5
6/*
7 * We don't want to include lp.h because of conflicts between
8 * <termios.h> and <sgtty> in SunOS.
9 */
10
11#if defined(i386)
12#undef _POSIX_SOURCE            /* 386BSD 0.1 no real POSIX ... */
13#endif
14
15#include <termios.h>
16#include <syslog.h>
17
18extern char     *printer;
19extern int      pfd;
20extern char     *MS;
21
22setms()
23{
24        struct termios t;
25        char *s;
26
27
28        syslog(LOG_ERR, "%s: %s" ,"MS", MS);
29        if (!MS) return;
30        if (tcgetattr(pfd, &t) < 0) {
31                syslog(LOG_ERR, "%s: tcgetattr: %m", printer);
32                exit(1);
33        }
34       
35        s = MS;
36        for (;;) {
37                char *p;
38                char saved;
39
40                for (p = s; *p != '\0' && *p != ','; p++)
41                        ;
42                saved = *p;
43                *p = '\0';
44                if (*s && setmode(&t, s) < 0)
45                        syslog(LOG_ERR, "%s: unknown mode: %s", printer, s);
46                if ((*p = saved) == '\0')
47                        break;
48                s = ++p;
49        }
50        if (tcsetattr(pfd, TCSADRAIN, &t) < 0) {
51                syslog(LOG_ERR, "%s: tcsetattr: %m", printer);
52                exit(1);
53        }
54}
Note: See TracBrowser for help on using the repository browser.