static int sln_media_upd(struct ifnet *ifp) { struct sln_softc *sc = ifp->if_softc; struct ifmedia *ifm = &sc->ifmedia; if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) return EINVAL; if (ifp->if_flags & IFF_UP) sln_init(sc); return 0; }
/* 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; }
/****************************************************************************** * 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; }