vncserver.c
int
vnc_init_server(struct server_softc *sc, char *hostname) {
    static const char *passwordList[0];
    passwordList[0] = NULL;

    if (load_functions() == 0) {
        srv = malloc(sizeof(struct vncserver_handler));
        srv->vs_screen = (struct _rfbScreenInfo *)malloc(sizeof(rfbScreenInfoPtr));
        if (!srv->vs_screen) {
            free(srv);
            errx(EX_OSERR, "error to allocate memory for vs_screen");
        }

        if (sc) {
            srv->vs_screen = (*get_screen)(NULL, NULL, sc->vs_width,
                sc->vs_height, 8, 3, 4);
            srv->vs_screen->desktopName = sc->desktopName;
            srv->vs_screen->alwaysShared = sc->alwaysShared;
            srv->vs_screen->serverFormat.redShift = sc->redShift;
            srv->vs_screen->serverFormat.greenShift = sc->greenShift;
            srv->vs_screen->serverFormat.blueShift = sc->blueShift;
            srv->vs_screen->frameBuffer = sc->frameBuffer;
            srv->vs_screen->screenData = sc;
            srv->vs_screen->port = sc->bind_port;

            if (hostname && strlen(hostname) > 0)
                srv->vs_screen->listenInterface = inet_addr(hostname);
            else
                srv->vs_screen->listenInterface = htonl(INADDR_LOOPBACK);

            srv->vs_screen->ipv6port = sc->bind_port;
            srv->vs_screen->newClientHook = vncserver_newclient;
        } else
            errx(EX_DATAERR, "there is no data to initialize the server");

        if (sc->kbd_handler && sc->ptr_handler) {
            srv->vs_screen->kbdAddEvent = (void *)sc->kbd_handler;
            srv->vs_screen->ptrAddEvent = (void *)sc->ptr_handler;
        } else {
            WPRINTF(("[hyverem]: Keyboard and mouse functions not provided.\n"));
            srv->vs_screen->kbdAddEvent = (void *)dokey_fallback;
            srv->vs_screen->ptrAddEvent = (void *)doptr_fallback;
        }

        if (vnc_password) {
            passwordList[0] = vnc_password;
            srv->vs_screen->authPasswdData = (void *)passwordList;
            srv->vs_screen->passwordCheck = (void *)vnc_password_check;
        }

        if (hp) {
            srv->vs_screen->httpDir = hp->webdir;
            srv->vs_screen->httpEnableProxyConnect = hp->enable;
        }

        if (sc->vs_conn_wait == 1) {
            wait_cond = sc->vs_cond;
        }

        DPRINTF(("Bind port: %d for guest: %s on ip address: %s\n", sc->bind_port, sc->desktopName, hostname));
        start_vnc_server(srv->vs_screen);

	free(sc);
        return (0);
    }
    return (1);
}
/*
 * Initialize the VNC SERVER with data received from server_softc structure.
 */
Initialize the VNC SERVER with data received from server_softc structure.
Initialize the VNC SERVER with data received from server_softc structure .
int
vnc_init_server(struct server_softc *sc, char *hostname) {
    static const char *passwordList[0];
    passwordList[0] = NULL;
    if (load_functions() == 0) {
        srv = malloc(sizeof(struct vncserver_handler));
        srv->vs_screen = (struct _rfbScreenInfo *)malloc(sizeof(rfbScreenInfoPtr));
        if (!srv->vs_screen) {
            free(srv);
            errx(EX_OSERR, "error to allocate memory for vs_screen");
        }
        if (sc) {
            srv->vs_screen = (*get_screen)(NULL, NULL, sc->vs_width,
                sc->vs_height, 8, 3, 4);
            srv->vs_screen->desktopName = sc->desktopName;
            srv->vs_screen->alwaysShared = sc->alwaysShared;
            srv->vs_screen->serverFormat.redShift = sc->redShift;
            srv->vs_screen->serverFormat.greenShift = sc->greenShift;
            srv->vs_screen->serverFormat.blueShift = sc->blueShift;
            srv->vs_screen->frameBuffer = sc->frameBuffer;
            srv->vs_screen->screenData = sc;
            srv->vs_screen->port = sc->bind_port;
            if (hostname && strlen(hostname) > 0)
                srv->vs_screen->listenInterface = inet_addr(hostname);
            else
                srv->vs_screen->listenInterface = htonl(INADDR_LOOPBACK);
            srv->vs_screen->ipv6port = sc->bind_port;
            srv->vs_screen->newClientHook = vncserver_newclient;
        } else
            errx(EX_DATAERR, "there is no data to initialize the server");
        if (sc->kbd_handler && sc->ptr_handler) {
            srv->vs_screen->kbdAddEvent = (void *)sc->kbd_handler;
            srv->vs_screen->ptrAddEvent = (void *)sc->ptr_handler;
        } else {
            WPRINTF(("[hyverem]: Keyboard and mouse functions not provided.\n"));
            srv->vs_screen->kbdAddEvent = (void *)dokey_fallback;
            srv->vs_screen->ptrAddEvent = (void *)doptr_fallback;
        }
        if (vnc_password) {
            passwordList[0] = vnc_password;
            srv->vs_screen->authPasswdData = (void *)passwordList;
            srv->vs_screen->passwordCheck = (void *)vnc_password_check;
        }
        if (hp) {
            srv->vs_screen->httpDir = hp->webdir;
            srv->vs_screen->httpEnableProxyConnect = hp->enable;
        }
        if (sc->vs_conn_wait == 1) {
            wait_cond = sc->vs_cond;
        }
        DPRINTF(("Bind port: %d for guest: %s on ip address: %s\n", sc->bind_port, sc->desktopName, hostname));
        start_vnc_server(srv->vs_screen);
	free(sc);
        return (0);
    }
    return (1);
}
int vnc_init_server ( struct server_softc * sc , char * hostname ) { static const char * passwordList [ 0 ] ; passwordList [ 0 ] = NULL ; if ( load_functions ( ) == 0 ) { srv = malloc ( sizeof ( struct vncserver_handler ) ) ; srv -> vs_screen = ( struct _rfbScreenInfo * ) malloc ( sizeof ( rfbScreenInfoPtr ) ) ; if ( ! srv -> vs_screen ) { free ( srv ) ; errx ( EX_OSERR , " " ) ; } if ( sc ) { srv -> vs_screen = ( * get_screen ) ( NULL , NULL , sc -> vs_width , sc -> vs_height , 8 , 3 , 4 ) ; srv -> vs_screen -> desktopName = sc -> desktopName ; srv -> vs_screen -> alwaysShared = sc -> alwaysShared ; srv -> vs_screen -> serverFormat . redShift = sc -> redShift ; srv -> vs_screen -> serverFormat . greenShift = sc -> greenShift ; srv -> vs_screen -> serverFormat . blueShift = sc -> blueShift ; srv -> vs_screen -> frameBuffer = sc -> frameBuffer ; srv -> vs_screen -> screenData = sc ; srv -> vs_screen -> port = sc -> bind_port ; if ( hostname && strlen ( hostname ) > 0 ) srv -> vs_screen -> listenInterface = inet_addr ( hostname ) ; else srv -> vs_screen -> listenInterface = htonl ( INADDR_LOOPBACK ) ; srv -> vs_screen -> ipv6port = sc -> bind_port ; srv -> vs_screen -> newClientHook = vncserver_newclient ; } else errx ( EX_DATAERR , " " ) ; if ( sc -> kbd_handler && sc -> ptr_handler ) { srv -> vs_screen -> kbdAddEvent = ( void * ) sc -> kbd_handler ; srv -> vs_screen -> ptrAddEvent = ( void * ) sc -> ptr_handler ; } else { WPRINTF ( ( " \n " ) ) ; srv -> vs_screen -> kbdAddEvent = ( void * ) dokey_fallback ; srv -> vs_screen -> ptrAddEvent = ( void * ) doptr_fallback ; } if ( vnc_password ) { passwordList [ 0 ] = vnc_password ; srv -> vs_screen -> authPasswdData = ( void * ) passwordList ; srv -> vs_screen -> passwordCheck = ( void * ) vnc_password_check ; } if ( hp ) { srv -> vs_screen -> httpDir = hp -> webdir ; srv -> vs_screen -> httpEnableProxyConnect = hp -> enable ; } if ( sc -> vs_conn_wait == 1 ) { wait_cond = sc -> vs_cond ; } DPRINTF ( ( " \n " , sc -> bind_port , sc -> desktopName , hostname ) ) ; start_vnc_server ( srv -> vs_screen ) ; free ( sc ) ; return ( 0 ) ; } return ( 1 ) ; }
Initialize the VNC SERVER with data received from server_softc structure.
Initialize the VNC SERVER with data received from server_softc structure .