Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / usbmodeswitch / jim / jim-readline.c
blob3990d0c0b3fb1ad1c29b3f053eb379a075d72e9f
2 /* Jim - Readline bindings for Jim
3 * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * A copy of the license is also included in the source distribution
12 * of Jim, as a TXT file name called LICENSE.
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include "jim.h"
22 #include "jimautoconf.h"
24 #include <readline/readline.h>
25 #include <readline/history.h>
27 static int JimRlReadlineCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
29 char *line;
31 if (argc != 2) {
32 Jim_WrongNumArgs(interp, 1, argv, "prompt");
33 return JIM_ERR;
35 line = readline(Jim_String(argv[1]));
36 if (!line) {
37 return JIM_EXIT;
39 Jim_SetResult(interp, Jim_NewStringObj(interp, line, -1));
40 return JIM_OK;
43 static int JimRlAddHistoryCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
45 if (argc != 2) {
46 Jim_WrongNumArgs(interp, 1, argv, "string");
47 return JIM_ERR;
49 add_history(Jim_String(argv[1]));
50 return JIM_OK;
53 int Jim_readlineInit(Jim_Interp *interp)
55 if (Jim_PackageProvide(interp, "readline", "1.0", JIM_ERRMSG))
56 return JIM_ERR;
58 Jim_CreateCommand(interp, "readline.readline", JimRlReadlineCommand, NULL, NULL);
59 Jim_CreateCommand(interp, "readline.addhistory", JimRlAddHistoryCommand, NULL, NULL);
60 return JIM_OK;