lptcontrol.c (2ae9a4a0794ece63c5a137b02b43b43a17cfedb4) lptcontrol.c (167ce4fb005015eb751409c9838051b28f44b524)
1/*
2 * Copyright (c) 1994 Geoffrey M. Rehmet
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 42 unchanged lines hidden (view full) ---

51#define PATH_LPCTL _PATH_DEV "lpctl"
52#define DEFAULT_DEVICE _PATH_DEV "lpt0"
53#define IRQ_INVALID -1
54#define DO_POLL 0
55#define USE_IRQ 1
56#define USE_EXT_MODE 2
57#define USE_STD_MODE 3
58
1/*
2 * Copyright (c) 1994 Geoffrey M. Rehmet
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 42 unchanged lines hidden (view full) ---

51#define PATH_LPCTL _PATH_DEV "lpctl"
52#define DEFAULT_DEVICE _PATH_DEV "lpt0"
53#define IRQ_INVALID -1
54#define DO_POLL 0
55#define USE_IRQ 1
56#define USE_EXT_MODE 2
57#define USE_STD_MODE 3
58
59static void usage()
59static void usage(void)
60{
61 fprintf(stderr, "usage: lptcontrol -i | -p | -s | -e [-d device]\n");
62 exit(1);
63}
64
65static void set_interrupt_status(int irq_status, const char * file)
66{
67 int fd;

--- 4 unchanged lines hidden (view full) ---

72 err(1, "ioctl");
73 close(fd);
74}
75
76int main (int argc, char * argv[])
77{
78 int opt;
79 int irq_status = IRQ_INVALID;
60{
61 fprintf(stderr, "usage: lptcontrol -i | -p | -s | -e [-d device]\n");
62 exit(1);
63}
64
65static void set_interrupt_status(int irq_status, const char * file)
66{
67 int fd;

--- 4 unchanged lines hidden (view full) ---

72 err(1, "ioctl");
73 close(fd);
74}
75
76int main (int argc, char * argv[])
77{
78 int opt;
79 int irq_status = IRQ_INVALID;
80 char *device = DEFAULT_DEVICE;
80 const char *device = DEFAULT_DEVICE;
81
82 while((opt = getopt(argc, argv, "ipesd:")) != -1)
83 switch(opt) {
84 case 'i': irq_status = USE_IRQ; break;
85 case 'p': irq_status = DO_POLL; break;
86 case 'e': irq_status = USE_EXT_MODE; break;
87 case 's': irq_status = USE_STD_MODE; break;
88 case 'd': device = optarg; break;
89 default : usage();
90 }
91 if(irq_status == IRQ_INVALID)
92 usage();
93
94 set_interrupt_status(irq_status, device);
95
96 exit(0);
97}
81
82 while((opt = getopt(argc, argv, "ipesd:")) != -1)
83 switch(opt) {
84 case 'i': irq_status = USE_IRQ; break;
85 case 'p': irq_status = DO_POLL; break;
86 case 'e': irq_status = USE_EXT_MODE; break;
87 case 's': irq_status = USE_STD_MODE; break;
88 case 'd': device = optarg; break;
89 default : usage();
90 }
91 if(irq_status == IRQ_INVALID)
92 usage();
93
94 set_interrupt_status(irq_status, device);
95
96 exit(0);
97}