JS_SetBranchCallback(cx, my_BranchCallback);
main(int argc, char **argv){    JSVersion version;    JSRuntime *rt;    JSContext *cx;    JSObject *glob, *it;    int result;#ifdef LIVECONNECT    JavaVM *java_vm = NULL;#endif#ifdef JSDEBUGGER_JAVA_UI    JNIEnv *java_env;#endif#ifdef XP_OS2   /* these streams are normally line buffered on OS/2 and need a \n, *    * so we need to unbuffer then to get a reasonable prompt          */    setbuf(stdout,0);    setbuf(stderr,0);#endif    gErrFile = stderr;    gOutFile = stdout;#ifdef XP_MAC#ifndef XP_MAC_MPW	initConsole("\pJavaScript Shell", "Welcome to js shell.", &argc, &argv);#endif#endif#ifdef MAC_TEST_HACK/*        Open a file "testArgs.txt" and read each line into argc/argv.        Re-direct all output to "results.txt"*/        {                char argText[256];                FILE *f = fopen("testargs.txt", "r");                if (f != NULL) {                        int maxArgs = 32; /* arbitrary max !!! */                        argc = 1;                        argv = malloc(sizeof(char *) * maxArgs);                        argv[0] = NULL;                        while (fgets(argText, 255, f) != NULL) {                                 /* argText includes '\n' */                                argv[argc] = malloc(strlen(argText));                                strncpy(argv[argc], argText,                                                    strlen(argText) - 1);                                argv[argc][strlen(argText) - 1] = '\0';                                argc++;                                if (argc >= maxArgs) break;                        }                        fclose(f);                }                gTestResultFile = fopen("results.txt", "w");        }        gErrFile = gTestResultFile;        gOutFile = gTestResultFile;#endif    version = JSVERSION_DEFAULT;    argc--;    argv++;    rt = JS_NewRuntime(8L * 1024L * 1024L);    if (!rt)	return 1;    cx = JS_NewContext(rt, gStackChunkSize);    if (!cx)	return 1;    JS_SetErrorReporter(cx, my_ErrorReporter);    glob = JS_NewObject(cx, &global_class, NULL, NULL);    if (!glob)	return 1;    if (!JS_InitStandardClasses(cx, glob))	return 1;    if (!JS_DefineFunctions(cx, glob, shell_functions))	return 1;    /* Set version only after there is a global object. */    if (version != JSVERSION_DEFAULT)	JS_SetVersion(cx, version);    it = JS_DefineObject(cx, glob, "it", &its_class, NULL, 0);    if (!it)	return 1;    if (!JS_DefineProperties(cx, it, its_props))	return 1;#ifdef PERLCONNECT    if (!JS_InitPerlClass(cx, glob))	return 1;#endif#ifdef JSDEBUGGER    /*    * XXX A command line option to enable debugging (or not) would be good    */    _jsdc = JSD_DebuggerOnForUser(rt, NULL, NULL);    if (!_jsdc)	return 1;    JSD_JSContextInUse(_jsdc, cx);#ifdef JSD_LOWLEVEL_SOURCE    JS_SetSourceHandler(rt, SendSourceToJSDebugger, _jsdc);#endif /* JSD_LOWLEVEL_SOURCE */#ifdef JSDEBUGGER_JAVA_UI    _jsdjc = JSDJ_CreateContext();    if (! _jsdjc)	return 1;    JSDJ_SetJSDContext(_jsdjc, _jsdc);    java_env = JSDJ_CreateJavaVMAndStartDebugger(_jsdjc);#ifdef LIVECONNECT    if (java_env)	(*java_env)->GetJavaVM(java_env, &java_vm);#endif    /*    * XXX This would be the place to wait for the debugger to start.    * Waiting would be nice in general, but especially when a js file    * is passed on the cmd line.    */#endif /* JSDEBUGGER_JAVA_UI */#ifdef JSDEBUGGER_C_UI    JSDB_InitDebugger(rt, _jsdc, 0);#endif /* JSDEBUGGER_C_UI */#endif /* JSDEBUGGER */#ifdef LIVECONNECT	if (!JSJ_SimpleInit(cx, glob, java_vm, getenv("CLASSPATH")))	    return 1;#endif    result = ProcessArgs(cx, glob, argv, argc);#ifdef JSDEBUGGER    if (_jsdc)	JSD_DebuggerOff(_jsdc);#endif  /* JSDEBUGGER */#ifdef MAC_TEST_HACK    fclose(gTestResultFile);#endif    JS_DestroyContext(cx);    JS_DestroyRuntime(rt);    JS_ShutDown();    return result;}