1 /*
2 * LASH
3 *
4 * Copyright (C) 2002 Robert Ham <rah@bash.sh>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include "config.h"
22
23 #include <lash/lash.h>
24
25 #include <getopt.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29
30 #include "lash_control.h"
31
32 static void
print_help()33 print_help()
34 {
35 printf("LASH Control version %s\n", PACKAGE_VERSION);
36 printf("Copyright (C) 2002 Robert Ham <rah@bash.sh>\n");
37 printf("\n");
38 printf
39 ("This program comes with ABSOLUTELY NO WARRANTY. You are licensed to use it\n");
40 printf
41 ("under the terms of the GNU General Public License, version 2 or later. See\n");
42 printf("the COPYING file that came with this software for details.\n");
43 printf("\n");
44 printf(" -h, --help Display this help info\n");
45 printf
46 (" --lash-server <host> Connect to server running on <host>\n");
47 printf(" --lash-port <port> Connect to server on port <port>\n");
48 printf("\n");
49 }
50
51 int
main(int argc,char ** argv)52 main(int argc, char **argv)
53 {
54 lash_control_t control;
55 lash_args_t *lash_args;
56 lash_client_t *lash_client;
57 int opt;
58 const char *options = "h";
59 struct option long_options[] = {
60 {"help", 0, NULL, 'h'},
61 {0, 0, 0, 0}
62 };
63
64 lash_args = lash_extract_args(&argc, &argv);
65
66 while ((opt = getopt_long(argc, argv, options, long_options, NULL)) != -1) {
67 switch (opt) {
68 case 'h':
69 print_help();
70 exit(0);
71 break;
72
73 case ':':
74 print_help();
75 exit(1);
76 break;
77 case '?':
78 print_help();
79 exit(1);
80 break;
81 }
82 }
83
84 lash_client =
85 lash_init(lash_args, "LASH Control",
86 LASH_Server_Interface | LASH_Terminal, LASH_PROTOCOL(2, 0));
87
88 if (!lash_client) {
89 fprintf(stderr, "%s: could not initialise lash\n", __FUNCTION__);
90 exit(1);
91 }
92
93 lash_control_init(&control);
94 control.client = lash_client;
95
96 lash_control_main(&control);
97
98 return 0;
99 }
100