summaryrefslogtreecommitdiff
path: root/jimsh.c
diff options
context:
space:
mode:
authorantirez <antirez>2005-03-08 17:06:08 +0000
committerantirez <antirez>2005-03-08 17:06:08 +0000
commita0944453b0c6b1ef1f83713708cb41dd50e21925 (patch)
treed2fcddb7497fd09971ea5ef53aeae38ff5e3ecab /jimsh.c
parent4e213d5078ebbd043fdd9e8c8593ec8949c3cf92 (diff)
Did some fix in jimsh.c, exported some more API function to set
variables and global variables using a string C as name instead of a Jim_Obj. This is more handy in mani conditions.
Diffstat (limited to 'jimsh.c')
-rw-r--r--jimsh.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/jimsh.c b/jimsh.c
index 41fca1f..4d0d27c 100644
--- a/jimsh.c
+++ b/jimsh.c
@@ -1,3 +1,24 @@
+/* Jimsh - An interactive shell for Jim
+ * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
+ *
+ * $Id: jimsh.c,v 1.3 2005/03/08 17:06:08 antirez Exp $
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * A copy of the license is also included in the source distribution
+ * of Jim, as a TXT file name called LICENSE.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <stdio.h>
#include <stdlib.h>
@@ -8,7 +29,7 @@ int main(int argc, char *const argv[])
{
int retcode, n;
Jim_Interp *interp;
- Jim_Obj *listObj, *argObj[2];
+ Jim_Obj *listObj;
Jim_InitEmbedded(); /* This is the first function embedders should call. */
@@ -18,15 +39,12 @@ int main(int argc, char *const argv[])
listObj = Jim_NewListObj(interp, NULL, 0);
for (n = 2; n < argc; n++) {
- Jim_Obj *obj = Jim_NewStringObjNoAlloc(interp, argv[n], -1);
+ Jim_Obj *obj = Jim_NewStringObj(interp, argv[n], -1);
Jim_ListAppendElement(interp, listObj, obj);
}
- argObj[0] = Jim_NewStringObj(interp, "argv0", -1);
- argObj[1] = Jim_NewStringObj(interp, "argv", -1);
- for (n = 0; n < 2; n++) Jim_IncrRefCount(argObj[n]);
- Jim_SetVariable(interp, argObj[0], Jim_NewStringObjNoAlloc(interp, argv[0], -1));
- Jim_SetVariable(interp, argObj[1], listObj);
+ Jim_SetVariableStr(interp, "argv0", Jim_NewStringObj(interp, argv[0], -1));
+ Jim_SetVariableStr(interp, "argv", listObj);
if (argc == 1) {
retcode = Jim_InteractivePrompt(interp);
@@ -36,7 +54,6 @@ int main(int argc, char *const argv[])
}
}
- for (n = 0; n < 2; n++) Jim_DecrRefCount(interp, argObj[n]);
Jim_FreeInterp(interp);
return retcode;
}