Example #1
0
/*
 *   Deletion 
 */
TadsListenerThread::~TadsListenerThread()
{
    /* release our port, if we have one */
    if (port != 0)
        port->release_ref();
    
    /* release our quit event and shutdown event */
    quit_evt->release_ref();
    shutdown_evt->release_ref();
    
    /* release our mutex */
    mutex->release_ref();
    
    /* free the error message string */
    lib_free_str(errmsg);

    /* free the password string */
    lib_free_str(password);
    
    /* 
     *   Release all of our server threads.  Note that we don't need to
     *   protect against concurrent access here because we know that no one
     *   has a reference to this object any longer - it's the only way we can
     *   be deleted.  
     */
    TadsServerThread *tcur, *tnxt;
    for (tcur = servers ; tcur != 0 ; tcur = tnxt)
    {
        /* remember the next one, and release this one */
        tnxt = tcur->next_server;
        tcur->release_ref();
    }
}
Example #2
0
/*
 *   Get the listener IP address 
 */
int CVmObjHTTPServer::getp_get_ip(VMG_ vm_obj_id_t self,
                                  vm_val_t *retval, uint *oargc)
{
    static CVmNativeCodeDesc desc(0);
    if (get_prop_check_argc(retval, oargc, &desc))
        return TRUE;

    /* return the IP address */
    char *ip, *addr;
    int port;
    if (get_listener_addr(addr, ip, port))
    {
        /* got it - return the string value */
        G_interpreter->push_string(vmg_ ip);
        G_stk->pop(retval);

        /* free the source strings */
        lib_free_str(addr);
        lib_free_str(ip);
    }
    else
    {
        /* no IP address - return nil */
        retval->set_nil();
    }

    /* handled */
    return TRUE;
}
Example #3
0
/* payload item destruction */
OS_HttpPayloadItem::~OS_HttpPayloadItem()
{
    lib_free_str(name);
    lib_free_str(val);
    lib_free_str(mime_type);
    if (stream != 0)
        delete stream;
}
Example #4
0
/* 
 *   notify of deletion 
 */
void CVmObjHTTPServer::notify_delete(VMG_ int /*in_root_set*/)
{
    /* free our additional data, if we have any */
    vm_httpsrv_ext *ext = get_ext();
    if (ext != 0)
    {
        /* shut down the listener */
        if (ext->l != 0)
        {
            /* tell it to terminate */
            ext->l->shutdown();

            /* 
             *   Notify the listener thread that we're being deleted, so that
             *   it can drop its reference on us.  The listener thread object
             *   keeps a reference on us, but it isn't itself a
             *   garbage-collected object, so its reference on us won't
             *   prevent us from being deleted.  We therefore need to
             *   manually remove its reference on us when we're about to be
             *   deleted.  
             */
            ((TadsHttpListenerThread *)ext->l->get_thread())
                ->detach_server_obj();
            
            /* we're done with the listener object */
            ext->l->release_ref();
        }

        /* delete our address string */
        lib_free_str(ext->addr);

        /* delete the extension */
        G_mem->get_var_heap()->free_mem(ext_);
    }
}
Example #5
0
/*
 *   delete 
 */
CVmHostIfcStdio::~CVmHostIfcStdio()
{
    /* delete our system resource loader */
    delete sys_res_loader_;

    /* delete our saved argv[0] */
    lib_free_str(argv0_);
}
Example #6
0
/*
 *   delete 
 */
CVmHostIfcStdio::~CVmHostIfcStdio()
{
    /* delete our character map resource loader */
    delete cmap_loader_;

    /* delete our saved argv[0] */
    lib_free_str(argv0_);
}
Example #7
0
/*
 *   Get the port number
 */
int CVmObjHTTPServer::getp_get_port(VMG_ vm_obj_id_t self,
                                    vm_val_t *retval, uint *oargc)
{
    static CVmNativeCodeDesc desc(0);
    if (get_prop_check_argc(retval, oargc, &desc))
        return TRUE;

    /* return the port number */
    char *addr, *ip;
    int port;
    if (get_listener_addr(addr, ip, port))
    {
        retval->set_int(port);
        lib_free_str(addr);
        lib_free_str(ip);
    }
    else
        retval->set_nil();

    /* handled */
    return TRUE;
}
Example #8
0
    ~HttpReqThread()
    {
        /* establish the global context */
        VMGLOB_PTR(vmg);

        /* delete copied strings */
        lib_free_str(host);
        lib_free_str(resource);
        lib_free_str(verb);
        lib_free_str(hdrs);

        /* delete the content body */
        if (body != 0)
            delete body;

        /* release the message queue */
        if (queue != 0)
            queue->release_ref();

        /* delete our ID global, if we still own it */
        if (idg != 0)
            G_obj_table->delete_global_var(idg);

    }
Example #9
0
/*
 *   delete the compiler driver 
 */
CTcMain::~CTcMain()
{
    /* if there's a disassembly stream, delete it */
    if (G_disasm_out != 0)
        delete G_disasm_out;

    /* delete the various data streams */
    delete G_cs_main;
    delete G_cs_static;
    delete G_ds;
    delete G_os;
    delete G_icmod_stream;
    delete G_dict_stream;
    delete G_gramprod_stream;
    delete G_bignum_stream;
    delete G_int_class_stream;
    delete G_static_init_id_stream;
    delete G_lcl_stream;

    /* delete the console output character map, if there is one */
    if (console_mapper_ != 0)
    {
        /* release our reference on it */
        console_mapper_->release_ref();

        /* forget it (since it's static) */
        console_mapper_ = 0;
    }

    /* delete the target-specific code generator */
    delete G_cg;

    /* delete the parser and node memory pool */
    delete G_prs;
    delete G_prsmem;

    /* delete the parser */
    delete G_tok;

    /* delete our default character set name string */
    lib_free_str(default_charset_);
}
Example #10
0
    ~TadsHttpReqResult()
    {
        /* establish the global context */
        VMGLOB_PTR(vmg);

        /* delete our ID global */
        G_obj_table->delete_global_var(idg);

        /* delete the reply object */
        if (reply != 0)
            delete reply;

        /* free the reply headers */
        if (hdrs != 0)
            delete [] hdrs;

        /* free the redirect location string, if we have one */
        if (loc != 0)
            lib_free_str(loc);
    }
Example #11
0
/*
 *   delete resource loader 
 */
CResLoader::~CResLoader()
{
    /* free our root directory string and executable path string */
    lib_free_str(root_dir_);
    lib_free_str(exe_filename_);
}
Example #12
0
/*
 *   Connect to the Web UI
 */
void CVmBifNet::connect_ui(VMG_ uint oargc)
{
    /* check arguments */
    check_argc(vmg_ oargc, 2);

    /* get the server object */
    vm_val_t *srv = G_stk->get(0);
    if (srv->typ != VM_OBJ
        || !CVmObjHTTPServer::is_httpsrv_obj(vmg_ srv->val.obj))
        err_throw(VMERR_BAD_TYPE_BIF);

    /* get the object pointer properly cast */
    CVmObjHTTPServer *srvp = (CVmObjHTTPServer *)vm_objp(vmg_ srv->val.obj);

    /* get the URL path */
    const char *path = G_stk->get(1)->get_as_string(vmg0_);
    if (path == 0)
        err_throw(VMERR_BAD_TYPE_BIF);

    /* make a null-terminated copy of the path */
    char *pathb = lib_copy_str(path + VMB_LEN, vmb_get_len(path));

    /* get the server network address information */
    char *errmsg = 0;
    char *addr = 0, *ip = 0;
    int port;
    int ok = srvp->get_listener_addr(addr, ip, port);

    /* 
     *   If we don't have a network configuration yet, create one.  This
     *   notifies other subsystems that we have an active web UI; for
     *   example, the presence of a network UI disables the regular console
     *   UI, since all UI actions have to go through the web UI once it's
     *   established.
     *   
     *   The interpreter startup creates a network configuration if it
     *   receives command-line information telling it that the game was
     *   launched by a Web server in response to an incoming client request.
     *   When the user launches the game in stand-alone mode directly from
     *   the operating system shell, there's no Web server launch
     *   information, so the startup code doesn't create a net config object.
     *   So, if we get here and find we don't have this object, it means that
     *   we're running in local standalone mode.  
     */
    if (G_net_config == 0)
        G_net_config = new TadsNetConfig();

    /* connect */
    if (ok)
    {
        /* connect */
        ok = osnet_connect_webui(vmg_ addr, port, pathb, &errmsg);
    }
    else
    {
        /* couldn't get the server address */
        errmsg = lib_copy_str(
            "No address information available for HTTPServer");
    }

    /* free strings */
    lib_free_str(pathb);
    lib_free_str(addr);
    lib_free_str(ip);

    /* if there's an error, throw it */
    if (!ok)
    {
        G_interpreter->push_string(vmg_ errmsg);
        lib_free_str(errmsg);
        G_interpreter->throw_new_class(vmg_ G_predef->net_exception, 1,
                                       "Error connecting to Web UI");
    }

    /* no return value */
    retval_nil(vmg0_);
}
CTcLibParser::~CTcLibParser()
{
    /* delete our library filename and path */
    lib_free_str(lib_name_);
    lib_free_str(lib_path_);
}
 ~CVmImageLoaderMres_resload()
 {
     lib_free_str(link_);
 }
Example #15
0
/*
 *   Terminate the VM 
 */
void vm_terminate(vm_globals *vmg__, CVmMainClientIfc *clientifc)
{
    /* tell the debugger to shut down, if necessary */
    vm_terminate_debug_shutdown(vmg0_);
    
    /* drop all undo information */
    G_undo->drop_undo(vmg0_);

    /* delete the main console */
    clientifc->delete_console(VMGLOB_ADDR, G_console);

    /* release references on the character mappers */
    G_cmap_from_fname->release_ref();
    G_cmap_to_fname->release_ref();
    G_cmap_from_ui->release_ref();
    G_cmap_to_ui->release_ref();
    G_cmap_from_file->release_ref();
    G_cmap_to_file->release_ref();
    G_cmap_to_log->release_ref();

    /* delete the saved UI character set name, if any */
    lib_free_str(G_disp_cset_name);

    /* delete the BigNumber register cache */
    delete G_bignum_cache;

    /* delete the TADS intrinsic function set's globals */
    delete G_bif_tads_globals;

    /* delete the predefined object table */
    VM_IF_ALLOC_PRE_GLOBAL(delete G_predef);

    /* delete the interpreter */
    VM_IFELSE_ALLOC_PRE_GLOBAL(delete G_interpreter,
                               G_interpreter->terminate());

    /* terminate the TadsObject class */
    CVmObjTads::class_term(vmg0_);

    /* delete the source file table */
    delete G_srcf_table;

    /* delete debugger objects */
    vm_terminate_debug_delete(vmg0_);

    /* delete dynamic compilation objects */
    if (G_dyncomp != 0)
    {
        delete G_dyncomp;
        G_dyncomp = 0;
    }

    /* delete the constant pools */
    VM_IFELSE_ALLOC_PRE_GLOBAL(delete G_code_pool,
                               G_code_pool->terminate());
    VM_IFELSE_ALLOC_PRE_GLOBAL(delete G_const_pool,
                               G_const_pool->terminate());

    /* delete the object table */
    G_obj_table->delete_obj_table(vmg0_);
    VM_IF_ALLOC_PRE_GLOBAL(delete G_obj_table);

    /* delete the dependency tables */
    G_bif_table->clear(vmg0_);
    delete G_meta_table;
    delete G_bif_table;

    /* delete the undo manager */
    delete G_undo;

    /* delete the memory manager and heap manager */
    delete G_mem;
    delete G_varheap;

    /* delete the error context */
    err_terminate();

    /* delete the globals */
    vmglob_delete(vmg__);
}
Example #16
0
 ~url_param_alo()
 {
     lib_free_str((char *)name);
     lib_free_str((char *)val);
 }