blob: 264b6f55e84874c33039b99d24a2a6ace80a0ab8 [file] [log] [blame]
Colin Crossa3d386e2013-02-06 21:03:34 -08001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdio.h>
18#include <unistd.h>
Colin Crossa3d386e2013-02-06 21:03:34 -080019#include <cutils/klog.h>
Szymon Starzycki2a656c32013-09-05 14:26:28 -070020#include <getopt.h>
21#include <stdlib.h>
Colin Crossa3d386e2013-02-06 21:03:34 -080022
23#include "debug.h"
Szymon Starzyckib6c5f282013-07-24 17:08:04 -070024#include "trigger.h"
Szymon Starzycki2a656c32013-09-05 14:26:28 -070025#include "socket_client.h"
Colin Crossa3d386e2013-02-06 21:03:34 -080026
27unsigned int debug_level = DEBUG;
28
29void commands_init();
30void usb_init();
31void config_init();
Szymon Starzycki2a656c32013-09-05 14:26:28 -070032int transport_socket_init();
Colin Crossa3d386e2013-02-06 21:03:34 -080033
34int main(int argc, char **argv)
35{
Szymon Starzycki2a656c32013-09-05 14:26:28 -070036 int socket_client = 0;
37 int c;
38
39 klog_init();
40 klog_set_level(6);
41
42 const struct option longopts[] = {
43 {"socket", no_argument, 0, 'S'},
44 {0, 0, 0, 0}
45 };
46
47 while (1) {
48 c = getopt_long(argc, argv, "S", longopts, NULL);
49 /* Alphabetical cases */
50 if (c < 0)
51 break;
52 switch (c) {
53 case 'S':
54 socket_client = 1;
55 break;
56 case '?':
57 return 1;
58 default:
59 return 0;
60 }
61 }
62
Colin Crossa3d386e2013-02-06 21:03:34 -080063 (void)argc;
64 (void)argv;
65
66 klog_init();
67 klog_set_level(6);
68
Szymon Starzycki2a656c32013-09-05 14:26:28 -070069 if (socket_client) {
70 run_socket_client();
71 }
72 else {
73 config_init();
74 load_trigger();
75 commands_init();
76 usb_init();
77 if (!transport_socket_init())
78 exit(1);
79 while (1) {
80 sleep(1);
81 }
Colin Crossa3d386e2013-02-06 21:03:34 -080082 }
83 return 0;
84}