2
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
4
* Use is subject to the GNU General Public License, Version 2,
5
* June 1991, which is contained in the read-me file named
6
* "README_GNU_GPL." This program is free software; you can
7
* redistribute it and/or modify it under the terms of the GNU
8
* General Public License as published by the Free Software
9
* Foundation; either version 2 of the License, or (at your
10
* option) any later version. This library is distributed in the
11
* hope that it will be useful, but WITHOUT ANY WARRANTY; without
12
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU General Public License for
16
* You should have received a copy of the GNU General Public
17
* License along with this library; if not, write to the Free
18
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30
/* FIXME - timeout needed */
31
#define OPTIONS "sh1:i:"
33
int main(int argc, char **argv) {
35
int one, two, three, four, c, silent = 0;
36
char *line, ipstr[17], ipaddr[17];
41
opterr = 0; /* make getopt quiet */
45
strcpy(ipaddr, "000.000.000.000");
46
strcpy(ipstr, _("PRIMARY IP ADDR:"));
48
/* we silently ignore bad options. so, only -h returns usage. */
49
while ((c = getopt(argc, argv, OPTIONS)) != EOF) {
56
strncpy(ipstr, optarg, sizeof(ipstr) - 1);
60
strncpy(ipaddr, optarg, sizeof(ipaddr) - 1);
61
lcd_rev_format(ipaddr);
65
printf(_("Usage: %s [-1 <line text>] [-i <ip addr>]\n"),argv[0]);
74
if (!silent && (lcd_lock() < 0)) {
75
printf(_("LCD in use... try again later\n"));
79
if ((lcd = lcd_open(O_RDWR)) == NULL) {
80
printf(_("LCD is not present\n"));
85
lcd_set(lcd, LCD_Blink_Off);
86
lcd_wait_no_button(lcd);
87
lcd_write(lcd, ipstr, ipaddr);
88
lcd_setcursorpos(lcd, 0x40);
89
lcd_wait_no_button(lcd);
92
lcd_getdisplay(lcd, NULL, &line, NULL);
93
strncpy( ipaddr, line, 15 );
98
sscanf(ipaddr,"%d.%d.%d.%d", &one, &two, &three, &four);
99
if (one > 255) one = 0;
100
if (two > 255) two = 0;
101
if (three > 255) three = 0;
102
if (four > 255) four = 0;
103
printf("%d.%d.%d.%d",one,two,three,four);