source: BAORadio/libindi/v1.0.1/indidrivermain.c @ 652

Last change on this file since 652 was 501, checked in by frichard, 14 years ago

-BAOControl : petite interface permettant de contrôler les antennes via le pilote indi_BAO
-Le pilote indi_BAO utilise désormais libindi v 0.7

File size: 2.8 KB
Line 
1#if 0
2    INDI
3    Copyright (C) 2003-2006 Elwood C. Downey
4
5                        Updated by Jasem Mutlaq (2003-2010)
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 of the License, or (at your option) any later version.
11
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this library; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
21#endif
22
23/* main() for one INDI driver process.
24 * Drivers define IS*() functions we call to deliver INDI XML arriving on stdin.
25 * Drivers call ID*() functions to send INDI XML commands to stdout.
26 * Drivers call IE*() functions to build an event-driver program.
27 * Drivers call IU*() functions to perform various common utility tasks.
28 * Troubles are reported on stderr then we exit.
29 *
30 * This requires liblilxml.
31 */
32
33#include <stdio.h>
34#include <stdlib.h>
35#include <stdarg.h>
36#include <string.h>
37#include <errno.h>
38#include <time.h>
39#include <unistd.h>
40#include <sys/types.h>
41#include <sys/stat.h>
42
43#include "lilxml.h"
44#include "base64.h"
45#include "eventloop.h"
46#include "indidevapi.h"
47#include "indicom.h"
48#include "indidriver.h"
49
50#define MAXRBUF 2048
51
52ROSC *roCheck;
53int nroCheck;                   /* # of elements in roCheck */
54
55int verbose;                    /* chatty */
56char *me;                               /* a.out name */
57LilXML *clixml;                 /* XML parser context */
58
59static void  usage(void);
60
61int
62main (int ac, char *av[])
63{
64#ifndef _WIN32
65        setgid( getgid() );
66        setuid( getuid() );
67
68        if (geteuid() != getuid())
69            exit(255);
70#endif
71
72        /* save handy pointer to our base name */
73        for (me = av[0]; av[0][0]; av[0]++)
74            if (av[0][0] == '/')
75                me = &av[0][1];
76
77        /* crack args */
78        while (--ac && (*++av)[0] == '-')
79            while (*++(*av))
80                switch (*(*av)) {
81                case 'v':       /* verbose */
82                    verbose++;
83                    break;
84                default:
85                    usage();
86                }
87
88        /* ac remaining args starting at av[0] */
89        if (ac > 0)
90            usage();
91
92        /* init */
93        clixml =  newLilXML();
94        addCallback (0, clientMsgCB, NULL);
95
96        /* service client */
97        eventLoop();
98
99        /* eh?? */
100        fprintf (stderr, "%s: inf loop ended\n", me);
101        return (1);
102}
103
104/* print usage message and exit (1) */
105static void  usage(void)
106{
107            fprintf (stderr, "Usage: %s [options]\n", me);
108            fprintf (stderr, "Purpose: INDI Device driver framework.\n");
109            fprintf (stderr, "Options:\n");
110            fprintf (stderr, " -v    : more verbose to stderr\n");
111
112            exit (1);
113}
114
Note: See TracBrowser for help on using the repository browser.