diff options
author | antirez <antirez> | 2005-03-08 17:06:08 +0000 |
---|---|---|
committer | antirez <antirez> | 2005-03-08 17:06:08 +0000 |
commit | a0944453b0c6b1ef1f83713708cb41dd50e21925 (patch) | |
tree | d2fcddb7497fd09971ea5ef53aeae38ff5e3ecab /jimsh.c | |
parent | 4e213d5078ebbd043fdd9e8c8593ec8949c3cf92 (diff) | |
download | jimtcl-a0944453b0c6b1ef1f83713708cb41dd50e21925.zip jimtcl-a0944453b0c6b1ef1f83713708cb41dd50e21925.tar.gz jimtcl-a0944453b0c6b1ef1f83713708cb41dd50e21925.tar.bz2 |
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.c | 33 |
1 files changed, 25 insertions, 8 deletions
@@ -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; } |