aboutsummaryrefslogtreecommitdiffstats
path: root/missing
blob: 22e101ab1b08c028dd6774e833f46e9ec225977d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc.
# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

if test $# -eq 0; then
  echo 1>&2 "Try \`$0 --help' for more information"
  exit 1
fi

# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.in; then
  configure_ac=configure.ac
else
  configure_ac=configure.in
fi

case "$1" in

  -h|--h|--he|--hel|--help)
    echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...

Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.

Options:
  -h, --help      display this help and exit
  -v, --version   output version information and exit

Supported PROGRAM values:
  aclocal      touch file \`aclocal.m4'
  autoconf     touch file \`configure'
  autoheader   touch file \`config.h.in'
  automake     touch all \`Makefile.in' files
  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
  flex         create \`lex.yy.c', if possible, from existing .c
  lex          create \`lex.yy.c', if possible, from existing .c
  makeinfo     touch the output file
  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
    ;;

  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
    echo "missing - GNU libit 0.0"
    ;;

  -*)
    echo 1>&2 "$0: Unknown \`$1' option"
    echo 1>&2 "Try \`$0 --help' for more information"
    exit 1
    ;;

  aclocal*)
    echo 1>&2 "\
WARNING: \`$1' is missing on your system.  You should only need it if
         you modified \`acinclude.m4' or \`$configure_ac'.  You might want
         to install the \`Automake' and \`Perl' packages.  Grab them from
         any GNU archive site."
    touch aclocal.m4
    ;;

  autoconf)
    echo 1>&2 "\
WARNING: \`$1' is missing on your system.  You should only need it if
         you modified \`$configure_ac'.  You might want to install the
         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
         archive site."
    touch configure
    ;;

  autoheader)
    echo 1>&2 "\
WARNING: \`$1' is missing on your system.  You should only need it if
         you modified \`acconfig.h' or \`$configure_ac'.  You might want
         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
         from any GNU archive site."
    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' $configure_ac`
    test -z "$files" && files="config.h"
    touch_files=
    for f in $files; do
      case "$f" in
      *:*) touch_files="$touch_files "`echo "$f" |
				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
      *) touch_files="$touch_files $f.in";;
      esac
    done
    touch $touch_files
    ;;

  automake*)
    echo 1>&2 "\
WARNING: \`$1' is missing on your system.  You should only need it if
         you modified \`Makefile.am', \`acinclude.m4' or \`$configure_ac'.
         You might want to install the \`Automake' and \`Perl' packages.
         Grab them from any GNU archive site."
    find . -type f -name Makefile.am -print |
	   sed 's/\.am$/.in/' |
	   while read f; do touch "$f"; done
    ;;

  bison|yacc)
    echo 1>&2 "\
WARNING: \`$1' is missing on your system.  You should only need it if
         you modified a \`.y' file.  You may need the \`Bison' package
         in order for those modifications to take effect.  You can get
         \`Bison' from any GNU archive site."
    rm -f y.tab.c y.tab.h
    if [ $# -ne 1 ]; then
        eval LASTARG="\${$#}"
	case "$LASTARG" in
	*.y)
	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
	    if [ -f "$SRCFILE" ]; then
	         cp "$SRCFILE" y.tab.c
	    fi
	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
	    if [ -f "$SRCFILE" ]; then
	         cp "$SRCFILE" y.tab.h
	    fi
	  ;;
	esac
    fi
    if [ ! -f y.tab.h ]; then
	echo >y.tab.h
    fi
    if [ ! -f y.tab.c ]; then
	echo 'main() { return 0; }' >y.tab.c
    fi
    ;;

  lex|flex)
    echo 1>&2 "\
WARNING: \`$1' is missing on your system.  You should only need it if
         you modified a \`.l' file.  You may need the \`Flex' package
         in order for those modifications to take effect.  You can get
         \`Flex' from any GNU archive site."
    rm -f lex.yy.c
    if [ $# -ne 1 ]; then
        eval LASTARG="\${$#}"
	case "$LASTARG" in
	*.l)
	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
	    if [ -f "$SRCFILE" ]; then
	         cp "$SRCFILE" lex.yy.c
	    fi
	  ;;
	esac
    fi
    if [ ! -f lex.yy.c ]; then
	echo 'main() { return 0; }' >lex.yy.c
    fi
    ;;

  makeinfo)
    echo 1>&2 "\
WARNING: \`$1' is missing on your system.  You should only need it if
         you modified a \`.texi' or \`.texinfo' file, or any other file
         indirectly affecting the aspect of the manual.  The spurious
         call might also be the consequence of using a buggy \`make' (AIX,
         DU, IRIX).  You might want to install the \`Texinfo' package or
         the \`GNU make' package.  Grab either from any GNU archive site."
    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
    if test -z "$file"; then
      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
    fi
    touch $file
    ;;

  *)
    echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
         system.  You might have modified some files without having the
         proper tools for further handling them.  Check the \`README' file,
         it often tells you about the needed prerequirements for installing
         this package.  You may also peek at any GNU archive site, in case
         some other package would contain this missing \`$1' program."
    exit 1
    ;;
esac

exit 0
* new debugging scheme: error(), info(), debug() * uses syslog if in daemon mode * * Revision 1.25 2000/08/09 14:14:11 reinelt * * new switch -F (do not fork) * added automatic forking if -F not specified * * Revision 1.24 2000/08/09 09:50:29 reinelt * * opened 0.98 development * removed driver-specific signal-handlers * added 'quit'-function to driver structure * added global signal-handler * * Revision 1.23 2000/04/17 05:14:27 reinelt * * added README.44780 * * Revision 1.22 2000/04/15 16:56:52 reinelt * * moved delay loops to udelay.c * renamed -d (debugging) switch to -v (verbose) * new switch -d to calibrate delay loop * 'Delay' entry for HD44780 back again * delay loops will not calibrate automatically, because this will fail with hich CPU load * * Revision 1.21 2000/04/15 11:56:35 reinelt * * more debug messages * * Revision 1.20 2000/04/15 11:13:54 reinelt * * added '-d' (debugging) switch * added several debugging messages * removed config entry 'Delay' for HD44780 driver * delay loop for HD44780 will be calibrated automatically * * Revision 1.19 2000/04/10 04:40:53 reinelt * * minor changes and cleanups * * Revision 1.18 2000/04/07 05:42:20 reinelt * * UUCP style lockfiles for the serial port * * Revision 1.17 2000/04/03 17:31:52 reinelt * * suppress welcome message if display is smaller than 20x2 * change lcd4linux.ppm to 32 pixel high so KDE won't stretch the icon * * Revision 1.16 2000/04/03 04:46:38 reinelt * * added '-c key=val' option * * Revision 1.15 2000/04/01 22:40:42 herp * geometric correction (too many pixelgaps) * lcd4linux main should return int, not void * * Revision 1.14 2000/03/26 18:46:28 reinelt * * bug in pixmap.c that leaded to empty bars fixed * name conflicts with X11 resolved * * Revision 1.13 2000/03/26 12:55:03 reinelt * * enhancements to the PPM driver * * Revision 1.12 2000/03/25 05:50:43 reinelt * * memory leak in Raster_flush closed * driver family logic changed * * Revision 1.11 2000/03/24 11:36:56 reinelt * * new syntax for raster configuration * changed XRES and YRES to be configurable * PPM driver works nice * * Revision 1.10 2000/03/23 07:24:48 reinelt * * PPM driver up and running (but slow!) * * Revision 1.9 2000/03/22 15:36:21 reinelt * * added '-l' switch (list drivers) * generic pixmap driver added * X11 Framework done * * Revision 1.8 2000/03/22 07:33:50 reinelt * * FAQ added * new modules 'processor.c' contains all data processing * * Revision 1.7 2000/03/19 08:41:28 reinelt * * documentation available! README, README.MatrixOrbital, README.Drivers * added Skeleton.c as a starting point for new drivers * * Revision 1.6 2000/03/18 10:31:06 reinelt * * added sensor handling (for temperature etc.) * made data collecting happen only if data is used * (reading /proc/meminfo takes a lot of CPU!) * released lcd4linux-0.92 * * Revision 1.5 2000/03/18 08:07:04 reinelt * * vertical bars implemented * bar compaction improved * memory information implemented * * Revision 1.4 2000/03/17 09:21:42 reinelt * * various memory statistics added * * Revision 1.3 2000/03/13 15:58:24 reinelt * * release 0.9 * moved row parsing to parser.c * all basic work finished * * Revision 1.2 2000/03/10 17:36:02 reinelt * * first unstable but running release * */ #include "config.h" #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <signal.h> #include <time.h> #include "cfg.h" #include "debug.h" #include "pid.h" #include "udelay.h" #include "drv.h" #include "timer.h" #include "layout.h" #include "plugin.h" #ifdef WITH_DMALLOC #include <dmalloc.h> #endif #define PIDFILE "/var/run/lcd4linux.pid" static char *release="LCD4Linux " VERSION " (c) 2003 Michael Reinelt <reinelt@eunet.at>"; static char **my_argv; static int got_signal=0; int tick, tack; extern char* output; static void usage(void) { printf ("%s\n", release); printf ("usage: lcd4linux [-h]\n"); printf (" lcd4linux [-l]\n"); printf (" lcd4linux [-c key=value] [-i] [-f config-file] [-v]\n"); printf (" lcd4linux [-c key=value] [-F] [-f config-file] [-o output-file] [-q] [-v]\n"); } #if 0 // Fixme: how to hello() with new layout? int hello (void) { int i, x, y, flag; char *line1[] = { "* LCD4Linux " VERSION " *", "LCD4Linux " VERSION, "LCD4Linux", "L4Linux", NULL }; char *line2[] = { "(c) 2003 M.Reinelt", "(c) M.Reinelt", NULL }; lcd_query (&y, &x, NULL, NULL, NULL, NULL, NULL); flag=0; for (i=0; line1[i]; i++) { if (strlen(line1[i])<=x) { lcd_put (1, (x-strlen(line1[i]))/2+1, line1[i]); flag=1; break; } } for (i=0; line2[i]; i++) { if (strlen(line2[i])<=x) { lcd_put (2, (x-strlen(line2[i]))/2+1, line2[i]); flag=1; break; } } if (flag) lcd_flush(); return flag; } #endif void handler (int signal) { debug ("got signal %d", signal); got_signal=signal; } int main (int argc, char *argv[]) { char *cfg="/etc/lcd4linux.conf"; char *display, *driver, *layout; char section[32]; int c; int quiet=0; int interactive=0; // save arguments for restart my_argv=malloc(sizeof(char*)*(argc+1)); for (c=0; c<argc; c++) { my_argv[c]=strdup(argv[c]); } my_argv[c]=NULL; running_foreground=0; running_background=0; while ((c=getopt (argc, argv, "c:Ff:hilo:qv"))!=EOF) { switch (c) { case 'c': if (cfg_cmd (optarg)<0) { fprintf (stderr, "%s: illegal argument -c '%s'\n", argv[0], optarg); exit(2); } break; case 'F': running_foreground++; break; case 'f': cfg=optarg; break; case 'h': usage(); exit(0); case 'i': interactive++; break; case 'l': printf ("%s\n", release); drv_list(); exit(0); case 'o': output=optarg; break; case 'q': quiet++; break; case 'v': verbose_level++; break; default: exit(2); } } if (optind < argc) { fprintf (stderr, "%s: illegal option %s\n", argv[0], argv[optind]); exit(2); } // do not fork in interactive mode if (interactive) { running_foreground=1; } info ("Version " VERSION " starting"); if (!running_foreground && (my_argv[0]==NULL || my_argv[0][0]!='/')) { info ("invoked without full path; restart may not work!"); } if (cfg_init(cfg)==-1) exit (1); if (plugin_init()==-1) exit (1); display=cfg_get(NULL, "Display", NULL); if (display==NULL || *display=='\0') { error ("missing 'Display' entry in %s!", cfg_source()); exit (1); } snprintf (section, sizeof(section), "Display:%s", display); driver=cfg_get(section, "Driver", NULL); if (driver==NULL || *driver=='\0') { error ("missing '%s.Driver' entry in %s!", section, cfg_source()); exit (1); } if (!running_foreground) { pid_t i; int fd; debug ("going background..."); i=fork(); if (i<0) { error ("fork() failed: %s", strerror(errno)); exit (1); } if (i!=0) exit (0); // ignore nasty signals signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); // chdir("/") if (chdir("/")!=0) { error ("chdir(\"/\") failed: %s", strerror(errno)); exit (1); } // we want full control over permissions umask (0); // detach stdin if (freopen("/dev/null", "r", stdin)==NULL) { error ("freopen (/dev/null) failed: %s", strerror(errno)); exit (1); } // detach stdout and stderr fd=open("/dev/null", O_WRONLY, 0666); if (fd==-1) { error ("open (/dev/null) failed: %s", strerror(errno)); exit (1); } fflush(stdout); fflush(stderr); dup2(fd, STDOUT_FILENO); dup2(fd, STDERR_FILENO); close(fd); // create PID file if (pid_init(PIDFILE)!=0) { error ("PID file creation failed!"); exit (1); } // now we are a daemon running_background=1; } debug ("initializing driver %s", driver); if (drv_init(section, driver)==-1) { pid_exit(PIDFILE); exit (1); } // check for new-style layout layout=cfg_get(NULL, "Layout", NULL); if (layout==NULL || *layout=='\0') { error ("missing 'Layout' entry in %s!", cfg_source()); exit (1); } layout_init(layout); // maybe go into interactive mode if (interactive) { char line[1024]; RESULT result = {0, 0.0, NULL}; printf("\neval> "); for(fgets(line, 1024, stdin); !feof(stdin); fgets(line, 1024, stdin)) { if (line[strlen(line)-1]=='\n') line[strlen(line)-1]='\0'; if (strlen(line)>0) { Eval(line, &result); if (result.type==R_NUMBER) { printf ("%g\n", R2N(&result)); } else if (result.type==R_STRING) { printf ("'%s'\n", R2S(&result)); } DelResult (&result); } printf("eval> "); } printf ("\n"); drv_quit(); pid_exit(PIDFILE); cfg_exit(); exit (0); } // check the conf to see if quiet startup is wanted if (!quiet) { cfg_number(NULL, "Quiet", 0, 0, 1, &quiet); } #if 0 // Fixme: how to hello() with new layout? if (!quiet && hello()) { sleep (3); lcd_clear(1); } #endif debug ("starting main loop"); // now install our own signal handler signal(SIGHUP, handler); signal(SIGINT, handler); signal(SIGQUIT, handler); signal(SIGTERM, handler); while (got_signal==0) { struct timespec delay; if (timer_process(&delay)<0) break; nanosleep(&delay, NULL); } debug ("leaving main loop"); #if 0 // Fixme: how to hello() with new layout? lcd_clear(1); if (!quiet) hello(); #endif drv_quit(); pid_exit(PIDFILE); cfg_exit(); if (got_signal==SIGHUP) { long fd; debug ("restarting..."); // close all files on exec for (fd=sysconf(_SC_OPEN_MAX); fd>2; fd--) { int flag; if ((flag=fcntl(fd,F_GETFD,0))!=-1) fcntl(fd,F_SETFD,flag|FD_CLOEXEC); } execv (my_argv[0], my_argv); error ("execv() failed: %s", strerror(errno)); exit(1); } exit (0); }