xref: /dpdk/examples/cmdline/main.c (revision e9d48c0072d36eb6423b45fba4ec49d0def6c36f)
1af75078fSIntel /*-
2af75078fSIntel  *   BSD LICENSE
3af75078fSIntel  *
4*e9d48c00SBruce Richardson  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5af75078fSIntel  *   All rights reserved.
6af75078fSIntel  *
7af75078fSIntel  *   Redistribution and use in source and binary forms, with or without
8af75078fSIntel  *   modification, are permitted provided that the following conditions
9af75078fSIntel  *   are met:
10af75078fSIntel  *
11af75078fSIntel  *     * Redistributions of source code must retain the above copyright
12af75078fSIntel  *       notice, this list of conditions and the following disclaimer.
13af75078fSIntel  *     * Redistributions in binary form must reproduce the above copyright
14af75078fSIntel  *       notice, this list of conditions and the following disclaimer in
15af75078fSIntel  *       the documentation and/or other materials provided with the
16af75078fSIntel  *       distribution.
17af75078fSIntel  *     * Neither the name of Intel Corporation nor the names of its
18af75078fSIntel  *       contributors may be used to endorse or promote products derived
19af75078fSIntel  *       from this software without specific prior written permission.
20af75078fSIntel  *
21af75078fSIntel  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22af75078fSIntel  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23af75078fSIntel  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24af75078fSIntel  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25af75078fSIntel  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26af75078fSIntel  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27af75078fSIntel  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28af75078fSIntel  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29af75078fSIntel  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30af75078fSIntel  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31af75078fSIntel  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32af75078fSIntel  */
33af75078fSIntel 
34af75078fSIntel /*
35af75078fSIntel  * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
36af75078fSIntel  * All rights reserved.
37af75078fSIntel  * Redistribution and use in source and binary forms, with or without
38af75078fSIntel  * modification, are permitted provided that the following conditions are met:
39af75078fSIntel  *
40af75078fSIntel  *     * Redistributions of source code must retain the above copyright
41af75078fSIntel  *       notice, this list of conditions and the following disclaimer.
42af75078fSIntel  *     * Redistributions in binary form must reproduce the above copyright
43af75078fSIntel  *       notice, this list of conditions and the following disclaimer in the
44af75078fSIntel  *       documentation and/or other materials provided with the distribution.
45af75078fSIntel  *     * Neither the name of the University of California, Berkeley nor the
46af75078fSIntel  *       names of its contributors may be used to endorse or promote products
47af75078fSIntel  *       derived from this software without specific prior written permission.
48af75078fSIntel  *
49af75078fSIntel  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
50af75078fSIntel  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
51af75078fSIntel  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
52af75078fSIntel  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
53af75078fSIntel  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
54af75078fSIntel  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
55af75078fSIntel  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
56af75078fSIntel  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57af75078fSIntel  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
58af75078fSIntel  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59af75078fSIntel  */
60af75078fSIntel 
61af75078fSIntel #include <stdio.h>
62af75078fSIntel #include <string.h>
63af75078fSIntel #include <stdint.h>
64af75078fSIntel #include <errno.h>
65af75078fSIntel #include <termios.h>
66af75078fSIntel #include <sys/queue.h>
67af75078fSIntel 
68af75078fSIntel #include <cmdline_rdline.h>
69af75078fSIntel #include <cmdline_parse.h>
70af75078fSIntel #include <cmdline_socket.h>
71af75078fSIntel #include <cmdline.h>
72af75078fSIntel 
73af75078fSIntel #include <rte_memory.h>
74af75078fSIntel #include <rte_memzone.h>
75af75078fSIntel #include <rte_tailq.h>
76af75078fSIntel #include <rte_eal.h>
77af75078fSIntel #include <rte_debug.h>
78af75078fSIntel 
79af75078fSIntel #include "commands.h"
80af75078fSIntel #include "main.h"
81af75078fSIntel 
82af75078fSIntel int MAIN(int argc, char **argv)
83af75078fSIntel {
84af75078fSIntel 	int ret;
85af75078fSIntel 	struct cmdline *cl;
86af75078fSIntel 
87af75078fSIntel 	ret = rte_eal_init(argc, argv);
88af75078fSIntel 	if (ret < 0)
89af75078fSIntel 		rte_panic("Cannot init EAL\n");
90af75078fSIntel 
91af75078fSIntel 	cl = cmdline_stdin_new(main_ctx, "example> ");
92af75078fSIntel 	if (cl == NULL)
93af75078fSIntel 		rte_panic("Cannot create cmdline instance\n");
94af75078fSIntel 	cmdline_interact(cl);
95af75078fSIntel 	cmdline_stdin_exit(cl);
96af75078fSIntel 
97af75078fSIntel 	return 0;
98af75078fSIntel }
99