示例#1
0
文件: xt-lua.c 项目: xtforever/xtcw
/* returns socket fd */
int xtlua_init( Widget w, char *host, char *port )
{
    int sln = sln_init();
    
    /* init commands */
    cp_init();
    cp_add( "PUT:", cmd_put );
    cp_add( "EXIT", cmd_exit );
    cp_add( "CIRCLE:", cmd_circle );    

    int fd = sln_connect(sln, host, port, process_new_packet, w );
    if(fd < 0 ) ERR("server not found");

    return fd;
}
示例#2
0
complex cp_cos(complex x) {
    complex cp_i = get_cp(0, 1);
    complex cp_1 = get_cp(1, 0);
    complex cp_ix = cp_mul(cp_i, x);
    complex cp_eix = cp_exp(cp_ix);
    complex cp_meix = cp_rdiv(cp_1, cp_eix);
    complex cp_cos = cp_add(cp_eix, cp_meix);
    cp_cos = cp_mul_real(cp_cos, 0.5);
    return (cp_cos);
}
示例#3
0
文件: cwnet.c 项目: xtforever/xtcw
/******************************************************************************
*   MAIN function
******************************************************************************/
int main ( int argc, char **argv )
{
    trace_main = TRACE_MAIN;

    XtAppContext app;
    m_init();
    XtSetLanguageProc (NULL, NULL, NULL);
    XawInitializeWidgetSet();

    /*  --  Intialize Toolkit creating the application shell
     */
    Widget appShell = XtOpenApplication (&app, APP_NAME,
             /* resources: can be set from argv */
             options, XtNumber(options),
	     &argc, argv,
	     fallback_resources,
	     sessionShellWidgetClass,
	     NULL, 0
	   );
    load_icon(XtDisplay(appShell));
    //    load_icon_default();

    /*  --  Enable Editres support
     */
    XtAddEventHandler(appShell, (EventMask) 0, True, _XEditResCheckMessages, NULL);

    XtAddCallback( appShell, XtNdieCallback, quit_cb, NULL );

    /*  --  not parsed options are removed by XtOpenApplication
            the only entry left should be the program name
    */
    if (argc != 1) { m_destruct(); syntax(); exit(1); }
    TopLevel = appShell;


    /*  --  Register all application specific
            callbacks and widget classes
    */
    RegisterApplication ( appShell );

    /*  --  Register all Athena and Public
            widget classes, CBs, ACTs
    */
    XpRegisterAll ( app );

    /*  --  Create widget tree below toplevel shell
            using Xrm database
    */
    WcWidgetCreation ( appShell );


    /*  -- Get application resources and widget ptrs
     */
    XtGetApplicationResources(	appShell, (XtPointer)&CWNET,
				CWNET_CONFIG_RES,
				XtNumber(CWNET_CONFIG_RES),
				(ArgList)0, 0 );

    InitializeApplication(appShell);

    /*  --  Realize the widget tree and enter
            the main application loop  */
    XtRealizeWidget ( appShell );
    /*  --  Set Icon for Window */
    set_app_icon(appShell);

    grab_window_quit( appShell );


    /*------------------------------------------------------------------------*/
    CWNET.lgfx = lgfx_init( CWNET.widget_draw1 );

    /* init commands */
    cp_init();
    cp_add( "PUT:", cmd_put );
    cp_add( "EXIT", cmd_exit );
    cp_add( "CIRCLE:", cmd_circle );
    cp_add( "CLRSCR", cmd_clrscr );
    cp_add( "RECT:", cmd_rect );
    cp_add( "MEASURE", cmd_measure );
    int sln = sln_init();
    CWNET.sln = sln;
    XtAppAddTimeOut(app , 1000, try_connect, (XtPointer) (intptr_t) sln );
    /*------------------------------------------------------------------------*/

    
    XtAppMainLoop ( app ); /* use XtAppSetExitFlag */
    XtDestroyWidget(appShell);

    sln_destruct();
    m_destruct();

    return EXIT_SUCCESS;
}